]> git.saurik.com Git - wxWidgets.git/blame - include/wx/app.h
Added zillions of #if wxUSE_XXX
[wxWidgets.git] / include / wx / app.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: app.h
3// Purpose: wxApp inclusion
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_APP_H_BASE_
13#define _WX_APP_H_BASE_
c801d85f 14
7c78e7c7 15#ifdef __WXMSW__
c801d85f
KB
16class WXDLLEXPORT wxApp;
17typedef wxApp* (*wxAppInitializerFunction) (void);
10b959e3 18#endif
c801d85f
KB
19
20#include "wx/object.h"
21
7c78e7c7 22#ifndef __WXMSW__
c801d85f 23typedef wxObject* (*wxAppInitializerFunction) (void); // returning wxApp* won't work with gcc
10b959e3 24#endif
c801d85f 25
2049ba38 26#if defined(__WXMSW__)
c801d85f 27#include "wx/msw/app.h"
2049ba38 28#elif defined(__WXMOTIF__)
34138703 29#include "wx/motif/app.h"
b4e76e0d
RR
30#elif defined(__WXQT__)
31#include "wx/qt/app.h"
2049ba38 32#elif defined(__WXGTK__)
c801d85f 33#include "wx/gtk/app.h"
34138703
JS
34#elif defined(__WXMAC__)
35#include "wx/mac/app.h"
36#elif defined(__WXSTUBS__)
37#include "wx/stubs/app.h"
c801d85f
KB
38#endif
39
c801d85f
KB
40// Having a global instance of this class allows
41// wxApp to be aware of the app creator function.
42// wxApp can then call this function to create a new
43// app object. Convoluted, but necessary.
44
45class WXDLLEXPORT wxAppInitializer
46{
47public:
48 wxAppInitializer(wxAppInitializerFunction fn)
49 {
50 wxApp::SetInitializerFunction(fn);
51 }
52};
53
26a87b69
JS
54// Here's a macro you can use if your compiler
55// really, really wants main() to be in your main program
56// (e.g. hello.cpp).
57// Now IMPLEMENT_APP should add this code if required.
58
6163f5d8 59#if defined(__AIX__) || defined(__HPUX__)
6f65e337
JS
60#define IMPLEMENT_WXWIN_MAIN \
61extern int wxEntry( int argc, char *argv[] ); \
62int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
750b78ba
JS
63
64#elif defined(__WXMSW__) && defined(WXUSINGDLL)
65
66// NT defines APIENTRY, 3.x not
67#if !defined(WXAPIENTRY)
68# ifdef __WATCOMC__
69# define WXAPIENTRY PASCAL
70# else
71# define WXAPIENTRY FAR PASCAL
72# endif
73#endif
74
75#define IMPLEMENT_WXWIN_MAIN \
76int WXAPIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,\
77 LPSTR m_lpCmdLine, int nCmdShow )\
78{\
79 return wxEntry((WXHINSTANCE) hInstance, (WXHINSTANCE) hPrevInstance,\
80 m_lpCmdLine, nCmdShow);\
81}
82
26a87b69
JS
83#else
84#define IMPLEMENT_WXWIN_MAIN
85#endif
86
c801d85f
KB
87#define IMPLEMENT_APP(appname) \
88 wxApp *wxCreateApp(void) { return new appname; } \
89 wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
90 appname& wxGetApp(void) { return *(appname *)wxTheApp; } \
26a87b69 91 IMPLEMENT_WXWIN_MAIN
c801d85f
KB
92
93#define DECLARE_APP(appname) \
94 extern appname& wxGetApp(void) ;
95
96
97#endif
34138703 98 // _WX_APP_H_BASE_