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