+#if defined(__WXMSW__)
+ #include "wx/msw/private.h" // includes windows.h for LOGFONT
+#endif
+
+#if wxUSE_FONTMAP
+ #include "wx/fontmap.h"
+#endif // wxUSE_FONTMAP
+
+// DLL options compatibility check:
+#include "wx/build.h"
+WX_CHECK_BUILD_OPTIONS("wxCore")
+
+
+// ----------------------------------------------------------------------------
+// wxEventLoopPtr
+// ----------------------------------------------------------------------------
+
+// this defines wxEventLoopPtr
+wxDEFINE_TIED_SCOPED_PTR_TYPE(wxEventLoop);
+
+// ============================================================================
+// wxAppBase implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// initialization
+// ----------------------------------------------------------------------------
+
+wxAppBase::wxAppBase()
+{
+ m_topWindow = (wxWindow *)NULL;
+ 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
+ // to Yes initially as this dialog would be the last top level window.
+ // OTOH, if we set it to No initially we'll have to overwrite it with Yes
+ // when we enter our OnRun() because we do want the default behaviour from
+ // then on. But this would be a problem if the user code calls
+ // SetExitOnFrameDelete(false) from OnInit().
+ //
+ // So we use the special "Later" value which is such that
+ // GetExitOnFrameDelete() returns false for it but which we know we can
+ // safely (i.e. without losing the effect of the users SetExitOnFrameDelete
+ // call) overwrite in OnRun()
+ m_exitOnFrameDelete = Later;
+}
+
+bool wxAppBase::Initialize(int& argc, wxChar **argv)
+{
+ if ( !wxAppConsole::Initialize(argc, argv) )
+ return false;
+
+#if wxUSE_THREADS
+ wxPendingEventsLocker = new wxCriticalSection;
+#endif
+
+ wxInitializeStockLists();
+ wxInitializeStockObjects();
+
+ wxBitmap::InitStandardHandlers();
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+// cleanup
+// ----------------------------------------------------------------------------
+
+wxAppBase::~wxAppBase()
+{
+ // this destructor is required for Darwin
+}
+
+void wxAppBase::CleanUp()
+{
+ // clean up all the pending objects
+ DeletePendingObjects();
+
+ // and any remaining TLWs (they remove themselves from wxTopLevelWindows
+ // when destroyed, so iterate until none are left)
+ while ( !wxTopLevelWindows.empty() )
+ {
+ // do not use Destroy() here as it only puts the TLW in pending list
+ // but we want to delete them now
+ delete wxTopLevelWindows.GetFirst()->GetData();
+ }
+
+ // undo everything we did in Initialize() above
+ wxBitmap::CleanUpHandlers();
+
+ wxDeleteStockObjects();
+
+ wxDeleteStockLists();
+
+ delete wxTheColourDatabase;
+ wxTheColourDatabase = NULL;
+
+ delete wxPendingEvents;
+ wxPendingEvents = NULL;
+
+#if wxUSE_THREADS
+ delete wxPendingEventsLocker;
+ wxPendingEventsLocker = NULL;
+
+ #if wxUSE_VALIDATORS
+ // If we don't do the following, we get an apparent memory leak.
+ ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
+ #endif // wxUSE_VALIDATORS
+#endif // wxUSE_THREADS
+}
+
+#if wxUSE_CMDLINE_PARSER
+
+// ----------------------------------------------------------------------------
+// GUI-specific command line options handling