hi,

patch attached.

btw I'm not entirely sure if that ought to be split into multiple
events, but my gut feeling says no (probably prejudice by gtk
experience :)). 

I changed the event name to comply with mostly every other event (i.e.
OnHide, not OnHidden, likewise OnWindowStateChange, not
OnWindowStateChanged :))

cheers,
   Danny

Am Freitag, den 04.11.2005, 18:52 +0100 schrieb Mattias Gaertner:
> On Fri, 04 Nov 2005 18:41:23 +0100
> dannym <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> > 
> > since it's missing, I suggest adding a OnWindowStateChange event to
> > TForm (fired when the window manager changed the state of the window,
> > i.e. iconify/restore/maximize/......)
> > 
> > I can implement the gtk side
> > 
> > (it's just g_signal_connect 'window-state-event' )
> 
> I think, it's useful.
> 
>  
> > However, in delphi there is Application.OnMinimize,
> > Application.OnRestore and such too (i.e. for the TApplication), not sure
> > about the interactions of it (plus, OnRestore has a weird name - it's
> > actually OnUnminimize, not OnUnmaximize as well (?))
> 
> OnRestore is called when the whole application is unminized. AFAIK there is
> no unmaximize for the whole application.
> 
>  
> > Both are still not in lazarus. The latter is delphi compat (I don't
> > particular care about it, but
> > http://www.lazarus.freepascal.org/mantis/view.php?id=1391) and the
> > former is new.
> 
> 
> Mattias
> 
> _________________________________________________________________
>      To unsubscribe: mail [EMAIL PROTECTED] with
>                 "unsubscribe" as the Subject
>    archives at http://www.lazarus.freepascal.org/mailarchives
> 
Index: lcl/interfaces/gtk/gtkcallback.inc
===================================================================
--- lcl/interfaces/gtk/gtkcallback.inc	(Revision 8059)
+++ lcl/interfaces/gtk/gtkcallback.inc	(Arbeitskopie)
@@ -929,6 +929,30 @@
   DeliverMouseMoveMessage(Widget,Event,TWinControl(Data));
 end;
 
+function GTKWindowStateEventCB(widget: PGtkWidget;
+                               state: PGdkEventWindowState;
+                               data: gpointer): gboolean; cdecl;
+var
+  //changed: TGdkWindowState;
+  TheForm: TCustomForm;
+begin
+  Result := CallBackDefaultReturn;
+  // changed := state.changed_mask;
+
+  // if iconified in changed then OnIconify...
+
+  if (Data<>nil) then begin
+    if TObject(Data) is TCustomForm then begin
+      TheForm := TCustomForm(Data);
+      if TheForm.Parent = nil then begin (* toplevel window, just as a sanity check *)
+        if Assigned(TheForm.OnWindowStateChange) then begin
+          TheForm.OnWindowStateChange(TheForm);
+        end;
+      end;
+    end;
+  end;
+end;
+
 {-------------------------------------------------------------------------------
   function ControlGetsMouseDownBefore(AControl: TControl): boolean;
 
Index: lcl/interfaces/gtk/gtkobject.inc
===================================================================
--- lcl/interfaces/gtk/gtkobject.inc	(Revision 8059)
+++ lcl/interfaces/gtk/gtkobject.inc	(Arbeitskopie)
@@ -4785,6 +4785,9 @@
   if ACustomForm.Parent=nil then begin
     // create a floating form
     Result := gtk_window_new(WindowType);
+    g_signal_connect(GTK_OBJECT(Result), 'window-state-event',
+                         gtk_signal_func(@GTKWindowStateEventCB),
+                         ACustomForm);
 
     gtk_window_set_policy(GTK_WINDOW(Result), FormResizableMap[ABorderStyle],
       FormResizableMap[ABorderStyle], 0);
Index: lcl/interfaces/gtk/gtkproc.pp
===================================================================
--- lcl/interfaces/gtk/gtkproc.pp	(Revision 8059)
+++ lcl/interfaces/gtk/gtkproc.pp	(Arbeitskopie)
@@ -121,6 +121,11 @@
 function gtkchanged_editbox( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
 function gtkdaychanged(Widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
 function gtktoggledCB( widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
+
+function GTKWindowStateEventCB(widget: PGtkWidget;
+                               state: PGdkEventWindowState;
+                               data: gpointer): gboolean; cdecl;
+
 {$IfNdef GTK2}
 function gtkDrawAfter(Widget: PGtkWidget; area: PGDKRectangle;
   data: gPointer): GBoolean; cdecl;
Index: lcl/forms.pp
===================================================================
--- lcl/forms.pp	(Revision 8059)
+++ lcl/forms.pp	(Arbeitskopie)
@@ -376,7 +376,7 @@
     FOnHide: TNotifyEvent;
     FOnShortcut: TShortCutEvent;
     FOnShow: TNotifyEvent;
-    FOnWindowStateChanged: TNotifyEvent;
+    FOnWindowStateChange: TNotifyEvent;
     FPixelsPerInch: Longint;
     FPosition: TPosition;
     FRestoredLeft: integer;
@@ -534,8 +534,8 @@
     property OnResize stored IsForm;
     property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
     property OnShow: TNotifyEvent read FOnShow write FOnShow;
-    property OnWindowStateChanged: TNotifyEvent
-                         read fOnWindowStateChanged write fOnWindowStateChanged;
+    property OnWindowStateChange: TNotifyEvent
+                         read fOnWindowStateChange write fOnWindowStateChange;
     property PixelsPerInch: Longint read FPixelsPerInch write FPixelsPerInch stored False;
     property Position: TPosition read FPosition write SetPosition default poDesigned;
     property RestoredLeft: integer read FRestoredLeft;
@@ -618,6 +618,7 @@
     property UseDockManager;
     property Visible;
     property WindowState;
+    property OnWindowStateChange;
   end;
 
   TFormClass = class of TForm;

Reply via email to