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