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"
19 class WXDLLEXPORT wxEventLoopImpl
;
21 // ----------------------------------------------------------------------------
22 // wxEventLoop: a GUI event loop
23 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxEventLoop
29 wxEventLoop() { m_impl
= NULL
; }
32 virtual ~wxEventLoop();
34 // start the event loop, return the exit code when it is finished
37 // exit from the loop with the given exit code
38 virtual void Exit(int rc
= 0);
40 // return TRUE if any events are available
41 virtual bool Pending() const;
43 // dispatch a single event, return FALSE if we should exit from the loop
44 virtual bool Dispatch();
46 // is the event loop running now?
47 virtual bool IsRunning() const;
49 // return currently active (running) event loop, may be NULL
50 static wxEventLoop
*GetActive() { return ms_activeLoop
; }
52 // set currently active (running) event loop
53 static void SetActive(wxEventLoop
* loop
) { ms_activeLoop
= loop
; }
56 // this function should be called before the event loop terminates, whether
57 // this happens normally (because of Exit() call) or abnormally (because of
58 // an exception thrown from inside the loop)
59 virtual void OnExit() { }
62 // the pointer to currently active loop
63 static wxEventLoop
*ms_activeLoop
;
65 // the pointer to the port specific implementation class
66 wxEventLoopImpl
*m_impl
;
68 DECLARE_NO_COPY_CLASS(wxEventLoop
)
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 // this is a naive generic implementation which uses wxWindowDisabler to
76 // implement modality, we will surely need platform-specific implementations
77 // too, this generic implementation is here only temporarily to see how it
79 class WXDLLEXPORT wxModalEventLoop
: public wxEventLoop
82 wxModalEventLoop(wxWindow
*winModal
)
84 m_windowDisabler
= new wxWindowDisabler(winModal
);
90 delete m_windowDisabler
;
91 m_windowDisabler
= NULL
;
93 wxEventLoop::OnExit();
97 wxWindowDisabler
*m_windowDisabler
;
100 #endif // _WX_EVTLOOP_H_