/////////////////////////////////////////////////////////////////////////////
-// Name: common/appcmn.cpp
+// Name: src/common/appcmn.cpp
// Purpose: wxAppConsole and wxAppBase methods common to all platforms
// Author: Vadim Zeitlin
// Modified by:
// headers
// ---------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "appbase.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#endif
#ifndef WX_PRECOMP
+ #include "wx/list.h"
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/intl.h"
- #include "wx/list.h"
#include "wx/log.h"
#include "wx/msgdlg.h"
#include "wx/bitmap.h"
#include "wx/confbase.h"
+ #include "wx/utils.h"
#endif
#include "wx/apptrait.h"
#include "wx/evtloop.h"
#include "wx/msgout.h"
#include "wx/thread.h"
-#include "wx/utils.h"
#include "wx/ptr_scpd.h"
-#include "wx/evtloop.h"
#if defined(__WXMSW__)
#include "wx/msw/private.h" // includes windows.h for LOGFONT
#include "wx/build.h"
WX_CHECK_BUILD_OPTIONS("wxCore")
+WXDLLIMPEXP_DATA_CORE(wxList) wxPendingDelete;
// ----------------------------------------------------------------------------
// wxEventLoopPtr
// ----------------------------------------------------------------------------
// this defines wxEventLoopPtr
-wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop);
+wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop)
// ============================================================================
// wxAppBase implementation
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
m_exitOnFrameDelete = Later;
}
-bool wxAppBase::Initialize(int& argc, wxChar **argv)
+bool wxAppBase::Initialize(int& argcOrig, wxChar **argvOrig)
{
- if ( !wxAppConsole::Initialize(argc, argv) )
+ if ( !wxAppConsole::Initialize(argcOrig, argvOrig) )
return false;
#if wxUSE_THREADS
#endif
wxInitializeStockLists();
- wxInitializeStockObjects();
wxBitmap::InitStandardHandlers();
// undo everything we did in Initialize() above
wxBitmap::CleanUpHandlers();
- wxDeleteStockObjects();
+ wxStockGDI::DeleteAll();
wxDeleteStockLists();
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
}
// ----------------------------------------------------------------------------
(void)ProcessEvent(event);
}
+// ----------------------------------------------------------------------------
+// idle handling
+// ----------------------------------------------------------------------------
+
void wxAppBase::DeletePendingObjects()
{
wxList::compatibility_iterator node = wxPendingDelete.GetFirst();
}
// ----------------------------------------------------------------------------
-// exception handling
+// exceptions support
// ----------------------------------------------------------------------------
#if wxUSE_EXCEPTIONS
-void wxAppBase::HandleEvent(wxEvtHandler *handler,
- wxEventFunction func,
- wxEvent& event) const
+bool wxAppBase::OnExceptionInMainLoop()
{
- // by default, call wxApp::OnExceptionInMainLoop if an exception occurs
- try
- {
- handler->DoHandleEvent(func, event);
- }
- catch ( ... )
- {
- if ( !wxConstCast(this, wxAppBase)->OnExceptionInMainLoop() )
- {
- wxEventLoop *loop = wxEventLoop::GetActive();
- if ( loop )
- loop->Exit(-1);
- }
- //else: continue running the event loop
- }
+ throw;
+
+ // some compilers are too stupid to know that we never return after throw
+#if defined(__DMC__) || (defined(_MSC_VER) && _MSC_VER < 1200)
+ return false;
+#endif
}
#endif // wxUSE_EXCEPTIONS
#elif defined(__UNIX__) || defined(__DARWIN__) || defined(__OS2__)
#include "wx/unix/gsockunx.h"
#elif defined(__WXMAC__)
- #include <MacHeaders.c>
- #define OTUNIXERRORS 1
- #include <OpenTransport.h>
- #include <OpenTransportProviders.h>
- #include <OpenTptInternet.h>
+ #include <MacHeaders.c>
+ #define OTUNIXERRORS 1
+ #include <OpenTransport.h>
+ #include <OpenTransportProviders.h>
+ #include <OpenTptInternet.h>
- #include "wx/mac/gsockmac.h"
+ #include "wx/mac/gsockmac.h"
#else
#error "Must include correct GSocket header here"
#endif
}
#endif
-