]> git.saurik.com Git - wxWidgets.git/blob - include/wx/init.h
implemented wxDC::DoGetSize() correctly for metafile DC classes
[wxWidgets.git] / include / wx / init.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/init.h
3 // Purpose: wxWidgets initialization and finalization functions
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 29.06.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_INIT_H_
13 #define _WX_INIT_H_
14
15 #include "wx/wxchar.h"
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
22 // must be called later), otherwise the program can't use wxWidgets at all
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 //
27 // note that the parameters may be modified, this is why we pass them by
28 // reference!
29 extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);
30
31 // free the resources allocated by the library in wxEntryStart() and shut it
32 // down (wxEntryStart() may be called again afterwards if necessary)
33 extern void WXDLLIMPEXP_BASE wxEntryCleanup();
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
45 extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv);
46
47 // we overload wxEntry[Start]() to take "char **" pointers too
48 #if wxUSE_UNICODE
49
50 extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv);
51 extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv);
52
53 #endif// wxUSE_UNICODE
54
55 // ----------------------------------------------------------------------------
56 // Using the library without (explicit) application object: you may avoid using
57 // DECLARE_APP and IMPLEMENT_APP macros and call the functions below instead at
58 // the program startup and termination
59 // ----------------------------------------------------------------------------
60
61 // initialize the library (may be called as many times as needed, but each
62 // call to wxInitialize() must be matched by wxUninitialize())
63 extern bool WXDLLIMPEXP_BASE wxInitialize(int argc = 0, wxChar **argv = NULL);
64
65 // clean up -- the library can't be used any more after the last call to
66 // wxUninitialize()
67 extern void WXDLLIMPEXP_BASE wxUninitialize();
68
69 // create an object of this class on stack to initialize/cleanup the library
70 // automatically
71 class WXDLLIMPEXP_BASE wxInitializer
72 {
73 public:
74 // initialize the library
75 wxInitializer(int argc = 0, wxChar **argv = NULL)
76 {
77 m_ok = wxInitialize(argc, argv);
78 }
79
80 // has the initialization been successful? (explicit test)
81 bool IsOk() const { return m_ok; }
82
83 // has the initialization been successful? (implicit test)
84 operator bool() const { return m_ok; }
85
86 // dtor only does clean up if we initialized the library properly
87 ~wxInitializer() { if ( m_ok ) wxUninitialize(); }
88
89 private:
90 bool m_ok;
91 };
92
93 #endif // _WX_INIT_H_
94