]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/evtloop.cpp
converting menu ids and safeguarding against missing menu items
[wxWidgets.git] / src / mac / carbon / evtloop.cpp
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 #include "wx/app.h"
29
30 #include <Carbon/Carbon.h>
31
32 // ============================================================================
33 // wxEventLoop implementation
34 // ============================================================================
35
36 // ----------------------------------------------------------------------------
37 // high level functions for RunApplicationEventLoop() case
38 // ----------------------------------------------------------------------------
39
40 #if wxMAC_USE_RUN_APP_EVENT_LOOP
41
42 int wxEventLoop::Run()
43 {
44 wxEventLoopActivator activate(this);
45
46 RunApplicationEventLoop();
47
48 return m_exitcode;
49 }
50
51 void wxEventLoop::Exit(int rc)
52 {
53 m_exitcode = rc;
54
55 QuitApplicationEventLoop();
56
57 OnExit();
58 }
59
60 #else // manual event loop
61
62 // ----------------------------------------------------------------------------
63 // functions only used by wxEventLoopManual-based implementation
64 // ----------------------------------------------------------------------------
65
66 void wxEventLoop::WakeUp()
67 {
68 extern void wxMacWakeUp();
69
70 wxMacWakeUp();
71 }
72
73 #endif // high/low-level event loop
74
75 // ----------------------------------------------------------------------------
76 // low level functions used in both cases
77 // ----------------------------------------------------------------------------
78
79 bool wxEventLoop::Pending() const
80 {
81 EventRef theEvent;
82
83 return ReceiveNextEvent
84 (
85 0, // we want any event at all so we don't specify neither
86 NULL, // the number of event types nor the types themselves
87 kEventDurationNoWait,
88 false, // don't remove the event from queue
89 &theEvent
90 ) == noErr;
91 }
92
93 bool wxEventLoop::Dispatch()
94 {
95 // TODO: we probably should do the dispatching directly from here but for
96 // now it's easier to forward to wxApp which has all the code to do
97 // it
98 if ( !wxTheApp )
99 return false;
100
101 wxTheApp->MacDoOneEvent();
102 return true;
103 }
104