diff options
Diffstat (limited to 'docview/src')
-rw-r--r-- | docview/src/SettingsUnit.pas | 61 | ||||
-rw-r--r-- | docview/src/docview.lpi | 6 | ||||
-rw-r--r-- | docview/src/frm_configuration.pas | 174 | ||||
-rw-r--r-- | docview/src/frm_main.pas | 22 |
4 files changed, 165 insertions, 98 deletions
diff --git a/docview/src/SettingsUnit.pas b/docview/src/SettingsUnit.pas index 903e9fe7..e100b1b1 100644 --- a/docview/src/SettingsUnit.pas +++ b/docview/src/SettingsUnit.pas @@ -36,20 +36,6 @@ Const //clLightCyan = $c0ffff; //clLightGreen = $e0ffe0; - VGADefaultColors: array[ 0 .. NumColorSettings - 1 ] of TfpgColor - = ( clBoxColor, - clText1, - clText1, - clBoxColor, - clText1, - clBoxColor, - clText1, - clBoxColor, - clText1, - clBoxColor, - clGreen, - clYellow ); - DefaultColors: array[ 0 .. NumColorSettings - 1 ] of TfpgColor = ( clLightCyan, clBlack, @@ -67,9 +53,6 @@ Const ApplicationFontIndex = 0; NumFontSettings = 1; - DefaultTopicFont = DefaultTopicFont + '-' + DefaultTopicFontSize; - DefaultTopicFixedFont = DefaultTopicFixedFont + '-10' + DefaultTopicFixedFontSize; - Type TIndexStyle = ( isAlphabetical, isFileOnly, isFull ); @@ -93,10 +76,11 @@ Type StartupHelp: boolean; LeftPanelWidth: longint; ShowLeftPanel: boolean; + ScrollDistance: integer; FileDialogSplit: Double; Colors: array[ 0..NumColorSettings - 1 ] of TfpgColor; - NormalFont: TfpgFont; - FixedFont: TfpgFont; + NormalFontDesc: TfpgString; + FixedFontDesc: TfpgString; Fonts: array[ 0..NumFontSettings - 1 ] of TfpgFont; FixedFontSubstitution: boolean; FixedFontSubstitutes: string; @@ -116,7 +100,7 @@ Type // global procs procedure LoadSettings; procedure SaveSettings; -procedure writeSettingsDetailsTo(aStrings : TStrings); +procedure WriteSettingsDetailsTo(aStrings : TStrings); procedure AddToMRUList( const Title: string; Filenames: TStrings ); var @@ -186,13 +170,12 @@ begin ShowLeftPanel := ReadBool( GeneralSection, 'ShowLeftPanel', true ); + ScrollDistance := ReadInteger(GeneralSection, 'ScrollDistance', 75); + // Colours for ColorIndex := 0 to High( Colors ) do begin - //if GetScreenColorDepth > 8 then - DefaultColor := DefaultColors[ ColorIndex ]; - //else - // DefaultColor := VGADefaultColors[ ColorIndex ]; + DefaultColor := DefaultColors[ ColorIndex ]; Colors[ ColorIndex ] := ReadInteger( ColoursSection, 'Color' + IntToStr( ColorIndex ), DefaultColor ); @@ -226,13 +209,8 @@ begin end; // Fonts - NormalFont := fpgGetFont(ReadString(FontsSection, 'NormalFont', DefaultTopicFont)); - if NormalFont = nil then - NormalFont := fpgStyle.DefaultFont; - - FixedFont := fpgGetFont(ReadString(FontsSection, 'FixedFont', DefaultTopicFixedFont)); - if FixedFont = nil then - FixedFont := fpgStyle.FixedFont; + NormalFontDesc := ReadString(FontsSection, 'NormalFont', DefaultTopicFont); + FixedFontDesc := ReadString(FontsSection, 'FixedFont', DefaultTopicFixedFont); for i := 0 to NumFontSettings - 1 do begin @@ -243,7 +221,7 @@ begin end; FixedFontSubstitution := ReadBool( FontsSection, 'FixedFontSubstitution', true ); - FixedFontSubstitutes := ReadString( FontsSection, 'FixedFontSubstitutes', 'Mono-10' ); + FixedFontSubstitutes := ReadString( FontsSection, 'FixedFontSubstitutes', DefaultTopicFixedFont ); // Index style SettingString := ReadString( GeneralSection, 'IndexStyle', 'Full' ); @@ -327,6 +305,7 @@ begin WriteInteger( GeneralSection, 'FileDialogSplit', Round( FileDialogSplit * 1000 ) ); WriteBool( GeneralSection, 'ShowLeftPanel', ShowLeftPanel); + WriteInteger(GeneralSection, 'ScrollDistance', ScrollDistance); // Colours for ColorIndex := 0 to High( Colors ) do @@ -357,8 +336,8 @@ begin end; // Fonts - WriteString( FontsSection, 'NormalFont', NormalFont.FontDesc ); - WriteString( FontsSection, 'FixedFont', FixedFont.FontDesc ); + WriteString( FontsSection, 'NormalFont', NormalFontDesc ); + WriteString( FontsSection, 'FixedFont', FixedFontDesc ); for FontIndex := 0 to NumFontSettings - 1 do begin FontName := 'Font' + IntToStr( FontIndex ); @@ -473,7 +452,7 @@ begin end; end; -procedure writeSettingsDetailsTo(aStrings : TStrings); +procedure WriteSettingsDetailsTo(aStrings : TStrings); Begin aStrings.Add(''); aStrings.Add('---- Settings ----'); @@ -486,10 +465,11 @@ Begin aStrings.Add('StartupHelp: ' + boolToStr(Settings.StartupHelp)); // LeftPanelWidth: longint; aStrings.Add('ShowLeftPanel: ' + boolToStr(Settings.ShowLeftPanel)); + aStrings.Add('ScrollDistance: ' + IntToStr(Settings.ScrollDistance)); // FileDialogSplit: real; // Colors: array[ 0..NumColorSettings - 1 ] of TColor; - // NormalFont: TFont; - // FixedFont: TFont; + aStrings.Add('NormalFont: ' + Settings.NormalFontDesc); + aStrings.Add('FixedFont: ' + Settings.FixedFontDesc); // Fonts: array[ 0..NumFontSettings - 1 ] of TFont; aStrings.Add('FixedFontSubstitution: ' + boolToStr(Settings.FixedFontSubstitution)); aStrings.Add('FixedFontSubstitutes: ' + Settings.FixedFontSubstitutes); @@ -508,14 +488,9 @@ end; Initialization Settings.MRUList := TObjectList.Create; - - //Settings.NormalFont := fpgStyle.DefaultFont; - //Settings.FixedFont := fpgStyle.FixedFont; - //Settings.SearchDirectories := TStringList.Create; + Settings.SearchDirectories := TStringList.Create; Finalization - Settings.NormalFont.Free; - Settings.FixedFont.Free; Settings.SearchDirectories.Free; Settings.MRUList.Free; diff --git a/docview/src/docview.lpi b/docview/src/docview.lpi index 5e71947c..9b5c71a8 100644 --- a/docview/src/docview.lpi +++ b/docview/src/docview.lpi @@ -28,7 +28,7 @@ <PackageName Value="fpgui_toolkit"/> </Item1> </RequiredPackages> - <Units Count="32"> + <Units Count="33"> <Unit0> <Filename Value="docview.lpr"/> <IsPartOfProject Value="True"/> @@ -184,6 +184,10 @@ <Filename Value="docview.rc"/> <IsPartOfProject Value="True"/> </Unit31> + <Unit32> + <Filename Value="../docs/docview.ipf"/> + <IsPartOfProject Value="True"/> + </Unit32> </Units> </ProjectOptions> <CompilerOptions> diff --git a/docview/src/frm_configuration.pas b/docview/src/frm_configuration.pas index 9d63db94..10ea5616 100644 --- a/docview/src/frm_configuration.pas +++ b/docview/src/frm_configuration.pas @@ -7,22 +7,22 @@ interface uses SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_tab, fpg_button, fpg_label, fpg_edit, fpg_panel, fpg_combobox, fpg_listbox, fpg_checkbox, - fpg_editbtn; + fpg_editbtn, fpg_radiobutton; type TConfigurationForm = class(TfpgForm) private {@VFD_HEAD_BEGIN: ConfigurationForm} - PageControl1: TfpgPageControl; + pcSettings: TfpgPageControl; btnSave: TfpgButton; btnCancel: TfpgButton; tsGeneral: TfpgTabSheet; tsFontsColor: TfpgTabSheet; + tsIndex: TfpgTabSheet; Label1: TfpgLabel; Label2: TfpgLabel; pnlSearchHighlight: TfpgPanel; - cbIndexStyle: TfpgComboBox; lblIndexStyle: TfpgLabel; lblSearchDirs: TfpgLabel; btnSearchDirAdd: TfpgButton; @@ -35,6 +35,12 @@ type btnResetColors: TfpgButton; edtFixedFont: TfpgFontEdit; edtNormalFont: TfpgFontEdit; + rbIndexOrig: TfpgRadioButton; + rbIndexAlpha: TfpgRadioButton; + rbIndexBoth: TfpgRadioButton; + lblScrollDistance: TfpgLabel; + edtScrollDistance: TfpgEditInteger; + lblPixels: TfpgLabel; {@VFD_HEAD_END: ConfigurationForm} btnHelp: TfpgButton; procedure ConfigurationFormShow(Sender: TObject); @@ -79,7 +85,7 @@ end; procedure TConfigurationForm.ConfigurationFormShow(Sender: TObject); begin SettingsToGui; - PageControl1.ActivePage := tsGeneral; + pcSettings.ActivePage := tsGeneral; // programatically seting a tab does not fire OnChange event, so we do it mantually PageControl1Change(self, tsGeneral); end; @@ -143,31 +149,44 @@ End; procedure TConfigurationForm.SettingsToGui; begin // General - cbIndexStyle.FocusItem := Ord(Settings.IndexStyle); + edtScrollDistance.Value := Settings.ScrollDistance; lbSearchDirs.Items.Assign(Settings.SearchDirectories); chkEscapeIPFSymbols.Checked := Settings.IPFTopicSaveAsEscaped; chkStartupHelp.Checked := Settings.StartupHelp; chkOpenTOC.Checked := Settings.OpenWithExpandedContents; // Fonts & Color - edtNormalFont.FontDesc := Settings.NormalFont.FontDesc; - edtFixedFont.FontDesc := Settings.FixedFont.FontDesc; + edtNormalFont.FontDesc := Settings.NormalFontDesc; + edtFixedFont.FontDesc := Settings.FixedFontDesc; UpdateColorPanels; + // Index + rbIndexOrig.Checked := Settings.IndexStyle = isFileOnly; + rbIndexAlpha.Checked := Settings.IndexStyle = isAlphabetical; + rbIndexBoth.Checked := Settings.IndexStyle = isFull; end; procedure TConfigurationForm.GuiToSettings; begin // General - Settings.IndexStyle := TIndexStyle(cbIndexStyle.FocusItem); + if edtScrollDistance.Value < 1 then + edtScrollDistance.Value := 75; // default + if edtScrollDistance.Value > 400 then + edtScrollDistance.Value := 400; + Settings.ScrollDistance := edtScrollDistance.Value; Settings.SearchDirectories.Assign(lbSearchDirs.Items); Settings.IPFTopicSaveAsEscaped := chkEscapeIPFSymbols.Checked; Settings.StartupHelp := chkStartupHelp.Checked; Settings.OpenWithExpandedContents := chkOpenTOC.Checked; // Fonts & Color - Settings.NormalFont.Free; - Settings.NormalFont := fpgGetFont(edtNormalFont.FontDesc); - Settings.FixedFont.Free; - Settings.FixedFont := fpgGetFont(edtFixedFont.FontDesc); + Settings.NormalFontDesc := edtNormalFont.FontDesc; + Settings.FixedFontDesc := edtFixedFont.FontDesc; Settings.Colors[SearchHighlightTextColorIndex] := pnlSearchHighlight.BackgroundColor; + // Index + if rbIndexOrig.Checked then + Settings.IndexStyle := isFileOnly + else if rbIndexAlpha.Checked then + Settings.IndexStyle := isAlphabetical + else if rbIndexBoth.Checked then + Settings.IndexStyle := isFull; end; procedure TConfigurationForm.UpdateColorPanels; @@ -189,12 +208,13 @@ begin SetPosition(402, 189, 515, 439); WindowTitle := 'Configuration'; Hint := ''; + ShowHint := True; WindowPosition := wpOneThirdDown; - PageControl1 := TfpgPageControl.Create(self); - with PageControl1 do + pcSettings := TfpgPageControl.Create(self); + with pcSettings do begin - Name := 'PageControl1'; + Name := 'pcSettings'; SetPosition(4, 4, 506, 388); Anchors := [anLeft,anRight,anTop,anBottom]; ActivePageIndex := 0; @@ -212,7 +232,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 19; + TabOrder := 25; OnClick := @btnSaveClick; end; @@ -225,11 +245,11 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 20; + TabOrder := 26; OnClick := @btnCancelClick; end; - tsGeneral := TfpgTabSheet.Create(PageControl1); + tsGeneral := TfpgTabSheet.Create(pcSettings); with tsGeneral do begin Name := 'tsGeneral'; @@ -237,7 +257,7 @@ begin Text := 'General'; end; - tsFontsColor := TfpgTabSheet.Create(PageControl1); + tsFontsColor := TfpgTabSheet.Create(pcSettings); with tsFontsColor do begin Name := 'tsFontsColor'; @@ -245,6 +265,14 @@ begin Text := 'Fonts & Color'; end; + tsIndex := TfpgTabSheet.Create(pcSettings); + with tsIndex do + begin + Name := 'tsIndex'; + SetPosition(3, 24, 500, 361); + Text := 'Index'; + end; + Label1 := TfpgLabel.Create(tsFontsColor); with Label1 do begin @@ -278,25 +306,12 @@ begin Text := 'Search Highlight Color'; end; - cbIndexStyle := TfpgComboBox.Create(tsGeneral); - with cbIndexStyle do - begin - Name := 'cbIndexStyle'; - SetPosition(12, 32, 160, 25); - FontDesc := '#List'; - Hint := ''; - Items.Add('Alphabetical'); - Items.Add('FileOnly'); - Items.Add('Full'); - TabOrder := 2; - end; - - lblIndexStyle := TfpgLabel.Create(tsGeneral); + lblIndexStyle := TfpgLabel.Create(tsIndex); with lblIndexStyle do begin Name := 'lblIndexStyle'; - SetPosition(12, 13, 296, 17); - FontDesc := '#Label1'; + SetPosition(12, 12, 224, 17); + FontDesc := '#Label2'; Hint := ''; Text := 'Index style'; end; @@ -320,7 +335,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 5; + TabOrder := 3; OnClick :=@btnSearchDirAddClicked; end; @@ -333,7 +348,7 @@ begin Hint := ''; HotTrack := False; PopupFrame := False; - TabOrder := 7; + TabOrder := 5; Items.Duplicates := dupIgnore; end; @@ -346,7 +361,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 6; + TabOrder := 4; end; chkEscapeIPFSymbols := TfpgCheckBox.Create(tsGeneral); @@ -357,7 +372,7 @@ begin Anchors := [anLeft,anRight,anTop]; FontDesc := '#Label1'; Hint := ''; - TabOrder := 8; + TabOrder := 6; Text := 'Escape symbols when saving topics as IPF text'; end; @@ -370,7 +385,7 @@ begin Checked := True; FontDesc := '#Label1'; Hint := ''; - TabOrder := 9; + TabOrder := 7; Text := 'Show DocView help at startup if no files opened'; end; @@ -382,7 +397,7 @@ begin Anchors := [anLeft,anRight,anTop]; FontDesc := '#Label1'; Hint := ''; - TabOrder := 10; + TabOrder := 8; Text := 'Open files with contents expanded'; end; @@ -395,7 +410,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 17; + TabOrder := 15; OnClick := @btnSearchHighlightClicked; end; @@ -408,7 +423,7 @@ begin FontDesc := '#Label1'; Hint := ''; ImageName := ''; - TabOrder := 18; + TabOrder := 16; OnClick := @ResetColorsButtonOnClick; end; @@ -419,7 +434,7 @@ begin SetPosition(124, 48, 340, 24); Anchors := [anLeft,anRight,anTop]; FontDesc := ''; - TabOrder := 15; + TabOrder := 14; end; edtNormalFont := TfpgFontEdit.Create(tsFontsColor); @@ -429,14 +444,81 @@ begin SetPosition(124, 16, 340, 24); Anchors := [anLeft,anRight,anTop]; FontDesc := ''; - TabOrder := 14; + TabOrder := 13; + end; + + rbIndexOrig := TfpgRadioButton.Create(tsIndex); + with rbIndexOrig do + begin + Name := 'rbIndexOrig'; + SetPosition(24, 28, 280, 20); + FontDesc := '#Label1'; + GroupIndex := 1; + Hint := ''; + TabOrder := 21; + Text := 'File Only (only entries specified in file)'; + end; + + rbIndexAlpha := TfpgRadioButton.Create(tsIndex); + with rbIndexAlpha do + begin + Name := 'rbIndexAlpha'; + SetPosition(24, 48, 280, 20); + FontDesc := '#Label1'; + GroupIndex := 1; + Hint := ''; + TabOrder := 22; + Text := 'Alphabetical listing of topics'; + end; + + rbIndexBoth := TfpgRadioButton.Create(tsIndex); + with rbIndexBoth do + begin + Name := 'rbIndexBoth'; + SetPosition(24, 68, 280, 20); + FontDesc := '#Label1'; + GroupIndex := 1; + Hint := ''; + TabOrder := 23; + Text := 'Both'; + end; + + lblScrollDistance := TfpgLabel.Create(tsGeneral); + with lblScrollDistance do + begin + Name := 'lblScrollDistance'; + SetPosition(12, 12, 280, 17); + FontDesc := '#Label1'; + Hint := ''; + Text := 'Mouse Wheel Scroll Distance'; + end; + + edtScrollDistance := TfpgEditInteger.Create(tsGeneral); + with edtScrollDistance do + begin + Name := 'edtScrollDistance'; + SetPosition(12, 32, 72, 24); + Hint := ''; + TabOrder := 2; + FontDesc := '#Edit1'; + Value := 0; + end; + + lblPixels := TfpgLabel.Create(tsGeneral); + with lblPixels do + begin + Name := 'lblPixels'; + SetPosition(88, 36, 80, 17); + FontDesc := '#Label1'; + Hint := ''; + Text := '(pixels)'; end; {@VFD_BODY_END: ConfigurationForm} {%endregion} // always reset pagecotrol - PageControl1.ActivePageIndex := 0; + pcSettings.ActivePageIndex := 0; //btnHelp := TfpgButton.Create(self); //with btnHelp do diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index 4f040105..4cc0abfa 100644 --- a/docview/src/frm_main.pas +++ b/docview/src/frm_main.pas @@ -95,6 +95,7 @@ type CurrentHistoryIndex: integer; OpenAdditionalFile: boolean; + procedure UpdateRichViewFromSettings; procedure btnBackHistClick(Sender: TObject); procedure btnFwdHistClick(Sender: TObject); procedure btnPrevClick(Sender: TObject); @@ -210,6 +211,7 @@ uses ,frm_configuration ,frm_text ,NewViewConstantsUnit + ,CanvasFontManager ; const @@ -237,6 +239,13 @@ begin end end; +procedure TMainForm.UpdateRichViewFromSettings; +begin + RichView.RichTextSettings.NormalFont := fpgGetFont(Settings.NormalFontDesc); + RichView.RichTextSettings.FixedFont := fpgGetFont(Settings.FixedFontDesc); + RichView.ScrollDistance := Settings.ScrollDistance; +end; + procedure TMainForm.btnBackHistClick(Sender: TObject); begin if CurrentHistoryIndex > 0 then @@ -359,16 +368,11 @@ begin PageControl1.Width := gINI.ReadInteger('Options', 'SplitterLeft', 260); UpdateWindowPosition; - Settings.NormalFont := fpgStyle.DefaultFont; - Settings.FixedFont := fpgStyle.FixedFont; - Settings.SearchDirectories := TStringList.Create; - - LogEvent(LogSettings, 'Loading settings'); - LoadSettings; CreateMRUMenuItems; ProcessCommandLineParams; RichView.Images := FImages; + UpdateRichViewFromSettings; if ParamCount = 0 then begin @@ -382,7 +386,6 @@ begin OpenFile(lFilename, '', true); end; end; - end; procedure TMainForm.MainFormDestroy(Sender: TObject); @@ -436,6 +439,7 @@ end; procedure TMainForm.miConfigureClicked(Sender: TObject); begin ShowConfigForm; + UpdateRichViewFromSettings; end; procedure TMainForm.miViewExpandAllClicked(Sender: TObject); @@ -1934,6 +1938,8 @@ begin 'dv.arrowdown', @usr_arrow_down, sizeof(usr_arrow_down), 0, 0); + // load custom user settings like Fonts, Search Highlight Color etc. + LoadSettings; end; destructor TMainForm.Destroy; @@ -2745,7 +2751,7 @@ const var s: string; begin - s := '<font "Arial" 12><b>' + cLongName + '</b></font>' + le + s := '<font "' + DefaultTopicFontName + '" 12><b>' + cLongName + '</b></font>' + le + cVersion + le + le + 'Supported command line parameters:' + le + le + '<tt>' |