diff options
Diffstat (limited to 'docview')
-rw-r--r-- | docview/components/richtext/RichTextView.pas | 77 | ||||
-rw-r--r-- | docview/src/SettingsUnit.pas | 5 | ||||
-rw-r--r-- | docview/src/frm_configuration.pas | 9 | ||||
-rw-r--r-- | docview/src/frm_main.pas | 13 |
4 files changed, 54 insertions, 50 deletions
diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas index 87e68318..9ebfcc46 100644 --- a/docview/components/richtext/RichTextView.pas +++ b/docview/components/richtext/RichTextView.pas @@ -49,9 +49,10 @@ Type TLinkEvent = procedure( Sender: TRichTextView; Link: string ) of object; - TRichTextView = Class( TfpgWidget ) + TRichTextView = class(TfpgWidget) private FPopupMenu: TfpgPopupMenu; + FScrollDistance: integer; procedure FVScrollbarScroll(Sender: TObject; position: integer); procedure FHScrollbarScroll(Sender: TObject; position: integer); procedure ShowDefaultPopupMenu(const x, y: integer; const shiftstate: TShiftState); virtual; @@ -63,6 +64,7 @@ Type Procedure SmoothScrollMIClick( Sender: TObject ); Procedure DebugMIClick( Sender: TObject ); Procedure DefaultMenuPopup( Sender: TObject ); + procedure SetScrollDistance(const AValue: integer); protected FFontManager: TCanvasFontManager; FRichTextSettings: TRichTextSettings; @@ -79,12 +81,12 @@ Type FOnClickLink: TLinkEvent; FDefaultMenu: TfpgPopupMenu; - FSelectAllMI: TfpgMenuItem; - FCopyMI: TfpgMenuItem; - FRefreshMI: TfpgMenuItem; - FWordWrapMI: TfpgMenuItem; - FSmoothScrollMI: TfpgMenuItem; - FDebugMI: TfpgMenuItem; + FSelectAllMI: TfpgMenuItem; + FCopyMI: TfpgMenuItem; + FRefreshMI: TfpgMenuItem; + FWordWrapMI: TfpgMenuItem; + FSmoothScrollMI: TfpgMenuItem; + FDebugMI: TfpgMenuItem; // Internal layout data FNeedVScroll, FNeedHScroll: boolean; @@ -366,6 +368,7 @@ Type property RichTextSettings: TRichTextSettings read FRichTextSettings; property ScrollBarWidth: longint read FScrollBarWidth write SetScrollBarWidth default 15; property SmoothScroll: boolean read FSmoothScroll write FSmoothScroll; + property ScrollDistance: integer read FScrollDistance write SetScrollDistance default 75; property UseDefaultMenu: boolean read FUseDefaultMenu write FUseDefaultMenu default True; property Debug: boolean read FDebug write SetDebug default False; property Images: TfpgImageList read FImages write SetImages; @@ -581,6 +584,17 @@ begin FDebugMI.Checked := Debug; end; +procedure TRichTextView.SetScrollDistance(const AValue: integer); +begin + if FScrollDistance = AValue then + exit; + FScrollDistance := AValue; + if Assigned(FVScrollBar) then + FVScrollBar.ScrollStep := FScrollDistance; + if Assigned(FHScrollBar) then + FHScrollBar.ScrollStep := FScrollDistance; +end; + constructor TRichTextView.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -1205,12 +1219,12 @@ begin FVScrollBar.Max := 0; end; - FHScrollBar.ScrollStep := 25; // pixels - FHScrollBar.PageSize := AvailableWidth - FHScrollbar.ScrollStep; // slightly less than width - FHScrollBar.SliderSize := AvailableWidth / MaxDisplayWidth; - FVScrollBar.ScrollStep := 25; // not used (line up/down calculated explicitly) - FVScrollBar.PageSize := AvailableHeight - FVScrollBar.ScrollStep; - FVScrollBar.SliderSize := AvailableHeight / FLayout.Height; + FHScrollBar.ScrollStep := FScrollDistance; // pixels + FHScrollBar.PageSize := AvailableWidth - FHScrollbar.ScrollStep; // slightly less than width + FHScrollBar.SliderSize := AvailableWidth / MaxDisplayWidth; + FVScrollBar.ScrollStep := FScrollDistance; // pixels + FVScrollBar.PageSize := AvailableHeight - FVScrollBar.ScrollStep; + FVScrollBar.SliderSize := AvailableHeight / FLayout.Height; // Physical horizontal scroll setup FHScrollbar.Visible := FNeedHScroll; @@ -1422,7 +1436,7 @@ begin Result := 0; end; -Function TRichTextView.GetLineUpPosition: longint; +function TRichTextView.GetLineUpPosition: longint; var FirstVisibleLine: longint; Offset: longint; @@ -1431,8 +1445,7 @@ begin Result := GetLineUpPositionFrom( FirstVisibleLine, Offset ); end; -Function TRichTextView.GetLineUpPositionFrom( FirstVisibleLine: longint; - Offset: longint ): longint; +function TRichTextView.GetLineUpPositionFrom( FirstVisibleLine: longint; Offset: longint ): longint; begin // we should never have scrolled all lines off the top!! assert( FirstVisibleLine <> -1 ); @@ -1449,15 +1462,13 @@ begin end; // scroll so that top line is fully visible... - Result := FVScrollBar.Position - - Offset; + Result := FVScrollBar.Position - Offset; if Offset < (FLayout.FLines^[ FirstVisibleLine ].Height div 2) then // more than half the line was already displayed so if FirstVisibleLine > 0 then // AND to make next line up visible dec( Result, FLayout.FLines^[ FirstVisibleLine - 1 ].Height ); - end; Function Sign( arg: longint ): longint; @@ -1526,54 +1537,26 @@ end; *) Procedure TRichTextView.DoVerticalScroll( NewY: longint ); -//var -// ScrollDistance: longint; begin FYScroll := 0 - NewY; - if not Visible then begin FLastYScroll := FYScroll; exit; end; - -// ScrollDistance := FYScroll - FLastYScroll; - - { TODO -ograeme -cscrolling : Implement vertical scrolling here } - //ScrollControlRect( Self, - // GetTextAreaRect, - // 0, - // ScrollDistance, - // Color, - // FSmoothScroll ); - FLastYScroll := FYScroll; RePaint; SetupCursor; end; Procedure TRichTextView.DoHorizontalScroll( NewX: longint ); -var - ScrollDistance: longint; begin FXScroll := NewX; - if not Visible then begin FLastXScroll := FXScroll; exit; end; - -// ScrollDistance := FXScroll - FLastXScroll; - - { TODO -ograemeg -cscrolling : Implement horizontal scrolling } - //ScrollControlRect( Self, - // GetTextAreaRect, - // - ScrollDistance, - // 0, - // Color, - // FSmoothScroll ); - FLastXScroll := FXScroll; RePaint; SetupCursor; diff --git a/docview/src/SettingsUnit.pas b/docview/src/SettingsUnit.pas index 3c9a8efc..e100b1b1 100644 --- a/docview/src/SettingsUnit.pas +++ b/docview/src/SettingsUnit.pas @@ -76,6 +76,7 @@ Type StartupHelp: boolean; LeftPanelWidth: longint; ShowLeftPanel: boolean; + ScrollDistance: integer; FileDialogSplit: Double; Colors: array[ 0..NumColorSettings - 1 ] of TfpgColor; NormalFontDesc: TfpgString; @@ -169,6 +170,8 @@ begin ShowLeftPanel := ReadBool( GeneralSection, 'ShowLeftPanel', true ); + ScrollDistance := ReadInteger(GeneralSection, 'ScrollDistance', 75); + // Colours for ColorIndex := 0 to High( Colors ) do begin @@ -302,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 @@ -461,6 +465,7 @@ 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; aStrings.Add('NormalFont: ' + Settings.NormalFontDesc); diff --git a/docview/src/frm_configuration.pas b/docview/src/frm_configuration.pas index 4d21dddf..f7fbb2d9 100644 --- a/docview/src/frm_configuration.pas +++ b/docview/src/frm_configuration.pas @@ -38,6 +38,9 @@ type rbIndexOrig: TfpgRadioButton; rbIndexAlpha: TfpgRadioButton; rbIndexBoth: TfpgRadioButton; + lblScrollDistance: TfpgLabel; + edtScrollDistance: TfpgEditInteger; + lblPixels: TfpgLabel; {@VFD_HEAD_END: ConfigurationForm} btnHelp: TfpgButton; procedure ConfigurationFormShow(Sender: TObject); @@ -146,6 +149,7 @@ End; procedure TConfigurationForm.SettingsToGui; begin // General + edtScrollDistance.Value := Settings.ScrollDistance; lbSearchDirs.Items.Assign(Settings.SearchDirectories); chkEscapeIPFSymbols.Checked := Settings.IPFTopicSaveAsEscaped; chkStartupHelp.Checked := Settings.StartupHelp; @@ -163,6 +167,11 @@ end; procedure TConfigurationForm.GuiToSettings; begin // General + 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; diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index fdf86064..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); @@ -238,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 @@ -364,6 +372,7 @@ begin ProcessCommandLineParams; RichView.Images := FImages; + UpdateRichViewFromSettings; if ParamCount = 0 then begin @@ -377,7 +386,6 @@ begin OpenFile(lFilename, '', true); end; end; - end; procedure TMainForm.MainFormDestroy(Sender: TObject); @@ -431,8 +439,7 @@ end; procedure TMainForm.miConfigureClicked(Sender: TObject); begin ShowConfigForm; - RichView.RichTextSettings.NormalFont := fpgGetFont(Settings.NormalFontDesc); - RichView.RichTextSettings.FixedFont := fpgGetFont(Settings.FixedFontDesc); + UpdateRichViewFromSettings; end; procedure TMainForm.miViewExpandAllClicked(Sender: TObject); |