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