1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWidgets initialization and finalization functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
16 #include "wx/chartype.h"
18 // ----------------------------------------------------------------------------
19 // wxEntry helper functions which allow to have more fine grained control
20 // ----------------------------------------------------------------------------
22 // do common initialization, return true if ok (in this case wxEntryCleanup
23 // must be called later), otherwise the program can't use wxWidgets at all
25 // this function also creates wxTheApp as a side effect, if IMPLEMENT_APP
26 // hadn't been used a dummy default application object is created
28 // note that the parameters may be modified, this is why we pass them by
30 extern bool WXDLLIMPEXP_BASE
wxEntryStart(int& argc
, wxChar
**argv
);
32 // free the resources allocated by the library in wxEntryStart() and shut it
33 // down (wxEntryStart() may be called again afterwards if necessary)
34 extern void WXDLLIMPEXP_BASE
wxEntryCleanup();
37 // ----------------------------------------------------------------------------
38 // wxEntry: this function initializes the library, runs the main event loop
40 // ----------------------------------------------------------------------------
42 // note that other, platform-specific, overloads of wxEntry may exist as well
43 // but this one always exists under all platforms
45 // returns the program exit code
46 extern int WXDLLIMPEXP_BASE
wxEntry(int& argc
, wxChar
**argv
);
48 // we overload wxEntry[Start]() to take "char **" pointers too
51 extern bool WXDLLIMPEXP_BASE
wxEntryStart(int& argc
, char **argv
);
52 extern int WXDLLIMPEXP_BASE
wxEntry(int& argc
, char **argv
);
54 #endif// wxUSE_UNICODE
56 // Under Windows we define additional wxEntry() overloads with signature
57 // compatible with WinMain() and not the traditional main().
58 #if wxUSE_GUI && defined(__WINDOWS__)
59 #include "wx/msw/init.h"
62 // ----------------------------------------------------------------------------
63 // Using the library without (explicit) application object: you may avoid using
64 // wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at
65 // the program startup and termination
66 // ----------------------------------------------------------------------------
68 // initialize the library (may be called as many times as needed, but each
69 // call to wxInitialize() must be matched by wxUninitialize())
70 extern bool WXDLLIMPEXP_BASE
wxInitialize();
71 extern bool WXDLLIMPEXP_BASE
wxInitialize(int argc
, wxChar
**argv
);
73 extern bool WXDLLIMPEXP_BASE
wxInitialize(int argc
, char **argv
);
76 // clean up -- the library can't be used any more after the last call to
78 extern void WXDLLIMPEXP_BASE
wxUninitialize();
80 // create an object of this class on stack to initialize/cleanup the library
82 class WXDLLIMPEXP_BASE wxInitializer
85 // initialize the library
88 m_ok
= wxInitialize();
91 wxInitializer(int argc
, wxChar
**argv
)
93 m_ok
= wxInitialize(argc
, argv
);
97 wxInitializer(int argc
, char **argv
)
99 m_ok
= wxInitialize(argc
, argv
);
101 #endif // wxUSE_UNICODE
103 // has the initialization been successful? (explicit test)
104 bool IsOk() const { return m_ok
; }
106 // has the initialization been successful? (implicit test)
107 operator bool() const { return m_ok
; }
109 // dtor only does clean up if we initialized the library properly
110 ~wxInitializer() { if ( m_ok
) wxUninitialize(); }
116 #endif // _WX_INIT_H_