// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#endif //WX_PRECOMP
// ----------------------------------------------------------------------------
-// globals
+// wxEventLoopBase
// ----------------------------------------------------------------------------
wxEventLoopBase *wxEventLoopBase::ms_activeLoop = NULL;
+wxEventLoopBase::wxEventLoopBase()
+{
+ m_isInsideYield = false;
+ m_eventsToProcessInsideYield = wxEVT_CATEGORY_ALL;
+}
+
+bool wxEventLoopBase::IsMain() const
+{
+ if (wxTheApp)
+ return wxTheApp->GetMainLoop() == this;
+ return false;
+}
+
+/* static */
+void wxEventLoopBase::SetActive(wxEventLoopBase* loop)
+{
+ ms_activeLoop = loop;
+
+ if (wxTheApp)
+ wxTheApp->OnEventLoopEnter(loop);
+}
+
+void wxEventLoopBase::OnExit()
+{
+ if (wxTheApp)
+ wxTheApp->OnEventLoopExit(this);
+}
+
+void wxEventLoopBase::WakeUpIdle()
+{
+ WakeUp();
+}
+
+bool wxEventLoopBase::ProcessIdle()
+{
+ if (!wxTheApp)
+ return false;
+
+ // process pending wx events before sending idle events
+ wxTheApp->ProcessPendingEvents();
+
+ // synthetize an idle event and send it to wxApp
+ wxIdleEvent event;
+ event.SetEventObject(wxTheApp);
+ wxTheApp->ProcessEvent(event);
+
+ return event.MoreRequested();
+}
+
+bool wxEventLoopBase::Yield(bool onlyIfNeeded)
+{
+ if ( m_isInsideYield )
+ {
+ if ( !onlyIfNeeded )
+ {
+ wxFAIL_MSG( wxT("wxYield called recursively" ) );
+ }
+
+ return false;
+ }
+
+ return YieldFor(wxEVT_CATEGORY_ALL);
+}
+
// wxEventLoopManual is unused in the other ports
#if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__) || (defined(__UNIX__) && wxUSE_BASE)
#endif // __WXMSW__ || __WXMAC__ || __WXDFB__
-#ifdef wxNEEDS_GENERIC_DISPATCH_TIMEOUT
-
-int wxGUIEventLoop::DispatchTimeout(unsigned long timeout)
-{
- // TODO: this is, of course, horribly inefficient and a proper wait with
- // timeout should be implemented for all ports natively...
- const wxMilliClock_t timeEnd = wxGetLocalTimeMillis() + timeout;
- for ( ;; )
- {
- if ( Pending() )
- return Dispatch();
-
- if ( wxGetLocalTimeMillis() >= timeEnd )
- return -1;
- }
-}
-
-#endif // wxNEEDS_GENERIC_DISPATCH_TIMEOUT
-