+ wxEventLoopImpl *m_impl;
+
+ DECLARE_NO_COPY_CLASS(wxGUIEventLoop)
+};
+
+#endif // platforms
+
+// also include the header defining wxConsoleEventLoop for Unix systems
+#if defined(__UNIX__)
+ #include "wx/unix/evtloop.h"
+#endif
+
+// we use a class rather than a typedef because wxEventLoop is forward-declared
+// in many places
+#if wxUSE_GUI
+ class wxEventLoop : public wxGUIEventLoop { };
+#else // !GUI
+ // we can't define wxEventLoop differently in GUI and base libraries so use
+ // a #define to still allow writing wxEventLoop in the user code
+ #if wxUSE_CONSOLE_EVENTLOOP && (defined(__WXMSW__) || defined(__UNIX__))
+ #define wxEventLoop wxConsoleEventLoop
+ #else // we still must define it somehow for the code below...
+ #define wxEventLoop wxEventLoopBase
+ #endif
+#endif
+
+inline bool wxEventLoopBase::IsRunning() const { return GetActive() == this; }
+
+#if wxUSE_GUI
+// ----------------------------------------------------------------------------
+// wxModalEventLoop
+// ----------------------------------------------------------------------------
+
+// this is a naive generic implementation which uses wxWindowDisabler to
+// implement modality, we will surely need platform-specific implementations
+// too, this generic implementation is here only temporarily to see how it
+// works
+class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
+{
+public:
+ wxModalEventLoop(wxWindow *winModal)
+ {
+ m_windowDisabler = new wxWindowDisabler(winModal);
+ }
+
+protected:
+ virtual void OnExit()
+ {
+ delete m_windowDisabler;
+ m_windowDisabler = NULL;
+
+ wxGUIEventLoop::OnExit();
+ }
+
+private:
+ wxWindowDisabler *m_windowDisabler;
+};
+
+#endif //wxUSE_GUI
+
+// ----------------------------------------------------------------------------
+// wxEventLoopActivator: helper class for wxEventLoop implementations
+// ----------------------------------------------------------------------------
+
+// this object sets the wxEventLoop given to the ctor as the currently active
+// one and unsets it in its dtor, this is especially useful in presence of
+// exceptions but is more tidy even when we don't use them
+class wxEventLoopActivator
+{
+public:
+ wxEventLoopActivator(wxEventLoopBase *evtLoop)
+ {
+ m_evtLoopOld = wxEventLoopBase::GetActive();
+ wxEventLoopBase::SetActive(evtLoop);
+ }
+
+ ~wxEventLoopActivator()
+ {
+ // restore the previously active event loop
+ wxEventLoopBase::SetActive(m_evtLoopOld);
+ }
+
+private:
+ wxEventLoopBase *m_evtLoopOld;
+};
+
+#if wxUSE_CONSOLE_EVENTLOOP
+
+class wxEventLoopGuarantor
+{
+public:
+ wxEventLoopGuarantor()
+ {
+ m_evtLoopNew = NULL;
+ if (!wxEventLoop::GetActive())
+ {
+ m_evtLoopNew = new wxEventLoop;
+ wxEventLoop::SetActive(m_evtLoopNew);
+ }
+ }
+
+ ~wxEventLoopGuarantor()
+ {
+ if (m_evtLoopNew)
+ {
+ wxEventLoop::SetActive(NULL);
+ delete m_evtLoopNew;
+ }
+ }
+
+private:
+ wxEventLoop *m_evtLoopNew;