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