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