summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docview/TODO.txt12
-rw-r--r--docview/src/HelpFile.pas5
-rw-r--r--docview/src/SettingsUnit.pas25
-rw-r--r--docview/src/docview.lpi11
-rw-r--r--docview/src/docview.lpr5
-rw-r--r--docview/src/dvconstants.pas5
-rw-r--r--docview/src/frm_main.pas185
-rw-r--r--src/frm_configuration.pas376
8 files changed, 569 insertions, 55 deletions
diff --git a/docview/TODO.txt b/docview/TODO.txt
index 38e2b3d5..03ad3642 100644
--- a/docview/TODO.txt
+++ b/docview/TODO.txt
@@ -28,7 +28,16 @@ Todo list
[ ] - Communication between application and docview. Both directions. Possible
solutions is Pipes or IPC unit.
[ ] - Create help file for DocView listing all supported features etc..
-[ ] -
+[ ] - Searching for two words as-is does not seem to work.
+ eg: 'file descriptor' exists is fppoll help, but trying to search for
+ those two words doesn't find anything.
+[ ] - Sometimes searching for a word doesn't find help even though it exists.
+ eg: 'descriptor' doesn't find the help in fppoll topic, even though the
+ work is clearly in the topic contents.
+[ ] - Implement History tab and tracking - including Back & Next buttons.
+[ ] - Options or Configuration dialog to set various things.
+[ ] - Hyperlinks on scrolled content doesn't work.
+[ ] - Implement popup window for "notes" hyperlinks.
[x] - Display topic by ID via command line parameters
[x] - 'Could not load topic slots' message when trying to view some topics.
@@ -36,6 +45,7 @@ Todo list
LCL documentation needs to be split in two, to compile. (this was an issue
with the Open Watcom WIPFC - limit is now set to 65000 entries)
[x] - Clicking in index list should set the text in the index search edit box.
+[x] - MRU menu item doesn't seem to remember all opened documents.
fpdoc IPF todo list
diff --git a/docview/src/HelpFile.pas b/docview/src/HelpFile.pas
index b3ee7317..af4a2cb9 100644
--- a/docview/src/HelpFile.pas
+++ b/docview/src/HelpFile.pas
@@ -446,12 +446,12 @@ end;
procedure THelpFile.Open;
begin
+ LogEvent(LogDebug, 'Open File >>');
if not FileExists( _Filename ) then
raise EHelpFileException.Create( FileErrorNotFound );
try
- _Handle := TFileStream.Create(_FileName, fmOpenRead);
-
+ _Handle := TFileStream.Create(_FileName, fmOpenRead or fmShareDenyWrite);
except
on E: Exception do
raise EHelpFileException.Create(E.Message);
@@ -471,6 +471,7 @@ begin
//end;
_FileSize := GetFileSize(_Filename);
+ LogEvent(LogDebug, 'Open File <<');
end;
procedure THelpFile.Close;
diff --git a/docview/src/SettingsUnit.pas b/docview/src/SettingsUnit.pas
index f6b34bc4..82a3aaf7 100644
--- a/docview/src/SettingsUnit.pas
+++ b/docview/src/SettingsUnit.pas
@@ -13,6 +13,7 @@ Interface
Uses
Classes
+ ,contnrs
,fpg_base
,fpg_main
,CanvasFontManager
@@ -75,7 +76,7 @@ Const
Type
- TIndexStyle = ( isFileOnly, isAlphabetical, isFull );
+ TIndexStyle = ( isAlphabetical, isFileOnly, isFull );
TToolbarStyle = ( tsNone, tsImages, tsText, tsImagesAndText );
TGlobalSearchLocation = ( gsHelpPaths, gsFixedDrives, gsSelectedHelpPaths, gsCustom );
@@ -89,7 +90,7 @@ Type
TSettings = record
- MRUList: TList;
+ MRUList: TObjectList;
LastOpenDirectory: string;
LastSaveDirectory: string;
StartupHelp: boolean;
@@ -133,8 +134,7 @@ Uses
,nvUtilities
;
-Const
- IniFileName = 'NewView.ini';
+const
GeneralSection = 'General';
FontsSection = 'Fonts';
ColoursSection = 'Colours';
@@ -172,7 +172,7 @@ var
i: longint;
Count: longint;
MRUFilename: string;
- MRUFileTitle: string;
+// MRUFileTitle: string;
begin
LogEvent(LogSettings, 'LoadSettings' );
with gINI do
@@ -224,7 +224,7 @@ begin
else
begin
// not valid
- MRUItem.Destroy;
+ MRUItem.Free;
MRUItem := nil;
end;
end;
@@ -459,9 +459,9 @@ begin
if PreviousMRUIndex > -1 then
begin
- // is already in list, move to top of list
- MRUItem := TMRUItem(Settings.MRUList[ PreviousMRUIndex ]);
- Settings.MRUList.Delete( PreviousMRUIndex );
+ // is already in list. Get instance so we can move it to the top of list
+ MRUItem := TMRUItem(Settings.MRUList[PreviousMRUIndex]);
+ Settings.MRUList.Extract(MRUItem);
end
else
begin
@@ -474,9 +474,7 @@ begin
Settings.MRUList.Insert( 0, MRUItem );
while Settings.MRUList.Count > MaxMRUListEntries do
begin
- MRUItem := TMRUItem(Settings.MRUList[ MaxMRUListEntries ]);
- Settings.MRUList.Delete( MaxMRUListEntries );
- MRUItem.Destroy;
+ Settings.MRUList.Remove(Settings.MRUList.Last);
end;
end;
@@ -515,6 +513,8 @@ end;
Initialization
+ Settings.MRUList := TObjectList.Create;
+
//Settings.NormalFont := fpgStyle.DefaultFont;
//Settings.FixedFont := fpgStyle.FixedFont;
//Settings.SearchDirectories := TStringList.Create;
@@ -523,5 +523,6 @@ Finalization
Settings.NormalFont.Free;
Settings.FixedFont.Free;
Settings.SearchDirectories.Free;
+ Settings.MRUList.Free;
End.
diff --git a/docview/src/docview.lpi b/docview/src/docview.lpi
index 2495cb6a..2996f4cf 100644
--- a/docview/src/docview.lpi
+++ b/docview/src/docview.lpi
@@ -32,7 +32,7 @@
<PackageName Value="fpgui_toolkit"/>
</Item1>
</RequiredPackages>
- <Units Count="27">
+ <Units Count="28">
<Unit0>
<Filename Value="docview.lpr"/>
<IsPartOfProject Value="True"/>
@@ -150,7 +150,7 @@
<Unit23>
<Filename Value="dvconstants.pas"/>
<IsPartOfProject Value="True"/>
- <UnitName Value="dvconstants"/>
+ <UnitName Value="dvConstants"/>
</Unit23>
<Unit24>
<Filename Value="dvHelpers.pas"/>
@@ -166,6 +166,11 @@
<Filename Value="../TODO.txt"/>
<IsPartOfProject Value="True"/>
</Unit26>
+ <Unit27>
+ <Filename Value="frm_configuration.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frm_configuration"/>
+ </Unit27>
</Units>
</ProjectOptions>
<CompilerOptions>
@@ -190,7 +195,7 @@
</CodeGeneration>
<Other>
<CustomOptions Value="-O-
-"/>
+-Fu/home/graemeg/programming/fpgui/lib/i386-win32aa/"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
diff --git a/docview/src/docview.lpr b/docview/src/docview.lpr
index 32a80f3b..105414dc 100644
--- a/docview/src/docview.lpr
+++ b/docview/src/docview.lpr
@@ -7,13 +7,12 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
Classes,
- {$IFDEF Timing}EpikTimer,{$ENDIF}
fpg_main, frm_main, IPFEscapeCodes, HelpTopic, CompareWordUnit, SearchTable,
TextSearchQuery, nvUtilities, nvNullObjects, HelpFile, SearchUnit,
- fpg_cmdlineparams, customstyle, IPFFileFormatUnit, HelpWindowDimensions,
+ fpg_cmdlineparams, fpgui_toolkit, customstyle, IPFFileFormatUnit, HelpWindowDimensions,
NewViewConstantsUnit, SettingsUnit, RichTextStyleUnit, CanvasFontManager,
ACLStringUtility, RichTextDocumentUnit, RichTextView, RichTextLayoutUnit,
- RichTextDisplayUnit, dvconstants, dvHelpers;
+ RichTextDisplayUnit, dvconstants, dvHelpers, frm_configuration;
procedure MainProc;
diff --git a/docview/src/dvconstants.pas b/docview/src/dvconstants.pas
index ae8b414d..626e0840 100644
--- a/docview/src/dvconstants.pas
+++ b/docview/src/dvconstants.pas
@@ -1,4 +1,4 @@
-unit dvconstants;
+unit dvConstants;
{$mode objfpc}{$H+}
@@ -29,6 +29,9 @@ resourcestring
rsDVSearchFoundMsg = 'Found %d matches for ';
rsDVCouldNotOpen = 'Could not open <%s>';
+const
+ hcConfigGeneralTab = 510;
+ hcConfigFontsColorTab = 520;
implementation
diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas
index 0d1a8495..b5120378 100644
--- a/docview/src/frm_main.pas
+++ b/docview/src/frm_main.pas
@@ -7,7 +7,7 @@ interface
uses
SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_panel, fpg_tab,
fpg_tree, fpg_splitter, fpg_menu, fpg_button, fpg_listbox,
- fpg_label, fpg_edit, fpg_radiobutton, fpg_progressbar, fpg_mru,
+ fpg_label, fpg_edit, fpg_radiobutton, fpg_progressbar,
HelpFile, RichTextView, HelpTopic;
type
@@ -59,11 +59,10 @@ type
miBookmarks: TfpgPopupMenu;
miHelp: TfpgPopupMenu;
miDebug: TfpgPopupMenu;
- miOpenRecentMenu: TfpgPopupMenu;
{@VFD_HEAD_END: MainForm}
+ miOpenRecentMenu: TfpgPopupMenu;
Files: TList; // current open help files.
Debug: boolean;
- mru: TfpgMRU;
FFileOpenRecent: TfpgMenuItem;
LoadingFilenameList: TStringList;
@@ -86,12 +85,13 @@ type
procedure miFileQuitClicked(Sender: TObject);
procedure miFileOpenClicked(Sender: TObject);
procedure miFileCloseClicked(Sender: TObject);
+ procedure miConfigureClicked(Sender: TObject);
procedure miHelpProdInfoClicked(Sender: TObject);
procedure miHelpAboutFPGui(Sender: TObject);
procedure miDebugHeader(Sender: TObject);
procedure miDebugHex(Sender: TObject);
procedure miFileSaveTopicAsIPF(Sender: TObject);
- procedure miMRUClick(Sender: TObject; const FileName: String);
+ procedure OnMRUMenuItemClick(Sender: TObject);
procedure btnShowIndex(Sender: TObject);
procedure btnGoClicked(Sender: TObject);
procedure tvContentsChange(Sender: TObject);
@@ -102,6 +102,7 @@ type
procedure PageControl1Change(Sender: TObject; NewActiveSheet: TfpgTabSheet);
procedure tvContentsDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure lbIndexDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
+ procedure lbIndexKeyPress(Sender: TObject; var KeyCode: word; var ShiftState: TShiftState; var Consumed: boolean);
procedure lbSearchResultsDoubleClick(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure btnSearchClicked(Sender: TObject);
procedure IndexSearchEditOnChange(Sender: TObject);
@@ -126,6 +127,7 @@ type
// Used in loading contents
procedure AddChildNodes(AHelpFile: THelpFile; AParentNode: TfpgTreeNode; ALevel: longint; var ATopicIndex: longint );
procedure ClearNotes;
+ procedure ClearIndexComponents;
procedure SaveNotes(AHelpFile: THelpFile);
procedure DisplayTopic(ATopic: TTopic = nil);
procedure ResetProgress;
@@ -138,7 +140,8 @@ type
function FindTopicForLink( Link: THelpLink ): TTopic;
function FindTopicByResourceID( ID: word ): TTopic;
function FindTopicByName(const AName: string): TTopic;
-
+ procedure AddCurrentToMRUFiles;
+ procedure CreateMRUMenuItems;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@@ -155,6 +158,8 @@ uses
,fpg_constants
,fpg_iniutils
,fpg_cmdlineparams
+ ,fpg_utils
+ ,fpg_stringutils
,nvUtilities
,ACLStringUtility
,TextSearchQuery
@@ -163,6 +168,7 @@ uses
,IPFFileFormatUnit
,SettingsUnit
,dvHelpers
+ ,frm_configuration
;
const
@@ -177,6 +183,16 @@ begin
TfpgMessageDialog.Critical('An unexpected error occurred.', E.Message);
end;
+procedure TMainForm.lbIndexKeyPress(Sender: TObject; var KeyCode: word;
+ var ShiftState: TShiftState; var Consumed: boolean);
+begin
+ if (KeyCode = keyReturn) or (KeyCode = keyPEnter) then
+ begin
+ Consumed := True;
+ DisplayTopic(nil);
+ end
+end;
+
procedure TMainForm.RichViewClickLink(Sender: TRichTextView; Link: string);
var
LinkIndex: integer;
@@ -251,13 +267,14 @@ begin
LogEvent(LogSettings, 'Loading settings');
LoadSettings;
-
+ CreateMRUMenuItems;
ProcessCommandLineParams;
end;
procedure TMainForm.MainFormDestroy(Sender: TObject);
begin
+ ClearAllWordSequences;
DisplayedIndex.Free;
// save splitter position
gINI.WriteInteger('Options', 'SplitterLeft', PageControl1.Width);
@@ -283,6 +300,11 @@ begin
CloseFile;
end;
+procedure TMainForm.miConfigureClicked(Sender: TObject);
+begin
+ ShowConfigForm;
+end;
+
procedure TMainForm.miHelpProdInfoClicked(Sender: TObject);
var
s: TfpgString;
@@ -487,9 +509,16 @@ begin
end;
end;
-procedure TMainForm.miMRUClick(Sender: TObject; const FileName: String);
+procedure TMainForm.OnMRUMenuItemClick(Sender: TObject);
+var
+ lTag: longint;
+ MenuItem: TfpgMenuItem;
+ MRUItem: TMRUItem;
begin
- OpenFile(FileName, '', True);
+ MenuItem := Sender as TfpgMenuItem;
+ lTag := MenuItem.Tag;
+ MRUItem := TMRUItem(Settings.MRUList[ lTag ]);
+ OpenFiles(MRUItem.FileNames, '', True);
end;
procedure TMainForm.btnShowIndex(Sender: TObject);
@@ -845,7 +874,6 @@ begin
if dlg.RunOpenFile then
begin
- mru.AddItem(dlg.Filename);
Settings.LastOpenDirectory := ExtractFilePath(dlg.Filename);
OpenFile(dlg.Filename, '', true);
end;
@@ -905,7 +933,6 @@ begin
for FileIndex := 0 to LoadingFilenameList.Count - 1 do
begin
Filename := LoadingFilenameList[ FileIndex ];
- mru.AddItem(FileName);
LogEvent(LogStartup, ' Loading: ' + Filename );
try
LoadingFileIndex := FileIndex;
@@ -966,7 +993,6 @@ begin
SetWaitCursor;
tmpHelpFiles := TList.Create;
-// RBRi Translate
if not LoadFiles(FileNames, tmpHelpFiles) then
begin
ClearWaitCursor;
@@ -990,7 +1016,7 @@ begin
ProgressBar.Position := 50;
SetStatus( rsDVDisplaying );
-// AddCurrentToMRUFiles;
+ AddCurrentToMRUFiles;
if AWindowTitle = '' then
MainTitle := THelpFile( CurrentOpenFiles[ 0 ] ).Title
@@ -1071,7 +1097,8 @@ begin
SaveNotes( lHelpFile );
end;
- DisplayedIndex.Clear;
+ ClearIndexComponents;
+ ClearAllWordSequences;
// Now destroy help files
for FileIndex := 0 to Files.Count - 1 do
@@ -1344,7 +1371,9 @@ begin
LogEvent(LogStartup, ' Display index (count = ' + IntToStr(DisplayedIndex.Count) + ')');
// Now display the final index list
+ lbIndex.BeginUpdate;
lbIndex.Items.Assign( DisplayedIndex );
+ lbIndex.EndUpdate;
LogEvent(LogStartup, ' Tidy up' );
tmpIndexLists.Free;
@@ -1399,6 +1428,15 @@ begin
{ TODO -oGraeme : Implement me }
end;
+procedure TMainForm.ClearIndexComponents;
+begin
+ IndexSearchEdit.Clear;
+ lbIndex.FocusItem := -1;
+ lbIndex.Items.Clear;
+ DisplayedIndex.Clear;
+ IndexLoaded := False;
+end;
+
procedure TMainForm.SaveNotes(AHelpFile: THelpFile);
begin
{ TODO -oGraeme : Implement me }
@@ -1541,19 +1579,14 @@ begin
end;
destructor TMainForm.Destroy;
-var
- FileIndex: integer;
- lHelpFile: THelpFile;
begin
-writeln('DEBUG: TMainForm.Destroy >>>>');
CurrentTopic := nil; // it was a reference only
FFileOpenRecent := nil; // it was a reference only
+ miOpenRecentMenu.Free;
DestroyListAndObjects(Files);
DestroyListAndObjects(AllFilesWordSequences);
DestroyListAndObjects(CurrentOpenFiles);
-writeln('DEBUG: TMainForm.Destroy 1');
inherited Destroy;
-writeln('DEBUG: TMainForm.Destroy <<<<');
end;
procedure TMainForm.AfterCreate;
@@ -1683,6 +1716,7 @@ begin
PopupFrame := False;
TabOrder := 1;
OnDoubleClick := @lbIndexDoubleClick;
+ OnKeyPress:=@lbIndexKeyPress;
end;
IndexSearchEdit := TfpgEdit.Create(tsIndex);
@@ -1986,7 +2020,7 @@ begin
begin
Name := 'miSettings';
SetPosition(292, 76, 132, 20);
- AddMenuItem('Options...', '', nil);
+ AddMenuItem('Options...', '', @miConfigureClicked);
end;
miBookmarks := TfpgPopupMenu.Create(self);
@@ -2019,16 +2053,16 @@ begin
AddMenuItem('Toggle Hex INF Values in Contents', '', @miDebugHex);
end;
- miOpenRecentMenu := TfpgPopupMenu.Create(self);
+ {@VFD_BODY_END: MainForm}
+ {%endregion}
+
+ miOpenRecentMenu := TfpgPopupMenu.Create(nil);
with miOpenRecentMenu do
begin
Name := 'miOpenRecentMenu';
SetPosition(309, 52, 132, 20);
end;
- {@VFD_BODY_END: MainForm}
- {%endregion}
-
// hook up the sub-menus.
MainMenu.AddMenuItem('&File', nil).SubMenu := miFile;
MainMenu.AddMenuItem('&Settings', nil).SubMenu := miSettings;
@@ -2039,15 +2073,6 @@ begin
// correct default visible tabsheet
PageControl1.ActivePageIndex := 0;
-
- // most recently used files
- mru := TfpgMRU.Create(self);
- mru.Name := 'MRU';
- mru.ParentMenuItem := miOpenRecentMenu;
- mru.OnClick :=@miMRUClick;
- mru.MaxItems := gINI.ReadInteger('Options', 'MRUFileCount', 8);
- mru.ShowFullPath := gINI.ReadBool('Options', 'ShowFullPath', True);
- mru.LoadMRU;
end;
procedure TMainForm.RefreshFontSubstitutions;
@@ -2206,5 +2231,99 @@ begin
Result := nil;
end;
+// Add the current list of open files as
+// a Most Recently Used entry
+procedure TMainForm.AddCurrentToMRUFiles;
+var
+ tmpFilenames: TStringList;
+ i: longint;
+ tmpHelpFile: THelpFile;
+begin
+ tmpFilenames := TStringList.Create;
+
+ if CurrentOpenFiles.Count > 0 then
+ begin
+ for i := 0 to CurrentOpenFiles.Count - 1 do
+ begin
+ tmpHelpFile := THelpFile(CurrentOpenFiles[ i ]);
+ tmpFilenames.Add(tmpHelpFile.Filename);
+ end;
+
+ // update most-recently-used file list
+ tmpHelpFile := THelpFile(CurrentOpenFiles[ 0 ]);
+ AddToMRUList(tmpHelpFile.Title, tmpFilenames);
+ end;
+
+ // recreate menu
+ CreateMRUMenuItems;
+
+ tmpFilenames.Destroy;
+end;
+
+procedure TMainForm.CreateMRUMenuItems;
+var
+ MenuItem: TfpgMenuItem;
+ i: integer;
+ FileName: TfpgString;
+ FileNameIndex: longint;
+ MRUText: TfpgString;
+ MRUItem: TMRUItem;
+begin
+ FFileOpenRecent.SubMenu := nil;
+ miOpenRecentMenu.Free;
+ miOpenRecentMenu := TfpgPopupMenu.Create(nil);
+ FFileOpenRecent.SubMenu := miOpenRecentMenu;
+
+ // Add items for the MRU files
+ for i:= 0 to Settings.MRUList.Count -1 do
+ begin
+ MRUItem := TMRUItem(Settings.MRUList[ i ]);
+ MenuItem := miOpenRecentMenu.AddMenuItem('?', '', @OnMRUMenuItemClick);
+// MenuItem.Name := 'MRUItem' + IntToStr( i ) + 'MI';
+
+ MRUText := MRUItem.Title;
+ if Trim( MRUText ) = '' then
+ begin
+ // Take the filenames, less path, as caption...
+ MRUText := '';
+ for FileNameIndex := 0 to MRUItem.Filenames.Count - 1 do
+ begin
+ FileName := MRUItem.Filenames[ FileNameIndex ];
+ FileName := fpgExtractFileName(FileName);
+ FileName := ChangeFileExt( FileName, '' );// remove extension
+
+ if FileNameIndex > 0 then
+ begin
+ MRUText := MRUText + HELP_FILE_DELIMITER;
+ end;
+ MRUText := MRUText + FileName;
+
+ // stop after 50 chars
+ if UTF8Length( MRUText ) > 50 then
+ begin
+ MRUText := MRUText + HELP_FILE_DELIMITER + ' ...';
+ break;
+ end;
+ end;
+ end;
+
+ MenuItem.Text := '&'
+ + IntToStr( i + 1 )
+ + '. '
+ + MRUText;
+ if MRUItem.Filenames.Count = 1 then
+ MenuItem.Hint := MRUItem.Filenames[ 0 ]
+ else
+ MenuItem.Hint := MRUItem.Title
+ + ' ('
+ + IntToStr( MRUItem.Filenames.Count )
+ + ' '
+ + rsfiles
+ + ')';
+
+ MenuItem.Tag := i;
+ end;
+end;
+
end.
diff --git a/src/frm_configuration.pas b/src/frm_configuration.pas
new file mode 100644
index 00000000..490c2596
--- /dev/null
+++ b/src/frm_configuration.pas
@@ -0,0 +1,376 @@
+unit frm_configuration;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_tab, fpg_button,
+ fpg_label, fpg_edit, fpg_panel, fpg_combobox, fpg_listbox;
+
+type
+
+ TConfigurationForm = class(TfpgForm)
+ private
+ {@VFD_HEAD_BEGIN: ConfigurationForm}
+ PageControl1: TfpgPageControl;
+ btnSave: TfpgButton;
+ btnCancel: TfpgButton;
+ tsGeneral: TfpgTabSheet;
+ tsFontsColor: TfpgTabSheet;
+ Label1: TfpgLabel;
+ edtNormalFont: TfpgEdit;
+ btnNormalFont: TfpgButton;
+ Label2: TfpgLabel;
+ edtFixedFont: TfpgEdit;
+ btnFixedFont: TfpgButton;
+ btnHelp: TfpgButton;
+ Panel1: TfpgPanel;
+ cbIndexStyle: TfpgComboBox;
+ lblIndexStyle: TfpgLabel;
+ lblSearchDirs: TfpgLabel;
+ btnSearchDirAdd: TfpgButton;
+ lbSearchDirs: TfpgListBox;
+ btnSearchDirDelete: TfpgButton;
+ {@VFD_HEAD_END: ConfigurationForm}
+ procedure ConfigurationFormShow(Sender: TObject);
+ procedure btnHelpClick(Sender: TObject);
+ procedure PageControl1Change(Sender: TObject; NewActiveSheet: TfpgTabSheet);
+ procedure btnCancelClick(Sender: TObject);
+ procedure btnSaveClick(Sender: TObject);
+ procedure btnSearchDirAddClicked(Sender: TObject);
+ procedure SettingsToGui;
+ procedure GuiToSettings;
+ public
+ constructor Create(AOwner: TComponent); override;
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+procedure ShowConfigForm;
+
+implementation
+
+uses
+ fpg_dialogs, SettingsUnit, dvConstants;
+
+procedure ShowConfigForm;
+var
+ frm: TConfigurationForm;
+begin
+ frm := TConfigurationForm.Create(nil);
+ try
+ frm.ShowModal;
+ finally
+ frm.Free;
+ end;
+end;
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TConfigurationForm.ConfigurationFormShow(Sender: TObject);
+begin
+ SettingsToGui;
+ PageControl1.ActivePage := tsGeneral;
+ // programatically seting a tab does not fire OnChange event, so we do it mantually
+ PageControl1Change(self, tsGeneral);
+end;
+
+procedure TConfigurationForm.btnHelpClick(Sender: TObject);
+begin
+ ShowMessage(IntToStr(btnHelp.HelpContext));
+end;
+
+procedure TConfigurationForm.PageControl1Change(Sender: TObject;
+ NewActiveSheet: TfpgTabSheet);
+begin
+ if NewActiveSheet = tsGeneral then
+ begin
+ btnHelp.HelpContext := hcConfigGeneralTab;
+ end
+ else if NewActiveSheet = tsFontsColor then
+ begin
+ btnHelp.HelpContext := hcConfigFontsColorTab;
+ end;
+end;
+
+procedure TConfigurationForm.btnCancelClick(Sender: TObject);
+begin
+ ModalResult := mrCancel;
+end;
+
+procedure TConfigurationForm.btnSaveClick(Sender: TObject);
+begin
+ GuiToSettings;
+ SaveSettings;
+ ModalResult := mrOK;
+end;
+
+procedure TConfigurationForm.btnSearchDirAddClicked(Sender: TObject);
+var
+ s: TfpgString;
+begin
+ s := SelectDirDialog('');
+ if s <> '' then
+ lbSearchDirs.Items.Add(s);
+end;
+
+procedure TConfigurationForm.SettingsToGui;
+begin
+ // General
+ cbIndexStyle.FocusItem := Ord(Settings.IndexStyle);
+ lbSearchDirs.Items.Assign(Settings.SearchDirectories);
+ // Fonts & Color
+ edtNormalFont.Text := Settings.NormalFont.FontDesc;
+ edtFixedFont.Text := Settings.FixedFont.FontDesc;
+end;
+
+procedure TConfigurationForm.GuiToSettings;
+begin
+ // General
+ Settings.IndexStyle := TIndexStyle(cbIndexStyle.FocusItem);
+ Settings.SearchDirectories.Assign(lbSearchDirs.Items);
+ // Fonts & Color
+ Settings.NormalFont.Free;
+ Settings.NormalFont := fpgGetFont(edtNormalFont.Text);
+ Settings.FixedFont.Free;
+ Settings.FixedFont := fpgGetFont(edtFixedFont.Text);
+end;
+
+constructor TConfigurationForm.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ OnShow := @ConfigurationFormShow;
+end;
+
+procedure TConfigurationForm.AfterCreate;
+begin
+ {%region 'Auto-generated GUI code' -fold}
+ {@VFD_BODY_BEGIN: ConfigurationForm}
+ Name := 'ConfigurationForm';
+ SetPosition(310, 157, 515, 439);
+ WindowTitle := 'Configuration';
+ WindowPosition := wpOneThirdDown;
+
+ PageControl1 := TfpgPageControl.Create(self);
+ with PageControl1 do
+ begin
+ Name := 'PageControl1';
+ SetPosition(4, 4, 506, 388);
+ Anchors := [anLeft,anRight,anTop,anBottom];
+ ActivePageIndex := 1;
+ TabOrder := 0;
+ OnChange := @PageControl1Change;
+ end;
+
+ btnSave := TfpgButton.Create(self);
+ with btnSave do
+ begin
+ Name := 'btnSave';
+ SetPosition(344, 408, 80, 24);
+ Text := 'Save';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnSaveClick;
+ end;
+
+ btnCancel := TfpgButton.Create(self);
+ with btnCancel do
+ begin
+ Name := 'btnCancel';
+ SetPosition(428, 408, 80, 24);
+ Text := 'Cancel';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 2;
+ OnClick := @btnCancelClick;
+ end;
+
+ tsGeneral := TfpgTabSheet.Create(PageControl1);
+ with tsGeneral do
+ begin
+ Name := 'tsGeneral';
+ SetPosition(3, 24, 500, 361);
+ Text := 'General';
+ end;
+
+ tsFontsColor := TfpgTabSheet.Create(PageControl1);
+ with tsFontsColor do
+ begin
+ Name := 'tsFontsColor';
+ SetPosition(3, 24, 500, 361);
+ Text := 'Fonts & Color';
+ end;
+
+ Label1 := TfpgLabel.Create(tsFontsColor);
+ with Label1 do
+ begin
+ Name := 'Label1';
+ SetPosition(12, 20, 108, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Normal Font';
+ end;
+
+ edtNormalFont := TfpgEdit.Create(tsFontsColor);
+ with edtNormalFont do
+ begin
+ Name := 'edtNormalFont';
+ SetPosition(124, 16, 248, 24);
+ Anchors := [anLeft,anRight,anTop];
+ TabOrder := 1;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ btnNormalFont := TfpgButton.Create(tsFontsColor);
+ with btnNormalFont do
+ begin
+ Name := 'btnNormalFont';
+ SetPosition(384, 16, 80, 24);
+ Anchors := [anRight,anTop];
+ Text := 'Select...';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 2;
+ end;
+
+ Label2 := TfpgLabel.Create(tsFontsColor);
+ with Label2 do
+ begin
+ Name := 'Label2';
+ SetPosition(12, 52, 104, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Fixed Font';
+ end;
+
+ edtFixedFont := TfpgEdit.Create(tsFontsColor);
+ with edtFixedFont do
+ begin
+ Name := 'edtFixedFont';
+ SetPosition(124, 48, 248, 24);
+ Anchors := [anLeft,anRight,anTop];
+ TabOrder := 4;
+ Text := '';
+ FontDesc := '#Edit1';
+ end;
+
+ btnFixedFont := TfpgButton.Create(tsFontsColor);
+ with btnFixedFont do
+ begin
+ Name := 'btnFixedFont';
+ SetPosition(384, 48, 80, 24);
+ Anchors := [anRight,anTop];
+ Text := 'Select...';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 5;
+ end;
+
+ btnHelp := TfpgButton.Create(self);
+ with btnHelp do
+ begin
+ Name := 'btnHelp';
+ SetPosition(468, 356, 28, 24);
+ Anchors := [anRight,anBottom];
+ Text := '?';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 6;
+ HelpType := htContext;
+ OnClick := @btnHelpClick;
+ end;
+
+ Panel1 := TfpgPanel.Create(tsFontsColor);
+ with Panel1 do
+ begin
+ Name := 'Panel1';
+ SetPosition(128, 116, 204, 28);
+ FontDesc := '#Label1';
+ Style := bsLowered;
+ Text := 'Panel';
+ end;
+
+ cbIndexStyle := TfpgComboBox.Create(tsGeneral);
+ with cbIndexStyle do
+ begin
+ Name := 'cbIndexStyle';
+ SetPosition(12, 32, 160, 22);
+ FontDesc := '#List';
+ Items.Add('Alphabetical');
+ Items.Add('FileOnly');
+ Items.Add('Full');
+ TabOrder := 0;
+ end;
+
+ lblIndexStyle := TfpgLabel.Create(tsGeneral);
+ with lblIndexStyle do
+ begin
+ Name := 'lblIndexStyle';
+ SetPosition(12, 12, 212, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Index style';
+ end;
+
+ lblSearchDirs := TfpgLabel.Create(tsGeneral);
+ with lblSearchDirs do
+ begin
+ Name := 'lblSearchDirs';
+ SetPosition(12, 64, 216, 16);
+ FontDesc := '#Label1';
+ Hint := '';
+ Text := 'Search directories';
+ end;
+
+ btnSearchDirAdd := TfpgButton.Create(tsGeneral);
+ with btnSearchDirAdd do
+ begin
+ Name := 'btnSearchDirAdd';
+ SetPosition(408, 84, 80, 24);
+ Text := 'Add...';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 4;
+ OnClick :=@btnSearchDirAddClicked;
+ end;
+
+ lbSearchDirs := TfpgListBox.Create(tsGeneral);
+ with lbSearchDirs do
+ begin
+ Name := 'lbSearchDirs';
+ SetPosition(12, 84, 388, 148);
+ FontDesc := '#List';
+ HotTrack := False;
+ PopupFrame := False;
+ TabOrder := 5;
+ Items.Duplicates := dupIgnore;
+ end;
+
+ btnSearchDirDelete := TfpgButton.Create(tsGeneral);
+ with btnSearchDirDelete do
+ begin
+ Name := 'btnSearchDirDelete';
+ SetPosition(408, 116, 80, 24);
+ Text := 'Remove...';
+ FontDesc := '#Label1';
+ Hint := '';
+ ImageName := '';
+ TabOrder := 5;
+ end;
+
+ {@VFD_BODY_END: ConfigurationForm}
+ {%endregion}
+end;
+
+
+end.