]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/evtloop.h
streamlining OSX event support first step, see #11805, see #11797
[wxWidgets.git] / include / wx / osx / evtloop.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: include/wx/osx/evtloop.h
3 // Purpose: simply forwards to wx/mac/carbon/evtloop.h for consistency with
4 // the other Mac headers
5 // Author: Vadim Zeitlin
6 // Modified by:
7 // Created: 2006-01-12
8 // RCS-ID: $Id$
9 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
10 // Licence: wxWindows licence
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_OSX_EVTLOOP_H_
14 #define _WX_OSX_EVTLOOP_H_
15
16 typedef struct __CFRunLoop * CFRunLoopRef;
17
18 class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
19 {
20 public:
21 wxCFEventLoop();
22 virtual ~wxCFEventLoop();
23
24 // enters a loop calling OnNextIteration(), Pending() and Dispatch() and
25 // terminating when Exit() is called
26 virtual int Run();
27
28 // sets the "should exit" flag and wakes up the loop so that it terminates
29 // soon
30 virtual void Exit(int rc = 0);
31
32 // return true if any events are available
33 virtual bool Pending() const;
34
35 // dispatch a single event, return false if we should exit from the loop
36 virtual bool Dispatch();
37
38 // same as Dispatch() but doesn't wait for longer than the specified (in
39 // ms) timeout, return true if an event was processed, false if we should
40 // exit the loop or -1 if timeout expired
41 virtual int DispatchTimeout(unsigned long timeout);
42
43 // implement this to wake up the loop: usually done by posting a dummy event
44 // to it (can be called from non main thread)
45 virtual void WakeUp();
46
47 virtual bool YieldFor(long eventsToProcess);
48
49 #if wxUSE_EVENTLOOP_SOURCE
50 virtual wxEventLoopSource *
51 AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
52 #endif // wxUSE_EVENTLOOP_SOURCE
53
54 protected:
55 // get the currently executing CFRunLoop
56 virtual CFRunLoopRef CFGetCurrentRunLoop() const;
57
58 virtual int DoDispatchTimeout(unsigned long timeout);
59
60 double m_sleepTime;
61
62 // should we exit the loop?
63 bool m_shouldExit;
64
65 // the loop exit code
66 int m_exitcode;
67
68 private:
69 // process all already pending events and dispatch a new one (blocking
70 // until it appears in the event queue if necessary)
71 //
72 // returns the return value of DoDispatchTimeout()
73 int DoProcessEvents();
74 };
75
76 #if wxUSE_GUI
77 #ifdef __WXOSX_COCOA__
78 #include "wx/osx/cocoa/evtloop.h"
79 #else
80 #include "wx/osx/carbon/evtloop.h"
81 #endif
82 #endif // wxUSE_GUI
83
84 #endif // _WX_OSX_EVTLOOP_H_