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