]> git.saurik.com Git - wxWidgets.git/blame - src/common/init.cpp
gcc warning about printf() format mismatch corrected
[wxWidgets.git] / src / common / init.cpp
CommitLineData
e90c1d2a
VZ
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
f4c890fd
JS
24#include "wx/wxprec.h"
25
26#ifdef __BORLANDC__
27 #pragma hdrstop
28#endif //__BORLANDC__
29
30
e90c1d2a
VZ
31#include "wx/app.h"
32#include "wx/debug.h"
33
34// ----------------------------------------------------------------------------
35// global vars
36// ----------------------------------------------------------------------------
37
38wxApp * WXDLLEXPORT wxTheApp = NULL;
39
40wxAppInitializerFunction
41 wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL;
42
bbfa0322
VZ
43#if wxUSE_THREADS
44 // List of events pending processing
45 wxList *wxPendingEvents = NULL;
46 wxCriticalSection *wxPendingEventsLocker = NULL;
47#endif // wxUSE_THREADS
48
e90c1d2a
VZ
49// ----------------------------------------------------------------------------
50// private classes
51// ----------------------------------------------------------------------------
52
53class /* no WXDLLEXPORT */ wxConsoleApp : public wxApp
54{
55public:
223d09f6 56 virtual int OnRun() { wxFAIL_MSG(wxT("unreachable")); return 0; }
e90c1d2a
VZ
57};
58
59// ----------------------------------------------------------------------------
60// private vars
61// ----------------------------------------------------------------------------
62
63static size_t gs_nInitCount = 0;
64
65// ============================================================================
66// implementation
67// ============================================================================
68
69bool WXDLLEXPORT wxInitialize()
70{
bbfa0322 71 if ( gs_nInitCount )
e90c1d2a
VZ
72 {
73 // already initialized
74 return TRUE;
75 }
76
77 wxASSERT_MSG( !wxTheApp,
223d09f6 78 wxT("either call wxInitialize or create app, not both!") );
e90c1d2a 79
bbfa0322
VZ
80 wxClassInfo::InitializeClasses();
81
82 wxModule::RegisterModules();
83 if ( !wxModule::InitializeModules() )
84 {
85 return FALSE;
86 }
87
e90c1d2a
VZ
88 wxTheApp = new wxConsoleApp;
89
bbfa0322
VZ
90 if ( !wxTheApp )
91 {
92 return FALSE;
93 }
94
95 gs_nInitCount++;
96
97 return TRUE;
e90c1d2a
VZ
98}
99
100void WXDLLEXPORT wxUninitialize()
101{
102 if ( !--gs_nInitCount )
103 {
bbfa0322
VZ
104 wxModule::CleanUpModules();
105
106 wxClassInfo::CleanUpClasses();
107
e90c1d2a
VZ
108 // delete the application object
109 delete wxTheApp;
110 wxTheApp = (wxApp *)NULL;
111 }
112}