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