add PostSizeEvent() and use it in wxMSW status bar code (#9795)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54837 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -92,7 +92,7 @@ public:
|
|||||||
#endif // tooltips
|
#endif // tooltips
|
||||||
|
|
||||||
// override the base class function to handle iconized/maximized frames
|
// override the base class function to handle iconized/maximized frames
|
||||||
virtual void SendSizeEvent();
|
virtual void SendSizeEvent(int flags = 0);
|
||||||
|
|
||||||
virtual wxPoint GetClientAreaOrigin() const;
|
virtual wxPoint GetClientAreaOrigin() const;
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ public:
|
|||||||
virtual bool IsMaximized(void) const;
|
virtual bool IsMaximized(void) const;
|
||||||
virtual void Maximize(bool bMaximize = true);
|
virtual void Maximize(bool bMaximize = true);
|
||||||
virtual void Restore(void);
|
virtual void Restore(void);
|
||||||
virtual void SendSizeEvent(void);
|
virtual void SendSizeEvent(int flags = 0);
|
||||||
virtual void SetIcons(const wxIconBundle& rIcons);
|
virtual void SetIcons(const wxIconBundle& rIcons);
|
||||||
|
|
||||||
virtual bool Show(bool bShow = true);
|
virtual bool Show(bool bShow = true);
|
||||||
|
@@ -131,6 +131,12 @@ enum wxShowEffect
|
|||||||
wxSHOW_EFFECT_MAX
|
wxSHOW_EFFECT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// flags for SendSizeEvent()
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
wxSEND_EVENT_POST = 1
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// (pseudo)template list classes
|
// (pseudo)template list classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -538,14 +544,24 @@ public:
|
|||||||
|
|
||||||
// sends a size event to the window using its current size -- this has an
|
// sends a size event to the window using its current size -- this has an
|
||||||
// effect of refreshing the window layout
|
// effect of refreshing the window layout
|
||||||
virtual void SendSizeEvent();
|
//
|
||||||
|
// by default the event is sent, i.e. processed immediately, but if flags
|
||||||
|
// value includes wxSEND_EVENT_POST then it's posted, i.e. only schedule
|
||||||
|
// for later processing
|
||||||
|
virtual void SendSizeEvent(int flags = 0);
|
||||||
|
|
||||||
// this is a safe wrapper for GetParent()->SendSizeEvent(): it checks that
|
// 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
|
// 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
|
// this is used by controls such as tool/status bars changes to which must
|
||||||
// also result in parent re-layout
|
// also result in parent re-layout
|
||||||
void SendSizeEventToParent();
|
void SendSizeEventToParent(int flags = 0);
|
||||||
|
|
||||||
|
// this is a more readable synonym for SendSizeEvent(wxSEND_EVENT_POST)
|
||||||
|
void PostSizeEvent() { SendSizeEvent(wxSEND_EVENT_POST); }
|
||||||
|
|
||||||
|
// this is the same as SendSizeEventToParent() but using PostSizeEvent()
|
||||||
|
void PostSizeEventToParent() { SendSizeEventToParent(wxSEND_EVENT_POST); }
|
||||||
|
|
||||||
|
|
||||||
// window state
|
// window state
|
||||||
|
@@ -1588,6 +1588,21 @@ public:
|
|||||||
bool PopupMenu(wxMenu* menu, int x, int y);
|
bool PopupMenu(wxMenu* menu, int x, int y);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posts a size event to the window.
|
||||||
|
|
||||||
|
This is the same as SendSizeEvent() with @c wxSEND_EVENT_POST argument.
|
||||||
|
*/
|
||||||
|
void PostSizeEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Posts a size event to the parent of this window.
|
||||||
|
|
||||||
|
This is the same as SendSizeEventToParent() with @c wxSEND_EVENT_POST
|
||||||
|
argument.
|
||||||
|
*/
|
||||||
|
void PostSizeEventToParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Pushes this event handler onto the event stack for the window.
|
Pushes this event handler onto the event stack for the window.
|
||||||
|
|
||||||
@@ -1793,8 +1808,16 @@ public:
|
|||||||
if the frame is using either sizers or constraints for the children
|
if the frame is using either sizers or constraints for the children
|
||||||
layout, it is enough to call wxWindow::Layout() directly and this
|
layout, it is enough to call wxWindow::Layout() directly and this
|
||||||
function should not be used in this case.
|
function should not be used in this case.
|
||||||
|
|
||||||
|
If @a flags includes @c wxSEND_EVENT_POST value, this function posts
|
||||||
|
the event, i.e. schedules it for later processing, instead of
|
||||||
|
dispatching it directly. You can also use PostSizeEvent() as a more
|
||||||
|
readable equivalent of calling this function with this flag.
|
||||||
|
|
||||||
|
@param flags
|
||||||
|
May include @c wxSEND_EVENT_POST. Default value is 0.
|
||||||
*/
|
*/
|
||||||
void SendSizeEvent();
|
void SendSizeEvent(int flags = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Safe wrapper for GetParent()->SendSizeEvent().
|
Safe wrapper for GetParent()->SendSizeEvent().
|
||||||
@@ -1804,8 +1827,13 @@ public:
|
|||||||
used internally by windows such as toolbars changes to whose state
|
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
|
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).
|
top of the window, all the other windows must be shifted down).
|
||||||
|
|
||||||
|
@see PostSizeEventToParent()
|
||||||
|
|
||||||
|
@param flags
|
||||||
|
See description of this parameter in SendSizeEvent() documentation.
|
||||||
*/
|
*/
|
||||||
void SendSizeEventToParent();
|
void SendSizeEventToParent(int flags = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the accelerator table for this window. See wxAcceleratorTable.
|
Sets the accelerator table for this window. See wxAcceleratorTable.
|
||||||
|
@@ -841,18 +841,21 @@ void wxWindowBase::DoGetScreenPosition(int *x, int *y) const
|
|||||||
ClientToScreen(x, y);
|
ClientToScreen(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowBase::SendSizeEvent()
|
void wxWindowBase::SendSizeEvent(int flags)
|
||||||
{
|
{
|
||||||
wxSizeEvent event(GetSize(), GetId());
|
wxSizeEvent event(GetSize(), GetId());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
|
if ( flags & wxSEND_EVENT_POST )
|
||||||
|
wxPostEvent(this, event);
|
||||||
|
else
|
||||||
HandleWindowEvent(event);
|
HandleWindowEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowBase::SendSizeEventToParent()
|
void wxWindowBase::SendSizeEventToParent(int flags)
|
||||||
{
|
{
|
||||||
wxWindow * const parent = GetParent();
|
wxWindow * const parent = GetParent();
|
||||||
if ( parent && !parent->IsBeingDeleted() )
|
if ( parent && !parent->IsBeingDeleted() )
|
||||||
parent->SendSizeEvent();
|
parent->SendSizeEvent(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -310,16 +310,25 @@ void wxFrame::Raise()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// generate an artificial resize event
|
// generate an artificial resize event
|
||||||
void wxFrame::SendSizeEvent()
|
void wxFrame::SendSizeEvent(int flags)
|
||||||
{
|
{
|
||||||
if ( !m_iconized )
|
if ( !m_iconized )
|
||||||
{
|
{
|
||||||
RECT r = wxGetWindowRect(GetHwnd());
|
RECT r = wxGetWindowRect(GetHwnd());
|
||||||
|
|
||||||
(void)::SendMessage(GetHwnd(), WM_SIZE,
|
if ( flags & wxSEND_EVENT_POST )
|
||||||
|
{
|
||||||
|
::PostMessage(GetHwnd(), WM_SIZE,
|
||||||
IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
|
IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
|
||||||
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
||||||
}
|
}
|
||||||
|
else // send it
|
||||||
|
{
|
||||||
|
::SendMessage(GetHwnd(), WM_SIZE,
|
||||||
|
IsMaximized() ? SIZE_MAXIMIZED : SIZE_RESTORED,
|
||||||
|
MAKELPARAM(r.right - r.left, r.bottom - r.top));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
|
@@ -125,7 +125,11 @@ bool wxStatusBar::Create(wxWindow *parent,
|
|||||||
|
|
||||||
// we must refresh the frame size when the statusbar is created, because
|
// we must refresh the frame size when the statusbar is created, because
|
||||||
// its client area might change
|
// its client area might change
|
||||||
SendSizeEventToParent();
|
//
|
||||||
|
// notice that we must post the event, not send it, as the frame doesn't
|
||||||
|
// know that we're its status bar yet so laying it out right now wouldn't
|
||||||
|
// work correctly, we need to wait until we return to the main loop
|
||||||
|
PostSizeEventToParent();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -135,7 +139,7 @@ wxStatusBar::~wxStatusBar()
|
|||||||
// we must refresh the frame size when the statusbar is deleted but the
|
// 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
|
// frame is not - otherwise statusbar leaves a hole in the place it used to
|
||||||
// occupy
|
// occupy
|
||||||
SendSizeEventToParent();
|
PostSizeEventToParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
|
void wxStatusBar::SetFieldsCount(int nFields, const int *widths)
|
||||||
|
@@ -872,18 +872,29 @@ void wxTopLevelWindowOS2::Restore()
|
|||||||
} // end of wxTopLevelWindowOS2::Restore
|
} // end of wxTopLevelWindowOS2::Restore
|
||||||
|
|
||||||
// generate an artificial resize event
|
// generate an artificial resize event
|
||||||
void wxTopLevelWindowOS2::SendSizeEvent()
|
void wxTopLevelWindowOS2::SendSizeEvent(int flags)
|
||||||
{
|
{
|
||||||
if (!m_bIconized)
|
if (!m_bIconized)
|
||||||
{
|
{
|
||||||
RECTL vRect = wxGetWindowRect(GetHwnd());
|
RECTL vRect = wxGetWindowRect(GetHwnd());
|
||||||
|
|
||||||
|
if ( flags & wxSEND_EVENT_POST )
|
||||||
|
{
|
||||||
(void)::WinPostMsg( m_hFrame
|
(void)::WinPostMsg( m_hFrame
|
||||||
,WM_SIZE
|
,WM_SIZE
|
||||||
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
||||||
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else // send it
|
||||||
|
{
|
||||||
|
(void)::WinSendMsg( m_hFrame
|
||||||
|
,WM_SIZE
|
||||||
|
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
||||||
|
,MPFROM2SHORT(vRect.xRight - vRect.xLeft, vRect.yTop - vRect.yBottom)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // end of wxTopLevelWindowOS2::SendSizeEvent
|
} // end of wxTopLevelWindowOS2::SendSizeEvent
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user