]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/evtloop.cpp
using new API (no visual difference)
[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
VZ
29
30#include <Carbon/Carbon.h>
31
32// ============================================================================
c8026dea 33// wxEventLoop implementation
4d90072c
VZ
34// ============================================================================
35
c8026dea
VZ
36// ----------------------------------------------------------------------------
37// high level functions for RunApplicationEventLoop() case
38// ----------------------------------------------------------------------------
39
40#if wxMAC_USE_RUN_APP_EVENT_LOOP
4d90072c
VZ
41
42int wxEventLoop::Run()
43{
44 wxEventLoopActivator activate(this);
45
4d90072c 46 RunApplicationEventLoop();
4d90072c
VZ
47
48 return m_exitcode;
49}
50
51void wxEventLoop::Exit(int rc)
52{
53 m_exitcode = rc;
54
4d90072c 55 QuitApplicationEventLoop();
c8026dea
VZ
56
57 OnExit();
58}
59
4d90072c 60#else // manual event loop
c8026dea
VZ
61
62// ----------------------------------------------------------------------------
63// functions only used by wxEventLoopManual-based implementation
64// ----------------------------------------------------------------------------
65
66void wxEventLoop::WakeUp()
67{
68 extern void wxMacWakeUp();
69
70 wxMacWakeUp();
4d90072c
VZ
71}
72
c8026dea
VZ
73#endif // high/low-level event loop
74
75// ----------------------------------------------------------------------------
76// low level functions used in both cases
77// ----------------------------------------------------------------------------
78
4d90072c
VZ
79bool 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
93bool 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