wx/mac/dirdlg.h \
wx/mac/display.h \
wx/mac/dnd.h \
+ wx/mac/evtloop.h \
wx/mac/filedlg.h \
wx/mac/font.h \
wx/mac/fontdlg.h \
wx/mac/carbon/dirdlg.h \
wx/mac/carbon/display.h \
wx/mac/carbon/dnd.h \
+ wx/mac/carbon/evtloop.h \
wx/mac/carbon/filedlg.h \
wx/mac/carbon/font.h \
wx/mac/carbon/fontdlg.h \
monodll_dirdlg.o \
monodll_display.o \
monodll_dnd.o \
+ monodll_evtloop.o \
monodll_filedlg.o \
monodll_font.o \
monodll_fontdlg.o \
monolib_dirdlg.o \
monolib_display.o \
monolib_dnd.o \
+ monolib_evtloop.o \
monolib_filedlg.o \
monolib_font.o \
monolib_fontdlg.o \
coredll_dirdlg.o \
coredll_display.o \
coredll_dnd.o \
+ coredll_evtloop.o \
coredll_filedlg.o \
coredll_font.o \
coredll_fontdlg.o \
corelib_dirdlg.o \
corelib_display.o \
corelib_dnd.o \
+ corelib_evtloop.o \
corelib_filedlg.o \
corelib_font.o \
corelib_fontdlg.o \
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monodll_evtloop.o: $(srcdir)/src/motif/evtloop.cpp $(MONODLL_ODEP)
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/motif/evtloop.cpp
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_evtloop.o: $(srcdir)/src/mac/carbon/evtloop.cpp $(MONODLL_ODEP)
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/evtloop.cpp
+
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_evtloop.o: $(srcdir)/src/cocoa/evtloop.mm $(MONODLL_ODEP)
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/evtloop.mm
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@monolib_evtloop.o: $(srcdir)/src/motif/evtloop.cpp $(MONOLIB_ODEP)
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/motif/evtloop.cpp
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_evtloop.o: $(srcdir)/src/mac/carbon/evtloop.cpp $(MONOLIB_ODEP)
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/evtloop.cpp
+
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_evtloop.o: $(srcdir)/src/cocoa/evtloop.mm $(MONOLIB_ODEP)
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/evtloop.mm
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@coredll_evtloop.o: $(srcdir)/src/motif/evtloop.cpp $(COREDLL_ODEP)
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/motif/evtloop.cpp
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_evtloop.o: $(srcdir)/src/mac/carbon/evtloop.cpp $(COREDLL_ODEP)
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/mac/carbon/evtloop.cpp
+
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_evtloop.o: $(srcdir)/src/cocoa/evtloop.mm $(COREDLL_ODEP)
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/cocoa/evtloop.mm
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@corelib_evtloop.o: $(srcdir)/src/motif/evtloop.cpp $(CORELIB_ODEP)
@COND_TOOLKIT_MOTIF_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/motif/evtloop.cpp
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_evtloop.o: $(srcdir)/src/mac/carbon/evtloop.cpp $(CORELIB_ODEP)
+@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/mac/carbon/evtloop.cpp
+
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_evtloop.o: $(srcdir)/src/cocoa/evtloop.mm $(CORELIB_ODEP)
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/cocoa/evtloop.mm
src/mac/carbon/dirdlg.cpp
src/mac/carbon/display.cpp
src/mac/carbon/dnd.cpp
+ src/mac/carbon/evtloop.cpp
src/mac/carbon/filedlg.cpp
src/mac/carbon/font.cpp
src/mac/carbon/fontdlg.cpp
wx/mac/dirdlg.h
wx/mac/display.h
wx/mac/dnd.h
+ wx/mac/evtloop.h
wx/mac/filedlg.h
wx/mac/font.h
wx/mac/fontdlg.h
wx/mac/carbon/dirdlg.h
wx/mac/carbon/display.h
wx/mac/carbon/dnd.h
+ wx/mac/carbon/evtloop.h
wx/mac/carbon/filedlg.h
wx/mac/carbon/font.h
wx/mac/carbon/fontdlg.h
class WXDLLIMPEXP_BASE wxLog;
class WXDLLIMPEXP_BASE wxMessageOutput;
-// wxUSE_EVTLOOP_IN_APP is a temporary hack needed until all ports are updated
-// to use wxEventLoop, otherwise we get linking errors on wxMac, it's going to
-// disappear a.s.a.p.
-#ifdef __WXMAC__
- #define wxUSE_EVTLOOP_IN_APP 0
-#else
- #define wxUSE_EVTLOOP_IN_APP 1
+#if wxUSE_GUI
class WXDLLEXPORT wxEventLoop;
#endif
// (already) be dispatched
static bool IsMainLoopRunning()
{
-#if wxUSE_EVTLOOP_IN_APP
wxAppBase *app = wx_static_cast(wxAppBase *, GetInstance());
return app && app->m_mainLoop != NULL;
-#else
- return false;
-#endif
}
// execute the main GUI loop, the function returns when the loop ends
virtual wxAppTraits *CreateTraits();
-#if wxUSE_EVTLOOP_IN_APP
// the main event loop of the application (may be NULL if the loop hasn't
// been started yet or has already terminated)
wxEventLoop *m_mainLoop;
-#endif // wxUSE_EVTLOOP_IN_APP
// the main top level window (may be NULL)
wxWindow *m_topWindow;
#include "wx/palmos/evtloop.h"
#elif defined(__WXMSW__)
#include "wx/msw/evtloop.h"
-#else
+#elif defined(__WXMAC__)
+ #include "wx/mac/evtloop.h"
+#else // other platform
class WXDLLEXPORT wxEventLoopImpl;
wxEventLoopImpl *m_impl;
DECLARE_NO_COPY_CLASS(wxEventLoop)
- };
+};
-#endif // __WXMSW__/!__WXMSW__
+#endif // platforms
inline bool wxEventLoopBase::IsRunning() const { return GetActive() == this; }
wxApp();
virtual ~wxApp() {}
- virtual int MainLoop();
- virtual void ExitMainLoop();
- virtual bool Pending() ;
- virtual bool Dispatch() ;
-
- virtual void Exit();
-
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual void WakeUpIdle();
void OnEndSession(wxCloseEvent& event);
void OnQueryEndSession(wxCloseEvent& event);
+ void MacDoOneEvent() ;
+
protected:
bool m_showOnInit;
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
- bool IsExiting() { return !m_keepGoing ; }
-
// the installed application event handler
WXEVENTHANDLERREF MacGetEventHandler() { return m_macEventHandler ; }
WXEVENTHANDLERREF MacGetCurrentEventHandlerCallRef() { return m_macCurrentEventHandlerCallRef ; }
int m_nCmdShow;
private:
- bool m_keepGoing ;
-
// mac specifics
WXEVENTHANDLERREF m_macEventHandler ;
WXHRGN m_macSleepRgn ;
WXHRGN m_macHelpRgn ;
- void MacDoOneEvent() ;
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
void MacHandleOneEvent( WXEVENTREF ev ) ;
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/mac/carbon/evtloop.h
+// Purpose: declaration of wxEventLoop for wxMac
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 2006-01-12
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MAC_CARBON_EVTLOOP_H_
+#define _WX_MAC_CARBON_EVTLOOP_H_
+
+// set wxMAC_USE_RUN_APP_EVENT_LOOP to 1 if the standard
+// RunApplicationEventLoop function should be used, otherwise
+// the lower level CarbonEventLoop will be used
+//
+// in the long run we should make this 1 by default but we will have to clean
+// up event handling to make sure we don't miss handling of things like pending
+// events etc and perhaps we will also have to pipe events through an
+// ueber-event-handler to make sure we have one place to do all these
+// house-keeping functions
+#define wxMAC_USE_RUN_APP_EVENT_LOOP 0
+
+// ----------------------------------------------------------------------------
+// wxEventLoop
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxEventLoop : public wxEventLoopBase
+{
+public:
+ wxEventLoop();
+
+ // implement base class pure virtuals
+ virtual int Run();
+ virtual void Exit(int rc = 0);
+ virtual bool Pending() const;
+ virtual bool Dispatch();
+
+private:
+ // the loop exit code
+ int m_exitcode;
+
+#if !wxMAC_USE_RUN_APP_EVENT_LOOP
+ // should we exit the loop?
+ bool m_shouldExit;
+#endif // !wxMAC_USE_RUN_APP_EVENT_LOOP
+};
+
+#endif // _WX_MAC_CARBON_EVTLOOP_H_
+
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: include/wx/mac/evtloop.h
+// Purpose: simply forwards to wx/mac/carbon/evtloop.h for consistency with
+// the other Mac headers
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 2006-01-12
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifdef __WXMAC_CLASSIC__
+ #error "wxEventLoop is not implemented for Classic build."
+#else
+ #include "wx/mac/carbon/evtloop.h"
+#endif
+
m_useBestVisual = false;
m_isActive = true;
-#if wxUSE_EVTLOOP_IN_APP
m_mainLoop = NULL;
-#endif // wxUSE_EVTLOOP_IN_APP
// We don't want to exit the app if the user code shows a dialog from its
// OnInit() -- but this is what would happen if we set m_exitOnFrameDelete
int wxAppBase::MainLoop()
{
-#if wxUSE_EVTLOOP_IN_APP
wxEventLoopTiedPtr mainLoop(&m_mainLoop, new wxEventLoop);
return m_mainLoop->Run();
-#else // !wxUSE_EVTLOOP_IN_APP
- return 0;
-#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP
}
void wxAppBase::ExitMainLoop()
{
-#if wxUSE_EVTLOOP_IN_APP
// we should exit from the main event loop, not just any currently active
// (e.g. modal dialog) event loop
if ( m_mainLoop && m_mainLoop->IsRunning() )
{
m_mainLoop->Exit(0);
}
-#endif // wxUSE_EVTLOOP_IN_APP
}
bool wxAppBase::Pending()
{
-#if wxUSE_EVTLOOP_IN_APP
// use the currently active message loop here, not m_mainLoop, because if
// we're showing a modal dialog (with its own event loop) currently the
// main event loop is not running anyhow
wxEventLoop * const loop = wxEventLoop::GetActive();
return loop && loop->Pending();
-#else // wxUSE_EVTLOOP_IN_APP
- return false;
-#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP
}
bool wxAppBase::Dispatch()
{
-#if wxUSE_EVTLOOP_IN_APP
// see comment in Pending()
wxEventLoop * const loop = wxEventLoop::GetActive();
return loop && loop->Dispatch();
-#else // wxUSE_EVTLOOP_IN_APP
- return true;
-#endif // wxUSE_EVTLOOP_IN_APP/!wxUSE_EVTLOOP_IN_APP
}
// ----------------------------------------------------------------------------
extern wxList wxPendingDelete;
-// set wxMAC_USE_RAEL to 1 if RunApplicationEventLoop should be used
-// if 0 the lower level CarbonEventLoop will be used
-// on the long run RAEL should replace the low level event loop
-// we will have to clean up event handling to make sure we don't
-// miss handling of things like pending events etc
-// perhaps we will also have to pipe events through an ueber-event-handler
-// to make sure we have one place to do all these house-keeping functions
-
-#define wxMAC_USE_RAEL 0
-
#if wxUSE_THREADS
extern size_t g_numberOfThreads;
#endif
#endif
}
-int wxApp::MainLoop()
-{
- m_keepGoing = true;
-
-#if wxMAC_USE_RAEL
- RunApplicationEventLoop() ;
-#else
- while (m_keepGoing)
- {
- MacDoOneEvent() ;
- }
-#endif
-
- return 0;
-}
-
-void wxApp::ExitMainLoop()
-{
- m_keepGoing = false;
-
-#if wxMAC_USE_RAEL
- QuitApplicationEventLoop() ;
-#endif
-}
-
-// Is a message/event pending?
-bool wxApp::Pending()
-{
- // without the receive event (with pull param = false ) nothing is ever reported
- EventRef theEvent;
-
- ReceiveNextEvent(0, NULL, kEventDurationNoWait, false, &theEvent);
-
- return GetNumEventsInQueue( GetMainEventQueue() ) > 0 ;
-}
-
-// Dispatch a message.
-bool wxApp::Dispatch()
-{
- MacDoOneEvent() ;
-
- return true;
-}
-
void wxApp::OnIdle(wxIdleEvent& event)
{
wxAppBase::OnIdle(event);
wxMacWakeUp() ;
}
-void wxApp::Exit()
-{
- wxApp::CleanUp();
- ::ExitToShell() ;
-}
-
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
{
if (GetTopWindow())
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: mac/carbon/evtloop.cpp
+// Purpose: implementation of wxEventLoop for wxMac
+// Author: Vadim Zeitlin
+// Modified by:
+// Created: 2006-01-12
+// RCS-ID: $Id$
+// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#include "wx/evtloop.h"
+
+#include <Carbon/Carbon.h>
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+wxEventLoop::wxEventLoop()
+{
+ m_exitcode = 0;
+#if !wxMAC_USE_RUN_APP_EVENT_LOOP
+ m_shouldExit = false;
+#endif
+}
+
+int wxEventLoop::Run()
+{
+ wxEventLoopActivator activate(this);
+
+#if wxMAC_USE_RUN_APP_EVENT_LOOP
+ RunApplicationEventLoop();
+#else // manual event loop
+ while ( !m_shouldExit )
+ {
+ Dispatch();
+ }
+#endif // auto/manual event loop
+
+ return m_exitcode;
+}
+
+void wxEventLoop::Exit(int rc)
+{
+ m_exitcode = rc;
+
+#if wxMAC_USE_RUN_APP_EVENT_LOOP
+ QuitApplicationEventLoop();
+#else // manual event loop
+ m_shouldExit = true;
+#endif // auto/manual event loop
+}
+
+bool wxEventLoop::Pending() const
+{
+ EventRef theEvent;
+
+ return ReceiveNextEvent
+ (
+ 0, // we want any event at all so we don't specify neither
+ NULL, // the number of event types nor the types themselves
+ kEventDurationNoWait,
+ false, // don't remove the event from queue
+ &theEvent
+ ) == noErr;
+}
+
+bool wxEventLoop::Dispatch()
+{
+ // TODO: we probably should do the dispatching directly from here but for
+ // now it's easier to forward to wxApp which has all the code to do
+ // it
+ if ( !wxTheApp )
+ return false;
+
+ wxTheApp->MacDoOneEvent();
+ return true;
+}
+