1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWidgets initialization and finalization functions
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
15 #include "wx/chartype.h"
17 // ----------------------------------------------------------------------------
18 // wxEntry helper functions which allow to have more fine grained control
19 // ----------------------------------------------------------------------------
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
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
27 // note that the parameters may be modified, this is why we pass them by
29 extern bool WXDLLIMPEXP_BASE
wxEntryStart(int& argc
, wxChar
**argv
);
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();
36 // ----------------------------------------------------------------------------
37 // wxEntry: this function initializes the library, runs the main event loop
39 // ----------------------------------------------------------------------------
41 // note that other, platform-specific, overloads of wxEntry may exist as well
42 // but this one always exists under all platforms
44 // returns the program exit code
45 extern int WXDLLIMPEXP_BASE
wxEntry(int& argc
, wxChar
**argv
);
47 // we overload wxEntry[Start]() to take "char **" pointers too
50 extern bool WXDLLIMPEXP_BASE
wxEntryStart(int& argc
, char **argv
);
51 extern int WXDLLIMPEXP_BASE
wxEntry(int& argc
, char **argv
);
53 #endif// wxUSE_UNICODE
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"
61 // ----------------------------------------------------------------------------
62 // Using the library without (explicit) application object: you may avoid using
63 // wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at
64 // the program startup and termination
65 // ----------------------------------------------------------------------------
67 // initialize the library (may be called as many times as needed, but each
68 // call to wxInitialize() must be matched by wxUninitialize())
69 extern bool WXDLLIMPEXP_BASE
wxInitialize();
70 extern bool WXDLLIMPEXP_BASE
wxInitialize(int argc
, wxChar
**argv
);
72 extern bool WXDLLIMPEXP_BASE
wxInitialize(int argc
, char **argv
);
75 // clean up -- the library can't be used any more after the last call to
77 extern void WXDLLIMPEXP_BASE
wxUninitialize();
79 // create an object of this class on stack to initialize/cleanup the library
81 class WXDLLIMPEXP_BASE wxInitializer
84 // initialize the library
87 m_ok
= wxInitialize();
90 wxInitializer(int argc
, wxChar
**argv
)
92 m_ok
= wxInitialize(argc
, argv
);
96 wxInitializer(int argc
, char **argv
)
98 m_ok
= wxInitialize(argc
, argv
);
100 #endif // wxUSE_UNICODE
102 // has the initialization been successful? (explicit test)
103 bool IsOk() const { return m_ok
; }
105 // has the initialization been successful? (implicit test)
106 operator bool() const { return m_ok
; }
108 // dtor only does clean up if we initialized the library properly
109 ~wxInitializer() { if ( m_ok
) wxUninitialize(); }
115 #endif // _WX_INIT_H_