]> git.saurik.com Git - wxWidgets.git/blame - include/wx/evtloop.h
finally really fixes IRIX build:
[wxWidgets.git] / include / wx / evtloop.h
CommitLineData
3808e191
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/evtloop.h
3// Purpose: declares wxEventLoop class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 01.06.01
7// RCS-ID: $Id$
8// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
3808e191
JS
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_EVTLOOP_H_
13#define _WX_EVTLOOP_H_
14
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
3808e191
JS
16 #pragma interface "evtloop.h"
17#endif
18
752464f9
VS
19#include "wx/utils.h"
20
3754265e 21class WXDLLEXPORT wxEventLoop;
4300caa7 22
3808e191
JS
23// ----------------------------------------------------------------------------
24// wxEventLoop: a GUI event loop
25// ----------------------------------------------------------------------------
26
3754265e 27class WXDLLEXPORT wxEventLoopBase
3808e191
JS
28{
29public:
3754265e
VZ
30 // trivial, but needed (because of wxEventLoopBase) ctor
31 wxEventLoopBase() { }
3808e191
JS
32
33 // dtor
3754265e 34 virtual ~wxEventLoopBase() { }
3808e191
JS
35
36 // start the event loop, return the exit code when it is finished
3754265e 37 virtual int Run() = 0;
3808e191
JS
38
39 // exit from the loop with the given exit code
3754265e 40 virtual void Exit(int rc = 0) = 0;
3808e191 41
1a18887b 42 // return true if any events are available
3754265e 43 virtual bool Pending() const = 0;
3808e191 44
1a18887b 45 // dispatch a single event, return false if we should exit from the loop
3754265e 46 virtual bool Dispatch() = 0;
3808e191
JS
47
48 // is the event loop running now?
3754265e 49 virtual bool IsRunning() const = 0;
f2108ede 50
b9f246f7
VS
51 // return currently active (running) event loop, may be NULL
52 static wxEventLoop *GetActive() { return ms_activeLoop; }
3808e191 53
df0e1b64
JS
54 // set currently active (running) event loop
55 static void SetActive(wxEventLoop* loop) { ms_activeLoop = loop; }
56
3808e191 57protected:
4300caa7
VZ
58 // this function should be called before the event loop terminates, whether
59 // this happens normally (because of Exit() call) or abnormally (because of
60 // an exception thrown from inside the loop)
61 virtual void OnExit() { }
62
63
b9f246f7
VS
64 // the pointer to currently active loop
65 static wxEventLoop *ms_activeLoop;
22f3361e 66
3754265e
VZ
67 DECLARE_NO_COPY_CLASS(wxEventLoopBase)
68};
69
70// we're moving away from old m_impl wxEventLoop model as otherwise the user
71// code doesn't have access to platform-specific wxEventLoop methods and this
72// can sometimes be very useful (e.g. under MSW this is necessary for
73// integration with MFC) but currently this is done for MSW only, other ports
74// should follow a.s.a.p.
4055ed82 75#if defined(__WXPALMOS__)
ffecfa5a
JS
76 #include "wx/palmos/evtloop.h"
77#elif defined(__WXMSW__)
3754265e
VZ
78 #include "wx/msw/evtloop.h"
79#else
80
81class WXDLLEXPORT wxEventLoopImpl;
82
83class WXDLLEXPORT wxEventLoop : public wxEventLoopBase
84{
85public:
86 wxEventLoop() { m_impl = NULL; }
eaca2a2c 87 virtual ~wxEventLoop();
1a18887b 88
3754265e
VZ
89 virtual int Run();
90 virtual void Exit(int rc = 0);
91 virtual bool Pending() const;
92 virtual bool Dispatch();
9213ca5d 93 virtual bool IsRunning() const { return GetActive() == this; }
3754265e
VZ
94
95protected:
4300caa7
VZ
96 // the pointer to the port specific implementation class
97 wxEventLoopImpl *m_impl;
98
22f3361e 99 DECLARE_NO_COPY_CLASS(wxEventLoop)
eaca2a2c 100 };
3754265e
VZ
101
102#endif // __WXMSW__/!__WXMSW__
3808e191 103
4300caa7
VZ
104// ----------------------------------------------------------------------------
105// wxModalEventLoop
106// ----------------------------------------------------------------------------
107
108// this is a naive generic implementation which uses wxWindowDisabler to
109// implement modality, we will surely need platform-specific implementations
110// too, this generic implementation is here only temporarily to see how it
111// works
112class WXDLLEXPORT wxModalEventLoop : public wxEventLoop
113{
114public:
115 wxModalEventLoop(wxWindow *winModal)
116 {
117 m_windowDisabler = new wxWindowDisabler(winModal);
118 }
119
120protected:
121 virtual void OnExit()
122 {
123 delete m_windowDisabler;
124 m_windowDisabler = NULL;
125
126 wxEventLoop::OnExit();
127 }
128
129private:
130 wxWindowDisabler *m_windowDisabler;
131};
132
3808e191 133#endif // _WX_EVTLOOP_H_