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