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