+/* static */
+wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
+{
+ wxAppConsole * const app = GetInstance();
+ return app ? app->GetTraits() : NULL;
+}
+
+/* static */
+wxAppTraits& wxAppConsoleBase::GetValidTraits()
+{
+ static wxConsoleAppTraits s_traitsConsole;
+ wxAppTraits* const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
+
+ return traits ? *traits : s_traitsConsole;
+}
+
+// ----------------------------------------------------------------------------
+// wxEventLoop redirection
+// ----------------------------------------------------------------------------
+
+int wxAppConsoleBase::MainLoop()
+{
+ wxEventLoopBaseTiedPtr mainLoop(&m_mainLoop, CreateMainLoop());
+
+#if defined(__WXOSX__) && wxOSX_USE_COCOA_OR_IPHONE
+ // OnLaunched called from native app controller
+#else
+ if (wxTheApp)
+ wxTheApp->OnLaunched();
+#endif
+
+ return m_mainLoop ? m_mainLoop->Run() : -1;
+}
+
+void wxAppConsoleBase::ExitMainLoop()
+{
+ // 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);
+ }
+}
+
+bool wxAppConsoleBase::Pending()
+{
+ // 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
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+
+ return loop && loop->Pending();
+}
+
+bool wxAppConsoleBase::Dispatch()
+{
+ // see comment in Pending()
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+
+ return loop && loop->Dispatch();
+}
+
+bool wxAppConsoleBase::Yield(bool onlyIfNeeded)
+{
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+ if ( loop )
+ return loop->Yield(onlyIfNeeded);
+
+ wxScopedPtr<wxEventLoopBase> tmpLoop(CreateMainLoop());
+ return tmpLoop->Yield(onlyIfNeeded);
+}
+
+void wxAppConsoleBase::WakeUpIdle()
+{
+ wxEventLoopBase * const loop = wxEventLoopBase::GetActive();
+
+ if ( loop )
+ loop->WakeUp();
+}
+
+bool wxAppConsoleBase::ProcessIdle()
+{
+ // synthesize an idle event and check if more of them are needed
+ wxIdleEvent event;
+ event.SetEventObject(this);
+ ProcessEvent(event);