2003-06-30 14:43:09 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/init.h
|
2004-05-23 10:56:36 -04:00
|
|
|
// Purpose: wxWidgets initialization and finalization functions
|
2003-06-30 14:43:09 -04:00
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29.06.2003
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-06-30 14:43:09 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_INIT_H_
|
|
|
|
#define _WX_INIT_H_
|
|
|
|
|
2006-10-19 03:43:24 -04:00
|
|
|
#include "wx/defs.h"
|
2007-03-19 10:45:38 -04:00
|
|
|
#include "wx/chartype.h"
|
2003-06-30 14:43:09 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxEntry helper functions which allow to have more fine grained control
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// do common initialization, return true if ok (in this case wxEntryCleanup
|
2004-05-23 10:56:36 -04:00
|
|
|
// must be called later), otherwise the program can't use wxWidgets at all
|
2003-06-30 14:43:09 -04:00
|
|
|
//
|
2015-04-23 07:49:01 -04:00
|
|
|
// this function also creates wxTheApp as a side effect, if wxIMPLEMENT_APP
|
2003-06-30 14:43:09 -04:00
|
|
|
// hadn't been used a dummy default application object is created
|
|
|
|
//
|
2003-06-30 16:02:05 -04:00
|
|
|
// note that the parameters may be modified, this is why we pass them by
|
|
|
|
// reference!
|
2003-07-04 09:00:07 -04:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);
|
2003-06-30 14:43:09 -04:00
|
|
|
|
|
|
|
// free the resources allocated by the library in wxEntryStart() and shut it
|
|
|
|
// down (wxEntryStart() may be called again afterwards if necessary)
|
2003-07-04 09:00:07 -04:00
|
|
|
extern void WXDLLIMPEXP_BASE wxEntryCleanup();
|
2003-06-30 14:43:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxEntry: this function initializes the library, runs the main event loop
|
|
|
|
// and cleans it up
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// note that other, platform-specific, overloads of wxEntry may exist as well
|
|
|
|
// but this one always exists under all platforms
|
|
|
|
//
|
|
|
|
// returns the program exit code
|
2003-07-04 09:00:07 -04:00
|
|
|
extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv);
|
2003-06-30 14:43:09 -04:00
|
|
|
|
2003-07-07 07:48:22 -04:00
|
|
|
// we overload wxEntry[Start]() to take "char **" pointers too
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
|
2003-10-03 23:00:46 -04:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv);
|
|
|
|
extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv);
|
2003-07-07 07:48:22 -04:00
|
|
|
|
|
|
|
#endif// wxUSE_UNICODE
|
2003-06-30 14:43:09 -04:00
|
|
|
|
2012-06-30 12:33:28 -04:00
|
|
|
// Under Windows we define additional wxEntry() overloads with signature
|
|
|
|
// compatible with WinMain() and not the traditional main().
|
2017-03-10 19:04:31 -05:00
|
|
|
#ifdef __WINDOWS__
|
2012-06-30 12:33:28 -04:00
|
|
|
#include "wx/msw/init.h"
|
|
|
|
#endif
|
|
|
|
|
2003-06-30 14:43:09 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Using the library without (explicit) application object: you may avoid using
|
2010-06-09 09:23:13 -04:00
|
|
|
// wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at
|
2003-06-30 14:43:09 -04:00
|
|
|
// the program startup and termination
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// initialize the library (may be called as many times as needed, but each
|
|
|
|
// call to wxInitialize() must be matched by wxUninitialize())
|
2009-07-31 14:48:34 -04:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize();
|
2014-12-07 11:40:24 -05:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, wxChar **argv);
|
2009-07-30 03:43:10 -04:00
|
|
|
#if wxUSE_UNICODE
|
2014-12-07 11:40:24 -05:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, char **argv);
|
2009-07-30 03:43:10 -04:00
|
|
|
#endif
|
2003-06-30 14:43:09 -04:00
|
|
|
|
|
|
|
// clean up -- the library can't be used any more after the last call to
|
|
|
|
// wxUninitialize()
|
2003-07-04 09:00:07 -04:00
|
|
|
extern void WXDLLIMPEXP_BASE wxUninitialize();
|
2003-06-30 14:43:09 -04:00
|
|
|
|
|
|
|
// create an object of this class on stack to initialize/cleanup the library
|
|
|
|
// automatically
|
2003-07-04 09:00:07 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxInitializer
|
2003-06-30 14:43:09 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// initialize the library
|
2009-07-31 14:48:34 -04:00
|
|
|
wxInitializer()
|
|
|
|
{
|
|
|
|
m_ok = wxInitialize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 11:40:24 -05:00
|
|
|
wxInitializer(int& argc, wxChar **argv)
|
2005-01-16 19:13:39 -05:00
|
|
|
{
|
|
|
|
m_ok = wxInitialize(argc, argv);
|
|
|
|
}
|
2003-06-30 14:43:09 -04:00
|
|
|
|
2009-07-30 03:43:10 -04:00
|
|
|
#if wxUSE_UNICODE
|
2014-12-07 11:40:24 -05:00
|
|
|
wxInitializer(int& argc, char **argv)
|
2009-07-30 03:43:10 -04:00
|
|
|
{
|
|
|
|
m_ok = wxInitialize(argc, argv);
|
|
|
|
}
|
|
|
|
#endif // wxUSE_UNICODE
|
|
|
|
|
2003-06-30 14:43:09 -04:00
|
|
|
// has the initialization been successful? (explicit test)
|
|
|
|
bool IsOk() const { return m_ok; }
|
|
|
|
|
|
|
|
// has the initialization been successful? (implicit test)
|
|
|
|
operator bool() const { return m_ok; }
|
|
|
|
|
|
|
|
// dtor only does clean up if we initialized the library properly
|
|
|
|
~wxInitializer() { if ( m_ok ) wxUninitialize(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_ok;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_INIT_H_
|
|
|
|
|