]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/app.h | |
3 | // Purpose: wxAppBase class and macros used for declaration of wxApp | |
4 | // derived class in the user code | |
5 | // Author: Julian Smart | |
6 | // Modified by: | |
7 | // Created: 01/02/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Julian Smart | |
10 | // Licence: wxWindows licence | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | #ifndef _WX_APP_H_BASE_ | |
14 | #define _WX_APP_H_BASE_ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers we have to include here | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
20 | #include "wx/event.h" // for the base class | |
21 | ||
22 | #if wxUSE_GUI | |
23 | #include "wx/window.h" // for wxTopLevelWindows | |
24 | ||
25 | #include "wx/vidmode.h" | |
26 | #endif // wxUSE_GUI | |
27 | ||
28 | #include "wx/build.h" | |
29 | #include "wx/init.h" // we must declare wxEntry() | |
30 | ||
31 | class WXDLLIMPEXP_BASE wxAppConsole; | |
32 | class WXDLLIMPEXP_BASE wxAppTraits; | |
33 | class WXDLLIMPEXP_BASE wxCmdLineParser; | |
34 | class WXDLLIMPEXP_BASE wxLog; | |
35 | class WXDLLIMPEXP_BASE wxMessageOutput; | |
36 | ||
37 | #if wxUSE_GUI | |
38 | class WXDLLEXPORT wxEventLoop; | |
39 | #endif | |
40 | ||
41 | // ---------------------------------------------------------------------------- | |
42 | // typedefs | |
43 | // ---------------------------------------------------------------------------- | |
44 | ||
45 | // the type of the function used to create a wxApp object on program start up | |
46 | typedef wxAppConsole* (*wxAppInitializerFunction)(); | |
47 | ||
48 | // ---------------------------------------------------------------------------- | |
49 | // constants | |
50 | // ---------------------------------------------------------------------------- | |
51 | ||
52 | enum | |
53 | { | |
54 | wxPRINT_WINDOWS = 1, | |
55 | wxPRINT_POSTSCRIPT = 2 | |
56 | }; | |
57 | ||
58 | // ---------------------------------------------------------------------------- | |
59 | // wxAppConsole: wxApp for non-GUI applications | |
60 | // ---------------------------------------------------------------------------- | |
61 | ||
62 | class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler | |
63 | { | |
64 | public: | |
65 | // ctor and dtor | |
66 | wxAppConsole(); | |
67 | virtual ~wxAppConsole(); | |
68 | ||
69 | ||
70 | // the virtual functions which may/must be overridden in the derived class | |
71 | // ----------------------------------------------------------------------- | |
72 | ||
73 | // This is the very first function called for a newly created wxApp object, | |
74 | // it is used by the library to do the global initialization. If, for some | |
75 | // reason, you must override it (instead of just overriding OnInit(), as | |
76 | // usual, for app-specific initializations), do not forget to call the base | |
77 | // class version! | |
78 | virtual bool Initialize(int& argc, wxChar **argv); | |
79 | ||
80 | // This gives wxCocoa a chance to call OnInit() with a memory pool in place | |
81 | virtual bool CallOnInit() { return OnInit(); } | |
82 | ||
83 | // Called before OnRun(), this is a good place to do initialization -- if | |
84 | // anything fails, return false from here to prevent the program from | |
85 | // continuing. The command line is normally parsed here, call the base | |
86 | // class OnInit() to do it. | |
87 | virtual bool OnInit(); | |
88 | ||
89 | // this is here only temporary hopefully (FIXME) | |
90 | virtual bool OnInitGui() { return true; } | |
91 | ||
92 | // This is the replacement for the normal main(): all program work should | |
93 | // be done here. When OnRun() returns, the programs starts shutting down. | |
94 | virtual int OnRun() = 0; | |
95 | ||
96 | // This is only called if OnInit() returned true so it's a good place to do | |
97 | // any cleanup matching the initializations done there. | |
98 | virtual int OnExit(); | |
99 | ||
100 | // This is the very last function called on wxApp object before it is | |
101 | // destroyed. If you override it (instead of overriding OnExit() as usual) | |
102 | // do not forget to call the base class version! | |
103 | virtual void CleanUp(); | |
104 | ||
105 | // Called when a fatal exception occurs, this function should take care not | |
106 | // to do anything which might provoke a nested exception! It may be | |
107 | // overridden if you wish to react somehow in non-default way (core dump | |
108 | // under Unix, application crash under Windows) to fatal program errors, | |
109 | // however extreme care should be taken if you don't want this function to | |
110 | // crash. | |
111 | virtual void OnFatalException() { } | |
112 | ||
113 | // Called from wxExit() function, should terminate the application a.s.a.p. | |
114 | virtual void Exit(); | |
115 | ||
116 | ||
117 | // application info: name, description, vendor | |
118 | // ------------------------------------------- | |
119 | ||
120 | // NB: all these should be set by the application itself, there are no | |
121 | // reasonable default except for the application name which is taken to | |
122 | // be argv[0] | |
123 | ||
124 | // set/get the application name | |
125 | wxString GetAppName() const | |
126 | { | |
127 | return m_appName.empty() ? m_className : m_appName; | |
128 | } | |
129 | void SetAppName(const wxString& name) { m_appName = name; } | |
130 | ||
131 | // set/get the app class name | |
132 | wxString GetClassName() const { return m_className; } | |
133 | void SetClassName(const wxString& name) { m_className = name; } | |
134 | ||
135 | // set/get the vendor name | |
136 | const wxString& GetVendorName() const { return m_vendorName; } | |
137 | void SetVendorName(const wxString& name) { m_vendorName = name; } | |
138 | ||
139 | ||
140 | // cmd line parsing stuff | |
141 | // ---------------------- | |
142 | ||
143 | // all of these methods may be overridden in the derived class to | |
144 | // customize the command line parsing (by default only a few standard | |
145 | // options are handled) | |
146 | // | |
147 | // you also need to call wxApp::OnInit() from YourApp::OnInit() for all | |
148 | // this to work | |
149 | ||
150 | #if wxUSE_CMDLINE_PARSER | |
151 | // this one is called from OnInit() to add all supported options | |
152 | // to the given parser (don't forget to call the base class version if you | |
153 | // override it!) | |
154 | virtual void OnInitCmdLine(wxCmdLineParser& parser); | |
155 | ||
156 | // called after successfully parsing the command line, return true | |
157 | // to continue and false to exit (don't forget to call the base class | |
158 | // version if you override it!) | |
159 | virtual bool OnCmdLineParsed(wxCmdLineParser& parser); | |
160 | ||
161 | // called if "--help" option was specified, return true to continue | |
162 | // and false to exit | |
163 | virtual bool OnCmdLineHelp(wxCmdLineParser& parser); | |
164 | ||
165 | // called if incorrect command line options were given, return | |
166 | // false to abort and true to continue | |
167 | virtual bool OnCmdLineError(wxCmdLineParser& parser); | |
168 | #endif // wxUSE_CMDLINE_PARSER | |
169 | ||
170 | ||
171 | // miscellaneous customization functions | |
172 | // ------------------------------------- | |
173 | ||
174 | // create the app traits object to which we delegate for everything which | |
175 | // either should be configurable by the user (then he can change the | |
176 | // default behaviour simply by overriding CreateTraits() and returning his | |
177 | // own traits object) or which is GUI/console dependent as then wxAppTraits | |
178 | Content-type: text/html ]>