]> git.saurik.com Git - wxWidgets.git/blob - include/wx/app.h
043856718e305e5608c3ddd6ad5f88b677f9cc9b
[wxWidgets.git] / include / wx / app.h
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
12 #ifndef __APPH_BASE__
13 #define __APPH_BASE__
14
15 #ifndef __GTK__
16 class WXDLLEXPORT wxApp;
17 typedef wxApp* (*wxAppInitializerFunction) (void);
18 #endif
19
20 #include "wx/object.h"
21
22 #ifdef __GTK
23 typedef wxObject* (*wxAppInitializerFunction) (void); // returning wxApp* won't work with gcc
24 #endif
25
26 #if defined(__WINDOWS__)
27 #include "wx/msw/app.h"
28 #elif defined(__MOTIF__)
29 #include "wx/xt/app.h"
30 #elif defined(__GTK__)
31 #include "wx/gtk/app.h"
32 #endif
33
34
35 // Having a global instance of this class allows
36 // wxApp to be aware of the app creator function.
37 // wxApp can then call this function to create a new
38 // app object. Convoluted, but necessary.
39
40 class WXDLLEXPORT wxAppInitializer
41 {
42 public:
43 wxAppInitializer(wxAppInitializerFunction fn)
44 {
45 wxApp::SetInitializerFunction(fn);
46 }
47 };
48
49 #define IMPLEMENT_APP(appname) \
50 wxApp *wxCreateApp(void) { return new appname; } \
51 wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
52 appname& wxGetApp(void) { return *(appname *)wxTheApp; } \
53 \
54 extern int wxEntry( int argc, char *argv[] ); \
55 int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
56
57
58 #define DECLARE_APP(appname) \
59 extern appname& wxGetApp(void) ;
60
61
62 #endif
63 // __APPH_BASE__