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