1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/evtloop.h
3 // Purpose: simply forwards to wx/osx/carbon/evtloop.h or
4 // wx/osx/cocoa/evtloop.h for consistency with the other Mac
6 // Author: Vadim Zeitlin
10 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_OSX_EVTLOOP_H_
15 #define _WX_OSX_EVTLOOP_H_
17 DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop
);
18 DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver
);
20 class WXDLLIMPEXP_BASE wxCFEventLoop
: public wxEventLoopBase
24 virtual ~wxCFEventLoop();
26 // enters a loop calling OnNextIteration(), Pending() and Dispatch() and
27 // terminating when Exit() is called
30 // sets the "should exit" flag and wakes up the loop so that it terminates
32 virtual void Exit(int rc
= 0);
34 // return true if any events are available
35 virtual bool Pending() const;
37 // dispatch a single event, return false if we should exit from the loop
38 virtual bool Dispatch();
40 // same as Dispatch() but doesn't wait for longer than the specified (in
41 // ms) timeout, return true if an event was processed, false if we should
42 // exit the loop or -1 if timeout expired
43 virtual int DispatchTimeout(unsigned long timeout
);
45 // implement this to wake up the loop: usually done by posting a dummy event
46 // to it (can be called from non main thread)
47 virtual void WakeUp();
49 virtual bool YieldFor(long eventsToProcess
);
51 #if wxUSE_EVENTLOOP_SOURCE
52 virtual wxEventLoopSource
*
53 AddSourceForFD(int fd
, wxEventLoopSourceHandler
*handler
, int flags
);
54 #endif // wxUSE_EVENTLOOP_SOURCE
56 void ObserverCallBack(CFRunLoopObserverRef observer
, int activity
);
59 // get the currently executing CFRunLoop
60 virtual CFRunLoopRef
CFGetCurrentRunLoop() const;
62 virtual int DoDispatchTimeout(unsigned long timeout
);
66 virtual void DoStop();
68 // should we exit the loop?
75 CFRunLoopRef m_runLoop
;
78 CFRunLoopObserverRef m_runLoopObserver
;
81 // process all already pending events and dispatch a new one (blocking
82 // until it appears in the event queue if necessary)
84 // returns the return value of DoDispatchTimeout()
85 int DoProcessEvents();
90 #ifdef __WXOSX_COCOA__
91 #include "wx/osx/cocoa/evtloop.h"
93 #include "wx/osx/carbon/evtloop.h"
96 class WXDLLIMPEXP_FWD_CORE wxWindow
;
97 class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow
;
99 class WXDLLIMPEXP_CORE wxModalEventLoop
: public wxGUIEventLoop
102 wxModalEventLoop(wxWindow
*modalWindow
);
103 wxModalEventLoop(WXWindow modalNativeWindow
);
106 virtual void DoRun();
108 virtual void DoStop();
110 // (in case) the modal window for this event loop
111 wxNonOwnedWindow
* m_modalWindow
;
112 WXWindow m_modalNativeWindow
;
117 #endif // _WX_OSX_EVTLOOP_H_