]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
rebaked makefiles with 0.2.4
[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
b5dbe15d
VS
18class WXDLLIMPEXP_FWD_BASE wxArrayString;
19class WXDLLIMPEXP_FWD_BASE wxConfigBase;
20class WXDLLIMPEXP_FWD_BASE wxEventLoopBase;
e2478fde 21#if wxUSE_FONTMAP
b5dbe15d 22 class WXDLLIMPEXP_FWD_CORE wxFontMapper;
e2478fde 23#endif // wxUSE_FONTMAP
b5dbe15d
VS
24class WXDLLIMPEXP_FWD_BASE wxLog;
25class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
26class WXDLLIMPEXP_FWD_BASE wxObject;
27class WXDLLIMPEXP_FWD_CORE wxRendererNative;
28class WXDLLIMPEXP_FWD_BASE wxStandardPathsBase;
29class WXDLLIMPEXP_FWD_BASE wxString;
30class WXDLLIMPEXP_FWD_BASE wxTimer;
31class WXDLLIMPEXP_FWD_BASE wxTimerImpl;
a8eaaeb2 32
2804f77d 33class GSocketManager;
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
fc480dc1
DE
76 // wxStandardPaths object is normally the same for wxBase and wxGUI
77 // except in the case of wxMac and wxCocoa
78 virtual wxStandardPathsBase& GetStandardPaths();
e2478fde 79
d774f916
VZ
80#if wxUSE_INTL
81 // called during wxApp initialization to set the locale to correspond to
82 // the user default (i.e. system locale under Windows, LC_ALL under Unix)
83 virtual void SetLocale();
84#endif // wxUSE_INTL
85
86
e2478fde
VZ
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
2804f77d
VZ
119 // return socket manager: this is usually different for console and GUI
120 // applications (although some ports use the same implementation for both)
121 virtual GSocketManager *GetSocketManager() = 0;
38bb138f
VS
122#endif
123
b46b1d59 124 // create a new, port specific, instance of the event loop used by wxApp
2ddff00c 125 virtual wxEventLoopBase *CreateEventLoop() = 0;
b46b1d59 126
c2ca375c
VZ
127#if wxUSE_TIMER
128 // return platform and toolkit dependent wxTimer implementation
129 virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0;
130#endif
d774f916 131
d254213e
PC
132#if wxUSE_THREADS
133 virtual void MutexGuiEnter();
134 virtual void MutexGuiLeave();
135#endif
136
d774f916
VZ
137 // functions returning port-specific information
138 // ------------------------------------------------------------------------
139
449090b5
VZ
140 // return information about the (native) toolkit currently used and its
141 // runtime (not compile-time) version.
8bb6b2c0
VZ
142 // returns wxPORT_BASE for console applications and one of the remaining
143 // wxPORT_* values for GUI applications.
1f5c6629 144 virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const = 0;
b98bd6af
VS
145
146 // return true if the port is using wxUniversal for the GUI, false if not
147 virtual bool IsUsingUniversalWidgets() const = 0;
db9febdf
RR
148
149 // return the name of the Desktop Environment such as
88bbc332 150 // "KDE" or "GNOME". May return an empty string.
d3a0a0ee
VZ
151 virtual wxString GetDesktopEnvironment() const = 0;
152
153 // returns a short string to identify the block of the standard command
154 // line options parsed automatically by current port: if this string is
155 // empty, there are no such options, otherwise the function also fills
156 // passed arrays with the names and the descriptions of those options.
157 virtual wxString GetStandardCmdLineOptions(wxArrayString& names,
158 wxArrayString& desc) const
159 {
160 wxUnusedVar(names);
161 wxUnusedVar(desc);
162
163 return wxEmptyString;
164 }
165
db9febdf
RR
166
167protected:
168#if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
169 // utility function: returns the stack frame as a plain wxString
170 virtual wxString GetAssertStackTrace();
171#endif
e2478fde
VZ
172};
173
174// ----------------------------------------------------------------------------
175// include the platform-specific version of the class
176// ----------------------------------------------------------------------------
177
532d575b
WS
178// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
179// Unix code (and otherwise __UNIX__ wouldn't be defined)
180// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 181#if defined(__WXPALMOS__)
ffecfa5a 182 #include "wx/palmos/apptbase.h"
532d575b 183#elif defined(__WIN32__)
e2478fde 184 #include "wx/msw/apptbase.h"
621ccd8a 185#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 186 #include "wx/unix/apptbase.h"
9fc852b7
SN
187#elif defined(__OS2__)
188 #include "wx/os2/apptbase.h"
46446cc2 189#else // no platform-specific methods to add to wxAppTraits
e2478fde 190 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 191 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
192 {
193 };
194#endif // platform
195
196// ============================================================================
197// standard traits for console and GUI applications
198// ============================================================================
199
200// ----------------------------------------------------------------------------
201// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
202// ----------------------------------------------------------------------------
203
7af1b539 204class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
205{
206public:
a1873279
VZ
207#if !wxUSE_CONSOLE_EVENTLOOP
208 virtual wxEventLoopBase *CreateEventLoop() { return NULL; }
209#endif // !wxUSE_CONSOLE_EVENTLOOP
210
e2478fde
VZ
211#if wxUSE_LOG
212 virtual wxLog *CreateLogTarget();
213#endif // wxUSE_LOG
214 virtual wxMessageOutput *CreateMessageOutput();
215#if wxUSE_FONTMAP
216 virtual wxFontMapper *CreateFontMapper();
217#endif // wxUSE_FONTMAP
f0244295 218 virtual wxRendererNative *CreateRenderer();
e2478fde
VZ
219
220#ifdef __WXDEBUG__
221 virtual bool ShowAssertDialog(const wxString& msg);
222#endif // __WXDEBUG__
223 virtual bool HasStderr();
224
225 virtual void ScheduleForDestroy(wxObject *object);
226 virtual void RemoveFromPendingDelete(wxObject *object);
8bb6b2c0
VZ
227
228 // the GetToolkitVersion for console application is always the same
1f5c6629 229 virtual wxPortId GetToolkitVersion(int *verMaj = NULL, int *verMin = NULL) const
8bb6b2c0
VZ
230 {
231 // no toolkits (wxBase is for console applications without GUI support)
232 // NB: zero means "no toolkit", -1 means "not initialized yet"
233 // so we must use zero here!
234 if (verMaj) *verMaj = 0;
235 if (verMin) *verMin = 0;
236 return wxPORT_BASE;
237 }
b98bd6af
VS
238
239 virtual bool IsUsingUniversalWidgets() const { return false; }
d3a0a0ee 240 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
e2478fde
VZ
241};
242
243// ----------------------------------------------------------------------------
244// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
245// ----------------------------------------------------------------------------
246
247#if wxUSE_GUI
248
53a2db12 249class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
250{
251public:
252#if wxUSE_LOG
253 virtual wxLog *CreateLogTarget();
254#endif // wxUSE_LOG
255 virtual wxMessageOutput *CreateMessageOutput();
256#if wxUSE_FONTMAP
257 virtual wxFontMapper *CreateFontMapper();
258#endif // wxUSE_FONTMAP
f0244295 259 virtual wxRendererNative *CreateRenderer();
e2478fde
VZ
260
261#ifdef __WXDEBUG__
262 virtual bool ShowAssertDialog(const wxString& msg);
263#endif // __WXDEBUG__
264 virtual bool HasStderr();
265
266 virtual void ScheduleForDestroy(wxObject *object);
267 virtual void RemoveFromPendingDelete(wxObject *object);
b98bd6af
VS
268
269 virtual bool IsUsingUniversalWidgets() const
270 {
271 #ifdef __WXUNIVERSAL__
272 return true;
273 #else
274 return false;
275 #endif
276 }
d3a0a0ee
VZ
277
278 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
e2478fde
VZ
279};
280
281#endif // wxUSE_GUI
282
283// ----------------------------------------------------------------------------
284// include the platform-specific version of the classes above
285// ----------------------------------------------------------------------------
286
532d575b 287// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 288#if defined(__WXPALMOS__)
ffecfa5a 289 #include "wx/palmos/apptrait.h"
532d575b 290#elif defined(__WIN32__)
e2478fde 291 #include "wx/msw/apptrait.h"
21d3d342
SN
292#elif defined(__OS2__)
293 #include "wx/os2/apptrait.h"
294#elif defined(__UNIX__)
2d2d4fc7 295 #include "wx/unix/apptrait.h"
9aecec9a
MW
296#elif defined(__DOS__)
297 #include "wx/msdos/apptrait.h"
4629016d 298#else
e2478fde 299 #if wxUSE_GUI
621ccd8a
SN
300 class wxGUIAppTraits : public wxGUIAppTraitsBase
301 {
621ccd8a 302 };
e2478fde 303 #endif // wxUSE_GUI
4629016d 304 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
621ccd8a 305 {
621ccd8a 306 };
e2478fde
VZ
307#endif // platform
308
309#endif // _WX_APPTRAIT_H_
310