]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/osx/evtloop.h
Use /bin/echo for creation of Mac OS X PkgInfo files.
[wxWidgets.git] / include / wx / osx / evtloop.h
... / ...
CommitLineData
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
5// headers
6// Author: Vadim Zeitlin
7// Modified by:
8// Created: 2006-01-12
9// RCS-ID: $Id$
10// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
11// Licence: wxWindows licence
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_OSX_EVTLOOP_H_
15#define _WX_OSX_EVTLOOP_H_
16
17DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop );
18DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver );
19
20class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
21{
22public:
23 wxCFEventLoop();
24 virtual ~wxCFEventLoop();
25
26 // enters a loop calling OnNextIteration(), Pending() and Dispatch() and
27 // terminating when Exit() is called
28 virtual int Run();
29
30 // sets the "should exit" flag and wakes up the loop so that it terminates
31 // soon
32 virtual void Exit(int rc = 0);
33
34 // return true if any events are available
35 virtual bool Pending() const;
36
37 // dispatch a single event, return false if we should exit from the loop
38 virtual bool Dispatch();
39
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);
44
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();
48
49 virtual bool YieldFor(long eventsToProcess);
50
51#if wxUSE_EVENTLOOP_SOURCE
52 virtual wxEventLoopSource *
53 AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
54#endif // wxUSE_EVENTLOOP_SOURCE
55
56
57protected:
58 void CommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
59 void DefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity);
60
61 static void OSXCommonModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
62 static void OSXDefaultModeObserverCallBack(CFRunLoopObserverRef observer, int activity, void *info);
63
64 // get the currently executing CFRunLoop
65 virtual CFRunLoopRef CFGetCurrentRunLoop() const;
66
67 virtual int DoDispatchTimeout(unsigned long timeout);
68
69 virtual void DoRun();
70
71 virtual void DoStop();
72
73 // should we exit the loop?
74 bool m_shouldExit;
75
76 // the loop exit code
77 int m_exitcode;
78
79 // cfrunloop
80 CFRunLoopRef m_runLoop;
81
82 // common modes runloop observer
83 CFRunLoopObserverRef m_commonModeRunLoopObserver;
84
85 // default mode runloop observer
86 CFRunLoopObserverRef m_defaultModeRunLoopObserver;
87
88private:
89 // process all already pending events and dispatch a new one (blocking
90 // until it appears in the event queue if necessary)
91 //
92 // returns the return value of DoDispatchTimeout()
93 int DoProcessEvents();
94};
95
96#if wxUSE_GUI
97
98#ifdef __WXOSX_COCOA__
99 #include "wx/osx/cocoa/evtloop.h"
100#else
101 #include "wx/osx/carbon/evtloop.h"
102#endif
103
104class WXDLLIMPEXP_FWD_CORE wxWindow;
105class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
106
107class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
108{
109public:
110 wxModalEventLoop(wxWindow *modalWindow);
111 wxModalEventLoop(WXWindow modalNativeWindow);
112
113protected:
114 virtual void DoRun();
115
116 virtual void DoStop();
117
118 // (in case) the modal window for this event loop
119 wxNonOwnedWindow* m_modalWindow;
120 WXWindow m_modalNativeWindow;
121};
122
123#endif // wxUSE_GUI
124
125#endif // _WX_OSX_EVTLOOP_H_