From 3dd9b88ac26caa8dbcc26c7fafc10cd886fc97ac Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 31 May 2001 14:32:06 +0000
Subject: [PATCH] we now send iconize events

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/category.tex |   2 +
 docs/latex/wx/frame.tex    |   4 +-
 docs/latex/wx/sizeevt.tex  | 109 ++++++++++++++++++++++++++++++++++++-
 include/wx/event.h         |  27 +++++----
 include/wx/frame.h         |   3 +
 include/wx/gtk/frame.h     |  12 ++--
 include/wx/gtk1/frame.h    |  12 ++--
 src/common/framecmn.cpp    |   8 +++
 src/gtk/frame.cpp          |  52 ++++++++++++------
 src/gtk/win_gtk.c          |  86 ++++++++++++++---------------
 src/gtk1/frame.cpp         |  52 ++++++++++++------
 src/gtk1/win_gtk.c         |  86 ++++++++++++++---------------
 src/msw/frame.cpp          |  24 ++++----
 13 files changed, 320 insertions(+), 157 deletions(-)

diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex
index 9a4cc3ca86..02bd4f95fc 100644
--- a/docs/latex/wx/category.tex
+++ b/docs/latex/wx/category.tex
@@ -199,10 +199,12 @@ An event object contains information about a specific event. Event handlers
 \twocolitem{\helpref{wxEvent}{wxevent}}{The event base class}
 \twocolitem{\helpref{wxFocusEvent}{wxfocusevent}}{A window focus event}
 \twocolitem{\helpref{wxKeyEvent}{wxkeyevent}}{A keypress event}
+\twocolitem{\helpref{wxIconizeEvent}{wxiconizeevent}}{An iconize/restore event}
 \twocolitem{\helpref{wxIdleEvent}{wxidleevent}}{An idle event}
 \twocolitem{\helpref{wxInitDialogEvent}{wxinitdialogevent}}{A dialog initialisation event}
 \twocolitem{\helpref{wxJoystickEvent}{wxjoystickevent}}{A joystick event}
 \twocolitem{\helpref{wxListEvent}{wxlistevent}}{A list control event}
+\twocolitem{\helpref{wxMaximizeEvent}{wxmaximizeevent}}{A maximize event}
 \twocolitem{\helpref{wxMenuEvent}{wxmenuevent}}{A menu event}
 \twocolitem{\helpref{wxMouseEvent}{wxmouseevent}}{A mouse event}
 \twocolitem{\helpref{wxMoveEvent}{wxmoveevent}}{A move event}
diff --git a/docs/latex/wx/frame.tex b/docs/latex/wx/frame.tex
index bb875b6206..29c31e7c3b 100644
--- a/docs/latex/wx/frame.tex
+++ b/docs/latex/wx/frame.tex
@@ -276,7 +276,7 @@ Returns a pointer to the toolbar currently associated with the frame (if any).
 
 \func{void}{Iconize}{\param{bool}{ iconize}}
 
-Iconizes or restores the frame. Windows only.
+Iconizes or restores the frame.
 
 \wxheading{Parameters}
 
@@ -300,7 +300,7 @@ Returns TRUE if the frame is in fullscreen mode.
 
 \constfunc{bool}{IsIconized}{\void}
 
-Returns TRUE if the frame is iconized. Windows only.
+Returns TRUE if the frame is iconized.
 
 \membersection{wxFrame::IsMaximized}\label{wxframeismaximized}
 
diff --git a/docs/latex/wx/sizeevt.tex b/docs/latex/wx/sizeevt.tex
index 64256e167e..c30c12614c 100644
--- a/docs/latex/wx/sizeevt.tex
+++ b/docs/latex/wx/sizeevt.tex
@@ -1,3 +1,18 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name:        sizeevt.tex
+%% Purpose:     wxSizeEvent and related event classes documentation
+%% Author:      wxWindows team
+%% Modified by:
+%% Created:
+%% RCS-ID:      $Id$
+%% Copyright:   (c) wxWindows team
+%% License:     wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% wxSizeEvent
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \section{\class{wxSizeEvent}}\label{wxsizeevent}
 
 A size event holds information about size change events.
@@ -23,7 +38,8 @@ function that takes a wxSizeEvent argument.
 
 \wxheading{See also}
 
-\helpref{wxWindow::OnSize}{wxwindowonsize}, \helpref{wxSize}{wxsize}, \helpref{Event handling overview}{eventhandlingoverview}
+\helpref{wxSize}{wxsize},\rtfsp
+\helpref{Event handling overview}{eventhandlingoverview}
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
@@ -39,3 +55,94 @@ Constructor.
 
 Returns the entire size of the window generating the size change event.
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% wxIconizeEvent
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{\class{wxIconizeEvent}}\label{wxiconizeevent}
+
+An event being sent when the frame is iconized (minimized) or restored.
+
+Currently only wxMSW and wxGTK generate such events.
+
+\wxheading{Derived from}
+
+\helpref{wxEvent}{wxevent}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/event.h>
+
+\wxheading{Event table macros}
+
+To process an iconize event, use this event handler macro to direct input to a
+member function that takes a wxIconizeEvent argument.
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_ICONIZE(func)}}{Process a wxEVT\_ICONIZE event.}
+\end{twocollist}%
+
+\wxheading{See also}
+
+\helpref{Event handling overview}{eventhandlingoverview},\rtfsp
+\helpref{wxFrame::Iconize}{wxframeiconize},\rtfsp
+\helpref{wxFrame::IsIconized}{wxframeisiconized}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxIconizeEvent::wxIconizeEvent}\label{wxiconizeeventctor}
+
+\func{}{wxIconizeEvent}{\param{int }{id = 0}, \param{bool }{iconized = TRUE}}
+
+Constructor.
+
+\membersection{wxIconizeEvent::Iconized}\label{wxiconizeeventiconized}
+
+\constfunc{bool}{Iconized}{\void}
+
+Returns {\tt TRUE} if the frame has been iconized, {\tt FALSE} if it has been
+restored.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% wxMaximizeEvent
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\section{\class{wxMaximizeEvent}}\label{wxmaximizeevent}
+
+An event being sent when the frame is maximized (minimized) or restored.
+
+\wxheading{Derived from}
+
+\helpref{wxEvent}{wxevent}\\
+\helpref{wxObject}{wxobject}
+
+\wxheading{Include files}
+
+<wx/event.h>
+
+\wxheading{Event table macros}
+
+To process a maximize event, use this event handler macro to direct input to a
+member function that takes a wxMaximizeEvent argument.
+
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf EVT\_MAXIMIZE(func)}}{Process a wxEVT\_MAXIMIZE event.}
+\end{twocollist}%
+
+\wxheading{See also}
+
+\helpref{Event handling overview}{eventhandlingoverview},\rtfsp
+\helpref{wxFrame::Maximize}{wxframemaximize},\rtfsp
+\helpref{wxFrame::IsMaximized}{wxframeismaximized}
+
+\latexignore{\rtfignore{\wxheading{Members}}}
+
+\membersection{wxMaximizeEvent::wxMaximizeEvent}\label{wxmaximizeeventctor}
+
+\func{}{wxMaximizeEvent}{\param{int }{id = 0}}
+
+Constructor.
+
diff --git a/include/wx/event.h b/include/wx/event.h
index 24cc14c0b4..cb13126bf6 100644
--- a/include/wx/event.h
+++ b/include/wx/event.h
@@ -1043,10 +1043,7 @@ protected:
 
 class WXDLLEXPORT wxShowEvent : public wxEvent
 {
-    DECLARE_DYNAMIC_CLASS(wxShowEvent)
-
 public:
-
     wxShowEvent(int id = 0, bool show = FALSE)
         { m_eventType = wxEVT_SHOW; m_id = id; m_show = show; }
 
@@ -1057,6 +1054,8 @@ public:
 
 protected:
     bool m_show;
+
+    DECLARE_DYNAMIC_CLASS(wxShowEvent)
 };
 
 /*
@@ -1065,11 +1064,17 @@ protected:
 
 class WXDLLEXPORT wxIconizeEvent : public wxEvent
 {
-    DECLARE_DYNAMIC_CLASS(wxIconizeEvent)
-
 public:
-    wxIconizeEvent(int id = 0)
-        { m_eventType = wxEVT_ICONIZE; m_id = id; }
+    wxIconizeEvent(int id = 0, bool iconized = TRUE)
+        { m_eventType = wxEVT_ICONIZE; m_id = id; m_iconized = iconized; }
+
+    // return true if the frame was iconized, false if restored
+    bool Iconized() const { return m_iconized; }
+
+protected:
+    bool m_iconized;
+
+    DECLARE_DYNAMIC_CLASS(wxIconizeEvent)
 };
 
 /*
@@ -1078,11 +1083,11 @@ public:
 
 class WXDLLEXPORT wxMaximizeEvent : public wxEvent
 {
-    DECLARE_DYNAMIC_CLASS(wxMaximizeEvent)
-
 public:
-  wxMaximizeEvent(int id = 0)
-      { m_eventType = wxEVT_MAXIMIZE; m_id = id; }
+    wxMaximizeEvent(int id = 0)
+        { m_eventType = wxEVT_MAXIMIZE; m_id = id; }
+
+    DECLARE_DYNAMIC_CLASS(wxMaximizeEvent)
 };
 
 // Joystick event class
diff --git a/include/wx/frame.h b/include/wx/frame.h
index de126f6a57..61084a3f68 100644
--- a/include/wx/frame.h
+++ b/include/wx/frame.h
@@ -215,6 +215,9 @@ protected:
     virtual void DoClientToScreen(int *x, int *y) const;
     virtual void DoScreenToClient(int *x, int *y) const;
 
+    // send the iconize event, return TRUE if processed
+    bool SendIconizeEvent(bool iconized = TRUE);
+
     // the frame icon
     wxIcon m_icon;
 
diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h
index 702f519005..99aff948e1 100644
--- a/include/wx/gtk/frame.h
+++ b/include/wx/gtk/frame.h
@@ -99,13 +99,16 @@ public:
     // --------------------------
 
     // move the window to the specified location and resize it: this is called
-    // from both DoSetSize() and DoSetClientSize() 
+    // from both DoSetSize() and DoSetClientSize()
     virtual void DoMoveWindow(int x, int y, int width, int height);
-    
+
     // GTK callbacks
     virtual void GtkOnSize( int x, int y, int width, int height );
     virtual void OnInternalIdle();
 
+    // do *not* call this to iconize the frame, this is a private function!
+    void SetIconizeState(bool iconic);
+
     wxString      m_title;
     int           m_miniEdge,
                   m_miniTitle;
@@ -114,8 +117,6 @@ public:
     bool          m_toolBarDetached;
     bool          m_insertInClientArea;  /* not from within OnCreateXXX */
 
-    bool          m_isIconized;
-
     bool          m_fsIsShowing;         /* full screen */
     long          m_fsSaveStyle;
     long          m_fsSaveFlag;
@@ -133,6 +134,9 @@ protected:
     virtual void DoSetClientSize(int width, int height);
     virtual void DoGetClientSize( int *width, int *height ) const;
 
+    // is the frame currently iconized?
+    bool          m_isIconized;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxFrame)
 };
diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h
index 702f519005..99aff948e1 100644
--- a/include/wx/gtk1/frame.h
+++ b/include/wx/gtk1/frame.h
@@ -99,13 +99,16 @@ public:
     // --------------------------
 
     // move the window to the specified location and resize it: this is called
-    // from both DoSetSize() and DoSetClientSize() 
+    // from both DoSetSize() and DoSetClientSize()
     virtual void DoMoveWindow(int x, int y, int width, int height);
-    
+
     // GTK callbacks
     virtual void GtkOnSize( int x, int y, int width, int height );
     virtual void OnInternalIdle();
 
+    // do *not* call this to iconize the frame, this is a private function!
+    void SetIconizeState(bool iconic);
+
     wxString      m_title;
     int           m_miniEdge,
                   m_miniTitle;
@@ -114,8 +117,6 @@ public:
     bool          m_toolBarDetached;
     bool          m_insertInClientArea;  /* not from within OnCreateXXX */
 
-    bool          m_isIconized;
-
     bool          m_fsIsShowing;         /* full screen */
     long          m_fsSaveStyle;
     long          m_fsSaveFlag;
@@ -133,6 +134,9 @@ protected:
     virtual void DoSetClientSize(int width, int height);
     virtual void DoGetClientSize( int *width, int *height ) const;
 
+    // is the frame currently iconized?
+    bool          m_isIconized;
+
 private:
     DECLARE_DYNAMIC_CLASS(wxFrame)
 };
diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp
index 3cc2dff527..5782c231ef 100644
--- a/src/common/framecmn.cpp
+++ b/src/common/framecmn.cpp
@@ -290,6 +290,14 @@ void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
 #endif // wxUSE_STATUSBAR
 }
 
+bool wxFrameBase::SendIconizeEvent(bool iconized)
+{
+    wxIconizeEvent event(GetId(), iconized);
+    event.SetEventObject(this);
+
+    return GetEventHandler()->ProcessEvent(event);
+}
+
 // ----------------------------------------------------------------------------
 // status bar stuff
 // ----------------------------------------------------------------------------
diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp
index 71d58cae4d..cedfca99d5 100644
--- a/src/gtk/frame.cpp
+++ b/src/gtk/frame.cpp
@@ -332,7 +332,7 @@ gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
                         GdkEvent * WXUNUSED(event),
                         wxFrame *win )
 {
-    win->m_isIconized = FALSE;
+    win->SetIconizeState(FALSE);
 }
 
 //-----------------------------------------------------------------------------
@@ -344,7 +344,7 @@ gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
                           GdkEvent * WXUNUSED(event),
                           wxFrame *win )
 {
-    win->m_isIconized = TRUE;
+    win->SetIconizeState(TRUE);
 }
 
 //-----------------------------------------------------------------------------
@@ -356,8 +356,8 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev
     GtkPizza *pizza = GTK_PIZZA(widget);
 
     gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
-		GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
-        
+                GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
+
     return TRUE;
 }
 
@@ -370,8 +370,8 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW
 {
     GtkPizza *pizza = GTK_PIZZA(widget);
 
-    gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, 
-		GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
+    gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
+                GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
 }
 
 // ----------------------------------------------------------------------------
@@ -448,7 +448,7 @@ void wxFrame::Init()
     m_toolBarDetached = FALSE;
     m_insertInClientArea = TRUE;
     m_isFrame = TRUE;
-    m_isIconized = FALSE;
+    m_isIconized = TRUE;
     m_fsIsShowing = FALSE;
     m_themeEnabled = TRUE;
 }
@@ -489,7 +489,7 @@ bool wxFrame::Create( wxWindow *parent,
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
 
     GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
-    
+
     if (style & wxFRAME_TOOL_WINDOW)
         win_type = GTK_WINDOW_POPUP;
 
@@ -537,7 +537,7 @@ bool wxFrame::Create( wxWindow *parent,
 #endif
 
     /* we donm't allow the frame to get the focus as otherwise
-       the frame will grabit at arbitrary fcous changes. */
+       the frame will grab it at arbitrary focus changes. */
     GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
 
     if (m_parent) m_parent->AddChild( this );
@@ -601,24 +601,24 @@ bool wxFrame::ShowFullScreen(bool show, long style )
     if (show == m_fsIsShowing) return FALSE; // return what?
 
     m_fsIsShowing = show;
-    
+
     if (show)
     {
         m_fsSaveStyle = m_windowStyle;
         m_fsSaveFlag = style;
         GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
         GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
-        
+
         gtk_widget_hide( m_widget );
         gtk_widget_unrealize( m_widget );
-        
+
         m_windowStyle = wxSIMPLE_BORDER;
-        
+
         int x;
         int y;
         wxDisplaySize( &x, &y );
         SetSize( 0, 0, x, y );
-        
+
         gtk_widget_realize( m_widget );
         gtk_widget_show( m_widget );
     }
@@ -626,15 +626,15 @@ bool wxFrame::ShowFullScreen(bool show, long style )
     {
         gtk_widget_hide( m_widget );
         gtk_widget_unrealize( m_widget );
-    
+
         m_windowStyle = m_fsSaveStyle;
-        
+
         SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
-        
+
         gtk_widget_realize( m_widget );
         gtk_widget_show( m_widget );
     }
-    
+
     return TRUE;
 }
 
@@ -1216,3 +1216,19 @@ bool wxFrame::IsIconized() const
 {
     return m_isIconized;
 }
+
+void wxFrame::SetIconizeState(bool iconize)
+{
+    if ( iconize != m_isIconized )
+    {
+        m_isIconized = iconize;
+        (void)SendIconizeEvent(iconize);
+    }
+    else
+    {
+        // this is not supposed to happen if we're called only from
+        // gtk_frame_(un)map_callback!
+        wxFAIL_MSG( _T("unexpected call to SendIconizeEvent ignored") );
+    }
+}
+
diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c
index b184659774..2e69c20eef 100644
--- a/src/gtk/win_gtk.c
+++ b/src/gtk/win_gtk.c
@@ -190,7 +190,7 @@ gtk_pizza_init (GtkPizza *pizza)
     pizza->height = 20;
 
     pizza->bin_window = NULL;
-    
+
     pizza->xoffset = 0;
     pizza->yoffset = 0;
 
@@ -251,7 +251,7 @@ gtk_pizza_set_clear (GtkPizza  *pizza,
     pizza->clear_on_draw = clear;
 }
 
-void       
+void
 gtk_pizza_set_filter (GtkPizza  *pizza,
                       gboolean   use)
 {
@@ -259,9 +259,9 @@ gtk_pizza_set_filter (GtkPizza  *pizza,
     g_return_if_fail (GTK_IS_PIZZA (pizza));
 
     pizza->use_filter = use;
-}	
-					
-void       
+}
+
+void
 gtk_pizza_set_external (GtkPizza  *pizza,
                         gboolean   expose)
 {
@@ -436,7 +436,7 @@ gtk_pizza_set_size (GtkPizza   *pizza,
     }
 }
 
-gint       
+gint
 gtk_pizza_child_resized  (GtkPizza   *pizza,
                           GtkWidget  *widget)
 {
@@ -459,10 +459,10 @@ gtk_pizza_child_resized  (GtkPizza   *pizza,
                     (child->height == widget->allocation.height));
         }
     }
-    
+
     return FALSE;
 }
-					
+
 static void
 gtk_pizza_map (GtkWidget *widget)
 {
@@ -549,8 +549,7 @@ gtk_pizza_realize (GtkWidget *widget)
     attributes.wclass = GDK_INPUT_OUTPUT;
     attributes.visual = gtk_widget_get_visual (widget);
     attributes.colormap = gtk_widget_get_colormap (widget);
-    attributes.event_mask =
-       GDK_VISIBILITY_NOTIFY_MASK;
+    attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
     attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
 
     widget->window = gdk_window_new(gtk_widget_get_parent_window (widget),
@@ -561,21 +560,20 @@ gtk_pizza_realize (GtkWidget *widget)
     attributes.y = 0;
 
     attributes.event_mask = gtk_widget_get_events (widget);
-    attributes.event_mask |=
-       GDK_EXPOSURE_MASK        |
-       GDK_POINTER_MOTION_MASK        |
-       GDK_POINTER_MOTION_HINT_MASK  |
-       GDK_BUTTON_MOTION_MASK        |
-       GDK_BUTTON1_MOTION_MASK        |
-       GDK_BUTTON2_MOTION_MASK        |
-       GDK_BUTTON3_MOTION_MASK        |
-       GDK_BUTTON_PRESS_MASK        |
-       GDK_BUTTON_RELEASE_MASK        |
-       GDK_KEY_PRESS_MASK        |
-       GDK_KEY_RELEASE_MASK        |
-       GDK_ENTER_NOTIFY_MASK        |
-       GDK_LEAVE_NOTIFY_MASK        |
-       GDK_FOCUS_CHANGE_MASK;
+    attributes.event_mask |= GDK_EXPOSURE_MASK              |
+                             GDK_POINTER_MOTION_MASK        |
+                             GDK_POINTER_MOTION_HINT_MASK   |
+                             GDK_BUTTON_MOTION_MASK         |
+                             GDK_BUTTON1_MOTION_MASK        |
+                             GDK_BUTTON2_MOTION_MASK        |
+                             GDK_BUTTON3_MOTION_MASK        |
+                             GDK_BUTTON_PRESS_MASK          |
+                             GDK_BUTTON_RELEASE_MASK        |
+                             GDK_KEY_PRESS_MASK             |
+                             GDK_KEY_RELEASE_MASK           |
+                             GDK_ENTER_NOTIFY_MASK          |
+                             GDK_LEAVE_NOTIFY_MASK          |
+                             GDK_FOCUS_CHANGE_MASK;
 
     pizza->bin_window = gdk_window_new(widget->window,
                                           &attributes, attributes_mask);
@@ -775,7 +773,7 @@ gtk_pizza_expose (GtkWidget      *widget,
             gtk_widget_event (child->widget, (GdkEvent*) &child_event);
         }
     }
-    
+
     return TRUE;
 }
 
@@ -1189,29 +1187,29 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
     GtkPizza *pizza;
 
     xevent = (XEvent *)gdk_xevent;
-    
+
     pizza = GTK_PIZZA (data);
-    
+
     if (!pizza->use_filter)
         return GDK_FILTER_CONTINUE;
 
     switch (xevent->type)
     {
-    case Expose:
-      if (xevent->xexpose.serial == pizza->configure_serial)
-        {
-          xevent->xexpose.x += pizza->scroll_x;
-          xevent->xexpose.y += pizza->scroll_y;
-        }
-      break;
+        case Expose:
+            if (xevent->xexpose.serial == pizza->configure_serial)
+            {
+                xevent->xexpose.x += pizza->scroll_x;
+                xevent->xexpose.y += pizza->scroll_y;
+            }
+            break;
 
-    case ConfigureNotify:
-        {
-          pizza->configure_serial = xevent->xconfigure.serial;
-          pizza->scroll_x = xevent->xconfigure.x;
-          pizza->scroll_y = xevent->xconfigure.y;
-        }
-      break;
+        case ConfigureNotify:
+            {
+                pizza->configure_serial = xevent->xconfigure.serial;
+                pizza->scroll_x = xevent->xconfigure.x;
+                pizza->scroll_y = xevent->xconfigure.y;
+            }
+            break;
     }
 
     return GDK_FILTER_CONTINUE;
@@ -1231,7 +1229,7 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
 
     xevent = (XEvent *)gdk_xevent;
     pizza = GTK_PIZZA (data);
-    
+
     if (!pizza->use_filter)
         return GDK_FILTER_CONTINUE;
 
@@ -1251,7 +1249,7 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
                 pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
                 break;
         }
-        
+
         return GDK_FILTER_REMOVE;
     }
 
diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp
index 71d58cae4d..cedfca99d5 100644
--- a/src/gtk1/frame.cpp
+++ b/src/gtk1/frame.cpp
@@ -332,7 +332,7 @@ gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
                         GdkEvent * WXUNUSED(event),
                         wxFrame *win )
 {
-    win->m_isIconized = FALSE;
+    win->SetIconizeState(FALSE);
 }
 
 //-----------------------------------------------------------------------------
@@ -344,7 +344,7 @@ gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
                           GdkEvent * WXUNUSED(event),
                           wxFrame *win )
 {
-    win->m_isIconized = TRUE;
+    win->SetIconizeState(TRUE);
 }
 
 //-----------------------------------------------------------------------------
@@ -356,8 +356,8 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev
     GtkPizza *pizza = GTK_PIZZA(widget);
 
     gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
-		GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
-        
+                GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1);
+
     return TRUE;
 }
 
@@ -370,8 +370,8 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW
 {
     GtkPizza *pizza = GTK_PIZZA(widget);
 
-    gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, 
-		GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
+    gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL,
+                GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1);
 }
 
 // ----------------------------------------------------------------------------
@@ -448,7 +448,7 @@ void wxFrame::Init()
     m_toolBarDetached = FALSE;
     m_insertInClientArea = TRUE;
     m_isFrame = TRUE;
-    m_isIconized = FALSE;
+    m_isIconized = TRUE;
     m_fsIsShowing = FALSE;
     m_themeEnabled = TRUE;
 }
@@ -489,7 +489,7 @@ bool wxFrame::Create( wxWindow *parent,
     m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
 
     GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
-    
+
     if (style & wxFRAME_TOOL_WINDOW)
         win_type = GTK_WINDOW_POPUP;
 
@@ -537,7 +537,7 @@ bool wxFrame::Create( wxWindow *parent,
 #endif
 
     /* we donm't allow the frame to get the focus as otherwise
-       the frame will grabit at arbitrary fcous changes. */
+       the frame will grab it at arbitrary focus changes. */
     GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
 
     if (m_parent) m_parent->AddChild( this );
@@ -601,24 +601,24 @@ bool wxFrame::ShowFullScreen(bool show, long style )
     if (show == m_fsIsShowing) return FALSE; // return what?
 
     m_fsIsShowing = show;
-    
+
     if (show)
     {
         m_fsSaveStyle = m_windowStyle;
         m_fsSaveFlag = style;
         GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
         GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
-        
+
         gtk_widget_hide( m_widget );
         gtk_widget_unrealize( m_widget );
-        
+
         m_windowStyle = wxSIMPLE_BORDER;
-        
+
         int x;
         int y;
         wxDisplaySize( &x, &y );
         SetSize( 0, 0, x, y );
-        
+
         gtk_widget_realize( m_widget );
         gtk_widget_show( m_widget );
     }
@@ -626,15 +626,15 @@ bool wxFrame::ShowFullScreen(bool show, long style )
     {
         gtk_widget_hide( m_widget );
         gtk_widget_unrealize( m_widget );
-    
+
         m_windowStyle = m_fsSaveStyle;
-        
+
         SetSize( m_fsSaveFrame.x, m_fsSaveFrame.y, m_fsSaveFrame.width, m_fsSaveFrame.height );
-        
+
         gtk_widget_realize( m_widget );
         gtk_widget_show( m_widget );
     }
-    
+
     return TRUE;
 }
 
@@ -1216,3 +1216,19 @@ bool wxFrame::IsIconized() const
 {
     return m_isIconized;
 }
+
+void wxFrame::SetIconizeState(bool iconize)
+{
+    if ( iconize != m_isIconized )
+    {
+        m_isIconized = iconize;
+        (void)SendIconizeEvent(iconize);
+    }
+    else
+    {
+        // this is not supposed to happen if we're called only from
+        // gtk_frame_(un)map_callback!
+        wxFAIL_MSG( _T("unexpected call to SendIconizeEvent ignored") );
+    }
+}
+
diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c
index b184659774..2e69c20eef 100644
--- a/src/gtk1/win_gtk.c
+++ b/src/gtk1/win_gtk.c
@@ -190,7 +190,7 @@ gtk_pizza_init (GtkPizza *pizza)
     pizza->height = 20;
 
     pizza->bin_window = NULL;
-    
+
     pizza->xoffset = 0;
     pizza->yoffset = 0;
 
@@ -251,7 +251,7 @@ gtk_pizza_set_clear (GtkPizza  *pizza,
     pizza->clear_on_draw = clear;
 }
 
-void       
+void
 gtk_pizza_set_filter (GtkPizza  *pizza,
                       gboolean   use)
 {
@@ -259,9 +259,9 @@ gtk_pizza_set_filter (GtkPizza  *pizza,
     g_return_if_fail (GTK_IS_PIZZA (pizza));
 
     pizza->use_filter = use;
-}	
-					
-void       
+}
+
+void
 gtk_pizza_set_external (GtkPizza  *pizza,
                         gboolean   expose)
 {
@@ -436,7 +436,7 @@ gtk_pizza_set_size (GtkPizza   *pizza,
     }
 }
 
-gint       
+gint
 gtk_pizza_child_resized  (GtkPizza   *pizza,
                           GtkWidget  *widget)
 {
@@ -459,10 +459,10 @@ gtk_pizza_child_resized  (GtkPizza   *pizza,
                     (child->height == widget->allocation.height));
         }
     }
-    
+
     return FALSE;
 }
-					
+
 static void
 gtk_pizza_map (GtkWidget *widget)
 {
@@ -549,8 +549,7 @@ gtk_pizza_realize (GtkWidget *widget)
     attributes.wclass = GDK_INPUT_OUTPUT;
     attributes.visual = gtk_widget_get_visual (widget);
     attributes.colormap = gtk_widget_get_colormap (widget);
-    attributes.event_mask =
-       GDK_VISIBILITY_NOTIFY_MASK;
+    attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
     attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
 
     widget->window = gdk_window_new(gtk_widget_get_parent_window (widget),
@@ -561,21 +560,20 @@ gtk_pizza_realize (GtkWidget *widget)
     attributes.y = 0;
 
     attributes.event_mask = gtk_widget_get_events (widget);
-    attributes.event_mask |=
-       GDK_EXPOSURE_MASK        |
-       GDK_POINTER_MOTION_MASK        |
-       GDK_POINTER_MOTION_HINT_MASK  |
-       GDK_BUTTON_MOTION_MASK        |
-       GDK_BUTTON1_MOTION_MASK        |
-       GDK_BUTTON2_MOTION_MASK        |
-       GDK_BUTTON3_MOTION_MASK        |
-       GDK_BUTTON_PRESS_MASK        |
-       GDK_BUTTON_RELEASE_MASK        |
-       GDK_KEY_PRESS_MASK        |
-       GDK_KEY_RELEASE_MASK        |
-       GDK_ENTER_NOTIFY_MASK        |
-       GDK_LEAVE_NOTIFY_MASK        |
-       GDK_FOCUS_CHANGE_MASK;
+    attributes.event_mask |= GDK_EXPOSURE_MASK              |
+                             GDK_POINTER_MOTION_MASK        |
+                             GDK_POINTER_MOTION_HINT_MASK   |
+                             GDK_BUTTON_MOTION_MASK         |
+                             GDK_BUTTON1_MOTION_MASK        |
+                             GDK_BUTTON2_MOTION_MASK        |
+                             GDK_BUTTON3_MOTION_MASK        |
+                             GDK_BUTTON_PRESS_MASK          |
+                             GDK_BUTTON_RELEASE_MASK        |
+                             GDK_KEY_PRESS_MASK             |
+                             GDK_KEY_RELEASE_MASK           |
+                             GDK_ENTER_NOTIFY_MASK          |
+                             GDK_LEAVE_NOTIFY_MASK          |
+                             GDK_FOCUS_CHANGE_MASK;
 
     pizza->bin_window = gdk_window_new(widget->window,
                                           &attributes, attributes_mask);
@@ -775,7 +773,7 @@ gtk_pizza_expose (GtkWidget      *widget,
             gtk_widget_event (child->widget, (GdkEvent*) &child_event);
         }
     }
-    
+
     return TRUE;
 }
 
@@ -1189,29 +1187,29 @@ gtk_pizza_filter (GdkXEvent *gdk_xevent,
     GtkPizza *pizza;
 
     xevent = (XEvent *)gdk_xevent;
-    
+
     pizza = GTK_PIZZA (data);
-    
+
     if (!pizza->use_filter)
         return GDK_FILTER_CONTINUE;
 
     switch (xevent->type)
     {
-    case Expose:
-      if (xevent->xexpose.serial == pizza->configure_serial)
-        {
-          xevent->xexpose.x += pizza->scroll_x;
-          xevent->xexpose.y += pizza->scroll_y;
-        }
-      break;
+        case Expose:
+            if (xevent->xexpose.serial == pizza->configure_serial)
+            {
+                xevent->xexpose.x += pizza->scroll_x;
+                xevent->xexpose.y += pizza->scroll_y;
+            }
+            break;
 
-    case ConfigureNotify:
-        {
-          pizza->configure_serial = xevent->xconfigure.serial;
-          pizza->scroll_x = xevent->xconfigure.x;
-          pizza->scroll_y = xevent->xconfigure.y;
-        }
-      break;
+        case ConfigureNotify:
+            {
+                pizza->configure_serial = xevent->xconfigure.serial;
+                pizza->scroll_x = xevent->xconfigure.x;
+                pizza->scroll_y = xevent->xconfigure.y;
+            }
+            break;
     }
 
     return GDK_FILTER_CONTINUE;
@@ -1231,7 +1229,7 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
 
     xevent = (XEvent *)gdk_xevent;
     pizza = GTK_PIZZA (data);
-    
+
     if (!pizza->use_filter)
         return GDK_FILTER_CONTINUE;
 
@@ -1251,7 +1249,7 @@ gtk_pizza_main_filter (GdkXEvent *gdk_xevent,
                 pizza->visibility = GDK_VISIBILITY_UNOBSCURED;
                 break;
         }
-        
+
         return GDK_FILTER_REMOVE;
     }
 
diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp
index 9eb14a0f07..b37499c2fa 100644
--- a/src/msw/frame.cpp
+++ b/src/msw/frame.cpp
@@ -260,22 +260,20 @@ void wxFrame::DoSetClientSize(int width, int height)
 
 void wxFrame::DoGetSize(int *width, int *height) const
 {
-  RECT rect;
-  GetWindowRect(GetHwnd(), &rect);
-  *width = rect.right - rect.left;
-  *height = rect.bottom - rect.top;
+    RECT rect;
+    ::GetWindowRect(GetHwnd(), &rect);
+
+    *width = rect.right - rect.left;
+    *height = rect.bottom - rect.top;
 }
 
 void wxFrame::DoGetPosition(int *x, int *y) const
 {
-  RECT rect;
-  GetWindowRect(GetHwnd(), &rect);
-  POINT point;
-  point.x = rect.left;
-  point.y = rect.top;
+    RECT rect;
+    ::GetWindowRect(GetHwnd(), &rect);
 
-  *x = point.x;
-  *y = point.y;
+    *x = rect.left;
+    *y = rect.top;
 }
 
 // ----------------------------------------------------------------------------
@@ -976,6 +974,8 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id)
             // restore all child frames too
             IconizeChildFrames(FALSE);
 
+            (void)SendIconizeEvent(FALSE);
+
             // fall through
 
         case SIZEFULLSCREEN:
@@ -986,6 +986,8 @@ bool wxFrame::HandleSize(int x, int y, WXUINT id)
             // iconize all child frames too
             IconizeChildFrames(TRUE);
 
+            (void)SendIconizeEvent();
+
             m_iconized = TRUE;
             break;
     }
-- 
2.50.0

