implemented wxEventLoop for wxMac
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
25e2f480a7
commit
4d90072c22
18
Makefile.in
18
Makefile.in
@ -1833,6 +1833,7 @@ COND_TOOLKIT_MAC_GUI_HDR = \
|
||||
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 \
|
||||
@ -1917,6 +1918,7 @@ COND_TOOLKIT_MAC_GUI_HDR = \
|
||||
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 \
|
||||
@ -3674,6 +3676,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS = \
|
||||
monodll_dirdlg.o \
|
||||
monodll_display.o \
|
||||
monodll_dnd.o \
|
||||
monodll_evtloop.o \
|
||||
monodll_filedlg.o \
|
||||
monodll_font.o \
|
||||
monodll_fontdlg.o \
|
||||
@ -5159,6 +5162,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_1 = \
|
||||
monolib_dirdlg.o \
|
||||
monolib_display.o \
|
||||
monolib_dnd.o \
|
||||
monolib_evtloop.o \
|
||||
monolib_filedlg.o \
|
||||
monolib_font.o \
|
||||
monolib_fontdlg.o \
|
||||
@ -6869,6 +6873,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_2 = \
|
||||
coredll_dirdlg.o \
|
||||
coredll_display.o \
|
||||
coredll_dnd.o \
|
||||
coredll_evtloop.o \
|
||||
coredll_filedlg.o \
|
||||
coredll_font.o \
|
||||
coredll_fontdlg.o \
|
||||
@ -8067,6 +8072,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_3 = \
|
||||
corelib_dirdlg.o \
|
||||
corelib_display.o \
|
||||
corelib_dnd.o \
|
||||
corelib_evtloop.o \
|
||||
corelib_filedlg.o \
|
||||
corelib_font.o \
|
||||
corelib_fontdlg.o \
|
||||
@ -11929,6 +11935,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP)
|
||||
@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
|
||||
|
||||
@ -15430,6 +15439,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP)
|
||||
@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
|
||||
|
||||
@ -19348,6 +19360,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
|
||||
@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
|
||||
|
||||
@ -21862,6 +21877,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
|
||||
@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
|
||||
|
||||
|
@ -1806,6 +1806,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
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
|
||||
@ -1892,6 +1893,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
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
|
||||
@ -1979,6 +1981,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
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
|
||||
|
@ -34,13 +34,7 @@ class WXDLLIMPEXP_BASE wxCmdLineParser;
|
||||
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
|
||||
|
||||
@ -373,12 +367,8 @@ public:
|
||||
// (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
|
||||
@ -521,11 +511,9 @@ protected:
|
||||
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;
|
||||
|
@ -75,7 +75,9 @@ protected:
|
||||
#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;
|
||||
|
||||
@ -95,9 +97,9 @@ protected:
|
||||
wxEventLoopImpl *m_impl;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxEventLoop)
|
||||
};
|
||||
};
|
||||
|
||||
#endif // __WXMSW__/!__WXMSW__
|
||||
#endif // platforms
|
||||
|
||||
inline bool wxEventLoopBase::IsRunning() const { return GetActive() == this; }
|
||||
|
||||
|
@ -47,13 +47,6 @@ class WXDLLEXPORT wxApp: public wxAppBase
|
||||
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();
|
||||
|
||||
@ -69,6 +62,8 @@ class WXDLLEXPORT wxApp: public wxAppBase
|
||||
void OnEndSession(wxCloseEvent& event);
|
||||
void OnQueryEndSession(wxCloseEvent& event);
|
||||
|
||||
void MacDoOneEvent() ;
|
||||
|
||||
protected:
|
||||
bool m_showOnInit;
|
||||
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
|
||||
@ -80,8 +75,6 @@ public:
|
||||
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 ; }
|
||||
@ -98,8 +91,6 @@ public:
|
||||
int m_nCmdShow;
|
||||
|
||||
private:
|
||||
bool m_keepGoing ;
|
||||
|
||||
// mac specifics
|
||||
|
||||
WXEVENTHANDLERREF m_macEventHandler ;
|
||||
@ -131,7 +122,6 @@ public:
|
||||
WXHRGN m_macSleepRgn ;
|
||||
WXHRGN m_macHelpRgn ;
|
||||
|
||||
void MacDoOneEvent() ;
|
||||
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
|
||||
void MacHandleOneEvent( WXEVENTREF ev ) ;
|
||||
|
||||
|
52
include/wx/mac/carbon/evtloop.h
Normal file
52
include/wx/mac/carbon/evtloop.h
Normal file
@ -0,0 +1,52 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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_
|
||||
|
18
include/wx/mac/evtloop.h
Normal file
18
include/wx/mac/evtloop.h
Normal file
@ -0,0 +1,18 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
|
@ -80,9 +80,7 @@ wxAppBase::wxAppBase()
|
||||
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
|
||||
@ -265,51 +263,37 @@ bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -65,16 +65,6 @@
|
||||
|
||||
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
|
||||
@ -1108,50 +1098,6 @@ wxApp::wxApp()
|
||||
#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);
|
||||
@ -1177,12 +1123,6 @@ void wxApp::WakeUpIdle()
|
||||
wxMacWakeUp() ;
|
||||
}
|
||||
|
||||
void wxApp::Exit()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
::ExitToShell() ;
|
||||
}
|
||||
|
||||
void wxApp::OnEndSession(wxCloseEvent& WXUNUSED(event))
|
||||
{
|
||||
if (GetTopWindow())
|
||||
|
95
src/mac/carbon/evtloop.cpp
Normal file
95
src/mac/carbon/evtloop.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user