]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/evtloop.cpp
non-pch build fix
[wxWidgets.git] / src / mac / carbon / evtloop.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/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#ifndef WX_PRECOMP
30 #include "wx/app.h"
31#endif // WX_PRECOMP
32
33#ifdef __DARWIN__
34 #include <Carbon/Carbon.h>
35#else
36 #include <Carbon.h>
37#endif
38// ============================================================================
39// wxEventLoop implementation
40// ============================================================================
41
42// ----------------------------------------------------------------------------
43// high level functions for RunApplicationEventLoop() case
44// ----------------------------------------------------------------------------
45
46#if wxMAC_USE_RUN_APP_EVENT_LOOP
47
48int wxEventLoop::Run()
49{
50 wxEventLoopActivator activate(this);
51
52 RunApplicationEventLoop();
53
54 return m_exitcode;
55}
56
57void wxEventLoop::Exit(int rc)
58{
59 m_exitcode = rc;
60
61 QuitApplicationEventLoop();
62
63 OnExit();
64}
65
66#else // manual event loop
67
68// ----------------------------------------------------------------------------
69// functions only used by wxEventLoopManual-based implementation
70// ----------------------------------------------------------------------------
71
72void wxEventLoop::WakeUp()
73{
74 extern void wxMacWakeUp();
75
76 wxMacWakeUp();
77}
78
79#endif // high/low-level event loop
80
81// ----------------------------------------------------------------------------
82// low level functions used in both cases
83// ----------------------------------------------------------------------------
84
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}