]> git.saurik.com Git - wxWidgets.git/blob - include/wx/app.h
Added wxDirDialog
[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 _WX_APP_H_BASE_
13 #define _WX_APP_H_BASE_
14
15 #ifdef __WXMSW__
16 class WXDLLEXPORT wxApp;
17 typedef wxApp* (*wxAppInitializerFunction) (void);
18 #endif
19
20 #include "wx/object.h"
21
22 #ifndef __WXMSW__
23 typedef wxObject* (*wxAppInitializerFunction) (void); // returning wxApp* won't work with gcc
24 #endif
25
26 #if defined(__WXMSW__)
27 #include "wx/msw/app.h"
28 #elif defined(__WXMOTIF__)
29 #include "wx/motif/app.h"
30 #elif defined(__WXQT__)
31 #include "wx/qt/app.h"
32 #elif defined(__WXGTK__)
33 #include "wx/gtk/app.h"
34 #elif defined(__WXMAC__)
35 #include "wx/mac/app.h"
36 #elif defined(__WXSTUBS__)
37 #include "wx/stubs/app.h"
38 #endif
39
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
45 class WXDLLEXPORT wxAppInitializer
46 {
47 public:
48 wxAppInitializer(wxAppInitializerFunction fn)
49 {
50 wxApp::SetInitializerFunction(fn);
51 }
52 };
53
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
59 #if defined(__AIX__) || defined(__HPUX__)
60 #define IMPLEMENT_WXWIN_MAIN \
61 extern int wxEntry( int argc, char *argv[] ); \
62 int main(int argc, char *argv[]) { return wxEntry(argc, argv); }
63 #else
64 #define IMPLEMENT_WXWIN_MAIN
65 #endif
66
67 #define IMPLEMENT_APP(appname) \
68 wxApp *wxCreateApp(void) { return new appname; } \
69 wxAppInitializer wxTheAppInitializer((wxAppInitializerFunction) wxCreateApp); \
70 appname& wxGetApp(void) { return *(appname *)wxTheApp; } \
71 IMPLEMENT_WXWIN_MAIN
72
73 #define DECLARE_APP(appname) \
74 extern appname& wxGetApp(void) ;
75
76
77 #endif
78 // _WX_APP_H_BASE_