wxWidgets/include/wx/app.h
Julian Smart 750b78ba35 Cured some small doc typos; some WIN16 fixes; transferred DLL WinMain to
IMPLEMENT_APP() macro so dummy.obj doesn't have to be linked; lexer.l fix
for LEX (I hope)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1672 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1999-02-10 22:44:53 +00:00

99 lines
2.6 KiB
C++

/////////////////////////////////////////////////////////////////////////////
// Name: app.h
// Purpose: wxApp inclusion
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_BASE_
#define _WX_APP_H_BASE_
#ifdef __WXMSW__
class WXDLLEXPORT wxApp;
typedef wxApp* (*wxAppInitializerFunction) (void);
#endif
#include "wx/object.h"
#ifndef __WXMSW__
typedef wxObject* (*wxAppInitializerFunction) (void); // returning wxApp* won't work with gcc
#endif
#if defined(__WXMSW__)
#include "wx/msw/app.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/app.h"
#elif defined(__WXQT__)
#include "wx/qt/app.h"
#elif defined(__WXGTK__)
#include "wx/gtk/app.h"
#elif defined(__WXMAC__)
#include "wx/mac/app.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/app.h"
#endif
// Having a global instance of this class allows
// wxApp to be aware of the app creator function.
// wxApp can then call this function to create a new
// app object. Convoluted, but necessary.
class WXDLLEXPORT wxAppInitializer
{
public:
wxAppInitializer(wxAppInitializerFunction fn)
{
wxApp::SetInitializerFunction(fn);
}
};
// Here's a macro you can use if your compiler
// really, really wants main() to be in your main program
// (e.g. hello.cpp).
// Now IMPLEMENT_APP should add this code if required.
#if defined(__AIX__) || defined(__HPUX__)
#define IMPLEMENT_WXWIN_MAIN \
extern int wxEntry( int argc, char *argv[] ); \
int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
#elif defined(__WXMSW__) && defined(WXUSINGDLL)
// NT defines APIENTRY, 3.x not
#if !defined(WXAPIENTRY)
# ifdef __WATCOMC__
# define WXAPIENTRY PASCAL
# else
# define WXAPIENTRY FAR PASCAL
# endif
#endif
#define IMPLEMENT_WXWIN_MAIN \
int WXAPIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,\
LPSTR m_lpCmdLine, int nCmdShow )\
{\
return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,\
m_lpCmdLine, nCmdShow);\
}
#else
#define IMPLEMENT_WXWIN_MAIN
#endif
#define IMPLEMENT_APP(appname) \
wxApp *wxCreateApp(void) { return new appname; } \
wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
appname& wxGetApp(void) { return *(appname *)wxTheApp; } \
IMPLEMENT_WXWIN_MAIN
#define DECLARE_APP(appname) \
extern appname& wxGetApp(void) ;
#endif
// _WX_APP_H_BASE_