]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
cleaning up problems after string changes
[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
VS
17
18class WXDLLIMPEXP_BASE wxObject;
e2478fde
VZ
19class WXDLLEXPORT wxAppTraits;
20#if wxUSE_FONTMAP
21 class WXDLLEXPORT wxFontMapper;
22#endif // wxUSE_FONTMAP
a8eaaeb2
VS
23class WXDLLIMPEXP_BASE wxLog;
24class WXDLLIMPEXP_BASE wxMessageOutput;
f0244295 25class WXDLLEXPORT wxRendererNative;
a8eaaeb2 26class WXDLLIMPEXP_BASE wxString;
a8eaaeb2 27
3e1400ac 28class GSocketGUIFunctionsTable;
38bb138f 29
e2478fde
VZ
30
31// ----------------------------------------------------------------------------
32// wxAppTraits: this class defines various configurable aspects of wxApp
33// ----------------------------------------------------------------------------
34
fc480dc1
DE
35class WXDLLIMPEXP_BASE wxStandardPathsBase;
36
7af1b539 37class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
38{
39public:
ed62f740
VZ
40 // needed since this class declares virtual members
41 virtual ~wxAppTraitsBase() { }
42
d774f916 43 // hooks for working with the global objects, may be overridden by the user
e2478fde
VZ
44 // ------------------------------------------------------------------------
45
46#if wxUSE_LOG
47 // create the default log target
48 virtual wxLog *CreateLogTarget() = 0;
49#endif // wxUSE_LOG
50
51 // create the global object used for printing out messages
52 virtual wxMessageOutput *CreateMessageOutput() = 0;
53
54#if wxUSE_FONTMAP
55 // create the global font mapper object used for encodings/charset mapping
56 virtual wxFontMapper *CreateFontMapper() = 0;
57#endif // wxUSE_FONTMAP
58
f0244295
VZ
59 // get the renderer to use for drawing the generic controls (return value
60 // may be NULL in which case the default renderer for the current platform
61 // is used); this is used in GUI only and always returns NULL in console
62 //
63 // NB: returned pointer will be deleted by the caller
64 virtual wxRendererNative *CreateRenderer() = 0;
65
07158944 66#if wxUSE_STDPATHS
fc480dc1
DE
67 // wxStandardPaths object is normally the same for wxBase and wxGUI
68 // except in the case of wxMac and wxCocoa
69 virtual wxStandardPathsBase& GetStandardPaths();
07158944 70#endif // wxUSE_STDPATHS
e2478fde 71
d774f916
VZ
72#if wxUSE_INTL
73 // called during wxApp initialization to set the locale to correspond to
74 // the user default (i.e. system locale under Windows, LC_ALL under Unix)
75 virtual void SetLocale();
76#endif // wxUSE_INTL
77
78
e2478fde
VZ
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
d774f916
VZ
120
121 // functions returning port-specific information
122 // ------------------------------------------------------------------------
123
449090b5
VZ
124 // return information about the (native) toolkit currently used and its
125 // runtime (not compile-time) version.
8bb6b2c0
VZ
126 // returns wxPORT_BASE for console applications and one of the remaining
127 // wxPORT_* values for GUI applications.
128 virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
b98bd6af
VS
129
130 // return true if the port is using wxUniversal for the GUI, false if not
131 virtual bool IsUsingUniversalWidgets() const = 0;
db9febdf
RR
132
133 // return the name of the Desktop Environment such as
88bbc332
RR
134 // "KDE" or "GNOME". May return an empty string.
135 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
db9febdf
RR
136
137protected:
138#if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
139 // utility function: returns the stack frame as a plain wxString
140 virtual wxString GetAssertStackTrace();
141#endif
e2478fde
VZ
142};
143
144// ----------------------------------------------------------------------------
145// include the platform-specific version of the class
146// ----------------------------------------------------------------------------
147
532d575b
WS
148// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
149// Unix code (and otherwise __UNIX__ wouldn't be defined)
150// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 151#if defined(__WXPALMOS__)
ffecfa5a 152 #include "wx/palmos/apptbase.h"
532d575b 153#elif defined(__WIN32__)
e2478fde 154 #include "wx/msw/apptbase.h"
621ccd8a 155#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 156 #include "wx/unix/apptbase.h"
29c99ad3
VZ
157#elif defined(__WXMAC__)
158 #include "wx/mac/apptbase.h"
9fc852b7
SN
159#elif defined(__OS2__)
160 #include "wx/os2/apptbase.h"
46446cc2 161#else // no platform-specific methods to add to wxAppTraits
e2478fde 162 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 163 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
164 {
165 };
166#endif // platform
167
168// ============================================================================
169// standard traits for console and GUI applications
170// ============================================================================
171
172// ----------------------------------------------------------------------------
173// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
174// ----------------------------------------------------------------------------
175
7af1b539 176class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
177{
178public:
179#if wxUSE_LOG
180 virtual wxLog *CreateLogTarget();
181#endif // wxUSE_LOG
182 virtual wxMessageOutput *CreateMessageOutput();
183#if wxUSE_FONTMAP
184 virtual wxFontMapper *CreateFontMapper();
185#endif // wxUSE_FONTMAP
f0244295 186 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
187#if wxUSE_SOCKETS
188 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
189#endif
e2478fde
VZ
190
191#ifdef __WXDEBUG__
192 virtual bool ShowAssertDialog(const wxString& msg);
193#endif // __WXDEBUG__
194 virtual bool HasStderr();
195
196 virtual void ScheduleForDestroy(wxObject *object);
197 virtual void RemoveFromPendingDelete(wxObject *object);
8bb6b2c0
VZ
198
199 // the GetToolkitVersion for console application is always the same
b98bd6af 200 virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
8bb6b2c0
VZ
201 {
202 // no toolkits (wxBase is for console applications without GUI support)
203 // NB: zero means "no toolkit", -1 means "not initialized yet"
204 // so we must use zero here!
205 if (verMaj) *verMaj = 0;
206 if (verMin) *verMin = 0;
207 return wxPORT_BASE;
208 }
b98bd6af
VS
209
210 virtual bool IsUsingUniversalWidgets() const { return false; }
e2478fde
VZ
211};
212
213// ----------------------------------------------------------------------------
214// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
215// ----------------------------------------------------------------------------
216
217#if wxUSE_GUI
218
94826170 219class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
220{
221public:
222#if wxUSE_LOG
223 virtual wxLog *CreateLogTarget();
224#endif // wxUSE_LOG
225 virtual wxMessageOutput *CreateMessageOutput();
226#if wxUSE_FONTMAP
227 virtual wxFontMapper *CreateFontMapper();
228#endif // wxUSE_FONTMAP
f0244295 229 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
230#if wxUSE_SOCKETS
231 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
232#endif
e2478fde
VZ
233
234#ifdef __WXDEBUG__
235 virtual bool ShowAssertDialog(const wxString& msg);
236#endif // __WXDEBUG__
237 virtual bool HasStderr();
238
239 virtual void ScheduleForDestroy(wxObject *object);
240 virtual void RemoveFromPendingDelete(wxObject *object);
b98bd6af
VS
241
242 virtual bool IsUsingUniversalWidgets() const
243 {
244 #ifdef __WXUNIVERSAL__
245 return true;
246 #else
247 return false;
248 #endif
249 }
e2478fde
VZ
250};
251
252#endif // wxUSE_GUI
253
254// ----------------------------------------------------------------------------
255// include the platform-specific version of the classes above
256// ----------------------------------------------------------------------------
257
532d575b 258// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 259#if defined(__WXPALMOS__)
ffecfa5a 260 #include "wx/palmos/apptrait.h"
532d575b 261#elif defined(__WIN32__)
e2478fde 262 #include "wx/msw/apptrait.h"
21d3d342
SN
263#elif defined(__OS2__)
264 #include "wx/os2/apptrait.h"
265#elif defined(__UNIX__)
2d2d4fc7 266 #include "wx/unix/apptrait.h"
29c99ad3
VZ
267#elif defined(__WXMAC__)
268 #include "wx/mac/apptrait.h"
9aecec9a
MW
269#elif defined(__DOS__)
270 #include "wx/msdos/apptrait.h"
4629016d 271#else
e2478fde 272 #if wxUSE_GUI
621ccd8a
SN
273 class wxGUIAppTraits : public wxGUIAppTraitsBase
274 {
621ccd8a 275 };
e2478fde 276 #endif // wxUSE_GUI
4629016d 277 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
621ccd8a 278 {
621ccd8a 279 };
e2478fde
VZ
280#endif // platform
281
282#endif // _WX_APPTRAIT_H_
283