#ifndef WX_PRECOMP
#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"
#endif
#include "wx/apptrait.h"
// ============================================================================
// ----------------------------------------------------------------------------
-// initialization and termination
+// initialization
// ----------------------------------------------------------------------------
wxAppBase::wxAppBase()
m_exitOnFrameDelete = Later;
}
+bool wxAppBase::Initialize(int& argc, wxChar **argv)
+{
+ if ( !wxAppConsole::Initialize(argc, argv) )
+ return false;
+
+#if wxUSE_THREADS
+ wxPendingEventsLocker = new wxCriticalSection;
+#endif
+
+ wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
+ wxTheColourDatabase->Initialize();
+
+ wxInitializeStockLists();
+ wxInitializeStockObjects();
+
+ wxBitmap::InitStandardHandlers();
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+// cleanup
+// ----------------------------------------------------------------------------
+
wxAppBase::~wxAppBase()
{
// this destructor is required for Darwin
}
+void wxAppBase::CleanUp()
+{
+ // one last chance for pending objects to be cleaned up
+ DeletePendingObjects();
+
+ wxBitmap::CleanUpHandlers();
+
+ wxDeleteStockObjects();
+
+ wxDeleteStockLists();
+
+ delete wxTheColourDatabase;
+ wxTheColourDatabase = NULL;
+
+#if wxUSE_THREADS
+ delete wxPendingEvents;
+ wxPendingEvents = NULL;
+
+ 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
+}
+
+// ----------------------------------------------------------------------------
+// OnXXX() hooks
+// ----------------------------------------------------------------------------
+
bool wxAppBase::OnInitGui()
{
#ifdef __WXUNIVERSAL__
wxAppTraits *wxAppBase::CreateTraits()
{
- return wxAppTraits::CreateGUI();
+ return new wxGUIAppTraits;
}
// ----------------------------------------------------------------------------
(void)ProcessEvent(event);
}
+void wxAppBase::DeletePendingObjects()
+{
+ wxNode *node = wxPendingDelete.GetFirst();
+ while (node)
+ {
+ wxObject *obj = node->GetData();
+
+ delete obj;
+
+ if (wxPendingDelete.Member(obj))
+ delete node;
+
+ // Deleting one object may have deleted other pending
+ // objects, so start from beginning of list again.
+ node = wxPendingDelete.GetFirst();
+ }
+}
+
+// Returns TRUE if more time is needed.
+bool wxAppBase::ProcessIdle()
+{
+ wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
+ node = wxTopLevelWindows.GetFirst();
+ while (node)
+ {
+ wxWindow* win = node->GetData();
+ win->ProcessInternalIdle();
+ node = node->GetNext();
+ }
+
+ wxIdleEvent event;
+ event.SetEventObject(this);
+ bool processed = ProcessEvent(event);
+
+ wxUpdateUIEvent::ResetUpdateTime();
+
+ return processed && event.MoreRequested();
+}
+
+// Send idle event to all top-level windows
+bool wxAppBase::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;
+}
+
+// Send idle event to window and all subwindows
+bool wxAppBase::SendIdleEvents(wxWindow* win)
+{
+ bool needMore = FALSE;
+
+ if (wxIdleEvent::CanSend(win))
+ {
+ wxIdleEvent event;
+ event.SetEventObject(win);
+ win->GetEventHandler()->ProcessEvent(event);
+
+ needMore = event.MoreRequested();
+ }
+
+ wxWindowList::Node *node = win->GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindow *win = node->GetData();
+ if (SendIdleEvents(win))
+ needMore = TRUE;
+
+ node = node->GetNext();
+ }
+
+ return needMore;
+}
+
+
// ----------------------------------------------------------------------------
// wxGUIAppTraitsBase
// ----------------------------------------------------------------------------
wxPendingDelete.DeleteObject(object);
}
-// ----------------------------------------------------------------------------
-// wxAppTraits
-// ----------------------------------------------------------------------------
-
-wxAppTraits *wxAppTraitsBase::CreateGUI()
-{
- return new wxGUIAppTraits;
-}
-