]> git.saurik.com Git - wxWidgets.git/blame - include/wx/init.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / init.h
CommitLineData
94826170
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/init.h
77ffb593 3// Purpose: wxWidgets initialization and finalization functions
94826170
VZ
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 29.06.2003
77ffb593 7// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 8// Licence: wxWindows licence
94826170
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_INIT_H_
12#define _WX_INIT_H_
13
26497253 14#include "wx/defs.h"
e3f6cbd9 15#include "wx/chartype.h"
94826170
VZ
16
17// ----------------------------------------------------------------------------
18// wxEntry helper functions which allow to have more fine grained control
19// ----------------------------------------------------------------------------
20
21// do common initialization, return true if ok (in this case wxEntryCleanup
77ffb593 22// must be called later), otherwise the program can't use wxWidgets at all
94826170
VZ
23//
24// this function also creates wxTheApp as a side effect, if IMPLEMENT_APP
25// hadn't been used a dummy default application object is created
26//
05e2b077
VZ
27// note that the parameters may be modified, this is why we pass them by
28// reference!
bb24c68f 29extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);
94826170
VZ
30
31// free the resources allocated by the library in wxEntryStart() and shut it
32// down (wxEntryStart() may be called again afterwards if necessary)
bb24c68f 33extern void WXDLLIMPEXP_BASE wxEntryCleanup();
94826170
VZ
34
35
36// ----------------------------------------------------------------------------
37// wxEntry: this function initializes the library, runs the main event loop
38// and cleans it up
39// ----------------------------------------------------------------------------
40
41// note that other, platform-specific, overloads of wxEntry may exist as well
42// but this one always exists under all platforms
43//
44// returns the program exit code
bb24c68f 45extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv);
94826170 46
0acfb5bd
VZ
47// we overload wxEntry[Start]() to take "char **" pointers too
48#if wxUSE_UNICODE
49
487f2d58
RD
50extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv);
51extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv);
0acfb5bd
VZ
52
53#endif// wxUSE_UNICODE
94826170 54
26cdd42d
VZ
55// Under Windows we define additional wxEntry() overloads with signature
56// compatible with WinMain() and not the traditional main().
57#if wxUSE_GUI && defined(__WINDOWS__)
58 #include "wx/msw/init.h"
59#endif
60
94826170
VZ
61// ----------------------------------------------------------------------------
62// Using the library without (explicit) application object: you may avoid using
e4431849 63// wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at
94826170
VZ
64// the program startup and termination
65// ----------------------------------------------------------------------------
66
67// initialize the library (may be called as many times as needed, but each
68// call to wxInitialize() must be matched by wxUninitialize())
d3688603
VS
69extern bool WXDLLIMPEXP_BASE wxInitialize();
70extern bool WXDLLIMPEXP_BASE wxInitialize(int argc, wxChar **argv);
f380e251 71#if wxUSE_UNICODE
d3688603 72extern bool WXDLLIMPEXP_BASE wxInitialize(int argc, char **argv);
f380e251 73#endif
94826170
VZ
74
75// clean up -- the library can't be used any more after the last call to
76// wxUninitialize()
bb24c68f 77extern void WXDLLIMPEXP_BASE wxUninitialize();
94826170
VZ
78
79// create an object of this class on stack to initialize/cleanup the library
80// automatically
bb24c68f 81class WXDLLIMPEXP_BASE wxInitializer
94826170
VZ
82{
83public:
84 // initialize the library
d3688603
VS
85 wxInitializer()
86 {
87 m_ok = wxInitialize();
88 }
89
90 wxInitializer(int argc, wxChar **argv)
76cebbff
VZ
91 {
92 m_ok = wxInitialize(argc, argv);
93 }
94826170 94
f380e251 95#if wxUSE_UNICODE
d3688603 96 wxInitializer(int argc, char **argv)
f380e251
VS
97 {
98 m_ok = wxInitialize(argc, argv);
99 }
100#endif // wxUSE_UNICODE
101
94826170
VZ
102 // has the initialization been successful? (explicit test)
103 bool IsOk() const { return m_ok; }
104
105 // has the initialization been successful? (implicit test)
106 operator bool() const { return m_ok; }
107
108 // dtor only does clean up if we initialized the library properly
109 ~wxInitializer() { if ( m_ok ) wxUninitialize(); }
110
111private:
112 bool m_ok;
113};
114
115#endif // _WX_INIT_H_
116