From 0c3e2a5baacbb9f9a43f0887521061c9aa0239d4 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sat, 8 Jan 2011 06:42:41 +0000 Subject: [PATCH] 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 --- include/wx/app.h | 4 ---- include/wx/gtk/frame.h | 3 +-- include/wx/window.h | 5 +++-- interface/wx/app.h | 13 ------------- src/common/appcmn.cpp | 32 +------------------------------- src/common/wincmn.cpp | 28 ++++++++++++++++++++++++++++ src/gtk/frame.cpp | 32 ++++++++++++-------------------- 7 files changed, 45 insertions(+), 72 deletions(-) diff --git a/include/wx/app.h b/include/wx/app.h index 4b0c4fbc9d..0ea4a57464 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -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; } diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 9d97293d52..f65f85ee62 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -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 diff --git a/include/wx/window.h b/include/wx/window.h index cb68751aad..1527a1e0de 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -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 diff --git a/interface/wx/app.h b/interface/wx/app.h index 94878af4e6..3b7d17bc9a 100644 --- a/interface/wx/app.h +++ b/interface/wx/app.h @@ -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). diff --git a/src/common/appcmn.cpp b/src/common/appcmn.cpp index 844aec1f42..6eb1fc78d4 100644 --- a/src/common/appcmn.cpp +++ b/src/common/appcmn.cpp @@ -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 // ---------------------------------------------------------------------------- diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 82e0f7a3ee..76aca9086c 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -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()) diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 7d17af90ad..a4148d0ed0 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -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; } // ---------------------------------------------------------------------------- -- 2.45.2