]> git.saurik.com Git - wxWidgets.git/blame - src/common/init.cpp
Various small fixes and tweaks
[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"
e87271f3 29#endif
e90c1d2a 30
51abe921
SC
31#include "wx/module.h"
32
e90c1d2a
VZ
33// ----------------------------------------------------------------------------
34// global vars
35// ----------------------------------------------------------------------------
36
37wxApp * WXDLLEXPORT wxTheApp = NULL;
38
39wxAppInitializerFunction
40 wxAppBase::m_appInitFn = (wxAppInitializerFunction)NULL;
41
42// ----------------------------------------------------------------------------
43// private classes
44// ----------------------------------------------------------------------------
45
46class /* no WXDLLEXPORT */ wxConsoleApp : public wxApp
47{
48public:
223d09f6 49 virtual int OnRun() { wxFAIL_MSG(wxT("unreachable")); return 0; }
e90c1d2a
VZ
50};
51
52// ----------------------------------------------------------------------------
53// private vars
54// ----------------------------------------------------------------------------
55
56static size_t gs_nInitCount = 0;
57
58// ============================================================================
59// implementation
60// ============================================================================
61
252a752e
VZ
62// ----------------------------------------------------------------------------
63// stubs for some GUI functions
64// ----------------------------------------------------------------------------
65
66void WXDLLEXPORT wxExit()
67{
68 abort();
69}
70
71// Yield to other apps/messages
72bool WXDLLEXPORT wxYield()
73{
74 // do nothing
75 return TRUE;
76}
77
78// Yield to other apps/messages
79void WXDLLEXPORT wxWakeUpIdle()
80{
81 // do nothing
82}
83
84// ----------------------------------------------------------------------------
85// wxBase-specific functions
86// ----------------------------------------------------------------------------
87
e90c1d2a
VZ
88bool WXDLLEXPORT wxInitialize()
89{
bbfa0322 90 if ( gs_nInitCount )
e90c1d2a
VZ
91 {
92 // already initialized
93 return TRUE;
94 }
95
96 wxASSERT_MSG( !wxTheApp,
223d09f6 97 wxT("either call wxInitialize or create app, not both!") );
e90c1d2a 98
bbfa0322
VZ
99 wxClassInfo::InitializeClasses();
100
101 wxModule::RegisterModules();
102 if ( !wxModule::InitializeModules() )
103 {
104 return FALSE;
105 }
106
e90c1d2a
VZ
107 wxTheApp = new wxConsoleApp;
108
bbfa0322
VZ
109 if ( !wxTheApp )
110 {
111 return FALSE;
112 }
113
114 gs_nInitCount++;
115
116 return TRUE;
e90c1d2a
VZ
117}
118
119void WXDLLEXPORT wxUninitialize()
120{
121 if ( !--gs_nInitCount )
122 {
bbfa0322
VZ
123 wxModule::CleanUpModules();
124
125 wxClassInfo::CleanUpClasses();
126
e90c1d2a
VZ
127 // delete the application object
128 delete wxTheApp;
129 wxTheApp = (wxApp *)NULL;
130 }
131}