NiceGrid: Fix crash in gtk3 due to loading cursors. Introduce TNiceGridState to avoid defining the grid state by means of the current cursor.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8870 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-06-30 21:18:38 +00:00
parent 792ce273a7
commit e44baffbcc
2 changed files with 77 additions and 69 deletions

View File

@ -554,7 +554,7 @@ const
CursorArray: array [TGridHitTest] of TCursor =
//(gtNone, gtLeftTop, gtLeft, gtTop, gtCell, gtColSizing, gtSmallBox);
{$IFDEF LCLGtk3}
{$IFDEF LCLGtk3} // Issue with loading cursors in GTK3 --> use predefined cursors.
(crDefault, crSizeSE, crSizeE, crSizeS, crHandPoint, crHSplit, crCross);
{$ELSE}
(crDefault, crLeftTop, crRight, crDown, crPlus, crHSplit, crSmallCross);
@ -565,6 +565,15 @@ const
MergeID = -2;
{$HINTS OFF}
procedure Unused(const A1); overload;
begin
end;
procedure Unused(const A1, A2); overload;
begin
end;
{$HINTS ON}
{ TNiceGrid }
@ -638,13 +647,8 @@ begin
SmallBoxPos := 0;
SizingCol := -1;
SizingColX := -1;
{$IFDEF LCLGtk3}
Screen.Cursors[crPlus] := Screen.Cursors[crHandPoint];
Screen.Cursors[crSmallCross] := Screen.Cursors[crCross];
Screen.Cursors[crRight] := Screen.Cursors[crSizeE];
Screen.Cursors[crDown] := Screen.Cursors[crSizeS];
Screen.Cursors[crLeftTop] := Screen.Cursors[crSizeSE];
{$ELSE}
{$IFNDEF LCLGtk3} // Issue with loading cursors in GTK3.
Screen.Cursors[crPlus] := LoadCursor(hinstance, 'CR_PLUS');
Screen.Cursors[crSmallCross] := LoadCursor(hInstance, 'CR_CROSS');
Screen.Cursors[crRight] := LoadCursor(hinstance, 'CR_RIGHT');
@ -3172,6 +3176,7 @@ end;
procedure TNiceGrid.WMSetFocus(var Msg: {$IFDEF FPC}TLMSetFocus{$ELSE}TWMSetFocus{$ENDIF});
begin
Unused(Msg);
CreateCaret(Handle, 0, 1, FDefRowHeight - 2);
CaretVisible := False;
InvalidateCells;
@ -4176,6 +4181,7 @@ end;
procedure TNiceGridSync.SetScrollBar(AKind, AMax, APos, AMask: Integer);
begin
Unused(AMax);
if (AKind = SB_VERT) and Assigned(FGrid) then
begin
if ((AMask and SIF_POS) <> 0)
@ -4186,6 +4192,7 @@ end;
procedure TNiceGridSync.ShowHideScrollBar(HorzVisible,
VertVisible: Boolean);
begin
Unused(HorzVisible, VertVisible);
ShowScrollBar(Handle, SB_HORZ, True);
ShowScrollBar(Handle, SB_VERT, False);
EnableScrollBar(Handle, SB_HORZ, 3{ESB_DISABLE_BOTH});
@ -4193,6 +4200,7 @@ end;
procedure TNiceGridSync.SyncColRow(Sender: TObject; ACol, ARow: Integer);
begin
Unused(ACol);
if Assigned(FGrid)
then FGrid.Row := ARow;
end;