move SendSizeEvent() down to wxWindow from wxFrame; added SendSizeEventToParent() helper
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54803 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
9a6d14383a
commit
0dba08dd39
@ -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
|
||||
// ------------------
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
// ------------
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -170,15 +170,6 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
|
||||
return pt;
|
||||
}
|
||||
|
||||
|
||||
void wxFrameBase::SendSizeEvent()
|
||||
{
|
||||
wxSizeEvent event( GetSize(), GetId() );
|
||||
event.SetEventObject( this );
|
||||
GetEventHandler()->AddPendingEvent( event );
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user