mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 21:40:34 +02:00
LCL, implemented mousewheel scrolling grid, issue #12860
git-svn-id: trunk@18125 -
This commit is contained in:
parent
13c4eb0d63
commit
cf5fd331cf
@ -871,7 +871,7 @@ type
|
|||||||
function GetFixedcolor: TColor; virtual;
|
function GetFixedcolor: TColor; virtual;
|
||||||
function GetSelectedColor: TColor; virtual;
|
function GetSelectedColor: TColor; virtual;
|
||||||
function GridColumnFromColumnIndex(ColumnIndex: Integer): Integer;
|
function GridColumnFromColumnIndex(ColumnIndex: Integer): Integer;
|
||||||
|
procedure GridMouseWheel(shift: TShiftState; Delta: Integer); virtual;
|
||||||
procedure HeaderClick(IsColumn: Boolean; index: Integer); dynamic;
|
procedure HeaderClick(IsColumn: Boolean; index: Integer); dynamic;
|
||||||
procedure HeaderSized(IsColumn: Boolean; index: Integer); dynamic;
|
procedure HeaderSized(IsColumn: Boolean; index: Integer); dynamic;
|
||||||
procedure InternalSetColCount(ACount: Integer);
|
procedure InternalSetColCount(ACount: Integer);
|
||||||
@ -1056,6 +1056,7 @@ type
|
|||||||
TSetEditEvent = procedure (Sender: TObject; ACol, ARow: Integer; const Value: string) of object;
|
TSetEditEvent = procedure (Sender: TObject; ACol, ARow: Integer; const Value: string) of object;
|
||||||
TGetCheckboxStateEvent = procedure (Sender: TObject; ACol, ARow: Integer; var Value: TCheckboxState) of object;
|
TGetCheckboxStateEvent = procedure (Sender: TObject; ACol, ARow: Integer; var Value: TCheckboxState) of object;
|
||||||
TSetCheckboxStateEvent = procedure (Sender: TObject; ACol, ARow: Integer; const Value: TCheckboxState) of object;
|
TSetCheckboxStateEvent = procedure (Sender: TObject; ACol, ARow: Integer; const Value: TCheckboxState) of object;
|
||||||
|
TMouseWheelOption = (mwCursor, mwGrid);
|
||||||
|
|
||||||
|
|
||||||
{ TCustomDrawGrid }
|
{ TCustomDrawGrid }
|
||||||
@ -1073,6 +1074,7 @@ type
|
|||||||
FOnSelectCell: TOnSelectcellEvent;
|
FOnSelectCell: TOnSelectcellEvent;
|
||||||
FOnSetCheckboxState: TSetCheckboxStateEvent;
|
FOnSetCheckboxState: TSetCheckboxStateEvent;
|
||||||
FOnSetEditText: TSetEditEvent;
|
FOnSetEditText: TSetEditEvent;
|
||||||
|
FMouseWheelOption: TMouseWheelOption;
|
||||||
function CellNeedsCheckboxBitmaps(const aCol,aRow: Integer): boolean;
|
function CellNeedsCheckboxBitmaps(const aCol,aRow: Integer): boolean;
|
||||||
procedure DrawCellCheckboxBitmaps(const aCol,aRow: Integer; const aRect: TRect);
|
procedure DrawCellCheckboxBitmaps(const aCol,aRow: Integer; const aRect: TRect);
|
||||||
protected
|
protected
|
||||||
@ -1090,6 +1092,7 @@ type
|
|||||||
procedure GetCheckBoxState(const aCol, aRow:Integer; var aState:TCheckboxState); virtual;
|
procedure GetCheckBoxState(const aCol, aRow:Integer; var aState:TCheckboxState); virtual;
|
||||||
function GetEditMask(aCol, aRow: Longint): string; override;
|
function GetEditMask(aCol, aRow: Longint): string; override;
|
||||||
function GetEditText(aCol, aRow: Longint): string; override;
|
function GetEditText(aCol, aRow: Longint): string; override;
|
||||||
|
procedure GridMouseWheel(shift: TShiftState; Delta: Integer); override;
|
||||||
procedure HeaderClick(IsColumn: Boolean; index: Integer); override;
|
procedure HeaderClick(IsColumn: Boolean; index: Integer); override;
|
||||||
procedure HeaderSized(IsColumn: Boolean; index: Integer); override;
|
procedure HeaderSized(IsColumn: Boolean; index: Integer); override;
|
||||||
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
||||||
@ -1101,6 +1104,8 @@ type
|
|||||||
procedure SizeChanged(OldColCount, OldRowCount: Integer); override;
|
procedure SizeChanged(OldColCount, OldRowCount: Integer); override;
|
||||||
procedure ToggleCheckbox; virtual;
|
procedure ToggleCheckbox; virtual;
|
||||||
|
|
||||||
|
property MouseWheelOption: TMouseWheelOption read FMouseWheelOption
|
||||||
|
write FMouseWheelOption default mwCursor;
|
||||||
property OnGetCheckboxState: TGetCheckboxStateEvent
|
property OnGetCheckboxState: TGetCheckboxStateEvent
|
||||||
read FOnGetCheckboxState write FOnGetCheckboxState;
|
read FOnGetCheckboxState write FOnGetCheckboxState;
|
||||||
property OnSetCheckboxState: TSetCheckboxStateEvent
|
property OnSetCheckboxState: TSetCheckboxStateEvent
|
||||||
@ -1270,6 +1275,7 @@ type
|
|||||||
property GridLineWidth;
|
property GridLineWidth;
|
||||||
property HeaderHotZones;
|
property HeaderHotZones;
|
||||||
property HeaderPushZones;
|
property HeaderPushZones;
|
||||||
|
property MouseWheelOption;
|
||||||
property Options;
|
property Options;
|
||||||
//property ParentBiDiMode;
|
//property ParentBiDiMode;
|
||||||
property ParentColor default false;
|
property ParentColor default false;
|
||||||
@ -1462,6 +1468,7 @@ type
|
|||||||
property GridLineWidth;
|
property GridLineWidth;
|
||||||
property HeaderHotZones;
|
property HeaderHotZones;
|
||||||
property HeaderPushZones;
|
property HeaderPushZones;
|
||||||
|
property MouseWheelOption;
|
||||||
property Options;
|
property Options;
|
||||||
//property ParentBiDiMode;
|
//property ParentBiDiMode;
|
||||||
property ParentColor default false;
|
property ParentColor default false;
|
||||||
@ -5455,12 +5462,8 @@ function TCustomGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
|||||||
begin
|
begin
|
||||||
{$ifdef dbgScroll}DebugLn('doMouseWheelDown INIT');{$endif}
|
{$ifdef dbgScroll}DebugLn('doMouseWheelDown INIT');{$endif}
|
||||||
Result:=inherited DoMouseWheelDown(Shift, MousePos);
|
Result:=inherited DoMouseWheelDown(Shift, MousePos);
|
||||||
if not result then begin
|
if not Result then begin
|
||||||
// event wasn't handled by the user
|
GridMouseWheel(Shift, 1);
|
||||||
if ssCtrl in Shift then
|
|
||||||
MoveNextSelectable(true, 1, 0)
|
|
||||||
else
|
|
||||||
MoveNextSelectable(true, 0, 1);
|
|
||||||
Result := true;
|
Result := true;
|
||||||
end;
|
end;
|
||||||
{$ifdef dbgScroll}DebugLn('doMouseWheelDown END');{$endif}
|
{$ifdef dbgScroll}DebugLn('doMouseWheelDown END');{$endif}
|
||||||
@ -5471,13 +5474,9 @@ function TCustomGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
|||||||
begin
|
begin
|
||||||
{$ifdef dbgScroll}DebugLn('doMouseWheelUP INIT');{$endif}
|
{$ifdef dbgScroll}DebugLn('doMouseWheelUP INIT');{$endif}
|
||||||
Result:=inherited DoMouseWheelUp(Shift, MousePos);
|
Result:=inherited DoMouseWheelUp(Shift, MousePos);
|
||||||
if not result then begin
|
if not Result then begin
|
||||||
// event wasn't handled by the user
|
GridMouseWheel(Shift, -1);
|
||||||
if ssCtrl in Shift then
|
Result := true;
|
||||||
MoveNextSelectable(true, -1, 0)
|
|
||||||
else
|
|
||||||
MoveNextSelectable(true, 0, -1);
|
|
||||||
Result := True;
|
|
||||||
end;
|
end;
|
||||||
{$ifdef dbgScroll}DebugLn('doMouseWheelUP END');{$endif}
|
{$ifdef dbgScroll}DebugLn('doMouseWheelUP END');{$endif}
|
||||||
end;
|
end;
|
||||||
@ -6524,6 +6523,14 @@ begin
|
|||||||
result := result + FixedCols;
|
result := result + FixedCols;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomGrid.GridMouseWheel(shift: TShiftState; Delta: Integer);
|
||||||
|
begin
|
||||||
|
if ssCtrl in Shift then
|
||||||
|
MoveNextSelectable(true, Delta, 0)
|
||||||
|
else
|
||||||
|
MoveNextSelectable(true, 0, Delta);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomGrid.GetEditMask(ACol, ARow: Longint): string;
|
function TCustomGrid.GetEditMask(ACol, ARow: Longint): string;
|
||||||
begin
|
begin
|
||||||
result:='';
|
result:='';
|
||||||
@ -7992,6 +7999,18 @@ begin
|
|||||||
if assigned(OnGetEditText) then OnGetEditText(self, aCol, aRow, Result);
|
if assigned(OnGetEditText) then OnGetEditText(self, aCol, aRow, Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomDrawGrid.GridMouseWheel(shift: TShiftState; Delta: Integer);
|
||||||
|
begin
|
||||||
|
if FMouseWheelOption=mwCursor then
|
||||||
|
inherited GridMouseWheel(shift, Delta)
|
||||||
|
else begin
|
||||||
|
if ssCtrl in Shift then
|
||||||
|
TryScrollTo(LeftCol+Delta, TopRow)
|
||||||
|
else
|
||||||
|
TryScrollTo(LeftCol, TopRow+Delta);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomDrawGrid.NotifyColRowChange(WasInsert, IsColumn: boolean;
|
procedure TCustomDrawGrid.NotifyColRowChange(WasInsert, IsColumn: boolean;
|
||||||
FromIndex,ToIndex: Integer);
|
FromIndex,ToIndex: Integer);
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user