-bool wxApp::ProcessIdle()
-{
- wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
- node = wxTopLevelWindows.GetFirst();
- while (node)
- {
- wxWindow* win = node->GetData();
- CallInternalIdle( win );
-
- node = node->GetNext();
- }
-
- wxIdleEvent event;
- event.SetEventObject( this );
- ProcessEvent( event );
-
- return event.MoreRequested();
-}
-
-void wxApp::OnIdle( wxIdleEvent &event )
-{
- static bool s_inOnIdle = FALSE;
-
- // Avoid recursion (via ProcessEvent default case)
- if (s_inOnIdle)
- return;
-
- s_inOnIdle = TRUE;
-
- // Resend in the main thread events which have been prepared in other
- // threads
- ProcessPendingEvents();
-
- // 'Garbage' collection of windows deleted with Close()
- DeletePendingObjects();
-
- // Send OnIdle events to all windows
- bool needMore = SendIdleEvents();
-
- if (needMore)
- event.RequestMore(TRUE);
-
- s_inOnIdle = FALSE;
-}
-
-bool wxApp::SendIdleEvents()
-{
- bool needMore = FALSE;
-
- wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
- while (node)
- {
- wxWindow* win = node->GetData();
- if (SendIdleEvents(win))
- needMore = TRUE;
-
- node = node->GetNext();
- }
-
- return needMore;
-}
-
-bool wxApp::CallInternalIdle( wxWindow* win )
-{
- win->OnInternalIdle();
-
- wxWindowList::Node *node = win->GetChildren().GetFirst();
- while (node)
- {
- wxWindow *win = node->GetData();
-
- CallInternalIdle( win );
- node = node->GetNext();
- }
-
- return TRUE;
-}
-
-bool wxApp::SendIdleEvents( wxWindow* win )
-{
- bool needMore = FALSE;
-
- wxIdleEvent event;
- event.SetEventObject(win);
-
- win->GetEventHandler()->ProcessEvent(event);
-
- if (event.MoreRequested())
- needMore = TRUE;
-
- wxWindowList::Node *node = win->GetChildren().GetFirst();
- while (node)
- {
- wxWindow *win = node->GetData();
-
- if (SendIdleEvents(win))
- needMore = TRUE;
- node = node->GetNext();
- }
-
- return needMore;
-}
-
-int wxApp::MainLoop()
-{
- gtk_main();
- return 0;
-}
-
-void wxApp::ExitMainLoop()
-{
- if (gtk_main_level() > 0)
- gtk_main_quit();
-}
-
-bool wxApp::Initialized()
-{
- return m_initialized;
-}
-
-bool wxApp::Pending()
-{
- return (gtk_events_pending() > 0);
-}
-
-void wxApp::Dispatch()
-{
- gtk_main_iteration();
-}
-
-void wxApp::DeletePendingObjects()
-{
- wxNode *node = wxPendingDelete.GetFirst();
- while (node)
- {
- wxObject *obj = (wxObject *)node->GetData();
-
- delete obj;
-
- if (wxPendingDelete.Find(obj))
- delete node;
-
- node = wxPendingDelete.GetFirst();
- }
-}
-
-bool wxApp::Initialize()
-{
- wxClassInfo::InitializeClasses();
-
- // GL: I'm annoyed ... I don't know where to put this and I don't want to
- // create a module for that as it's part of the core.
-#if wxUSE_THREADS
- wxPendingEvents = new wxList();
- wxPendingEventsLocker = new wxCriticalSection();
-#endif
-
- wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
- wxTheColourDatabase->Initialize();
-
- wxInitializeStockLists();
- wxInitializeStockObjects();
-
- wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
- return FALSE;
-
-#if wxUSE_INTL
- wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
-#endif
-
- return TRUE;
-}
-
-void wxApp::CleanUp()
-{
- wxModule::CleanUpModules();
-
- delete wxTheColourDatabase;
- wxTheColourDatabase = (wxColourDatabase*) NULL;
-
- wxDeleteStockObjects();
-
- wxDeleteStockLists();
-
- delete wxTheApp;
- wxTheApp = (wxApp*) NULL;
-
- wxClassInfo::CleanUpClasses();
-
-#if wxUSE_THREADS
- delete wxPendingEvents;
- wxPendingEvents = NULL;
- delete wxPendingEventsLocker;
- wxPendingEventsLocker = NULL;
-#endif
-
- // check for memory leaks
-#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
- if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
- {
- wxLogDebug(wxT("There were memory leaks.\n"));
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
- }
-#endif // Debug
-
-#if wxUSE_LOG
- // do this as the very last thing because everything else can log messages
- wxLog::DontCreateOnDemand();
-
- wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL );
- if (oldLog)
- delete oldLog;
-#endif // wxUSE_LOG
-}
-
-//-----------------------------------------------------------------------------
-// wxEntry
-//-----------------------------------------------------------------------------
-
-// NB: argc and argv may be changed here, pass by reference!
-int wxEntryStart( int& argc, char *argv[] )