]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/osx/evtloop.h
Use "_x64" instead of "amd64" for x64 MSW makefile builds.
[wxWidgets.git] / include / wx / osx / evtloop.h
index 5ddb819d5533117b648d1daab5200492e178ad65..efbb220918f19abff8e7386bb4e72dcdbb05cd60 100644 (file)
@@ -1,7 +1,8 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        include/wx/osx/evtloop.h
-// Purpose:     simply forwards to wx/mac/carbon/evtloop.h for consistency with
-//              the other Mac headers
+// Name:        wx/osx/evtloop.h
+// Purpose:     simply forwards to wx/osx/carbon/evtloop.h or
+//              wx/osx/cocoa/evtloop.h for consistency with the other Mac
+//              headers
 // Author:      Vadim Zeitlin
 // Modified by:
 // Created:     2006-01-12
 #ifndef _WX_OSX_EVTLOOP_H_
 #define _WX_OSX_EVTLOOP_H_
 
-typedef struct __CFRunLoop * CFRunLoopRef;
+DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop );
+DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver );
+
+class WXDLLIMPEXP_BASE wxCFEventLoopPauseIdleEvents;
 
 class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
 {
+    friend class wxCFEventLoopPauseIdleEvents;
 public:
     wxCFEventLoop();
     virtual ~wxCFEventLoop();
@@ -24,17 +29,17 @@ public:
     // enters a loop calling OnNextIteration(), Pending() and Dispatch() and
     // terminating when Exit() is called
     virtual int Run();
-    
+
     // sets the "should exit" flag and wakes up the loop so that it terminates
     // soon
     virtual void Exit(int rc = 0);
 
     // return true if any events are available
     virtual bool Pending() const;
-    
+
     // dispatch a single event, return false if we should exit from the loop
     virtual bool Dispatch();
-    
+
     // 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
@@ -43,7 +48,7 @@ public:
     // implement this to wake up the loop: usually done by posting a dummy event
     // to it (can be called from non main thread)
     virtual void WakeUp();
-    
+
     virtual bool YieldFor(long eventsToProcess);
 
 #if wxUSE_EVENTLOOP_SOURCE
@@ -52,12 +57,23 @@ public:
 #endif // wxUSE_EVENTLOOP_SOURCE
 
 protected:
+    void CommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
+    void DefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
+
+    // set to false to avoid idling at unexpected moments - eg when having native message boxes
+    void SetProcessIdleEvents(bool process) { m_processIdleEvents = process; }
+
+    static void OSXCommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
+    static void OSXDefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
+
     // get the currently executing CFRunLoop
     virtual CFRunLoopRef CFGetCurrentRunLoop() const;
 
     virtual int DoDispatchTimeout(unsigned long timeout);
 
-    double m_sleepTime;
+    virtual void DoRun();
+
+    virtual void DoStop();
 
     // should we exit the loop?
     bool m_shouldExit;
@@ -65,20 +81,62 @@ protected:
     // the loop exit code
     int m_exitcode;
 
+    // cfrunloop
+    CFRunLoopRef m_runLoop;
+
+    // common modes runloop observer
+    CFRunLoopObserverRef m_commonModeRunLoopObserver;
+
+    // default mode runloop observer
+    CFRunLoopObserverRef m_defaultModeRunLoopObserver;
+    
+    // set to false to avoid idling at unexpected moments - eg when having native message boxes
+    bool m_processIdleEvents;
+
 private:
     // process all already pending events and dispatch a new one (blocking
     // until it appears in the event queue if necessary)
     //
     // returns the return value of DoDispatchTimeout()
     int DoProcessEvents();
+
+    wxDECLARE_NO_COPY_CLASS(wxCFEventLoop);
+};
+
+class WXDLLIMPEXP_BASE wxCFEventLoopPauseIdleEvents : public wxObject
+{
+public:
+    wxCFEventLoopPauseIdleEvents();
+    virtual ~wxCFEventLoopPauseIdleEvents();
 };
 
 #if wxUSE_GUI
-    #ifdef __WXOSX_COCOA__
-        #include "wx/osx/cocoa/evtloop.h"
-    #else
-        #include "wx/osx/carbon/evtloop.h"
-    #endif
+
+#ifdef __WXOSX_COCOA__
+    #include "wx/osx/cocoa/evtloop.h"
+#else
+    #include "wx/osx/carbon/evtloop.h"
+#endif
+
+class WXDLLIMPEXP_FWD_CORE wxWindow;
+class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
+
+class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
+{
+public:
+    wxModalEventLoop(wxWindow *modalWindow);
+    wxModalEventLoop(WXWindow modalNativeWindow);
+
+protected:
+    virtual void DoRun();
+
+    virtual void DoStop();
+
+    // (in case) the modal window for this event loop
+    wxNonOwnedWindow* m_modalWindow;
+    WXWindow m_modalNativeWindow;
+};
+
 #endif // wxUSE_GUI
 
 #endif // _WX_OSX_EVTLOOP_H_