// using it
virtual bool IsOk() const { return true; }
+
// start the event loop, return the exit code when it is finished
virtual int Run() = 0;
// dispatch a single event, return false if we should exit from the loop
virtual bool Dispatch() = 0;
+ // same as Dispatch() but doesn't wait for longer than the specified (in
+ // ms) timeout, return true if an event was processed, false if we should
+ // exit the loop or -1 if timeout expired
+ virtual int DispatchTimeout(unsigned long timeout) = 0;
+
+
// return currently active (running) event loop, may be NULL
static wxEventLoopBase *GetActive() { return ms_activeLoop; }
#include "wx/msw/evtloop.h"
#elif defined(__WXMAC__)
#include "wx/osx/evtloop.h"
+#elif defined(__WXCOCOA__)
+ #include "wx/cocoa/evtloop.h"
#elif defined(__WXDFB__)
#include "wx/dfb/evtloop.h"
+#elif defined(__WXGTK20__)
+ #include "wx/gtk/evtloop.h"
#else // other platform
+#include "wx/stopwatch.h" // for wxMilliClock_t
+
class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl;
class WXDLLIMPEXP_CORE wxGUIEventLoop : public wxEventLoopBase
virtual void Exit(int rc = 0);
virtual bool Pending() const;
virtual bool Dispatch();
+ virtual int 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;
+ }
+ }
virtual void WakeUp() { }
protected: