]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
fix unused parameters warnings
[wxWidgets.git] / include / wx / apptrait.h
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@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APPTRAIT_H_
13 #define _WX_APPTRAIT_H_
14
15 #include "wx/string.h"
16 #include "wx/platinfo.h"
17
18 class WXDLLIMPEXP_BASE wxObject;
19 class WXDLLEXPORT wxAppTraits;
20 #if wxUSE_FONTMAP
21 class WXDLLEXPORT wxFontMapper;
22 #endif // wxUSE_FONTMAP
23 class WXDLLIMPEXP_BASE wxLog;
24 class WXDLLIMPEXP_BASE wxMessageOutput;
25 class WXDLLEXPORT wxRendererNative;
26 class WXDLLIMPEXP_BASE wxString;
27 class WXDLLIMPEXP_BASE wxTimer;
28 class WXDLLIMPEXP_BASE wxTimerImpl;
29
30 class GSocketGUIFunctionsTable;
31
32
33 // ----------------------------------------------------------------------------
34 // wxAppTraits: this class defines various configurable aspects of wxApp
35 // ----------------------------------------------------------------------------
36
37 class WXDLLIMPEXP_BASE wxStandardPathsBase;
38
39 class WXDLLIMPEXP_BASE wxAppTraitsBase
40 {
41 public:
42 // needed since this class declares virtual members
43 virtual ~wxAppTraitsBase() { }
44
45 // hooks for working with the global objects, may be overridden by the user
46 // ------------------------------------------------------------------------
47
48 #if wxUSE_LOG
49 // create the default log target
50 virtual wxLog *CreateLogTarget() = 0;
51 #endif // wxUSE_LOG
52
53 // create the global object used for printing out messages
54 virtual wxMessageOutput *CreateMessageOutput() = 0;
55
56 #if wxUSE_FONTMAP
57 // create the global font mapper object used for encodings/charset mapping
58 virtual wxFontMapper *CreateFontMapper() = 0;
59 #endif // wxUSE_FONTMAP
60
61 // get the renderer to use for drawing the generic controls (return value
62 // may be NULL in which case the default renderer for the current platform
63 // is used); this is used in GUI only and always returns NULL in console
64 //
65 // NB: returned pointer will be deleted by the caller
66 virtual wxRendererNative *CreateRenderer() = 0;
67
68 #if wxUSE_STDPATHS
69 // wxStandardPaths object is normally the same for wxBase and wxGUI
70 // except in the case of wxMac and wxCocoa
71 virtual wxStandardPathsBase& GetStandardPaths();
72 #endif // wxUSE_STDPATHS
73
74 #if wxUSE_INTL
75 // called during wxApp initialization to set the locale to correspond to
76 // the user default (i.e. system locale under Windows, LC_ALL under Unix)
77 virtual void SetLocale();
78 #endif // wxUSE_INTL
79
80
81 // functions abstracting differences between GUI and console modes
82 // ------------------------------------------------------------------------
83
84 #ifdef __WXDEBUG__
85 // show the assert dialog with the specified message in GUI or just print
86 // the string to stderr in console mode
87 //
88 // base class version has an implementation (in spite of being pure
89 // virtual) in base/appbase.cpp which can be called as last resort.
90 //
91 // return true to suppress subsequent asserts, false to continue as before
92 virtual bool ShowAssertDialog(const wxString& msg) = 0;
93 #endif // __WXDEBUG__
94
95 // return true if fprintf(stderr) goes somewhere, false otherwise
96 virtual bool HasStderr() = 0;
97
98 // managing "pending delete" list: in GUI mode we can't immediately delete
99 // some objects because there may be unprocessed events for them and so we
100 // only do it during the next idle loop iteration while this is, of course,
101 // unnecessary in wxBase, so we have a few functions to abstract these
102 // operations
103
104 // add the object to the pending delete list in GUI, delete it immediately
105 // in wxBase
106 virtual void ScheduleForDestroy(wxObject *object) = 0;
107
108 // remove this object from the pending delete list in GUI, do nothing in
109 // wxBase
110 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
111
112 #if wxUSE_SOCKETS
113 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
114 // is needed because networking classes are in their own library and so
115 // they can't directly call GUI functions (the same net library can be
116 // used in both GUI and base apps). To complicate it further, GUI library
117 // ("wxCore") doesn't depend on networking library and so only a functions
118 // table can be passed around
119 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
120 #endif
121
122 #if wxUSE_TIMER
123 // return platform and toolkit dependent wxTimer implementation
124 virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0;
125 #endif
126
127 // functions returning port-specific information
128 // ------------------------------------------------------------------------
129
130 // return information about the (native) toolkit currently used and its
131 // runtime (not compile-time) version.
132 // returns wxPORT_BASE for console applications and one of the remaining
133 // wxPORT_* values for GUI applications.
134 virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
135
136 // return true if the port is using wxUniversal for the GUI, false if not
137 virtual bool IsUsingUniversalWidgets() const = 0;
138
139 // return the name of the Desktop Environment such as
140 // "KDE" or "GNOME". May return an empty string.
141 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
142
143 protected:
144 #if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
145 // utility function: returns the stack frame as a plain wxString
146 virtual wxString GetAssertStackTrace();
147 #endif
148 };
149
150 // ----------------------------------------------------------------------------
151 // include the platform-specific version of the class
152 // ----------------------------------------------------------------------------
153
154 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
155 // Unix code (and otherwise __UNIX__ wouldn't be defined)
156 // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
157 #if defined(__WXPALMOS__)
158 #include "wx/palmos/apptbase.h"
159 #elif defined(__WIN32__)
160 #include "wx/msw/apptbase.h"
161 #elif defined(__UNIX__) && !defined(__EMX__)
162 #include "wx/unix/apptbase.h"
163 #elif defined(__WXMAC__)
164 #include "wx/mac/apptbase.h"
165 #elif defined(__OS2__)
166 #include "wx/os2/apptbase.h"
167 #else // no platform-specific methods to add to wxAppTraits
168 // wxAppTraits must be a class because it was forward declared as class
169 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
170 {
171 };
172 #endif // platform
173
174 // ============================================================================
175 // standard traits for console and GUI applications
176 // ============================================================================
177
178 // ----------------------------------------------------------------------------
179 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
180 // ----------------------------------------------------------------------------
181
182 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
183 {
184 public:
185 #if wxUSE_LOG
186 virtual wxLog *CreateLogTarget();
187 #endif // wxUSE_LOG
188 virtual wxMessageOutput *CreateMessageOutput();
189 #if wxUSE_FONTMAP
190 virtual wxFontMapper *CreateFontMapper();
191 #endif // wxUSE_FONTMAP
192 virtual wxRendererNative *CreateRenderer();
193 #if wxUSE_SOCKETS
194 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
195 #endif
196
197 #ifdef __WXDEBUG__
198 virtual bool ShowAssertDialog(const wxString& msg);
199 #endif // __WXDEBUG__
200 virtual bool HasStderr();
201
202 virtual void ScheduleForDestroy(wxObject *object);
203 virtual void RemoveFromPendingDelete(wxObject *object);
204
205 // the GetToolkitVersion for console application is always the same
206 virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
207 {
208 // no toolkits (wxBase is for console applications without GUI support)
209 // NB: zero means "no toolkit", -1 means "not initialized yet"
210 // so we must use zero here!
211 if (verMaj) *verMaj = 0;
212 if (verMin) *verMin = 0;
213 return wxPORT_BASE;
214 }
215
216 virtual bool IsUsingUniversalWidgets() const { return false; }
217 };
218
219 // ----------------------------------------------------------------------------
220 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
221 // ----------------------------------------------------------------------------
222
223 #if wxUSE_GUI
224
225 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
226 {
227 public:
228 #if wxUSE_LOG
229 virtual wxLog *CreateLogTarget();
230 #endif // wxUSE_LOG
231 virtual wxMessageOutput *CreateMessageOutput();
232 #if wxUSE_FONTMAP
233 virtual wxFontMapper *CreateFontMapper();
234 #endif // wxUSE_FONTMAP
235 virtual wxRendererNative *CreateRenderer();
236 #if wxUSE_SOCKETS
237 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
238 #endif
239
240 #ifdef __WXDEBUG__
241 virtual bool ShowAssertDialog(const wxString& msg);
242 #endif // __WXDEBUG__
243 virtual bool HasStderr();
244
245 virtual void ScheduleForDestroy(wxObject *object);
246 virtual void RemoveFromPendingDelete(wxObject *object);
247
248 virtual bool IsUsingUniversalWidgets() const
249 {
250 #ifdef __WXUNIVERSAL__
251 return true;
252 #else
253 return false;
254 #endif
255 }
256 };
257
258 #endif // wxUSE_GUI
259
260 // ----------------------------------------------------------------------------
261 // include the platform-specific version of the classes above
262 // ----------------------------------------------------------------------------
263
264 // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
265 #if defined(__WXPALMOS__)
266 #include "wx/palmos/apptrait.h"
267 #elif defined(__WIN32__)
268 #include "wx/msw/apptrait.h"
269 #elif defined(__OS2__)
270 #include "wx/os2/apptrait.h"
271 #elif defined(__UNIX__)
272 #include "wx/unix/apptrait.h"
273 #elif defined(__WXMAC__)
274 #include "wx/mac/apptrait.h"
275 #elif defined(__DOS__)
276 #include "wx/msdos/apptrait.h"
277 #else
278 #if wxUSE_GUI
279 class wxGUIAppTraits : public wxGUIAppTraitsBase
280 {
281 };
282 #endif // wxUSE_GUI
283 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
284 {
285 };
286 #endif // platform
287
288 #endif // _WX_APPTRAIT_H_
289