]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/evtloop.h
supporting content size scaling (retina display)
[wxWidgets.git] / include / wx / osx / evtloop.h
CommitLineData
5c6eb3a8 1///////////////////////////////////////////////////////////////////////////////
233f5738
VZ
2// Name: wx/osx/evtloop.h
3// Purpose: simply forwards to wx/osx/carbon/evtloop.h or
4// wx/osx/cocoa/evtloop.h for consistency with the other Mac
5// headers
5c6eb3a8
SC
6// Author: Vadim Zeitlin
7// Modified by:
8// Created: 2006-01-12
9// RCS-ID: $Id$
10// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
11// Licence: wxWindows licence
12///////////////////////////////////////////////////////////////////////////////
13
5cd99866
VZ
14#ifndef _WX_OSX_EVTLOOP_H_
15#define _WX_OSX_EVTLOOP_H_
5c6eb3a8 16
293a13ba
SC
17DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoop );
18DECLARE_WXOSX_OPAQUE_CFREF( CFRunLoopObserver );
5cd99866 19
0056673c 20class WXDLLIMPEXP_BASE wxCFEventLoop : public wxEventLoopBase
5cd99866
VZ
21{
22public:
0056673c
SC
23 wxCFEventLoop();
24 virtual ~wxCFEventLoop();
25
26 // enters a loop calling OnNextIteration(), Pending() and Dispatch() and
27 // terminating when Exit() is called
28 virtual int Run();
ce00f59b 29
0056673c
SC
30 // sets the "should exit" flag and wakes up the loop so that it terminates
31 // soon
32 virtual void Exit(int rc = 0);
ce00f59b 33
0056673c
SC
34 // return true if any events are available
35 virtual bool Pending() const;
ce00f59b 36
0056673c
SC
37 // dispatch a single event, return false if we should exit from the loop
38 virtual bool Dispatch();
ce00f59b 39
0056673c
SC
40 // same as Dispatch() but doesn't wait for longer than the specified (in
41 // ms) timeout, return true if an event was processed, false if we should
42 // exit the loop or -1 if timeout expired
43 virtual int DispatchTimeout(unsigned long timeout);
44
45 // implement this to wake up the loop: usually done by posting a dummy event
46 // to it (can be called from non main thread)
47 virtual void WakeUp();
ce00f59b 48
0056673c
SC
49 virtual bool YieldFor(long eventsToProcess);
50
5cd99866
VZ
51#if wxUSE_EVENTLOOP_SOURCE
52 virtual wxEventLoopSource *
53 AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
54#endif // wxUSE_EVENTLOOP_SOURCE
55
293a13ba
SC
56 void ObserverCallBack(CFRunLoopObserverRef observer, int activity);
57
5cd99866
VZ
58protected:
59 // get the currently executing CFRunLoop
0056673c
SC
60 virtual CFRunLoopRef CFGetCurrentRunLoop() const;
61
62 virtual int DoDispatchTimeout(unsigned long timeout);
ce00f59b 63
80eee837 64 virtual void DoRun();
0056673c 65
80eee837 66 virtual void DoStop();
ce00f59b 67
0056673c
SC
68 // should we exit the loop?
69 bool m_shouldExit;
70
71 // the loop exit code
72 int m_exitcode;
ce00f59b 73
9aee1212
SC
74 // cfrunloop
75 CFRunLoopRef m_runLoop;
ce00f59b 76
293a13ba
SC
77 // runloop observer
78 CFRunLoopObserverRef m_runLoopObserver;
ce00f59b 79
0056673c
SC
80private:
81 // process all already pending events and dispatch a new one (blocking
82 // until it appears in the event queue if necessary)
83 //
84 // returns the return value of DoDispatchTimeout()
85 int DoProcessEvents();
5cd99866
VZ
86};
87
88#if wxUSE_GUI
80eee837
SC
89
90#ifdef __WXOSX_COCOA__
91 #include "wx/osx/cocoa/evtloop.h"
92#else
93 #include "wx/osx/carbon/evtloop.h"
94#endif
95
96class WXDLLIMPEXP_FWD_CORE wxWindow;
97class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
98
99class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
100{
101public:
cfb0ef70
SC
102 wxModalEventLoop(wxWindow *modalWindow);
103 wxModalEventLoop(WXWindow modalNativeWindow);
ce00f59b 104
80eee837
SC
105protected:
106 virtual void DoRun();
ce00f59b 107
80eee837 108 virtual void DoStop();
ce00f59b 109
80eee837
SC
110 // (in case) the modal window for this event loop
111 wxNonOwnedWindow* m_modalWindow;
cfb0ef70 112 WXWindow m_modalNativeWindow;
80eee837
SC
113};
114
5cd99866
VZ
115#endif // wxUSE_GUI
116
117#endif // _WX_OSX_EVTLOOP_H_