mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 12:19:13 +02:00
LCL, fix grid's column resizing problems, issue #16800
git-svn-id: trunk@26689 -
This commit is contained in:
parent
67561b71a3
commit
3a4d1d6c19
317
lcl/grids.pas
317
lcl/grids.pas
@ -135,7 +135,7 @@ type
|
|||||||
|
|
||||||
TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab,
|
TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab,
|
||||||
gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked,
|
gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked,
|
||||||
gfEditingDone);
|
gfEditingDone, gfSizingStarted);
|
||||||
TGridFlags = set of TGridFlagsOption;
|
TGridFlags = set of TGridFlagsOption;
|
||||||
|
|
||||||
TSortOrder = (soAscending, soDescending);
|
TSortOrder = (soAscending, soDescending);
|
||||||
@ -566,6 +566,14 @@ type
|
|||||||
TGridCoord = TPoint;
|
TGridCoord = TPoint;
|
||||||
TGridRect = TRect;
|
TGridRect = TRect;
|
||||||
|
|
||||||
|
TSizingRec = record
|
||||||
|
Index: Integer;
|
||||||
|
OffIni,OffEnd: Integer;
|
||||||
|
DeltaOff: Integer;
|
||||||
|
PrevLine: boolean;
|
||||||
|
PrevOffset: Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
TGridDataCache=record
|
TGridDataCache=record
|
||||||
FixedWidth: Integer; // Sum( Fixed ColsWidths[i] )
|
FixedWidth: Integer; // Sum( Fixed ColsWidths[i] )
|
||||||
FixedHeight: Integer; // Sum( Fixed RowsHeights[i] )
|
FixedHeight: Integer; // Sum( Fixed RowsHeights[i] )
|
||||||
@ -641,7 +649,7 @@ type
|
|||||||
FScrollBars: TScrollStyle;
|
FScrollBars: TScrollStyle;
|
||||||
FSelectActive: Boolean;
|
FSelectActive: Boolean;
|
||||||
FTopLeft: TPoint;
|
FTopLeft: TPoint;
|
||||||
FSplitter, FPivot: TPoint;
|
FPivot: TPoint;
|
||||||
FRange: TRect;
|
FRange: TRect;
|
||||||
FDragDx: Integer;
|
FDragDx: Integer;
|
||||||
FMoveLast: TPoint;
|
FMoveLast: TPoint;
|
||||||
@ -667,8 +675,6 @@ type
|
|||||||
FExtendedColSizing: boolean;
|
FExtendedColSizing: boolean;
|
||||||
FExtendedRowSizing: boolean;
|
FExtendedRowSizing: boolean;
|
||||||
FUpdatingAutoFillCols: boolean;
|
FUpdatingAutoFillCols: boolean;
|
||||||
FPrevLine: boolean;
|
|
||||||
FPrevValue: Integer;
|
|
||||||
FGridBorderStyle: TBorderStyle;
|
FGridBorderStyle: TBorderStyle;
|
||||||
FGridFlags: TGridFlags;
|
FGridFlags: TGridFlags;
|
||||||
FGridPropBackup: TGridPropertyBackup;
|
FGridPropBackup: TGridPropertyBackup;
|
||||||
@ -679,6 +685,7 @@ type
|
|||||||
FHeaderPushZones: TGridZoneSet;
|
FHeaderPushZones: TGridZoneSet;
|
||||||
FCheckedBitmap, FUnCheckedBitmap, FGrayedBitmap: TBitmap;
|
FCheckedBitmap, FUnCheckedBitmap, FGrayedBitmap: TBitmap;
|
||||||
FSavedCursor: TCursor;
|
FSavedCursor: TCursor;
|
||||||
|
FSizing: TSizingRec;
|
||||||
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
||||||
procedure CacheVisibleGrid;
|
procedure CacheVisibleGrid;
|
||||||
procedure CancelSelection;
|
procedure CancelSelection;
|
||||||
@ -772,6 +779,7 @@ type
|
|||||||
procedure SetSelectActive(const AValue: Boolean);
|
procedure SetSelectActive(const AValue: Boolean);
|
||||||
procedure SetSelection(const AValue: TGridRect);
|
procedure SetSelection(const AValue: TGridRect);
|
||||||
procedure SetTopRow(const AValue: Integer);
|
procedure SetTopRow(const AValue: Integer);
|
||||||
|
function StartColSizing(const X, Y: Integer): boolean;
|
||||||
procedure ChangeCursor(ACursor: Integer = MAXINT);
|
procedure ChangeCursor(ACursor: Integer = MAXINT);
|
||||||
procedure TryScrollTo(aCol,aRow: integer);
|
procedure TryScrollTo(aCol,aRow: integer);
|
||||||
procedure UpdateScrollBarPos(Which: TScrollStyle);
|
procedure UpdateScrollBarPos(Which: TScrollStyle);
|
||||||
@ -2322,6 +2330,84 @@ begin
|
|||||||
TryScrollTo(FTopLeft.X, Avalue);
|
TryScrollTo(FTopLeft.X, Avalue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomGrid.StartColSizing(const X, Y: Integer):boolean;
|
||||||
|
var
|
||||||
|
OrgIndex, TmpIndex: Integer;
|
||||||
|
ACase: Integer;
|
||||||
|
begin
|
||||||
|
|
||||||
|
with FSizing do begin
|
||||||
|
|
||||||
|
OrgIndex := FGCache.ClickCell.X;
|
||||||
|
Index := OrgIndex;
|
||||||
|
ColRowToOffset(true, true, Index, OffIni, OffEnd);
|
||||||
|
|
||||||
|
if (OffEnd-FGCache.ClickMouse.X) < (FGCache.ClickMouse.X-OffIni) then begin
|
||||||
|
if X>FGCache.ClickMouse.X then
|
||||||
|
ACase := 4 // dragging right side to the right
|
||||||
|
else
|
||||||
|
ACase := 3; // dragging right side to the left
|
||||||
|
end else begin
|
||||||
|
if X>FGCache.ClickMouse.X then
|
||||||
|
ACase := 2 // dragging left side to the right
|
||||||
|
else
|
||||||
|
ACase := 1; // dragging left side to the left
|
||||||
|
end;
|
||||||
|
|
||||||
|
if UseRightToLeftAlignment then begin
|
||||||
|
case ACase of
|
||||||
|
1: ACase := 4;
|
||||||
|
2: ACase := 3;
|
||||||
|
3: ACase := 2;
|
||||||
|
4: ACase := 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
case ACase of
|
||||||
|
3: ; // current column is the right one to resize
|
||||||
|
4: // find following covered column (visible 0-width) at the right side
|
||||||
|
begin
|
||||||
|
TmpIndex := Index;
|
||||||
|
while (TmpIndex<ColCount-1) and (ColWidths[TmpIndex+1]=0) do begin
|
||||||
|
Inc(TmpIndex);
|
||||||
|
if not Columns.Enabled or ColumnFromGridColumn(TmpIndex).Visible then
|
||||||
|
Index := TmpIndex;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
2: // find previous visible (width>0) or covered column
|
||||||
|
begin
|
||||||
|
Dec(Index);
|
||||||
|
while (Index>FixedCols) do begin
|
||||||
|
if not Columns.Enabled or ColumnFromGridColumn(Index).Visible then
|
||||||
|
break;
|
||||||
|
Dec(Index);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
1: // find previous visible (width>0) column
|
||||||
|
begin
|
||||||
|
Dec(Index);
|
||||||
|
while (Index>FixedCols) do begin
|
||||||
|
if ColWidths[Index]>0 then
|
||||||
|
break;
|
||||||
|
Dec(Index);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if OrgIndex<>Index then
|
||||||
|
ColRowToOffset(True, True, Index, OffIni, OffEnd);
|
||||||
|
|
||||||
|
// if precision on changing cursor from normal to split is expanded, there
|
||||||
|
// will be a starting big jump on size, to fix it, uncomment next lines
|
||||||
|
// TODO: check for RTL
|
||||||
|
//DeltaOff := OffEnd - FGCache.ClickMouse.X;
|
||||||
|
DeltaOff := 0;
|
||||||
|
|
||||||
|
result := (Index>=FixedCols);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.ChangeCursor(ACursor: Integer = MAXINT);
|
procedure TCustomGrid.ChangeCursor(ACursor: Integer = MAXINT);
|
||||||
begin
|
begin
|
||||||
if ACursor=MAXINT then
|
if ACursor=MAXINT then
|
||||||
@ -4655,30 +4741,53 @@ end;
|
|||||||
|
|
||||||
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
OffIni,OffEnd,Loc: Integer;
|
Offset: Integer;
|
||||||
|
|
||||||
|
procedure FindPrevColumn;
|
||||||
|
begin
|
||||||
|
with FSizing do begin
|
||||||
|
Dec(Index);
|
||||||
|
while (Index>FixedCols) and (ColWidths[Index]=0) do
|
||||||
|
Dec(Index);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
|
|
||||||
|
with FSizing do
|
||||||
if gsColSizing = fGridState then begin
|
if gsColSizing = fGridState then begin
|
||||||
|
|
||||||
|
if not (gfSizingStarted in FGridFlags) then
|
||||||
|
if not StartColSizing(X,Y) then
|
||||||
|
exit;
|
||||||
|
Include(FGridFlags, gfSizingStarted);
|
||||||
|
|
||||||
if FUseXORFeatures then begin
|
if FUseXORFeatures then begin
|
||||||
|
|
||||||
if UseRightToLeftAlignment then begin
|
if UseRightToLeftAlignment then begin
|
||||||
if (FSplitter.Y - x) <=0 then
|
if (OffEnd - x) <=0 then
|
||||||
x:= FSplitter.Y;
|
x:= OffEnd;
|
||||||
end
|
end
|
||||||
else if (x-FSplitter.Y)<=0 then
|
|
||||||
x:= FSplitter.Y;
|
|
||||||
if x<>FPrevValue then begin
|
|
||||||
if FPrevLine then
|
|
||||||
DrawXorVertLine(FPrevValue);
|
|
||||||
DrawXorVertLine(X);
|
|
||||||
FPrevLine:=True;
|
|
||||||
FPrevValue:=X;
|
|
||||||
end;
|
|
||||||
end else
|
|
||||||
if UseRightToLeftAlignment then
|
|
||||||
ResizeColumn(FSplitter.x, FSplitter.y - x)
|
|
||||||
else
|
else
|
||||||
ResizeColumn(FSplitter.x, x - FSplitter.y);
|
if (X-OffIni)<=0 then
|
||||||
HeaderSizing(true, FSplitter.x, x-FSplitter.y);
|
X := OffIni;
|
||||||
|
|
||||||
|
if X<>PrevOffset then begin
|
||||||
|
if PrevLine then
|
||||||
|
DrawXorVertLine(PrevOffset);
|
||||||
|
DrawXorVertLine(X);
|
||||||
|
PrevLine:=True;
|
||||||
|
PrevOffset:=X;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end else begin
|
||||||
|
if UseRightToLeftAlignment then
|
||||||
|
ResizeColumn(Index, OffEnd - X + DeltaOff)
|
||||||
|
else
|
||||||
|
ResizeColumn(Index, X - OffIni + DeltaOff);
|
||||||
|
end;
|
||||||
|
HeaderSizing(true, Index, X - OffIni + DeltaOff);
|
||||||
exit(true);
|
exit(true);
|
||||||
end else
|
end else
|
||||||
if (fGridState=gsNormal) and (ColCount>FixedCols) and
|
if (fGridState=gsNormal) and (ColCount>FixedCols) and
|
||||||
@ -4687,41 +4796,35 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
|
|
||||||
// find closest cell and cell boundaries
|
// find closest cell and cell boundaries
|
||||||
if (UseRightToLeftAlignment and (X < 1)) or
|
if (FlipX(X)>FGCache.GridWidth-1) then
|
||||||
(X>FGCache.GridWidth-1) then
|
Index := ColCount-1
|
||||||
FSplitter.x := ColCount-1
|
|
||||||
else
|
else
|
||||||
OffsetToColRow(True, True, X, FSplitter.X, Loc);
|
OffsetToColRow(True, True, X, Index, Offset);
|
||||||
ColRowToOffset(True, true, FSplitter.X, OffIni, OffEnd);
|
ColRowToOffset(True, true, Index, OffIni, OffEnd);
|
||||||
|
|
||||||
// find out what cell boundary is closer to X
|
if OffEnd>FGCache.ClientWidth then
|
||||||
if UseRightToLeftAlignment and (OffIni < 0) then
|
Offset := FGCache.ClientWidth
|
||||||
Loc := 0
|
else if (OffEnd-X)<(X-OffIni) then begin
|
||||||
else if OffEnd>FGCache.ClientWidth then
|
Offset := OffEnd;
|
||||||
Loc := FGCache.ClientWidth
|
|
||||||
else if UseRightToLeftAlignment and ((X-OffIni)<(OffEnd-X)) then
|
|
||||||
Loc := OffIni
|
|
||||||
else if not UseRightToLeftAlignment and ((OffEnd-X)<(X-OffIni)) then
|
|
||||||
Loc := OffEnd
|
|
||||||
else begin
|
|
||||||
if UseRightToLeftAlignment then
|
if UseRightToLeftAlignment then
|
||||||
Loc := OffEnd
|
FindPrevColumn;
|
||||||
else
|
end else begin
|
||||||
Loc := OffIni;
|
Offset := OffIni;
|
||||||
Dec(FSplitter.X);
|
if not UseRightToLeftAlignment then
|
||||||
|
FindPrevColumn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if it's not fixed col and if cursor is close enough to sel boundary
|
// check if it's not fixed col and if cursor is close enough to sel boundary
|
||||||
if (FSplitter.X>=FFixedCols)and(Abs(Loc-x)<=2) then begin
|
if (Index>=FFixedCols)and(Abs(Offset-x)<=2) then begin
|
||||||
// start resizing
|
// start resizing
|
||||||
if Cursor<>crHSplit then begin
|
if Cursor<>crHSplit then begin
|
||||||
FSplitter.Y := X;
|
PrevLine := false;
|
||||||
|
PrevOffset := -1;
|
||||||
ChangeCursor(crHSplit);
|
ChangeCursor(crHSplit);
|
||||||
FPrevLine := False;
|
|
||||||
FPrevValue := -1;
|
|
||||||
end;
|
end;
|
||||||
exit(true);
|
exit(true);
|
||||||
end
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (cursor=crHSplit) then
|
if (cursor=crHSplit) then
|
||||||
@ -4730,56 +4833,60 @@ end;
|
|||||||
|
|
||||||
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
OffIni,OffEnd,Loc: Integer;
|
Offset: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
|
|
||||||
|
with FSizing do
|
||||||
if gsRowSizing = fGridState then begin
|
if gsRowSizing = fGridState then begin
|
||||||
if FUseXORFeatures then begin
|
if FUseXORFeatures then begin
|
||||||
if (y-FSplitter.x)<=0 then
|
if (y-OffIni)<=0 then
|
||||||
y:= FSplitter.x;
|
y:= OffIni;
|
||||||
if y<>FPrevValue then begin
|
if y<>PrevOffset then begin
|
||||||
if FPrevLine then
|
if PrevLine then
|
||||||
DrawXorHorzLine(FPrevValue);
|
DrawXorHorzLine(PrevOffset);
|
||||||
DrawXorHorzLine(Y);
|
DrawXorHorzLine(Y);
|
||||||
FPrevLine:=True;
|
PrevLine:=True;
|
||||||
FPrevValue:=y;
|
PrevOffset:=y;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
ResizeRow(FSplitter.y, y-FSplitter.x);
|
ResizeRow(Index, y-OffIni);
|
||||||
HeaderSizing(false, FSplitter.Y, y-FSplitter.x);
|
HeaderSizing(false, Index, y-OffIni);
|
||||||
Result:=True;
|
Result:=True;
|
||||||
end else
|
end else
|
||||||
if (fGridState=gsNormal) and (RowCount>FixedRows) and
|
if (fGridState=gsNormal) and (RowCount>FixedRows) and
|
||||||
((FlipX(X)<FGCache.FixedWidth) or (FExtendedRowSizing and (FlipX(X)<FGCache.MaxClientXY.X))) and
|
((FlipX(X)<FGCache.FixedWidth) or
|
||||||
|
(FExtendedRowSizing and (FlipX(X)<FGCache.MaxClientXY.X))) and
|
||||||
(Y>FGCache.FixedHeight) then
|
(Y>FGCache.FixedHeight) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
// find closest cell and cell boundaries
|
// find closest cell and cell boundaries
|
||||||
if Y>FGCache.GridHeight-1 then
|
if Y>FGCache.GridHeight-1 then
|
||||||
FSplitter.Y := RowCount-1
|
Index := RowCount-1
|
||||||
else
|
else
|
||||||
OffsetToColRow(False, True, Y, FSplitter.Y, OffEnd{dummy});
|
OffsetToColRow(False, True, Y, Index, OffEnd{dummy});
|
||||||
ColRowToOffset(False, True, FSplitter.Y, OffIni, OffEnd);
|
ColRowToOffset(False, True, Index, OffIni, OffEnd);
|
||||||
|
|
||||||
// find out what cell boundary is closer to Y
|
// find out what cell boundary is closer to Y
|
||||||
if OffEnd>FGCache.ClientHeight then
|
if OffEnd>FGCache.ClientHeight then
|
||||||
Loc := FGCache.ClientHeight
|
Offset := FGCache.ClientHeight
|
||||||
else
|
else
|
||||||
if (OffEnd-Y)<(Y-OffIni) then
|
if (OffEnd-Y)<(Y-OffIni) then
|
||||||
Loc := OffEnd
|
Offset := OffEnd
|
||||||
else begin
|
else begin
|
||||||
Loc := OffIni;
|
Offset := OffIni;
|
||||||
Dec(FSplitter.Y);
|
Dec(Index);
|
||||||
|
ColRowToOffset(False, True, Index, OffIni, OffEnd);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if it's not fixed row and if cursor is close enough to sel boundary
|
// check if it's not fixed row and if cursor is close enough to
|
||||||
if (FSplitter.Y>=FFixedRows)and(Abs(Loc-Y)<=2) then begin
|
// selected boundary
|
||||||
|
if (Index>=FFixedRows)and(Abs(Offset-Y)<=2) then begin
|
||||||
// start resizing
|
// start resizing
|
||||||
if Cursor<>crVSplit then begin
|
if Cursor<>crVSplit then begin
|
||||||
FSplitter.X := Y;
|
|
||||||
ChangeCursor(crVSplit);
|
ChangeCursor(crVSplit);
|
||||||
FPrevLine := False;
|
PrevLine := False;
|
||||||
FPrevValue := -1;
|
PrevOffset := -1;
|
||||||
end;
|
end;
|
||||||
exit(true);
|
exit(true);
|
||||||
end
|
end
|
||||||
@ -4795,7 +4902,6 @@ var
|
|||||||
CurCell: TPoint;
|
CurCell: TPoint;
|
||||||
R: TRect;
|
R: TRect;
|
||||||
begin
|
begin
|
||||||
//debugLn('DoColMoving: FDragDX=',IntToStr(FDragDX), ' Sp.x= ', IntTOStr(FSplitter.X), 'Sp.y= ', IntToStr(FSplitter.y));
|
|
||||||
CurCell:=MouseToCell(Point(X,Y));
|
CurCell:=MouseToCell(Point(X,Y));
|
||||||
|
|
||||||
with FGCache do begin
|
with FGCache do begin
|
||||||
@ -5288,7 +5394,7 @@ var
|
|||||||
function DoAutoEdit: boolean;
|
function DoAutoEdit: boolean;
|
||||||
begin
|
begin
|
||||||
result := FAutoEdit and EditingAllowed(FCol) and
|
result := FAutoEdit and EditingAllowed(FCol) and
|
||||||
(FSplitter.X=Col) and (FSplitter.Y=Row);
|
(FGCache.ClickCell.X=Col) and (FGCache.ClickCell.Y=Row);
|
||||||
if result then begin
|
if result then begin
|
||||||
SelectEditor;
|
SelectEditor;
|
||||||
EditorShow(True);
|
EditorShow(True);
|
||||||
@ -5322,14 +5428,11 @@ begin
|
|||||||
|
|
||||||
gzFixedCols:
|
gzFixedCols:
|
||||||
begin
|
begin
|
||||||
if (goColSizing in Options) and (Cursor=crHSplit) then begin
|
if (goColSizing in Options) and (Cursor=crHSplit) then
|
||||||
R:=CellRect(FSplitter.x, 0{FTopLeft.y});
|
|
||||||
if UseRightToLeftAlignment then
|
fGridState:= gsColSizing
|
||||||
FSplitter.y:=R.Right
|
|
||||||
else
|
else begin
|
||||||
FSplitter.y:=R.Left;
|
|
||||||
fGridState:= gsColSizing;
|
|
||||||
end else begin
|
|
||||||
// ColMoving or Clicking
|
// ColMoving or Clicking
|
||||||
fGridState:=gsColMoving;
|
fGridState:=gsColMoving;
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
@ -5338,11 +5441,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
gzFixedRows:
|
gzFixedRows:
|
||||||
if (goRowSizing in Options)and(Cursor=crVSplit) then begin
|
if (goRowSizing in Options)and(Cursor=crVSplit) then
|
||||||
R:=CellRect(0{FTopLeft.X}, FSplitter.y);
|
|
||||||
FSplitter.x:=R.top;
|
fGridState:= gsRowSizing
|
||||||
fGridState:= gsRowSizing;
|
|
||||||
end else begin
|
else begin
|
||||||
// RowMoving or Clicking
|
// RowMoving or Clicking
|
||||||
fGridState:=gsRowMoving;
|
fGridState:=gsRowMoving;
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
@ -5360,14 +5463,12 @@ begin
|
|||||||
(Cursor=crHSplit) and
|
(Cursor=crHSplit) and
|
||||||
(goColSizing in Options) then begin
|
(goColSizing in Options) then begin
|
||||||
// extended column sizing
|
// extended column sizing
|
||||||
R:=CellRect(FSplitter.x, FTopLeft.y);
|
|
||||||
FSplitter.y:=R.Left;
|
|
||||||
fGridState:= gsColSizing;
|
fGridState:= gsColSizing;
|
||||||
|
|
||||||
end
|
end
|
||||||
else if not FixedGrid then begin
|
else if not FixedGrid then begin
|
||||||
// normal selecting
|
// normal selecting
|
||||||
fGridState:=gsSelecting;
|
fGridState:=gsSelecting;
|
||||||
FSplitter:=MouseToCell(Point(X,Y));
|
|
||||||
|
|
||||||
if not EditingAllowed(FCol) or
|
if not EditingAllowed(FCol) or
|
||||||
(ExtendedSelect and not EditorAlwaysShown) then begin
|
(ExtendedSelect and not EditorAlwaysShown) then begin
|
||||||
@ -5386,7 +5487,7 @@ begin
|
|||||||
// do that only if editor is not shown
|
// do that only if editor is not shown
|
||||||
GridFlags := GridFlags + [gfNeedsSelectActive];
|
GridFlags := GridFlags + [gfNeedsSelectActive];
|
||||||
|
|
||||||
FPivot:=FSplitter;
|
FPivot:=FGCache.ClickCell;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5396,7 +5497,7 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not MoveExtend(False, FSplitter.X, FSplitter.Y) then begin
|
if not MoveExtend(False, FGCache.ClickCell.X, FGCache.ClickCell.Y) then begin
|
||||||
if EditorAlwaysShown then begin
|
if EditorAlwaysShown then begin
|
||||||
SelectEditor;
|
SelectEditor;
|
||||||
EditorShow(true);
|
EditorShow(true);
|
||||||
@ -5511,35 +5612,36 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
gsColSizing:
|
gsColSizing:
|
||||||
begin
|
if gfSizingStarted in FGridFlags then
|
||||||
|
with FSizing do begin
|
||||||
if FUseXORFeatures then begin
|
if FUseXORFeatures then begin
|
||||||
if FPrevLine then
|
if PrevLine then
|
||||||
DrawXorVertLine(FPrevValue);
|
DrawXorVertLine(PrevOffset);
|
||||||
FPrevLine := False;
|
PrevLine := False;
|
||||||
FPrevValue := -1;
|
PrevOffset := -1;
|
||||||
end;
|
end;
|
||||||
if UseRightToLeftAlignment then
|
if UseRightToLeftAlignment then
|
||||||
ResizeColumn(FSplitter.x, FSplitter.y - x)
|
ResizeColumn(Index, OffEnd - X + DeltaOff)
|
||||||
else
|
else
|
||||||
ResizeColumn(FSplitter.x, x - FSplitter.y);
|
ResizeColumn(Index, X - OffIni + DeltaOff);
|
||||||
HeaderSized(True, FSplitter.X);
|
HeaderSized(True, Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
gsRowSizing:
|
gsRowSizing:
|
||||||
begin
|
with FSizing do begin
|
||||||
if FUseXORFeatures then begin
|
if FUseXORFeatures then begin
|
||||||
if FPrevLine then
|
if PrevLine then
|
||||||
DrawXorHorzLine(FPrevValue);
|
DrawXorHorzLine(PrevOffset);
|
||||||
FPrevLine := False;
|
PrevLine := False;
|
||||||
FPrevValue := -1;
|
PrevOffset := -1;
|
||||||
end;
|
end;
|
||||||
ResizeRow(FSplitter.y, y-FSplitter.x);
|
ResizeRow(Index, Y - OffIni);
|
||||||
HeaderSized( False, FSplitter.Y);
|
HeaderSized(False, Index);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
fGridState:=gsNormal;
|
fGridState:=gsNormal;
|
||||||
GridFlags := GridFlags - [gfNeedsSelectActive];
|
GridFlags := GridFlags - [gfNeedsSelectActive, gfSizingStarted];
|
||||||
|
|
||||||
if (goHeaderPushedLook in Options) and IsPushCellActive() then
|
if (goHeaderPushedLook in Options) and IsPushCellActive() then
|
||||||
begin
|
begin
|
||||||
@ -5550,13 +5652,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.DblClick;
|
procedure TCustomGrid.DblClick;
|
||||||
|
var
|
||||||
|
OldWidth: Integer;
|
||||||
begin
|
begin
|
||||||
{$IfDef dbgGrid}DebugLn('DoubleClick INIT');{$Endif}
|
{$IfDef dbgGrid}DebugLn('DoubleClick INIT');{$Endif}
|
||||||
SelectActive:=False;
|
SelectActive:=False;
|
||||||
fGridState:=gsNormal;
|
fGridState:=gsNormal;
|
||||||
if (goColSizing in Options) and (Cursor=crHSplit) then begin
|
if (goColSizing in Options) and (Cursor=crHSplit) then begin
|
||||||
if (goDblClickAutoSize in Options) then begin
|
if (goDblClickAutoSize in Options) then begin
|
||||||
AutoAdjustColumn( FSplitter.X );
|
OldWidth := ColWidths[FSizing.Index];
|
||||||
|
AutoAdjustColumn( FSizing.Index );
|
||||||
|
if OldWidth<>ColWidths[FSizing.Index] then
|
||||||
|
ChangeCursor;
|
||||||
end {else
|
end {else
|
||||||
DebugLn('Got Doubleclick on Col Resizing: AutoAdjust?');}
|
DebugLn('Got Doubleclick on Col Resizing: AutoAdjust?');}
|
||||||
end else
|
end else
|
||||||
|
Loading…
Reference in New Issue
Block a user