fpspreadsheet: Scroll active grid cell back into viewport if lost by zooming process.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5239 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-10-02 11:45:22 +00:00
parent 669aaf7798
commit 1257b32614
2 changed files with 20 additions and 2 deletions

View File

@ -42,7 +42,7 @@ object MainForm: TMainForm
Font.Height = -13
Font.Name = 'Arial'
MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goEditing, goThumbTracking, goDblClickAutoSize, goSmoothScroll, goHeaderHotTracking, goCellHints]
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goRowSizing, goColSizing, goEditing, goThumbTracking, goDblClickAutoSize, goHeaderHotTracking, goCellHints]
ParentFont = False
RowCount = 101
TabOrder = 1

View File

@ -5907,6 +5907,8 @@ begin
end;
procedure TsCustomWorksheetGrid.SetZoomFactor(AValue: Double);
var
c,r: Integer;
begin
if (AValue <> GetZoomFactor) and Assigned(Worksheet) then begin
inc(FZoomLock);
@ -5916,7 +5918,23 @@ begin
UpdateColWidths;
UpdateRowHeights;
dec(FZoomLock);
Invalidate;
// Bring active cell back into the viewport: There is a ScrollToCell but
// this method is private. It is called by SetCol/SetRow, though.
if ((Col < GCache.Visiblegrid.Left) or (Col >= GCache.VisibleGrid.Right)) and
(GCache.VisibleGrid.Left <> GCache.VisibleGrid.Right) then
begin
c := Col;
Col := c-1; // "Col" must change in order to call ScrtollToCell
Col := c;
end;
if ((Row < GCache.VisibleGrid.Top) or (Row >= GCache.VisibleGrid.Bottom)) and
(GCache.VisibleGrid.Top <> GCache.VisibleGrid.Bottom) then
begin
r := Row;
Row := r-1;
Row := r;
end;
end;
end;