]>
Commit | Line | Data |
---|---|---|
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 | ||
12 | #ifndef __APPH_BASE__ | |
13 | #define __APPH_BASE__ | |
14 | ||
10b959e3 | 15 | #ifndef __GTK__ |
c801d85f KB |
16 | class WXDLLEXPORT wxApp; |
17 | typedef wxApp* (*wxAppInitializerFunction) (void); | |
10b959e3 | 18 | #endif |
c801d85f KB |
19 | |
20 | #include "wx/object.h" | |
21 | ||
824e935a | 22 | #ifdef __GTK__ |
c801d85f | 23 | typedef wxObject* (*wxAppInitializerFunction) (void); // returning wxApp* won't work with gcc |
10b959e3 | 24 | #endif |
c801d85f KB |
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 | ||
26a87b69 JS |
49 | // Here's a macro you can use if your compiler |
50 | // really, really wants main() to be in your main program | |
51 | // (e.g. hello.cpp). | |
52 | // Now IMPLEMENT_APP should add this code if required. | |
53 | ||
6f65e337 JS |
54 | #if defined(__AIX__) || defined(__SUN__) || defined(__HPUX__) |
55 | #define IMPLEMENT_WXWIN_MAIN \ | |
56 | extern int wxEntry( int argc, char *argv[] ); \ | |
57 | int main(int argc, char *argv[]) { return wxEntry(argc, argv); } | |
26a87b69 JS |
58 | #else |
59 | #define IMPLEMENT_WXWIN_MAIN | |
60 | #endif | |
61 | ||
c801d85f KB |
62 | #define IMPLEMENT_APP(appname) \ |
63 | wxApp *wxCreateApp(void) { return new appname; } \ | |
64 | wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \ | |
65 | appname& wxGetApp(void) { return *(appname *)wxTheApp; } \ | |
26a87b69 | 66 | IMPLEMENT_WXWIN_MAIN |
c801d85f KB |
67 | |
68 | #define DECLARE_APP(appname) \ | |
69 | extern appname& wxGetApp(void) ; | |
70 | ||
71 | ||
72 | #endif | |
73 | // __APPH_BASE__ |