]> git.saurik.com Git - wxWidgets.git/blob - src/common/init.cpp
OnEnter/OnDragOver API update (compiles, links, somewhat runs under wxGTK)
[wxWidgets.git] / src / common / init.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/init.cpp
3 // Purpose: initialisation for the library
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 04.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "appbase.h"
22 #endif
23
24 #include "wx/wxprec.h"
25
26 #ifdef __BORLANDC__
27 #pragma hdrstop
28 #endif //__BORLANDC__
29
30
31 #include "wx/app.h"
32 #include "wx/debug.h"
33
34 // ----------------------------------------------------------------------------
35 // global vars
36 // ----------------------------------------------------------------------------
37
38 wxApp * WXDLLEXPORT wxTheApp = NULL;
39
40 wxAppInitializerFunction
41 wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL;
42
43 #if wxUSE_THREADS
44 // List of events pending processing
45 wxList *wxPendingEvents = NULL;
46 wxCriticalSection *wxPendingEventsLocker = NULL;
47 #endif // wxUSE_THREADS
48
49 // ----------------------------------------------------------------------------
50 // private classes
51 // ----------------------------------------------------------------------------
52
53 class /* no WXDLLEXPORT */ wxConsoleApp : public wxApp
54 {
55 public:
56 virtual int OnRun() { wxFAIL_MSG(wxT("unreachable")); return 0; }
57 };
58
59 // ----------------------------------------------------------------------------
60 // private vars
61 // ----------------------------------------------------------------------------
62
63 static size_t gs_nInitCount = 0;
64
65 // ============================================================================
66 // implementation
67 // ============================================================================
68
69 bool WXDLLEXPORT wxInitialize()
70 {
71 if ( gs_nInitCount )
72 {
73 // already initialized
74 return TRUE;
75 }
76
77 wxASSERT_MSG( !wxTheApp,
78 wxT("either call wxInitialize or create app, not both!") );
79
80 wxClassInfo::InitializeClasses();
81
82 wxModule::RegisterModules();
83 if ( !wxModule::InitializeModules() )
84 {
85 return FALSE;
86 }
87
88 wxTheApp = new wxConsoleApp;
89
90 if ( !wxTheApp )
91 {
92 return FALSE;
93 }
94
95 gs_nInitCount++;
96
97 return TRUE;
98 }
99
100 void WXDLLEXPORT wxUninitialize()
101 {
102 if ( !--gs_nInitCount )
103 {
104 wxModule::CleanUpModules();
105
106 wxClassInfo::CleanUpClasses();
107
108 // delete the application object
109 delete wxTheApp;
110 wxTheApp = (wxApp *)NULL;
111 }
112 }