]>
Commit | Line | Data |
---|---|---|
4d90072c VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: mac/carbon/evtloop.cpp | |
3 | // Purpose: implementation of wxEventLoop for wxMac | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 2006-01-12 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | // for compilers that support precompilation, includes "wx.h". | |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
27 | #include "wx/evtloop.h" | |
28 | ||
29 | #include <Carbon/Carbon.h> | |
30 | ||
31 | // ============================================================================ | |
c8026dea | 32 | // wxEventLoop implementation |
4d90072c VZ |
33 | // ============================================================================ |
34 | ||
c8026dea VZ |
35 | // ---------------------------------------------------------------------------- |
36 | // high level functions for RunApplicationEventLoop() case | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | #if wxMAC_USE_RUN_APP_EVENT_LOOP | |
4d90072c VZ |
40 | |
41 | int wxEventLoop::Run() | |
42 | { | |
43 | wxEventLoopActivator activate(this); | |
44 | ||
4d90072c | 45 | RunApplicationEventLoop(); |
4d90072c VZ |
46 | |
47 | return m_exitcode; | |
48 | } | |
49 | ||
50 | void wxEventLoop::Exit(int rc) | |
51 | { | |
52 | m_exitcode = rc; | |
53 | ||
4d90072c | 54 | QuitApplicationEventLoop(); |
c8026dea VZ |
55 | |
56 | OnExit(); | |
57 | } | |
58 | ||
4d90072c | 59 | #else // manual event loop |
c8026dea VZ |
60 | |
61 | // ---------------------------------------------------------------------------- | |
62 | // functions only used by wxEventLoopManual-based implementation | |
63 | // ---------------------------------------------------------------------------- | |
64 | ||
65 | void wxEventLoop::WakeUp() | |
66 | { | |
67 | extern void wxMacWakeUp(); | |
68 | ||
69 | wxMacWakeUp(); | |
4d90072c VZ |
70 | } |
71 | ||
c8026dea VZ |
72 | #endif // high/low-level event loop |
73 | ||
74 | // ---------------------------------------------------------------------------- | |
75 | // low level functions used in both cases | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
4d90072c VZ |
78 | bool wxEventLoop::Pending() const |
79 | { | |
80 | EventRef theEvent; | |
81 | ||
82 | return ReceiveNextEvent | |
83 | ( | |
84 | 0, // we want any event at all so we don't specify neither | |
85 | NULL, // the number of event types nor the types themselves | |
86 | kEventDurationNoWait, | |
87 | false, // don't remove the event from queue | |
88 | &theEvent | |
89 | ) == noErr; | |
90 | } | |
91 | ||
92 | bool wxEventLoop::Dispatch() | |
93 | { | |
94 | // TODO: we probably should do the dispatching directly from here but for | |
95 | // now it's easier to forward to wxApp which has all the code to do | |
96 | // it | |
97 | if ( !wxTheApp ) | |
98 | return false; | |
99 | ||
100 | wxTheApp->MacDoOneEvent(); | |
101 | return true; | |
102 | } | |
103 |