diff options
-rw-r--r-- | examples/gui/gridtest/gridtest.lpi | 13 | ||||
-rw-r--r-- | examples/gui/gridtest/gridtest.lpr | 3 | ||||
-rw-r--r-- | src/gui/fpg_basegrid.pas | 40 |
3 files changed, 38 insertions, 18 deletions
diff --git a/examples/gui/gridtest/gridtest.lpi b/examples/gui/gridtest/gridtest.lpi index 8d6de301..06af36d7 100644 --- a/examples/gui/gridtest/gridtest.lpi +++ b/examples/gui/gridtest/gridtest.lpi @@ -1,7 +1,7 @@ <?xml version="1.0"?> <CONFIG> <ProjectOptions> - <Version Value="8"/> + <Version Value="9"/> <General> <Flags> <SaveOnlyProjectUnits Value="True"/> @@ -9,11 +9,13 @@ </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> - <TargetFileExt Value=""/> </General> <VersionInfo> - <StringTable Comments="" CompanyName="" FileDescription="" FileVersion="0.0.0.0" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/> + <StringTable ProductVersion=""/> </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="default" Default="True"/> + </BuildModes> <PublishOptions> <Version Value="2"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> @@ -39,15 +41,14 @@ </Units> </ProjectOptions> <CompilerOptions> - <Version Value="9"/> + <Version Value="11"/> <Parsing> <SyntaxOptions> <UseAnsiStrings Value="False"/> </SyntaxOptions> </Parsing> <Other> - <CustomOptions Value="-FUunits -"/> + <CustomOptions Value="-FUunits"/> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> diff --git a/examples/gui/gridtest/gridtest.lpr b/examples/gui/gridtest/gridtest.lpr index 465281b2..9fbce666 100644 --- a/examples/gui/gridtest/gridtest.lpr +++ b/examples/gui/gridtest/gridtest.lpr @@ -219,6 +219,9 @@ begin AddColumn('Column 1', 100, taLeftJustify); AddColumn('Col 2', 50, taCenter); AddColumn('Numbers', 150, taRightJustify); + AddColumn('Column 4', 150, taRightJustify); + AddColumn('Column 5', 150, taRightJustify); + AddColumn('Column 6', 150, taRightJustify); FontDesc := '#Grid'; HeaderFontDesc := '#GridHeader'; Hint := ''; diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index cc8bf0a6..127403b3 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -593,6 +593,8 @@ var vl: integer; i: integer; x: integer; + hmax: integer; + vmax: integer; Hfits, showH : boolean; Vfits, showV : boolean; @@ -707,7 +709,10 @@ begin FVScrollBar.SliderSize := VisibleLines / RowCount else FVScrollBar.SliderSize := 0; - FVScrollBar.Max := RowCount-VisibleLines; + vmax := RowCount-VisibleLines; + if FFirstRow>vmax then + FFirstRow:=vmax; + FVScrollBar.Max := vmax; FVScrollBar.Position := FFirstRow; FVScrollBar.RepaintSlider; FVScrollBar.Top := 2; @@ -728,7 +733,10 @@ begin FHScrollBar.Min := 0; if go_SmoothScroll in FOptions then begin - FHScrollBar.Max := cw - vw; + hmax := cw - vw; + FHScrollBar.Max := hmax; + if FXOffset>hmax then + FXOffset:=hmax; FHScrollBar.Position := FXOffset; FHScrollBar.SliderSize := HWidth / TotalColumnWidth; FHScrollBar.PageSize := 5; @@ -1195,26 +1203,34 @@ end; procedure TfpgBaseGrid.HandleMouseHorizScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); var - lCol: Integer; + old_val: Integer; begin inherited HandleMouseHorizScroll(x, y, shiftstate, delta); - lCol := FFirstCol; - if go_SmoothScroll in Options then begin - ; + old_val := FXOffset; + inc(FXOffset, delta*FHScrollBar.ScrollStep); + if (FXOffset<0) then + FXOffset:=0; + // finding the maximum Xoffset is tricky, let updatescrollbars do it. + if (FXOffset=old_val) then + Exit; end else begin + old_val := FFirstCol; inc(FFirstCol, delta); + if FFirstCol<0 then + FFirstCol:=0 + else if FFirstCol > ColumnCount-1 then + FFirstCol:=ColumnCount-1; + if FFirstCol=old_val then + Exit; end; - if lCol <> FFirstCol then - begin - UpdateScrollBars; - RePaint; - end; + UpdateScrollBars; + RePaint; end; procedure TfpgBaseGrid.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); @@ -1500,7 +1516,7 @@ begin FHScrollBar.Orientation := orHorizontal; FHScrollBar.Visible := False; FHScrollBar.OnScroll := @HScrollBarMove; - FHScrollBar.ScrollStep := 5; + FHScrollBar.ScrollStep := 20; end; destructor TfpgBaseGrid.Destroy; |