Move SendIdleEvents() from wxApp to wxWindow.

Use it to properly implement idle events for
wxGTK menubar, toolbar and statusbar.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66648 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett 2011-01-08 06:42:41 +00:00
parent 8d6eed5f04
commit 0c3e2a5baa
7 changed files with 45 additions and 72 deletions

View File

@ -562,10 +562,6 @@ public:
// it should return true if more idle events are needed, false if not
virtual bool ProcessIdle();
// Send idle event to window and all subwindows
// Returns true if more idle time is requested.
virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
// override base class version: GUI apps always use an event loop
virtual bool UsesEventLoop() const { return true; }

View File

@ -61,8 +61,7 @@ public:
// implementation from now on
// --------------------------
// GTK callbacks
virtual void OnInternalIdle();
virtual bool SendIdleEvents(wxIdleEvent& event);
protected:
// common part of all ctors

View File

@ -1372,8 +1372,9 @@ public:
// behaviour
virtual void OnInternalIdle();
// call internal idle recursively
// void ProcessInternalIdle() ;
// Send idle event to window and all subwindows
// Returns true if more idle time is requested.
virtual bool SendIdleEvents(wxIdleEvent& event);
// get the handle of the window for the underlying window system: this
// is only used for wxWin itself or for user code which wants to call

View File

@ -722,19 +722,6 @@ public:
*/
bool ProcessMessage(WXMSG* msg);
/**
Sends idle events to a window and its children.
Please note that this function is internal to wxWidgets and shouldn't be used
by user code.
@remarks These functions poll the top-level windows, and their children,
for idle event processing. If @true is returned, more OnIdle
processing is requested by one or more window.
@see wxIdleEvent
*/
virtual bool SendIdleEvents(wxWindow* win, wxIdleEvent& event);
/**
Set display mode to use. This is only used in framebuffer wxWidgets
ports (such as wxMGL or wxDFB).

View File

@ -349,7 +349,7 @@ bool wxAppBase::ProcessIdle()
while (node)
{
wxWindow* win = node->GetData();
if (SendIdleEvents(win, event))
if (win->SendIdleEvents(event))
needMore = true;
node = node->GetNext();
}
@ -359,36 +359,6 @@ bool wxAppBase::ProcessIdle()
return needMore;
}
// Send idle event to window and all subwindows
bool wxAppBase::SendIdleEvents(wxWindow* win, wxIdleEvent& event)
{
bool needMore = false;
win->OnInternalIdle();
// should we send idle event to this window?
if ( wxIdleEvent::GetMode() == wxIDLE_PROCESS_ALL ||
win->HasExtraStyle(wxWS_EX_PROCESS_IDLE) )
{
event.SetEventObject(win);
win->HandleWindowEvent(event);
if (event.MoreRequested())
needMore = true;
}
wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst();
while ( node )
{
wxWindow *child = node->GetData();
if (SendIdleEvents(child, event))
needMore = true;
node = node->GetNext();
}
return needMore;
}
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase
// ----------------------------------------------------------------------------

View File

@ -2604,6 +2604,34 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
// Idle processing
// ----------------------------------------------------------------------------
// Send idle event to window and all subwindows
bool wxWindowBase::SendIdleEvents(wxIdleEvent& event)
{
bool needMore = false;
OnInternalIdle();
// should we send idle event to this window?
if (wxIdleEvent::GetMode() == wxIDLE_PROCESS_ALL ||
HasExtraStyle(wxWS_EX_PROCESS_IDLE))
{
event.SetEventObject(this);
HandleWindowEvent(event);
if (event.MoreRequested())
needMore = true;
}
wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
for (; node; node = node->GetNext())
{
wxWindow* child = node->GetData();
if (child->SendIdleEvents(event))
needMore = true;
}
return needMore;
}
void wxWindowBase::OnInternalIdle()
{
if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen())

View File

@ -235,32 +235,24 @@ bool wxFrame::ShowFullScreen(bool show, long style)
return true;
}
void wxFrame::OnInternalIdle()
bool wxFrame::SendIdleEvents(wxIdleEvent& event)
{
wxFrameBase::OnInternalIdle();
bool needMore = wxFrameBase::SendIdleEvents(event);
#if wxUSE_MENUS_NATIVE
if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
#endif // wxUSE_MENUS_NATIVE
#if wxUSE_MENUS
if (m_frameMenuBar && m_frameMenuBar->SendIdleEvents(event))
needMore = true;
#endif
#if wxUSE_TOOLBAR
if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
if (m_frameToolBar && m_frameToolBar->SendIdleEvents(event))
needMore = true;
#endif
#if wxUSE_STATUSBAR
if (m_frameStatusBar)
{
m_frameStatusBar->OnInternalIdle();
// There may be controls in the status bar that
// need to be updated
for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst();
node;
node = node->GetNext() )
{
wxWindow *child = node->GetData();
child->OnInternalIdle();
}
}
if (m_frameStatusBar && m_frameStatusBar->SendIdleEvents(event))
needMore = true;
#endif
return needMore;
}
// ----------------------------------------------------------------------------