From 0998885ee825b18ec1a03a151193f4fa5d2d4f82 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 20 Jun 2011 12:29:45 +0200 Subject: bug: a scrolled grid with smoothscroll enabled did not allow columns to be resized. - My calculations was totally out of wack! Now it works as it should. - Also made sure scrollbars are correctly updated if Beginupdate..Endupdate is used. --- src/gui/fpg_basegrid.pas | 27 +++++++-------------------- src/gui/fpg_grid.pas | 5 ++--- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/gui/fpg_basegrid.pas b/src/gui/fpg_basegrid.pas index 6f9de311..509fb3ff 100644 --- a/src/gui/fpg_basegrid.pas +++ b/src/gui/fpg_basegrid.pas @@ -1059,15 +1059,13 @@ begin begin inc(cw, ColumnWidth[n]); // Resizing is enabled 4 pixel either way of the cell border - if ((x >= (cLeft+cw-4)) and (x <= (cLeft+cw+4))) {or - (cw > (cLeft + VisibleWidth)) and (x >= (cLeft + VisibleWidth-4))} then + if ((x >= (cLeft+cw-4)) and (x <= (cLeft+cw+4))) then begin colresize := True; Break; end; - - if cw > VisibleWidth then - Break; + { TODO: We could optimize this slightly by breaking as soon as x is + greater than current column edge we are over. } end; { if } end; { if/else } @@ -1142,21 +1140,10 @@ begin FColResizing := True; FResizedCol := n; FDragPos := x; - Break; - //end - //else if (cw > cLeft+VisibleWidth) and (x >= cLeft+VisibleWidth-4) then - //begin - // FColResizing := True; - // FResizedCol := n; - // FDragPos := x; - // nw := ColumnWidth[FResizedCol] - (cw+cLeft-x); - // if nw > 0 then - // SetColumnWidth(FResizedCol, nw ); - // Break; + Exit; end; { if/else } - - if cw > VisibleWidth then - Break; + { TODO: We could optimize this slightly by breaking as soon as x is + greater than current column edge we are over. } end; { for } end else @@ -1320,7 +1307,7 @@ procedure TfpgBaseGrid.Update; begin if csUpdating in ComponentState then Exit; - FollowFocus; + UpdateScrollBars; RePaint; end; diff --git a/src/gui/fpg_grid.pas b/src/gui/fpg_grid.pas index 9b3d6f20..7e5e1e51 100644 --- a/src/gui/fpg_grid.pas +++ b/src/gui/fpg_grid.pas @@ -82,8 +82,6 @@ type end; - { TfpgCustomStringGrid } - TfpgCustomStringGrid = class(TfpgCustomGrid) private function GetCell(ACol, ARow: Integer): string; @@ -409,7 +407,8 @@ begin if ACol > ColumnCount-1 then Exit; //==> BeginUpdate; - TfpgStringColumn(FColumns.Items[ACol]).Width := AValue; + inherited SetColumnWidth(ACol, AValue); +// TfpgStringColumn(FColumns.Items[ACol]).Width := AValue; EndUpdate; end; -- cgit v1.2.3-70-g09d2