summaryrefslogtreecommitdiff
path: root/libgtk_kylix/GTKControls.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2025-11-27 19:28:03 +0100
committerTomas Bzatek <tbzatek@redhat.com>2025-11-27 21:43:01 +0100
commit36a656e6188f227956dbdf12bf5fda8be1ea7985 (patch)
treee32bf7d43d4ea7d6466db72ba1d6f0d29f75f059 /libgtk_kylix/GTKControls.pas
parent90db8b6652f73ddc335922d3a7c593878d83c45e (diff)
downloadtuxcmd-36a656e6188f227956dbdf12bf5fda8be1ea7985.tar.xz
Fix panel separator resizing
Diffstat (limited to 'libgtk_kylix/GTKControls.pas')
-rw-r--r--libgtk_kylix/GTKControls.pas151
1 files changed, 108 insertions, 43 deletions
diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas
index 502e1b9..79551ff 100644
--- a/libgtk_kylix/GTKControls.pas
+++ b/libgtk_kylix/GTKControls.pas
@@ -40,19 +40,6 @@ const
mrNoToAll = mrAll + 1;
mrYesToAll = mrNoToAll + 1;
-type
-{$IFNDEF CPU64} // 32-bit platform
- TComponent64 = class(TComponent);
-{$ELSE} // 64-bit platform
- TComponent64 = class(TComponent)
- private
- FTag: QWORD;
- published
- property Tag: QWORD read FTag write FTag default 0;
- end;
-{$ENDIF}
-
-
type
TGTKShadowType = (stNone, stShadowIn, stShadowOut, stEtchedIn, stEtchedOut);
@@ -65,14 +52,16 @@ type
TGDKMouseEvent = procedure (Sender: TObject; Button: TGDKMouseButton; Shift: TShiftState; X, Y: Integer; var Accept: boolean) of object;
TGDKFocusEvent = procedure (Sender: TObject; var Accept: boolean) of object;
TGDKExposeEvent = procedure (Sender: TObject; const Rect: PGdkRectangle; var Accept: boolean) of object;
+ TGDKSizeAllocateEvent = procedure (Sender: TObject; const Rect: PGdkRectangle) of object;
TGTKControlState = (csNormal, csActive, csPrelight, csSelected, csInsensitive, csInconsistent, csFocused, csBackdrop, csDirLTR, cdDirRTL, csLink, csVisited, csChecked, csDropActive);
- TGTKControl = class(TComponent64)
+ TGTKControl = class(TComponent)
private
FVisible: Boolean;
FParent: TGTKControl;
FPopupMenu: TGTKControl;
FButtonPressSignalHandler, FButtonReleaseSignalHandler, FKeyDownSignalHandler, FKeyUpSignalHandler,
- FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler, FMotionNotifyHandler: gulong;
+ FFocusInSignalHandler, FFocusOutSignalHandler, FExposeSignalHandler, FMotionNotifyHandler,
+ FRealizeSignalHandler, FSizeAllocateSignalHandler: gulong;
FOnKeyDown: TGDKKeyEvent;
FOnKeyUp: TGDKKeyEvent;
FOnEnter: TGDKFocusEvent;
@@ -82,6 +71,8 @@ type
FOnDblClick: TGDKMouseEvent;
FOnExpose: TGDKExposeEvent;
FOnMouseMove: TGDKMouseEvent;
+ FOnRealize: TNotifyEvent;
+ FOnSizeAllocate: TGDKSizeAllocateEvent;
FCSSProvider: PGtkCssProvider;
function GetWidth: Integer;
function GetHeight: Integer;
@@ -124,6 +115,8 @@ type
procedure SetMarginEnd(Value: Integer);
procedure SetMarginTop(Value: Integer);
procedure SetMarginBottom(Value: Integer);
+ procedure SetOnRealize(Value: TNotifyEvent);
+ procedure SetOnSizeAllocate(Value: TGDKSizeAllocateEvent);
protected
procedure SetParent(const Value: TGTKControl); virtual;
public
@@ -161,6 +154,8 @@ type
property OnMouseMove: TGDKMouseEvent read FOnMouseMove write SetOnMouseMove;
property OnDblClick: TGDKMouseEvent read FOnDblClick write SetOnDblClick;
property OnExpose: TGDKExposeEvent read FOnExpose write SetOnExpose;
+ property OnRealize: TNotifyEvent read FOnRealize write SetOnRealize;
+ property OnSizeAllocate: TGDKSizeAllocateEvent read FOnSizeAllocate write SetOnSizeAllocate;
property ComponentState;
property ControlState: TGTKControlState read GetControlState write SetControlState;
property HAlign: TGTKAlignment read GetHAlign write SetHAlign;
@@ -292,6 +287,8 @@ begin
FFocusInSignalHandler := 0;
FFocusOutSignalHandler := 0;
FExposeSignalHandler := 0;
+ FRealizeSignalHandler := 0;
+ FSizeAllocateSignalHandler := 0;
FVisible := True;
FWidget := nil;
FPopupMenu := nil;
@@ -303,6 +300,8 @@ begin
FOnMouseMove := nil;
FOnMouseDown := nil;
FOnMouseUp := nil;
+ FOnRealize := nil;
+ FOnSizeAllocate := nil;
FCSSProvider := nil;
end;
@@ -427,7 +426,6 @@ begin
Result := not Accept;
if Accept then
if (Event^.button = 3) and Assigned(TGTKControl(user_data).FPopupMenu) then begin
-// if Assigned(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup) then TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup(TGTKMenuItem(TGTKControl(user_data).FPopupMenu));
if Assigned(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup) then TGTKMenuItem(TGTKControl(user_data).FPopupMenu).OnPopup(TGTKControl(user_data));
gtk_menu_popup(PGtkMenu(TGTKMenuItem(TGTKControl(user_data).FPopupMenu).FMenu), nil, nil, nil, nil, event^.button, event^.time);
Result := False; // Allow list views to process their events - select an item beneath the cursor
@@ -439,10 +437,8 @@ begin
if FPopupMenu <> Value then begin
FPopupMenu := Value;
if not Assigned(Value) then begin
- if not Assigned(FOnMouseDown) then begin
- g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler);
- FButtonPressSignalHandler := 0;
- end;
+ g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler);
+ FButtonPressSignalHandler := 0;
end else
if FButtonPressSignalHandler = 0
then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT)
@@ -528,9 +524,13 @@ procedure TGTKControl.SetOnKeyDown(Value: TGDKKeyEvent);
begin
if @FOnKeyDown <> @Value then begin
FOnKeyDown := Value;
- if Assigned(Value)
- then FKeyDownSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-press-event', TGCallback(@TGTKControl_key_press_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FKeyDownSignalHandler);
+ if Assigned(Value) then begin
+ if FKeyDownSignalHandler = 0 then
+ FKeyDownSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-press-event', TGCallback(@TGTKControl_key_press_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FKeyDownSignalHandler);
+ FKeyDownSignalHandler := 0;
+ end;
end;
end;
@@ -538,9 +538,13 @@ procedure TGTKControl.SetOnKeyUp(Value: TGDKKeyEvent);
begin
if @FOnKeyUp <> @Value then begin
FOnKeyUp := Value;
- if Assigned(Value)
- then FKeyUpSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-release-event', TGCallback(@TGTKControl_key_release_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FKeyUpSignalHandler);
+ if Assigned(Value) then begin
+ if FKeyUpSignalHandler = 0 then
+ FKeyUpSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-release-event', TGCallback(@TGTKControl_key_release_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FKeyUpSignalHandler);
+ FKeyUpSignalHandler := 0;
+ end;
end;
end;
@@ -564,9 +568,13 @@ procedure TGTKControl.SetOnEnter(Value: TGDKFocusEvent);
begin
if @FOnEnter <> @Value then begin
FOnEnter := Value;
- if Assigned(Value)
- then FFocusInSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-in-event', TGCallback(@TGTKControl_focus_in_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FFocusInSignalHandler);
+ if Assigned(Value) then begin
+ if FFocusInSignalHandler = 0 then
+ FFocusInSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-in-event', TGCallback(@TGTKControl_focus_in_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FFocusInSignalHandler);
+ FFocusInSignalHandler := 0;
+ end;
end;
end;
@@ -574,9 +582,13 @@ procedure TGTKControl.SetOnExit(Value: TGDKFocusEvent);
begin
if @FOnExit <> @Value then begin
FOnExit := Value;
- if Assigned(Value)
- then FFocusOutSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-out-event', TGCallback(@TGTKControl_focus_out_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FFocusOutSignalHandler);
+ if Assigned(Value) then begin
+ if FFocusOutSignalHandler = 0 then
+ FFocusOutSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-out-event', TGCallback(@TGTKControl_focus_out_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FFocusOutSignalHandler);
+ FFocusOutSignalHandler := 0;
+ end;
end;
end;
@@ -591,7 +603,7 @@ begin
end;
end else
if FButtonPressSignalHandler = 0
- then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT)
+ then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT);
end;
end;
@@ -606,7 +618,7 @@ begin
end;
end else
if FButtonPressSignalHandler = 0
- then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT)
+ then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT);
end;
end;
@@ -628,8 +640,13 @@ procedure TGTKControl.SetOnMouseUp(Value: TGDKMouseEvent);
begin
if @FOnMouseUp <> @Value then begin
FOnMouseUp := Value;
- if Assigned(Value) then FButtonReleaseSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@TGTKControl_button_release_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FButtonReleaseSignalHandler);
+ if Assigned(Value) then begin
+ if FButtonReleaseSignalHandler = 0 then
+ FButtonReleaseSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@TGTKControl_button_release_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FButtonReleaseSignalHandler);
+ FButtonReleaseSignalHandler := 0;
+ end;
end;
end;
@@ -658,8 +675,13 @@ procedure TGTKControl.SetOnMouseMove(Value: TGDKMouseEvent);
begin
if @FOnMouseMove <> @Value then begin
FOnMouseMove := Value;
- if Assigned(Value) then FMotionNotifyHandler := g_signal_connect_data(PGObject(FWidget), 'motion-notify-event', TGCallback(@TGTKControl_motion_notify_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FMotionNotifyHandler);
+ if Assigned(Value) then begin
+ if FMotionNotifyHandler = 0 then
+ FMotionNotifyHandler := g_signal_connect_data(PGObject(FWidget), 'motion-notify-event', TGCallback(@TGTKControl_motion_notify_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FMotionNotifyHandler);
+ FMotionNotifyHandler := 0;
+ end;
end;
end;
@@ -696,9 +718,53 @@ procedure TGTKControl.SetOnExpose(Value: TGDKExposeEvent);
begin
if @FOnExpose <> @Value then begin
FOnExpose := Value;
- if Assigned(Value)
- then FExposeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'expose-event', TGCallback(@TGTKControl_expose_event), Self, nil, G_CONNECT_DEFAULT)
- else g_signal_handler_disconnect(PGObject(FWidget), FExposeSignalHandler);
+ if Assigned(Value) then begin
+ if FExposeSignalHandler = 0 then
+ FExposeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'expose-event', TGCallback(@TGTKControl_expose_event), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FExposeSignalHandler);
+ FExposeSignalHandler := 0;
+ end;
+ end;
+end;
+
+procedure TGTKControl_realize(widget: PGtkWidget; user_data: gpointer); cdecl;
+begin
+ if Assigned(TGTKControl(user_data).FOnRealize)
+ then TGTKControl(user_data).FOnRealize(TGTKControl(user_data));
+end;
+
+procedure TGTKControl.SetOnRealize(Value: TNotifyEvent);
+begin
+ if @FOnRealize <> @Value then begin
+ FOnRealize := Value;
+ if Assigned(Value) then begin
+ if FRealizeSignalHandler = 0 then
+ FRealizeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'realize', TGCallback(@TGTKControl_realize), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FRealizeSignalHandler);
+ FRealizeSignalHandler := 0;
+ end;
+ end;
+end;
+
+procedure TGTKControl_size_allocate(widget : PGtkWidget; allocation : PGtkAllocation; user_data : gpointer); cdecl;
+begin
+ if Assigned(TGTKControl(user_data).FOnSizeAllocate)
+ then TGTKControl(user_data).FOnSizeAllocate(TGTKControl(user_data), allocation);
+end;
+
+procedure TGTKControl.SetOnSizeAllocate(Value: TGDKSizeAllocateEvent);
+begin
+ if @FOnSizeAllocate <> @Value then begin
+ FOnSizeAllocate := Value;
+ if Assigned(Value) then begin
+ if FSizeAllocateSignalHandler = 0 then
+ FSizeAllocateSignalHandler := g_signal_connect_data(PGObject(FWidget), 'size-allocate', TGCallback(@TGTKControl_size_allocate), Self, nil, G_CONNECT_DEFAULT);
+ end else begin
+ g_signal_handler_disconnect(PGObject(FWidget), FSizeAllocateSignalHandler);
+ FSizeAllocateSignalHandler := 0;
+ end;
end;
end;
@@ -783,8 +849,7 @@ begin
end;
procedure TGTKControl.ApplyCustomCSS(Stylesheet: string);
-var provider: PGtkCssProvider;
- error: PGError;
+var error: PGError;
begin
error := nil;
// No stylesheet previously attached and asked to reset, nothing to do