]>
Commit | Line | Data |
---|---|---|
e2478fde VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/apptrait.h | |
3 | // Purpose: declaration of wxAppTraits and derived classes | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 19.06.2003 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_APPTRAIT_H_ | |
13 | #define _WX_APPTRAIT_H_ | |
14 | ||
a8eaaeb2 VS |
15 | #include "wx/string.h" |
16 | ||
17 | class WXDLLIMPEXP_BASE wxObject; | |
e2478fde VZ |
18 | class WXDLLEXPORT wxAppTraits; |
19 | #if wxUSE_FONTMAP | |
20 | class WXDLLEXPORT wxFontMapper; | |
21 | #endif // wxUSE_FONTMAP | |
a8eaaeb2 VS |
22 | class WXDLLIMPEXP_BASE wxLog; |
23 | class WXDLLIMPEXP_BASE wxMessageOutput; | |
f0244295 | 24 | class WXDLLEXPORT wxRendererNative; |
a8eaaeb2 | 25 | class WXDLLIMPEXP_BASE wxString; |
a8eaaeb2 | 26 | |
f46f68d9 VS |
27 | extern "C" |
28 | { | |
29 | struct GSocketGUIFunctionsTable; | |
30 | } | |
38bb138f | 31 | |
49bcad62 DE |
32 | // FIXME: Eventually unify Mac OS 9 |
33 | class GSocketBSD; | |
34 | ||
a8eaaeb2 VS |
35 | // ---------------------------------------------------------------------------- |
36 | // toolkit information | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | // Information about the toolkit that the app is running under (e.g. wxMSW): | |
40 | struct WXDLLIMPEXP_BASE wxToolkitInfo | |
41 | { | |
42 | // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console: | |
43 | wxString shortName; | |
44 | // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or | |
45 | // "wxMSW/Universal"); "wxBase" for console apps: | |
46 | wxString name; | |
47 | // Version of the underlying toolkit or of the OS for console apps: | |
48 | int versionMajor, versionMinor; | |
49 | // OS mnenomics, e.g. wxGTK or wxMSW: | |
50 | int os; | |
51 | }; | |
52 | ||
e2478fde VZ |
53 | |
54 | // ---------------------------------------------------------------------------- | |
55 | // wxAppTraits: this class defines various configurable aspects of wxApp | |
56 | // ---------------------------------------------------------------------------- | |
57 | ||
7af1b539 | 58 | class WXDLLIMPEXP_BASE wxAppTraitsBase |
e2478fde VZ |
59 | { |
60 | public: | |
e2478fde VZ |
61 | // hooks for creating the global objects, may be overridden by the user |
62 | // ------------------------------------------------------------------------ | |
63 | ||
64 | #if wxUSE_LOG | |
65 | // create the default log target | |
66 | virtual wxLog *CreateLogTarget() = 0; | |
67 | #endif // wxUSE_LOG | |
68 | ||
69 | // create the global object used for printing out messages | |
70 | virtual wxMessageOutput *CreateMessageOutput() = 0; | |
71 | ||
72 | #if wxUSE_FONTMAP | |
73 | // create the global font mapper object used for encodings/charset mapping | |
74 | virtual wxFontMapper *CreateFontMapper() = 0; | |
75 | #endif // wxUSE_FONTMAP | |
76 | ||
f0244295 VZ |
77 | // get the renderer to use for drawing the generic controls (return value |
78 | // may be NULL in which case the default renderer for the current platform | |
79 | // is used); this is used in GUI only and always returns NULL in console | |
80 | // | |
81 | // NB: returned pointer will be deleted by the caller | |
82 | virtual wxRendererNative *CreateRenderer() = 0; | |
83 | ||
e2478fde VZ |
84 | |
85 | // functions abstracting differences between GUI and console modes | |
86 | // ------------------------------------------------------------------------ | |
87 | ||
88 | #ifdef __WXDEBUG__ | |
89 | // show the assert dialog with the specified message in GUI or just print | |
90 | // the string to stderr in console mode | |
91 | // | |
92 | // base class version has an implementation (in spite of being pure | |
93 | // virtual) in base/appbase.cpp which can be called as last resort. | |
94 | // | |
95 | // return true to suppress subsequent asserts, false to continue as before | |
96 | virtual bool ShowAssertDialog(const wxString& msg) = 0; | |
97 | #endif // __WXDEBUG__ | |
98 | ||
99 | // return true if fprintf(stderr) goes somewhere, false otherwise | |
100 | virtual bool HasStderr() = 0; | |
101 | ||
102 | // managing "pending delete" list: in GUI mode we can't immediately delete | |
103 | // some objects because there may be unprocessed events for them and so we | |
104 | // only do it during the next idle loop iteration while this is, of course, | |
105 | // unnecessary in wxBase, so we have a few functions to abstract these | |
106 | // operations | |
107 | ||
108 | // add the object to the pending delete list in GUI, delete it immediately | |
109 | // in wxBase | |
110 | virtual void ScheduleForDestroy(wxObject *object) = 0; | |
111 | ||
112 | // remove this object from the pending delete list in GUI, do nothing in | |
113 | // wxBase | |
114 | virtual void RemoveFromPendingDelete(wxObject *object) = 0; | |
2739d4f0 | 115 | |
38bb138f VS |
116 | #if wxUSE_SOCKETS |
117 | // return table of GUI callbacks for GSocket code or NULL in wxBase | |
118 | virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0; | |
49bcad62 DE |
119 | |
120 | // return a new GSocket with the EventLoop_* stuff implemented. | |
121 | // or at least stubbed (i.e. wxBase) | |
122 | virtual GSocketBSD* CreateGSocket() = 0; | |
38bb138f VS |
123 | #endif |
124 | ||
2739d4f0 | 125 | |
a8eaaeb2 VS |
126 | // return information about what toolkit is running; we need for two things |
127 | // that are both contained in wxBase: | |
128 | // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under | |
129 | // Unix: in the former case it returns the information about the toolkit | |
130 | // and in the latter -- about the OS, so we need to virtualize it | |
131 | // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit | |
132 | // signature in DLL name | |
324899f6 | 133 | virtual wxToolkitInfo& GetToolkitInfo() = 0; |
e2478fde VZ |
134 | }; |
135 | ||
136 | // ---------------------------------------------------------------------------- | |
137 | // include the platform-specific version of the class | |
138 | // ---------------------------------------------------------------------------- | |
139 | ||
29c99ad3 VZ |
140 | // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the |
141 | // Unix code (and otherwise __UNIX__ wouldn't be defined) | |
e2478fde VZ |
142 | #if defined(__WXMSW__) |
143 | #include "wx/msw/apptbase.h" | |
621ccd8a | 144 | #elif defined(__UNIX__) && !defined(__EMX__) |
2d2d4fc7 | 145 | #include "wx/unix/apptbase.h" |
29c99ad3 VZ |
146 | #elif defined(__WXMAC__) |
147 | #include "wx/mac/apptbase.h" | |
9fc852b7 SN |
148 | #elif defined(__OS2__) |
149 | #include "wx/os2/apptbase.h" | |
46446cc2 | 150 | #else // no platform-specific methods to add to wxAppTraits |
e2478fde | 151 | // wxAppTraits must be a class because it was forward declared as class |
bb24c68f | 152 | class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase |
e2478fde VZ |
153 | { |
154 | }; | |
155 | #endif // platform | |
156 | ||
157 | // ============================================================================ | |
158 | // standard traits for console and GUI applications | |
159 | // ============================================================================ | |
160 | ||
161 | // ---------------------------------------------------------------------------- | |
162 | // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps | |
163 | // ---------------------------------------------------------------------------- | |
164 | ||
7af1b539 | 165 | class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits |
e2478fde VZ |
166 | { |
167 | public: | |
168 | #if wxUSE_LOG | |
169 | virtual wxLog *CreateLogTarget(); | |
170 | #endif // wxUSE_LOG | |
171 | virtual wxMessageOutput *CreateMessageOutput(); | |
172 | #if wxUSE_FONTMAP | |
173 | virtual wxFontMapper *CreateFontMapper(); | |
174 | #endif // wxUSE_FONTMAP | |
f0244295 | 175 | virtual wxRendererNative *CreateRenderer(); |
38bb138f VS |
176 | #if wxUSE_SOCKETS |
177 | virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable(); | |
49bcad62 | 178 | virtual GSocketBSD* CreateGSocket(); |
38bb138f | 179 | #endif |
e2478fde VZ |
180 | |
181 | #ifdef __WXDEBUG__ | |
182 | virtual bool ShowAssertDialog(const wxString& msg); | |
183 | #endif // __WXDEBUG__ | |
184 | virtual bool HasStderr(); | |
185 | ||
186 | virtual void ScheduleForDestroy(wxObject *object); | |
187 | virtual void RemoveFromPendingDelete(wxObject *object); | |
188 | }; | |
189 | ||
190 | // ---------------------------------------------------------------------------- | |
191 | // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps | |
192 | // ---------------------------------------------------------------------------- | |
193 | ||
194 | #if wxUSE_GUI | |
195 | ||
94826170 | 196 | class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits |
e2478fde VZ |
197 | { |
198 | public: | |
199 | #if wxUSE_LOG | |
200 | virtual wxLog *CreateLogTarget(); | |
201 | #endif // wxUSE_LOG | |
202 | virtual wxMessageOutput *CreateMessageOutput(); | |
203 | #if wxUSE_FONTMAP | |
204 | virtual wxFontMapper *CreateFontMapper(); | |
205 | #endif // wxUSE_FONTMAP | |
f0244295 | 206 | virtual wxRendererNative *CreateRenderer(); |
38bb138f VS |
207 | #if wxUSE_SOCKETS |
208 | virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable(); | |
49bcad62 DE |
209 | // return a new GSocket with the EventLoop_* stuff implemented. |
210 | // TODO: Remove this because each GUI should implement it separately | |
211 | virtual GSocketBSD* CreateGSocket(); | |
38bb138f | 212 | #endif |
e2478fde VZ |
213 | |
214 | #ifdef __WXDEBUG__ | |
215 | virtual bool ShowAssertDialog(const wxString& msg); | |
216 | #endif // __WXDEBUG__ | |
217 | virtual bool HasStderr(); | |
218 | ||
219 | virtual void ScheduleForDestroy(wxObject *object); | |
220 | virtual void RemoveFromPendingDelete(wxObject *object); | |
221 | }; | |
222 | ||
223 | #endif // wxUSE_GUI | |
224 | ||
225 | // ---------------------------------------------------------------------------- | |
226 | // include the platform-specific version of the classes above | |
227 | // ---------------------------------------------------------------------------- | |
228 | ||
229 | #if defined(__WXMSW__) | |
230 | #include "wx/msw/apptrait.h" | |
621ccd8a | 231 | #elif defined(__UNIX__) && !defined(__EMX__) |
2d2d4fc7 | 232 | #include "wx/unix/apptrait.h" |
29c99ad3 VZ |
233 | #elif defined(__WXMAC__) |
234 | #include "wx/mac/apptrait.h" | |
7332d96b | 235 | #elif defined(__WXPM__) |
a637417c | 236 | #include "wx/os2/apptrait.h" |
621ccd8a SN |
237 | #else |
238 | // at least, we need an implementation of GetToolkitInfo ! | |
e2478fde | 239 | #if wxUSE_GUI |
621ccd8a SN |
240 | class wxGUIAppTraits : public wxGUIAppTraitsBase |
241 | { | |
242 | virtual wxToolkitInfo& GetToolkitInfo(); | |
243 | }; | |
e2478fde | 244 | #endif // wxUSE_GUI |
621ccd8a SN |
245 | class wxConsoleAppTraits: public wxConsoleAppTraitsBase |
246 | { | |
247 | virtual wxToolkitInfo& GetToolkitInfo(); | |
248 | }; | |
e2478fde VZ |
249 | #endif // platform |
250 | ||
251 | #endif // _WX_APPTRAIT_H_ | |
252 |