2003-06-30 18:43:09 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/init.h
|
2004-05-23 14:56:36 +00:00
|
|
|
// Purpose: wxWidgets initialization and finalization functions
|
2003-06-30 18:43:09 +00:00
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29.06.2003
|
2004-05-23 14:56:36 +00:00
|
|
|
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
2003-06-30 18:43:09 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_INIT_H_
|
|
|
|
#define _WX_INIT_H_
|
|
|
|
|
2006-10-19 07:43:24 +00:00
|
|
|
#include "wx/defs.h"
|
2007-03-19 14:45:38 +00:00
|
|
|
#include "wx/chartype.h"
|
2003-06-30 18:43:09 +00: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 14:56:36 +00:00
|
|
|
// must be called later), otherwise the program can't use wxWidgets at all
|
2003-06-30 18:43:09 +00:00
|
|
|
//
|
2015-04-23 11:49:01 +00:00
|
|
|
// this function also creates wxTheApp as a side effect, if wxIMPLEMENT_APP
|
2003-06-30 18:43:09 +00:00
|
|
|
// hadn't been used a dummy default application object is created
|
|
|
|
//
|
2003-06-30 20:02:05 +00:00
|
|
|
// note that the parameters may be modified, this is why we pass them by
|
|
|
|
// reference!
|
2003-07-04 13:00:07 +00:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, wxChar **argv);
|
2003-06-30 18:43:09 +00: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 13:00:07 +00:00
|
|
|
extern void WXDLLIMPEXP_BASE wxEntryCleanup();
|
2003-06-30 18:43:09 +00: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 13:00:07 +00:00
|
|
|
extern int WXDLLIMPEXP_BASE wxEntry(int& argc, wxChar **argv);
|
2003-06-30 18:43:09 +00:00
|
|
|
|
2003-07-07 11:48:22 +00:00
|
|
|
// we overload wxEntry[Start]() to take "char **" pointers too
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
|
2003-10-04 03:00:46 +00:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxEntryStart(int& argc, char **argv);
|
|
|
|
extern int WXDLLIMPEXP_BASE wxEntry(int& argc, char **argv);
|
2003-07-07 11:48:22 +00:00
|
|
|
|
|
|
|
#endif// wxUSE_UNICODE
|
2003-06-30 18:43:09 +00:00
|
|
|
|
2012-06-30 16:33:28 +00:00
|
|
|
// Under Windows we define additional wxEntry() overloads with signature
|
|
|
|
// compatible with WinMain() and not the traditional main().
|
2017-03-11 00:04:31 +00:00
|
|
|
#ifdef __WINDOWS__
|
2012-06-30 16:33:28 +00:00
|
|
|
#include "wx/msw/init.h"
|
|
|
|
#endif
|
|
|
|
|
2003-06-30 18:43:09 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Using the library without (explicit) application object: you may avoid using
|
2010-06-09 13:23:13 +00:00
|
|
|
// wxDECLARE_APP and wxIMPLEMENT_APP macros and call the functions below instead at
|
2003-06-30 18:43:09 +00: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 18:48:34 +00:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize();
|
2014-12-07 16:40:24 +00:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, wxChar **argv);
|
2009-07-30 07:43:10 +00:00
|
|
|
#if wxUSE_UNICODE
|
2014-12-07 16:40:24 +00:00
|
|
|
extern bool WXDLLIMPEXP_BASE wxInitialize(int& argc, char **argv);
|
2009-07-30 07:43:10 +00:00
|
|
|
#endif
|
2003-06-30 18:43:09 +00:00
|
|
|
|
|
|
|
// clean up -- the library can't be used any more after the last call to
|
|
|
|
// wxUninitialize()
|
2003-07-04 13:00:07 +00:00
|
|
|
extern void WXDLLIMPEXP_BASE wxUninitialize();
|
2003-06-30 18:43:09 +00:00
|
|
|
|
|
|
|
// create an object of this class on stack to initialize/cleanup the library
|
|
|
|
// automatically
|
2003-07-04 13:00:07 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxInitializer
|
2003-06-30 18:43:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// initialize the library
|
2009-07-31 18:48:34 +00:00
|
|
|
wxInitializer()
|
|
|
|
{
|
|
|
|
m_ok = wxInitialize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 16:40:24 +00:00
|
|
|
wxInitializer(int& argc, wxChar **argv)
|
2005-01-17 00:13:39 +00:00
|
|
|
{
|
|
|
|
m_ok = wxInitialize(argc, argv);
|
|
|
|
}
|
2003-06-30 18:43:09 +00:00
|
|
|
|
2009-07-30 07:43:10 +00:00
|
|
|
#if wxUSE_UNICODE
|
2014-12-07 16:40:24 +00:00
|
|
|
wxInitializer(int& argc, char **argv)
|
2009-07-30 07:43:10 +00:00
|
|
|
{
|
|
|
|
m_ok = wxInitialize(argc, argv);
|
|
|
|
}
|
|
|
|
#endif // wxUSE_UNICODE
|
|
|
|
|
2003-06-30 18:43:09 +00: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_
|
|
|
|
|