]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/evtloop.h
flipped accessor conforming to plain c++ impl
[wxWidgets.git] / include / wx / evtloop.h
index 5d78a3bf56f983357128a998eddb0b32816b07c1..7d85458ff8f28f45d4e76f8b7f83296b61b4a7f5 100644 (file)
@@ -76,7 +76,7 @@ protected:
     // the pointer to currently active loop
     static wxEventLoopBase *ms_activeLoop;
 
-    DECLARE_NO_COPY_CLASS(wxEventLoopBase)
+    wxDECLARE_NO_COPY_CLASS(wxEventLoopBase);
 };
 
 #if defined(__WXMSW__) || defined(__WXMAC__) || defined(__WXDFB__) || defined(__UNIX__)
@@ -124,11 +124,15 @@ protected:
     #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
 
-#define wxNEEDS_GENERIC_DISPATCH_TIMEOUT
+#include "wx/stopwatch.h"   // for wxMilliClock_t
 
 class WXDLLIMPEXP_FWD_CORE wxEventLoopImpl;
 
@@ -142,14 +146,27 @@ public:
     virtual void Exit(int rc = 0);
     virtual bool Pending() const;
     virtual bool Dispatch();
-    virtual int DispatchTimeout(unsigned long timeout);
+    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:
     // the pointer to the port specific implementation class
     wxEventLoopImpl *m_impl;
 
-    DECLARE_NO_COPY_CLASS(wxGUIEventLoop)
+    wxDECLARE_NO_COPY_CLASS(wxGUIEventLoop);
 };
 
 #endif // platforms