]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
added wxStdDialogButtonSizer test (patch 1705382)
[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;
c2ca375c
VZ
27class WXDLLIMPEXP_BASE wxTimer;
28class WXDLLIMPEXP_BASE wxTimerImpl;
a8eaaeb2 29
3e1400ac 30class GSocketGUIFunctionsTable;
38bb138f 31
e2478fde
VZ
32
33// ----------------------------------------------------------------------------
34// wxAppTraits: this class defines various configurable aspects of wxApp
35// ----------------------------------------------------------------------------
36
fc480dc1
DE
37class WXDLLIMPEXP_BASE wxStandardPathsBase;
38
7af1b539 39class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
40{
41public:
ed62f740
VZ
42 // needed since this class declares virtual members
43 virtual ~wxAppTraitsBase() { }
44
d774f916 45 // hooks for working with the global objects, may be overridden by the user
e2478fde
VZ
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
f0244295
VZ
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
07158944 68#if wxUSE_STDPATHS
fc480dc1
DE
69 // wxStandardPaths object is normally the same for wxBase and wxGUI
70 // except in the case of wxMac and wxCocoa
71 virtual wxStandardPathsBase& GetStandardPaths();
07158944 72#endif // wxUSE_STDPATHS
e2478fde 73
d774f916
VZ
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
e2478fde
VZ
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;
2739d4f0 111
38bb138f 112#if wxUSE_SOCKETS
321b8029 113 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
4629016d 114 // is needed because networking classes are in their own library and so
321b8029
VS
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
38bb138f
VS
119 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
120#endif
121
c2ca375c
VZ
122#if wxUSE_TIMER
123 // return platform and toolkit dependent wxTimer implementation
124 virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0;
125#endif
d774f916
VZ
126
127 // functions returning port-specific information
128 // ------------------------------------------------------------------------
129
449090b5
VZ
130 // return information about the (native) toolkit currently used and its
131 // runtime (not compile-time) version.
8bb6b2c0
VZ
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;
b98bd6af
VS
135
136 // return true if the port is using wxUniversal for the GUI, false if not
137 virtual bool IsUsingUniversalWidgets() const = 0;
db9febdf
RR
138
139 // return the name of the Desktop Environment such as
88bbc332 140 // "KDE" or "GNOME". May return an empty string.
d3a0a0ee
VZ
141 virtual wxString GetDesktopEnvironment() const = 0;
142
143 // returns a short string to identify the block of the standard command
144 // line options parsed automatically by current port: if this string is
145 // empty, there are no such options, otherwise the function also fills
146 // passed arrays with the names and the descriptions of those options.
147 virtual wxString GetStandardCmdLineOptions(wxArrayString& names,
148 wxArrayString& desc) const
149 {
150 wxUnusedVar(names);
151 wxUnusedVar(desc);
152
153 return wxEmptyString;
154 }
155
db9febdf
RR
156
157protected:
158#if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
159 // utility function: returns the stack frame as a plain wxString
160 virtual wxString GetAssertStackTrace();
161#endif
e2478fde
VZ
162};
163
164// ----------------------------------------------------------------------------
165// include the platform-specific version of the class
166// ----------------------------------------------------------------------------
167
532d575b
WS
168// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
169// Unix code (and otherwise __UNIX__ wouldn't be defined)
170// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 171#if defined(__WXPALMOS__)
ffecfa5a 172 #include "wx/palmos/apptbase.h"
532d575b 173#elif defined(__WIN32__)
e2478fde 174 #include "wx/msw/apptbase.h"
621ccd8a 175#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 176 #include "wx/unix/apptbase.h"
29c99ad3
VZ
177#elif defined(__WXMAC__)
178 #include "wx/mac/apptbase.h"
9fc852b7
SN
179#elif defined(__OS2__)
180 #include "wx/os2/apptbase.h"
46446cc2 181#else // no platform-specific methods to add to wxAppTraits
e2478fde 182 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 183 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
184 {
185 };
186#endif // platform
187
188// ============================================================================
189// standard traits for console and GUI applications
190// ============================================================================
191
192// ----------------------------------------------------------------------------
193// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
194// ----------------------------------------------------------------------------
195
7af1b539 196class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
197{
198public:
199#if wxUSE_LOG
200 virtual wxLog *CreateLogTarget();
201#endif // wxUSE_LOG
202 virtual wxMessageOutput *CreateMessageOutput();
203#if wxUSE_FONTMAP
204 virtual wxFontMapper *CreateFontMapper();
205#endif // wxUSE_FONTMAP
f0244295 206 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
207#if wxUSE_SOCKETS
208 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
209#endif
e2478fde
VZ
210
211#ifdef __WXDEBUG__
212 virtual bool ShowAssertDialog(const wxString& msg);
213#endif // __WXDEBUG__
214 virtual bool HasStderr();
215
216 virtual void ScheduleForDestroy(wxObject *object);
217 virtual void RemoveFromPendingDelete(wxObject *object);
8bb6b2c0
VZ
218
219 // the GetToolkitVersion for console application is always the same
b98bd6af 220 virtual wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
8bb6b2c0
VZ
221 {
222 // no toolkits (wxBase is for console applications without GUI support)
223 // NB: zero means "no toolkit", -1 means "not initialized yet"
224 // so we must use zero here!
225 if (verMaj) *verMaj = 0;
226 if (verMin) *verMin = 0;
227 return wxPORT_BASE;
228 }
b98bd6af
VS
229
230 virtual bool IsUsingUniversalWidgets() const { return false; }
d3a0a0ee 231 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
e2478fde
VZ
232};
233
234// ----------------------------------------------------------------------------
235// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
236// ----------------------------------------------------------------------------
237
238#if wxUSE_GUI
239
94826170 240class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
241{
242public:
243#if wxUSE_LOG
244 virtual wxLog *CreateLogTarget();
245#endif // wxUSE_LOG
246 virtual wxMessageOutput *CreateMessageOutput();
247#if wxUSE_FONTMAP
248 virtual wxFontMapper *CreateFontMapper();
249#endif // wxUSE_FONTMAP
f0244295 250 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
251#if wxUSE_SOCKETS
252 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
253#endif
e2478fde
VZ
254
255#ifdef __WXDEBUG__
256 virtual bool ShowAssertDialog(const wxString& msg);
257#endif // __WXDEBUG__
258 virtual bool HasStderr();
259
260 virtual void ScheduleForDestroy(wxObject *object);
261 virtual void RemoveFromPendingDelete(wxObject *object);
b98bd6af
VS
262
263 virtual bool IsUsingUniversalWidgets() const
264 {
265 #ifdef __WXUNIVERSAL__
266 return true;
267 #else
268 return false;
269 #endif
270 }
d3a0a0ee
VZ
271
272 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
e2478fde
VZ
273};
274
275#endif // wxUSE_GUI
276
277// ----------------------------------------------------------------------------
278// include the platform-specific version of the classes above
279// ----------------------------------------------------------------------------
280
532d575b 281// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 282#if defined(__WXPALMOS__)
ffecfa5a 283 #include "wx/palmos/apptrait.h"
532d575b 284#elif defined(__WIN32__)
e2478fde 285 #include "wx/msw/apptrait.h"
21d3d342
SN
286#elif defined(__OS2__)
287 #include "wx/os2/apptrait.h"
288#elif defined(__UNIX__)
2d2d4fc7 289 #include "wx/unix/apptrait.h"
29c99ad3
VZ
290#elif defined(__WXMAC__)
291 #include "wx/mac/apptrait.h"
9aecec9a
MW
292#elif defined(__DOS__)
293 #include "wx/msdos/apptrait.h"
4629016d 294#else
e2478fde 295 #if wxUSE_GUI
621ccd8a
SN
296 class wxGUIAppTraits : public wxGUIAppTraitsBase
297 {
621ccd8a 298 };
e2478fde 299 #endif // wxUSE_GUI
4629016d 300 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
621ccd8a 301 {
621ccd8a 302 };
e2478fde
VZ
303#endif // platform
304
305#endif // _WX_APPTRAIT_H_
306