mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 20:29:12 +02:00
LCL, fixed grid changed user cursor when col/row sizing/moving, issue #13335
git-svn-id: trunk@19039 -
This commit is contained in:
parent
8ed5064c16
commit
6a269eed85
137
lcl/grids.pas
137
lcl/grids.pas
@ -667,6 +667,7 @@ type
|
|||||||
FHeaderHotZones: TGridZoneSet;
|
FHeaderHotZones: TGridZoneSet;
|
||||||
FHeaderPushZones: TGridZoneSet;
|
FHeaderPushZones: TGridZoneSet;
|
||||||
FCheckedBitmap, FUnCheckedBitmap, FGrayedBitmap: TBitmap;
|
FCheckedBitmap, FUnCheckedBitmap, FGrayedBitmap: TBitmap;
|
||||||
|
FSavedCursor: TCursor;
|
||||||
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
procedure AdjustCount(IsColumn:Boolean; OldValue, NewValue:Integer);
|
||||||
procedure CacheVisibleGrid;
|
procedure CacheVisibleGrid;
|
||||||
procedure CancelSelection;
|
procedure CancelSelection;
|
||||||
@ -760,6 +761,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);
|
||||||
|
procedure ChangeCursor(ACursor: Integer = MAXINT);
|
||||||
procedure TryScrollTo(aCol,aRow: integer);
|
procedure TryScrollTo(aCol,aRow: integer);
|
||||||
procedure UpdateScrollBarPos(Which: TScrollStyle);
|
procedure UpdateScrollBarPos(Which: TScrollStyle);
|
||||||
procedure UpdateCachedSizes;
|
procedure UpdateCachedSizes;
|
||||||
@ -2204,6 +2206,16 @@ begin
|
|||||||
TryScrollTo(FTopLeft.X, Avalue);
|
TryScrollTo(FTopLeft.X, Avalue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomGrid.ChangeCursor(ACursor: Integer = MAXINT);
|
||||||
|
begin
|
||||||
|
if ACursor=MAXINT then
|
||||||
|
Cursor := FSavedCursor
|
||||||
|
else begin
|
||||||
|
FSavedCursor := Cursor;
|
||||||
|
Cursor := TCursor(ACursor);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.Setrowheights(Arow: Integer; Avalue: Integer);
|
procedure TCustomGrid.Setrowheights(Arow: Integer; Avalue: Integer);
|
||||||
var
|
var
|
||||||
R: TRect;
|
R: TRect;
|
||||||
@ -4372,8 +4384,7 @@ end;
|
|||||||
|
|
||||||
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doColSizing(X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
R: TRect;
|
OffIni,OffEnd,Loc: Integer;
|
||||||
Loc: Integer;
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if gsColSizing = fGridState then begin
|
if gsColSizing = fGridState then begin
|
||||||
@ -4389,49 +4400,51 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
ResizeColumn(FSplitter.x, x-FSplitter.y);
|
ResizeColumn(FSplitter.x, x-FSplitter.y);
|
||||||
Result:=True;
|
exit(true);
|
||||||
end else
|
end else
|
||||||
if (fGridState=gsNormal) and (ColCount>FixedCols) and
|
if (fGridState=gsNormal) and (ColCount>FixedCols) and
|
||||||
((Y<FGCache.FixedHeight) or (FExtendedColSizing and (Y<FGCache.MaxClientXY.Y))) and
|
((Y<FGCache.FixedHeight) or (FExtendedColSizing and (Y<FGCache.MaxClientXY.Y))) and
|
||||||
(X>FGCache.FixedWidth)
|
(X>FGCache.FixedWidth)
|
||||||
then begin
|
then begin
|
||||||
//FSplitter.X:= OffsetToColRow(True, True, X, Loc);
|
|
||||||
FSplitter.Y:=0;
|
|
||||||
if OffsetToColRow(True, True, X, FSplitter.X, Loc) then begin
|
|
||||||
R:=CellRect(FSplitter.x, FSplitter.y);
|
|
||||||
FSplitter.y:=X; // Resizing X reference
|
|
||||||
|
|
||||||
// if resizing column is partially visible, take the visible boundary.
|
// find closest cell and cell boundaries
|
||||||
if R.Right>FGCache.ClientWidth then
|
if X>FGCache.GridWidth-1 then
|
||||||
Loc:=FGCache.Clientwidth
|
FSplitter.x := ColCount-1
|
||||||
else
|
else
|
||||||
if (R.Right-X)<(X-R.Left) then
|
OffsetToColRow(True, True, X, FSplitter.X, Loc);
|
||||||
Loc:=R.Right
|
ColRowToOffset(True, true, FSplitter.X, OffIni, OffEnd);
|
||||||
else begin
|
|
||||||
Loc:=R.Left;
|
// find out what cell boundary is closer to X
|
||||||
Dec(FSplitter.x); // Resizing col is the previous
|
if OffEnd>FGCache.ClientWidth then
|
||||||
end;
|
Loc := FGCache.ClientWidth
|
||||||
iF (Abs(Loc-x)<=2)and(FSplitter.X>=FFixedCols) then begin
|
else
|
||||||
// start resizing
|
if (OffEnd-X)<(X-OffIni) then
|
||||||
Cursor:=crHSplit;
|
Loc := OffEnd
|
||||||
{.$ifdef UseXOR}
|
else begin
|
||||||
|
Loc := OffIni;
|
||||||
|
Dec(FSplitter.X);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// start resizing
|
||||||
|
if Cursor<>crHSplit then begin
|
||||||
|
FSplitter.Y := X;
|
||||||
|
ChangeCursor(crHSplit);
|
||||||
FPrevLine := False;
|
FPrevLine := False;
|
||||||
FPrevValue := -1;
|
FPrevValue := -1;
|
||||||
{.$endif}
|
end;
|
||||||
end
|
exit(true);
|
||||||
else
|
end
|
||||||
Cursor:=crDefault;
|
end;
|
||||||
Result:=True;
|
|
||||||
end;
|
if (cursor=crHSplit) then
|
||||||
end
|
ChangeCursor;
|
||||||
else
|
|
||||||
if (cursor=crHSplit) then
|
|
||||||
Cursor:=crDefault;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
function TCustomGrid.doRowSizing(X, Y: Integer): Boolean;
|
||||||
var
|
var
|
||||||
OffTop,OffBottom: Integer;
|
OffIni,OffEnd,Loc: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
if gsRowSizing = fGridState then begin
|
if gsRowSizing = fGridState then begin
|
||||||
@ -4453,25 +4466,41 @@ begin
|
|||||||
((X<FGCache.FixedWidth) or (FExtendedRowSizing and (X<FGCache.MaxClientXY.X))) and
|
((X<FGCache.FixedWidth) or (FExtendedRowSizing and (X<FGCache.MaxClientXY.X))) and
|
||||||
(Y>FGCache.FixedHeight) then
|
(Y>FGCache.FixedHeight) then
|
||||||
begin
|
begin
|
||||||
//fSplitter.Y:=OffsetToColRow(False, True, Y, OffTop{dummy});
|
|
||||||
if OffsetToColRow(False, True, Y, FSplitter.Y, OffTop{dummy}) then begin
|
// find closest cell and cell boundaries
|
||||||
ColRowToOffset(False, True, FSplitter.Y, OffTop, OffBottom);
|
if Y>FGCache.GridHeight-1 then
|
||||||
FSplitter.X:=Y;
|
FSplitter.Y := RowCount-1
|
||||||
if (OffBottom-Y)<(Y-OffTop) then SwapInt(OffTop, OffBottom)
|
else
|
||||||
else Dec(FSplitter.y);
|
OffsetToColRow(False, True, Y, FSplitter.Y, OffEnd{dummy});
|
||||||
if (Abs(OffTop-y)<=2)and(FSplitter.Y>=FFixedRows) then begin
|
ColRowToOffset(False, True, FSplitter.Y, OffIni, OffEnd);
|
||||||
// start resizing
|
|
||||||
Cursor:=crVSplit;
|
// find out what cell boundary is closer to Y
|
||||||
|
if OffEnd>FGCache.ClientHeight then
|
||||||
|
Loc := FGCache.ClientHeight
|
||||||
|
else
|
||||||
|
if (OffEnd-Y)<(Y-OffIni) then
|
||||||
|
Loc := OffEnd
|
||||||
|
else begin
|
||||||
|
Loc := OffIni;
|
||||||
|
Dec(FSplitter.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// check if it's not fixed row and if cursor is close enough to sel boundary
|
||||||
|
if (FSplitter.Y>=FFixedRows)and(Abs(Loc-Y)<=2) then begin
|
||||||
|
// start resizing
|
||||||
|
if Cursor<>crVSplit then begin
|
||||||
|
FSplitter.X := Y;
|
||||||
|
ChangeCursor(crVSplit);
|
||||||
FPrevLine := False;
|
FPrevLine := False;
|
||||||
FPrevValue := -1;
|
FPrevValue := -1;
|
||||||
end else
|
end;
|
||||||
Cursor:=crDefault;
|
exit(true);
|
||||||
Result:=True;
|
end
|
||||||
end;
|
|
||||||
end
|
end;
|
||||||
else
|
|
||||||
if Cursor=crVSplit then
|
if (cursor=crVSplit) then
|
||||||
Cursor:=crDefault;
|
ChangeCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGrid.doColMoving(X, Y: Integer);
|
procedure TCustomGrid.doColMoving(X, Y: Integer);
|
||||||
@ -4485,7 +4514,7 @@ begin
|
|||||||
with FGCache do begin
|
with FGCache do begin
|
||||||
|
|
||||||
if (Abs(ClickMouse.X-X)>FDragDX) and (Cursor<>crMultiDrag) then begin
|
if (Abs(ClickMouse.X-X)>FDragDX) and (Cursor<>crMultiDrag) then begin
|
||||||
Cursor:=crMultiDrag;
|
ChangeCursor(crMultiDrag);
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
ResetOffset(True, False);
|
ResetOffset(True, False);
|
||||||
end;
|
end;
|
||||||
@ -4521,7 +4550,7 @@ begin
|
|||||||
with FGCache do begin
|
with FGCache do begin
|
||||||
|
|
||||||
if (Cursor<>crMultiDrag) and (Abs(ClickMouse.Y-Y)>FDragDX) then begin
|
if (Cursor<>crMultiDrag) and (Abs(ClickMouse.Y-Y)>FDragDX) then begin
|
||||||
Cursor:=crMultiDrag;
|
ChangeCursor(crMultiDrag);
|
||||||
FMoveLast:=Point(-1,-1);
|
FMoveLast:=Point(-1,-1);
|
||||||
ResetOffset(False, True);
|
ResetOffset(False, True);
|
||||||
end;
|
end;
|
||||||
@ -5145,7 +5174,7 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
{$endif}
|
{$endif}
|
||||||
DoOPMoveColRow(True, FGCache.ClickCell.X, FMoveLast.X);
|
DoOPMoveColRow(True, FGCache.ClickCell.X, FMoveLast.X);
|
||||||
Cursor:=crDefault;
|
ChangeCursor;
|
||||||
end else
|
end else
|
||||||
if Cur.X=FGCache.ClickCell.X then
|
if Cur.X=FGCache.ClickCell.X then
|
||||||
HeaderClick(True, FGCache.ClickCell.X);
|
HeaderClick(True, FGCache.ClickCell.X);
|
||||||
@ -5156,7 +5185,7 @@ begin
|
|||||||
//DebugLn('Move Row From ',Fsplitter.Y,' to ', FMoveLast.Y);
|
//DebugLn('Move Row From ',Fsplitter.Y,' to ', FMoveLast.Y);
|
||||||
if FMoveLast.Y>=0 then begin
|
if FMoveLast.Y>=0 then begin
|
||||||
DoOPMoveColRow(False, FGCache.ClickCell.Y, FMoveLast.Y);
|
DoOPMoveColRow(False, FGCache.ClickCell.Y, FMoveLast.Y);
|
||||||
Cursor:=crDefault;
|
ChangeCursor;
|
||||||
end else
|
end else
|
||||||
if Cur.Y=FGCache.ClickCell.Y then
|
if Cur.Y=FGCache.ClickCell.Y then
|
||||||
HeaderClick(False, FGCache.ClickCell.Y);
|
HeaderClick(False, FGCache.ClickCell.Y);
|
||||||
|
Loading…
Reference in New Issue
Block a user