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