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