]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
wxPyDataObjectSimple::SetData should not be const
[wxWidgets.git] / include / wx / apptrait.h
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$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APPTRAIT_H_
13 #define _WX_APPTRAIT_H_
14
15 #include "wx/string.h"
16
17 class WXDLLIMPEXP_BASE wxObject;
18 class WXDLLEXPORT wxAppTraits;
19 #if wxUSE_FONTMAP
20 class WXDLLEXPORT wxFontMapper;
21 #endif // wxUSE_FONTMAP
22 class WXDLLIMPEXP_BASE wxLog;
23 class WXDLLIMPEXP_BASE wxMessageOutput;
24 class WXDLLEXPORT wxRendererNative;
25 class WXDLLIMPEXP_BASE wxString;
26
27 class GSocketGUIFunctionsTable;
28
29 // ----------------------------------------------------------------------------
30 // toolkit information
31 // ----------------------------------------------------------------------------
32
33 // Information about the toolkit that the app is running under (e.g. wxMSW):
34 struct 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
47
48 // ----------------------------------------------------------------------------
49 // wxAppTraits: this class defines various configurable aspects of wxApp
50 // ----------------------------------------------------------------------------
51
52 class WXDLLIMPEXP_BASE wxStandardPathsBase;
53
54 class WXDLLIMPEXP_BASE wxAppTraitsBase
55 {
56 public:
57 // needed since this class declares virtual members
58 virtual ~wxAppTraitsBase() { }
59
60 // hooks for creating the global objects, may be overridden by the user
61 // ------------------------------------------------------------------------
62
63 #if wxUSE_LOG
64 // create the default log target
65 virtual wxLog *CreateLogTarget() = 0;
66 #endif // wxUSE_LOG
67
68 // create the global object used for printing out messages
69 virtual wxMessageOutput *CreateMessageOutput() = 0;
70
71 #if wxUSE_FONTMAP
72 // create the global font mapper object used for encodings/charset mapping
73 virtual wxFontMapper *CreateFontMapper() = 0;
74 #endif // wxUSE_FONTMAP
75
76 // get the renderer to use for drawing the generic controls (return value
77 // may be NULL in which case the default renderer for the current platform
78 // is used); this is used in GUI only and always returns NULL in console
79 //
80 // NB: returned pointer will be deleted by the caller
81 virtual wxRendererNative *CreateRenderer() = 0;
82
83 #if wxUSE_STDPATHS
84 // wxStandardPaths object is normally the same for wxBase and wxGUI
85 // except in the case of wxMac and wxCocoa
86 virtual wxStandardPathsBase& GetStandardPaths();
87 #endif // wxUSE_STDPATHS
88
89 // functions abstracting differences between GUI and console modes
90 // ------------------------------------------------------------------------
91
92 #ifdef __WXDEBUG__
93 // show the assert dialog with the specified message in GUI or just print
94 // the string to stderr in console mode
95 //
96 // base class version has an implementation (in spite of being pure
97 // virtual) in base/appbase.cpp which can be called as last resort.
98 //
99 // return true to suppress subsequent asserts, false to continue as before
100 virtual bool ShowAssertDialog(const wxString& msg) = 0;
101 #endif // __WXDEBUG__
102
103 // return true if fprintf(stderr) goes somewhere, false otherwise
104 virtual bool HasStderr() = 0;
105
106 // managing "pending delete" list: in GUI mode we can't immediately delete
107 // some objects because there may be unprocessed events for them and so we
108 // only do it during the next idle loop iteration while this is, of course,
109 // unnecessary in wxBase, so we have a few functions to abstract these
110 // operations
111
112 // add the object to the pending delete list in GUI, delete it immediately
113 // in wxBase
114 virtual void ScheduleForDestroy(wxObject *object) = 0;
115
116 // remove this object from the pending delete list in GUI, do nothing in
117 // wxBase
118 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
119
120 #if wxUSE_SOCKETS
121 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
122 // is needed because networking classes are in their own library and so
123 // they can't directly call GUI functions (the same net library can be
124 // used in both GUI and base apps). To complicate it further, GUI library
125 // ("wxCore") doesn't depend on networking library and so only a functions
126 // table can be passed around
127 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
128 #endif
129
130
131 // return information about what toolkit is running; we need for two things
132 // that are both contained in wxBase:
133 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
134 // Unix: in the former case it returns the information about the toolkit
135 // and in the latter -- about the OS, so we need to virtualize it
136 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
137 // signature in DLL name
138 virtual wxToolkitInfo& GetToolkitInfo() = 0;
139 };
140
141 // ----------------------------------------------------------------------------
142 // include the platform-specific version of the class
143 // ----------------------------------------------------------------------------
144
145 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
146 // Unix code (and otherwise __UNIX__ wouldn't be defined)
147 // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
148 #if defined(__WXPALMOS__)
149 #include "wx/palmos/apptbase.h"
150 #elif defined(__WIN32__)
151 #include "wx/msw/apptbase.h"
152 #elif defined(__UNIX__) && !defined(__EMX__)
153 #include "wx/unix/apptbase.h"
154 #elif defined(__WXMAC__)
155 #include "wx/mac/apptbase.h"
156 #elif defined(__OS2__)
157 #include "wx/os2/apptbase.h"
158 #else // no platform-specific methods to add to wxAppTraits
159 // wxAppTraits must be a class because it was forward declared as class
160 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
161 {
162 };
163 #endif // platform
164
165 // ============================================================================
166 // standard traits for console and GUI applications
167 // ============================================================================
168
169 // ----------------------------------------------------------------------------
170 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
171 // ----------------------------------------------------------------------------
172
173 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
174 {
175 public:
176 #if wxUSE_LOG
177 virtual wxLog *CreateLogTarget();
178 #endif // wxUSE_LOG
179 virtual wxMessageOutput *CreateMessageOutput();
180 #if wxUSE_FONTMAP
181 virtual wxFontMapper *CreateFontMapper();
182 #endif // wxUSE_FONTMAP
183 virtual wxRendererNative *CreateRenderer();
184 #if wxUSE_SOCKETS
185 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
186 #endif
187
188 #ifdef __WXDEBUG__
189 virtual bool ShowAssertDialog(const wxString& msg);
190 #endif // __WXDEBUG__
191 virtual bool HasStderr();
192
193 virtual void ScheduleForDestroy(wxObject *object);
194 virtual void RemoveFromPendingDelete(wxObject *object);
195 };
196
197 // ----------------------------------------------------------------------------
198 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
199 // ----------------------------------------------------------------------------
200
201 #if wxUSE_GUI
202
203 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
204 {
205 public:
206 #if wxUSE_LOG
207 virtual wxLog *CreateLogTarget();
208 #endif // wxUSE_LOG
209 virtual wxMessageOutput *CreateMessageOutput();
210 #if wxUSE_FONTMAP
211 virtual wxFontMapper *CreateFontMapper();
212 #endif // wxUSE_FONTMAP
213 virtual wxRendererNative *CreateRenderer();
214 #if wxUSE_SOCKETS
215 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
216 #endif
217
218 #ifdef __WXDEBUG__
219 virtual bool ShowAssertDialog(const wxString& msg);
220 #endif // __WXDEBUG__
221 virtual bool HasStderr();
222
223 virtual void ScheduleForDestroy(wxObject *object);
224 virtual void RemoveFromPendingDelete(wxObject *object);
225 };
226
227 #endif // wxUSE_GUI
228
229 // ----------------------------------------------------------------------------
230 // include the platform-specific version of the classes above
231 // ----------------------------------------------------------------------------
232
233 // ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
234 #if defined(__WXPALMOS__)
235 #include "wx/palmos/apptrait.h"
236 #elif defined(__WIN32__)
237 #include "wx/msw/apptrait.h"
238 #elif defined(__UNIX__) && !defined(__EMX__)
239 #include "wx/unix/apptrait.h"
240 #elif defined(__WXMAC__)
241 #include "wx/mac/apptrait.h"
242 #elif defined(__WXPM__)
243 #include "wx/os2/apptrait.h"
244 #else
245 // at least, we need an implementation of GetToolkitInfo !
246 #if wxUSE_GUI
247 class wxGUIAppTraits : public wxGUIAppTraitsBase
248 {
249 virtual wxToolkitInfo& GetToolkitInfo();
250 };
251 #endif // wxUSE_GUI
252 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
253 {
254 virtual wxToolkitInfo& GetToolkitInfo();
255 };
256 #endif // platform
257
258 #endif // _WX_APPTRAIT_H_
259