]> git.saurik.com Git - wxWidgets.git/commitdiff
move SendSizeEvent() down to wxWindow from wxFrame; added SendSizeEventToParent(...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 29 Jul 2008 12:32:47 +0000 (12:32 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 29 Jul 2008 12:32:47 +0000 (12:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54803 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

16 files changed:
include/wx/frame.h
include/wx/motif/frame.h
include/wx/msw/frame.h
include/wx/os2/frame.h
include/wx/univ/frame.h
include/wx/window.h
interface/wx/frame.h
interface/wx/window.h
src/common/framecmn.cpp
src/common/wincmn.cpp
src/motif/frame.cpp
src/msw/statusbar.cpp
src/msw/toolbar.cpp
src/os2/frame.cpp
src/univ/framuniv.cpp
src/univ/toolbar.cpp

index 3816a57b3e7ec6eca2abaf0f428b0031458b14af..fe6694fbc746c13b0b5f7a1fc93f8762ef499b31 100644 (file)
@@ -72,9 +72,6 @@ public:
     // if the frame has a toolbar) in client coordinates
     virtual wxPoint GetClientAreaOrigin() const;
 
-    // sends a size event to the window using its current size -- this has an
-    // effect of refreshing the window layout
-    virtual void SendSizeEvent();
 
     // menu bar functions
     // ------------------
index 9aa7129aa399b813ebbaef81402c27e22be1d720..64f808bbadd4203ac56dd766216e3f4844f84ace 100644 (file)
@@ -87,10 +87,9 @@ public:
 
     bool PreResize();
 
-    void SendSizeEvent();
-
     // for generic/mdig.h
     virtual void DoGetClientSize(int *width, int *height) const;
+
 private:
     // common part of all ctors
     void Init();
index 11e881d5a8d78e56bbea37060e45bd6595745985..50f8f160647d7a9be27c713d1830b9d75fba652c 100644 (file)
@@ -91,8 +91,7 @@ public:
     void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
 #endif // tooltips
 
-    // a MSW only function which sends a size event to the window using its
-    // current size - this has an effect of refreshing the window layout
+    // override the base class function to handle iconized/maximized frames
     virtual void SendSizeEvent();
 
     virtual wxPoint GetClientAreaOrigin() const;
index b6e2c09e291734fc7cf3caad0335985b99b96d66..b8ad5deaef7ae4628d449cda9b5e4be9e3340567 100644 (file)
@@ -125,8 +125,6 @@ public:
     void   SetToolTipCtrl(WXHWND hHwndTT) { m_hWndToolTip = hHwndTT; }
 #endif // tooltips
 
-    virtual void SendSizeEvent(void);
-
     void      SetClient(WXHWND    c_Hwnd);
     void      SetClient(wxWindow* c_Window);
     wxWindow *GetClient();
index 924ea90a96a26b36857eb2011d7b104457e927ec..cd75831ca02d52c17aeb115646065d100bc1aa0a 100644 (file)
@@ -58,9 +58,6 @@ public:
 
     virtual wxSize GetMinSize() const;
 
-    // sends wxSizeEvent to itself (used after attaching xxxBar)
-    virtual void SendSizeEvent();
-
 protected:
     void OnSize(wxSizeEvent& event);
     void OnSysColourChanged(wxSysColourChangedEvent& event);
index fc3f46dbc0d60870762c2b3b3f00bcc64d3c1e0b..52712b7d2272b0476ed57faabbfd4526c45f2874 100644 (file)
@@ -528,8 +528,25 @@ public:
     // stretch over several lines). Parameter availableOtherDir
     // tells the item how much more space there is available in the opposite
     // direction (-1 if unknown).
-    virtual bool InformFirstDirection( int WXUNUSED(direction), int WXUNUSED(size), int WXUNUSED(availableOtherDir) )
-    { return false; }
+    virtual bool
+    InformFirstDirection(int WXUNUSED(direction),
+                         int WXUNUSED(size),
+                         int WXUNUSED(availableOtherDir))
+    {
+        return false;
+    }
+
+    // sends a size event to the window using its current size -- this has an
+    // effect of refreshing the window layout
+    virtual void SendSizeEvent();
+
+    // this is a safe wrapper for GetParent()->SendSizeEvent(): it checks that
+    // we have a parent window and it's not in process of being deleted
+    //
+    // this is used by controls such as tool/status bars changes to which must
+    // also result in parent re-layout
+    void SendSizeEventToParent();
+
 
     // window state
     // ------------
index aad65984d5f9b21de692bff1615ce013cff938c2..fd6c78c87836407d28a8bd1318ae04f963726a0a 100644 (file)
@@ -328,17 +328,6 @@ public:
     */
     void ProcessCommand(int id);
 
-    /**
-        This function sends a dummy @ref overview_wxsizeevent "size event" to the frame
-        forcing it to reevaluate its children positions. It is sometimes useful to call
-        this function after adding or deleting a children after the frame creation or
-        if a child size changes.
-        Note that if the frame is using either sizers or constraints for the children
-        layout, it is enough to call wxWindow::Layout directly and
-        this function should not be used in this case.
-    */
-    void SendSizeEvent();
-
     /**
         Tells the frame to show the given menu bar.
 
index c1106244e9c77581fd8340ce9d082108777fd471..01c7fa6065ac0376de26ca5bb5755a956612c66b 100644 (file)
@@ -1784,6 +1784,29 @@ public:
     virtual void ScrollWindow(int dx, int dy,
                               const wxRect* rect = NULL);
 
+    /**
+        This function sends a dummy @ref overview_wxsizeevent "size event" to
+        the window allowing it to re-layout its children positions.
+
+        It is sometimes useful to call this function after adding or deleting a
+        children after the frame creation or if a child size changes. Note that
+        if the frame is using either sizers or constraints for the children
+        layout, it is enough to call wxWindow::Layout() directly and this
+        function should not be used in this case.
+    */
+    void SendSizeEvent();
+
+    /**
+        Safe wrapper for GetParent()->SendSizeEvent().
+
+        This function simply checks that the window has a valid parent which is
+        not in process of being deleted and calls SendSizeEvent() on it. It is
+        used internally by windows such as toolbars changes to whose state
+        should result in parent re-layout (e.g. when a toolbar is added to the
+        top of the window, all the other windows must be shifted down).
+     */
+    void SendSizeEventToParent();
+
     /**
         Sets the accelerator table for this window. See wxAcceleratorTable.
     */
index f09e2c67cc704fa565040cc7018830cf14a125d2..61efbb6cf699a34e54616384468517978f817bb7 100644 (file)
@@ -170,15 +170,6 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
     return pt;
 }
 
-
-void wxFrameBase::SendSizeEvent()
-{
-    wxSizeEvent event( GetSize(), GetId() );
-    event.SetEventObject( this );
-    GetEventHandler()->AddPendingEvent( event );
-}
-
-
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
index 6ccc05323efcb0a2e5d862e4a4c0eade07d8a53b..bf4f7da3012712c2e5794a4e4b7e12600733a895 100644 (file)
@@ -841,6 +841,20 @@ void wxWindowBase::DoGetScreenPosition(int *x, int *y) const
     ClientToScreen(x, y);
 }
 
+void wxWindowBase::SendSizeEvent()
+{
+    wxSizeEvent event(GetSize(), GetId());
+    event.SetEventObject(this);
+    HandleWindowEvent(event);
+}
+
+void wxWindowBase::SendSizeEventToParent()
+{
+    wxWindow * const parent = GetParent();
+    if ( parent && !parent->IsBeingDeleted() )
+        parent->SendSizeEvent();
+}
+
 // ----------------------------------------------------------------------------
 // show/hide/enable/disable the window
 // ----------------------------------------------------------------------------
index 355b54f48a4ab7273bc1b0ac58809fed127233f4..184daa28e0920503a1c1d104839eb3bcbc472545 100644 (file)
@@ -557,13 +557,6 @@ void wxFrame::OnActivate(wxActivateEvent& event)
     }
 }
 
-void wxFrame::SendSizeEvent()
-{
-    wxSizeEvent event(GetSize(), GetId());
-    event.SetEventObject(this);
-    GetEventHandler()->AddPendingEvent(event);
-}
-
 #if wxUSE_TOOLBAR
 
 wxToolBar* wxFrame::CreateToolBar(long style,
index aef8e5c5676e477b2555a2283bcb0d9eb04b548d..69826207decfecac1697bdf3e5d6a36904486bed 100644 (file)
@@ -125,11 +125,7 @@ bool wxStatusBar::Create(wxWindow *parent,
 
     // we must refresh the frame size when the statusbar is created, because
     // its client area might change
-    wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
-    if ( frame )
-    {
-        frame->SendSizeEvent();
-    }
+    SendSizeEventToParent();
 
     return true;
 }
@@ -139,11 +135,7 @@ wxStatusBar::~wxStatusBar()
     // we must refresh the frame size when the statusbar is deleted but the
     // frame is not - otherwise statusbar leaves a hole in the place it used to
     // occupy
-    wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
-    if ( frame && !frame->IsBeingDeleted() )
-    {
-        frame->SendSizeEvent();
-    }
+    SendSizeEventToParent();
 }
 
 void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
index e8c47e5ed3e09a7ec923a530ca2bcf1e785f5a94..33c4950b307032a0dcd2df623e9a1b9b95f1a2a6 100644 (file)
@@ -397,9 +397,7 @@ wxToolBar::~wxToolBar()
 {
     // we must refresh the frame size when the toolbar is deleted but the frame
     // is not - otherwise toolbar leaves a hole in the place it used to occupy
-    wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
-    if ( frame && !frame->IsBeingDeleted() )
-        frame->SendSizeEvent();
+    SendSizeEventToParent();
 
     if ( m_hBitmap )
         ::DeleteObject((HBITMAP) m_hBitmap);
@@ -1422,11 +1420,7 @@ void wxToolBar::UpdateSize()
     // toolbar to full width again, but only if the parent is a frame and the
     // toolbar is managed by the frame.  Otherwise assume that some other
     // layout mechanism is controlling the toolbar size and leave it alone.
-    wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
-    if ( frame && frame->GetToolBar() == this )
-    {
-        frame->SendSizeEvent();
-    }
+    SendSizeEventToParent();
 }
 
 // ----------------------------------------------------------------------------
index 567fa20eb632c7d04b1456ea90f1410f0b0de4bf..98dbc1ba94061782d4653aeac5c66f5cdab4bac2 100644 (file)
@@ -1379,20 +1379,3 @@ wxWindow* wxFrame::GetClient()
     return wxFindWinFromHandle((WXHWND)::WinWindowFromID(m_hFrame, FID_CLIENT));
 }
 
-void wxFrame::SendSizeEvent()
-{
-    if (!m_bIconized)
-    {
-        RECTL                       vRect = wxGetWindowRect(GetHwnd());
-
-        ::WinPostMsg( GetHwnd()
-                     ,WM_SIZE
-                     ,MPFROM2SHORT( vRect.xRight - vRect.xLeft
-                                   ,vRect.xRight - vRect.xLeft
-                                  )
-                     ,MPFROM2SHORT( vRect.yTop - vRect.yBottom
-                                   ,vRect.yTop - vRect.yBottom
-                                  )
-                    );
-    }
-}
index 91c5a9d7eb1b04b4b7d8c2c9ca7a665bfe56bd1b..cb7aa42d0bfde0517f763a950295a1121335018b 100644 (file)
@@ -92,13 +92,6 @@ void wxFrame::OnSize(wxSizeEvent& event)
     event.Skip();
 }
 
-void wxFrame::SendSizeEvent()
-{
-    wxSizeEvent event(GetSize(), GetId());
-    event.SetEventObject(this);
-    GetEventHandler()->ProcessEvent(event);
-}
-
 #if wxUSE_MENUS
 
 void wxFrame::PositionMenuBar()
index 41dc5d22813557a9012a4c98c65da2cc82e2aa72..9b36cc74ac75e1494c520c32705f21615e3af164 100644 (file)
@@ -587,13 +587,7 @@ void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     // otherwise the toolbar can be shown incorrectly
     if ( old_width != width || old_height != height )
     {
-        // But before we send the size event check it
-        // we have a frame that is not being deleted.
-        wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
-        if ( frame && !frame->IsBeingDeleted() )
-        {
-            frame->SendSizeEvent();
-        }
+        SendSizeEventToParent();
     }
 }