]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
undef CreateWindow too, even if we don't use it ourselves it's still a very common...
[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
VS
15#include "wx/string.h"
16
17class WXDLLIMPEXP_BASE wxObject;
e2478fde
VZ
18class WXDLLEXPORT wxAppTraits;
19#if wxUSE_FONTMAP
20 class WXDLLEXPORT wxFontMapper;
21#endif // wxUSE_FONTMAP
a8eaaeb2
VS
22class WXDLLIMPEXP_BASE wxLog;
23class WXDLLIMPEXP_BASE wxMessageOutput;
f0244295 24class WXDLLEXPORT wxRendererNative;
a8eaaeb2 25class WXDLLIMPEXP_BASE wxString;
a8eaaeb2 26
3e1400ac 27class GSocketGUIFunctionsTable;
38bb138f 28
a8eaaeb2
VS
29// ----------------------------------------------------------------------------
30// toolkit information
31// ----------------------------------------------------------------------------
32
33// Information about the toolkit that the app is running under (e.g. wxMSW):
34struct WXDLLIMPEXP_BASE wxToolkitInfo
35{
36 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
37 wxString shortName;
38 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
39 // "wxMSW/Universal"); "wxBase" for console apps:
40 wxString name;
41 // Version of the underlying toolkit or of the OS for console apps:
42 int versionMajor, versionMinor;
43 // OS mnenomics, e.g. wxGTK or wxMSW:
44 int os;
45};
46
e2478fde
VZ
47
48// ----------------------------------------------------------------------------
49// wxAppTraits: this class defines various configurable aspects of wxApp
50// ----------------------------------------------------------------------------
51
fc480dc1
DE
52class WXDLLIMPEXP_BASE wxStandardPathsBase;
53
7af1b539 54class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
55{
56public:
e2478fde
VZ
57 // hooks for creating the global objects, may be overridden by the user
58 // ------------------------------------------------------------------------
59
60#if wxUSE_LOG
61 // create the default log target
62 virtual wxLog *CreateLogTarget() = 0;
63#endif // wxUSE_LOG
64
65 // create the global object used for printing out messages
66 virtual wxMessageOutput *CreateMessageOutput() = 0;
67
68#if wxUSE_FONTMAP
69 // create the global font mapper object used for encodings/charset mapping
70 virtual wxFontMapper *CreateFontMapper() = 0;
71#endif // wxUSE_FONTMAP
72
f0244295
VZ
73 // get the renderer to use for drawing the generic controls (return value
74 // may be NULL in which case the default renderer for the current platform
75 // is used); this is used in GUI only and always returns NULL in console
76 //
77 // NB: returned pointer will be deleted by the caller
78 virtual wxRendererNative *CreateRenderer() = 0;
79
fc480dc1
DE
80 // wxStandardPaths object is normally the same for wxBase and wxGUI
81 // except in the case of wxMac and wxCocoa
82 virtual wxStandardPathsBase& GetStandardPaths();
e2478fde
VZ
83
84 // functions abstracting differences between GUI and console modes
85 // ------------------------------------------------------------------------
86
87#ifdef __WXDEBUG__
88 // show the assert dialog with the specified message in GUI or just print
89 // the string to stderr in console mode
90 //
91 // base class version has an implementation (in spite of being pure
92 // virtual) in base/appbase.cpp which can be called as last resort.
93 //
94 // return true to suppress subsequent asserts, false to continue as before
95 virtual bool ShowAssertDialog(const wxString& msg) = 0;
96#endif // __WXDEBUG__
97
98 // return true if fprintf(stderr) goes somewhere, false otherwise
99 virtual bool HasStderr() = 0;
100
101 // managing "pending delete" list: in GUI mode we can't immediately delete
102 // some objects because there may be unprocessed events for them and so we
103 // only do it during the next idle loop iteration while this is, of course,
104 // unnecessary in wxBase, so we have a few functions to abstract these
105 // operations
106
107 // add the object to the pending delete list in GUI, delete it immediately
108 // in wxBase
109 virtual void ScheduleForDestroy(wxObject *object) = 0;
110
111 // remove this object from the pending delete list in GUI, do nothing in
112 // wxBase
113 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
2739d4f0 114
38bb138f 115#if wxUSE_SOCKETS
321b8029 116 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
4629016d 117 // is needed because networking classes are in their own library and so
321b8029
VS
118 // they can't directly call GUI functions (the same net library can be
119 // used in both GUI and base apps). To complicate it further, GUI library
120 // ("wxCore") doesn't depend on networking library and so only a functions
121 // table can be passed around
38bb138f
VS
122 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
123#endif
124
2739d4f0 125
a8eaaeb2
VS
126 // return information about what toolkit is running; we need for two things
127 // that are both contained in wxBase:
128 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
129 // Unix: in the former case it returns the information about the toolkit
130 // and in the latter -- about the OS, so we need to virtualize it
131 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
132 // signature in DLL name
324899f6 133 virtual wxToolkitInfo& GetToolkitInfo() = 0;
e2478fde
VZ
134};
135
136// ----------------------------------------------------------------------------
137// include the platform-specific version of the class
138// ----------------------------------------------------------------------------
139
29c99ad3
VZ
140// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
141// Unix code (and otherwise __UNIX__ wouldn't be defined)
ffecfa5a
JS
142#if defined(__PALMOS__)
143 #include "wx/palmos/apptbase.h"
144#elif defined(__WXMSW__)
e2478fde 145 #include "wx/msw/apptbase.h"
621ccd8a 146#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 147 #include "wx/unix/apptbase.h"
29c99ad3
VZ
148#elif defined(__WXMAC__)
149 #include "wx/mac/apptbase.h"
9fc852b7
SN
150#elif defined(__OS2__)
151 #include "wx/os2/apptbase.h"
46446cc2 152#else // no platform-specific methods to add to wxAppTraits
e2478fde 153 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 154 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
155 {
156 };
157#endif // platform
158
159// ============================================================================
160// standard traits for console and GUI applications
161// ============================================================================
162
163// ----------------------------------------------------------------------------
164// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
165// ----------------------------------------------------------------------------
166
7af1b539 167class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
168{
169public:
170#if wxUSE_LOG
171 virtual wxLog *CreateLogTarget();
172#endif // wxUSE_LOG
173 virtual wxMessageOutput *CreateMessageOutput();
174#if wxUSE_FONTMAP
175 virtual wxFontMapper *CreateFontMapper();
176#endif // wxUSE_FONTMAP
f0244295 177 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
178#if wxUSE_SOCKETS
179 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
180#endif
e2478fde
VZ
181
182#ifdef __WXDEBUG__
183 virtual bool ShowAssertDialog(const wxString& msg);
184#endif // __WXDEBUG__
185 virtual bool HasStderr();
186
187 virtual void ScheduleForDestroy(wxObject *object);
188 virtual void RemoveFromPendingDelete(wxObject *object);
189};
190
191// ----------------------------------------------------------------------------
192// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
193// ----------------------------------------------------------------------------
194
195#if wxUSE_GUI
196
94826170 197class WXDLLEXPORT wxGUIAppTraitsBase : 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);
219};
220
221#endif // wxUSE_GUI
222
223// ----------------------------------------------------------------------------
224// include the platform-specific version of the classes above
225// ----------------------------------------------------------------------------
226
ffecfa5a
JS
227#if defined(__PALMOS__)
228 #include "wx/palmos/apptrait.h"
229#elif defined(__WXMSW__)
e2478fde 230 #include "wx/msw/apptrait.h"
621ccd8a 231#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 232 #include "wx/unix/apptrait.h"
29c99ad3
VZ
233#elif defined(__WXMAC__)
234 #include "wx/mac/apptrait.h"
7332d96b 235#elif defined(__WXPM__)
a637417c 236 #include "wx/os2/apptrait.h"
4629016d 237#else
621ccd8a 238 // at least, we need an implementation of GetToolkitInfo !
e2478fde 239 #if wxUSE_GUI
621ccd8a
SN
240 class wxGUIAppTraits : public wxGUIAppTraitsBase
241 {
242 virtual wxToolkitInfo& GetToolkitInfo();
243 };
e2478fde 244 #endif // wxUSE_GUI
4629016d 245 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
621ccd8a
SN
246 {
247 virtual wxToolkitInfo& GetToolkitInfo();
248 };
e2478fde
VZ
249#endif // platform
250
251#endif // _WX_APPTRAIT_H_
252