1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declares wxEventLoop class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_EVTLOOP_H_
13 #define _WX_EVTLOOP_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "evtloop.h"
21 class WXDLLEXPORT wxEventLoopImpl
;
23 // ----------------------------------------------------------------------------
24 // wxEventLoop: a GUI event loop
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxEventLoop
31 wxEventLoop() { m_impl
= NULL
; }
34 virtual ~wxEventLoop();
36 // start the event loop, return the exit code when it is finished
39 // exit from the loop with the given exit code
40 virtual void Exit(int rc
= 0);
42 // return TRUE if any events are available
43 virtual bool Pending() const;
45 // dispatch a single event, return FALSE if we should exit from the loop
46 virtual bool Dispatch();
48 // is the event loop running now?
49 virtual bool IsRunning() const;
51 // return currently active (running) event loop, may be NULL
52 static wxEventLoop
*GetActive() { return ms_activeLoop
; }
54 // set currently active (running) event loop
55 static void SetActive(wxEventLoop
* loop
) { ms_activeLoop
= loop
; }
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() { }
64 // the pointer to currently active loop
65 static wxEventLoop
*ms_activeLoop
;
67 // the pointer to the port specific implementation class
68 wxEventLoopImpl
*m_impl
;
70 DECLARE_NO_COPY_CLASS(wxEventLoop
)
73 // ----------------------------------------------------------------------------
75 // ----------------------------------------------------------------------------
77 // this is a naive generic implementation which uses wxWindowDisabler to
78 // implement modality, we will surely need platform-specific implementations
79 // too, this generic implementation is here only temporarily to see how it
81 class WXDLLEXPORT wxModalEventLoop
: public wxEventLoop
84 wxModalEventLoop(wxWindow
*winModal
)
86 m_windowDisabler
= new wxWindowDisabler(winModal
);
92 delete m_windowDisabler
;
93 m_windowDisabler
= NULL
;
95 wxEventLoop::OnExit();
99 wxWindowDisabler
*m_windowDisabler
;
102 #endif // _WX_EVTLOOP_H_