// 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
// ------------------
bool PreResize();
- void SendSizeEvent();
-
// for generic/mdig.h
virtual void DoGetClientSize(int *width, int *height) const;
+
private:
// common part of all ctors
void Init();
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;
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();
virtual wxSize GetMinSize() const;
- // sends wxSizeEvent to itself (used after attaching xxxBar)
- virtual void SendSizeEvent();
-
protected:
void OnSize(wxSizeEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
// 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
// ------------
*/
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.
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.
*/
return pt;
}
-
-void wxFrameBase::SendSizeEvent()
-{
- wxSizeEvent event( GetSize(), GetId() );
- event.SetEventObject( this );
- GetEventHandler()->AddPendingEvent( event );
-}
-
-
// ----------------------------------------------------------------------------
// misc
// ----------------------------------------------------------------------------
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
// ----------------------------------------------------------------------------
}
}
-void wxFrame::SendSizeEvent()
-{
- wxSizeEvent event(GetSize(), GetId());
- event.SetEventObject(this);
- GetEventHandler()->AddPendingEvent(event);
-}
-
#if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style,
// 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;
}
// 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)
{
// 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);
// 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();
}
// ----------------------------------------------------------------------------
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
- )
- );
- }
-}
event.Skip();
}
-void wxFrame::SendSizeEvent()
-{
- wxSizeEvent event(GetSize(), GetId());
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
-}
-
#if wxUSE_MENUS
void wxFrame::PositionMenuBar()
// 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();
}
}