]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
Removed this file since it was only stubs and we now have the common
[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@wxwindows.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 extern "C"
28 {
29 struct GSocketGUIFunctionsTable;
30 }
31
32 // FIXME: Eventually unify Mac OS 9
33 class GSocketBSD;
34
35 // ----------------------------------------------------------------------------
36 // toolkit information
37 // ----------------------------------------------------------------------------
38
39 // Information about the toolkit that the app is running under (e.g. wxMSW):
40 struct WXDLLIMPEXP_BASE wxToolkitInfo
41 {
42 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
43 wxString shortName;
44 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
45 // "wxMSW/Universal"); "wxBase" for console apps:
46 wxString name;
47 // Version of the underlying toolkit or of the OS for console apps:
48 int versionMajor, versionMinor;
49 // OS mnenomics, e.g. wxGTK or wxMSW:
50 int os;
51 };
52
53
54 // ----------------------------------------------------------------------------
55 // wxAppTraits: this class defines various configurable aspects of wxApp
56 // ----------------------------------------------------------------------------
57
58 class WXDLLIMPEXP_BASE wxAppTraitsBase
59 {
60 public:
61 // hooks for creating the global objects, may be overridden by the user
62 // ------------------------------------------------------------------------
63
64 #if wxUSE_LOG
65 // create the default log target
66 virtual wxLog *CreateLogTarget() = 0;
67 #endif // wxUSE_LOG
68
69 // create the global object used for printing out messages
70 virtual wxMessageOutput *CreateMessageOutput() = 0;
71
72 #if wxUSE_FONTMAP
73 // create the global font mapper object used for encodings/charset mapping
74 virtual wxFontMapper *CreateFontMapper() = 0;
75 #endif // wxUSE_FONTMAP
76
77 // get the renderer to use for drawing the generic controls (return value
78 // may be NULL in which case the default renderer for the current platform
79 // is used); this is used in GUI only and always returns NULL in console
80 //
81 // NB: returned pointer will be deleted by the caller
82 virtual wxRendererNative *CreateRenderer() = 0;
83
84
85 // functions abstracting differences between GUI and console modes
86 // ------------------------------------------------------------------------
87
88 #ifdef __WXDEBUG__
89 // show the assert dialog with the specified message in GUI or just print
90 // the string to stderr in console mode
91 //
92 // base class version has an implementation (in spite of being pure
93 // virtual) in base/appbase.cpp which can be called as last resort.
94 //
95 // return true to suppress subsequent asserts, false to continue as before
96 virtual bool ShowAssertDialog(const wxString& msg) = 0;
97 #endif // __WXDEBUG__
98
99 // return true if fprintf(stderr) goes somewhere, false otherwise
100 virtual bool HasStderr() = 0;
101
102 // managing "pending delete" list: in GUI mode we can't immediately delete
103 // some objects because there may be unprocessed events for them and so we
104 // only do it during the next idle loop iteration while this is, of course,
105 // unnecessary in wxBase, so we have a few functions to abstract these
106 // operations
107
108 // add the object to the pending delete list in GUI, delete it immediately
109 // in wxBase
110 virtual void ScheduleForDestroy(wxObject *object) = 0;
111
112 // remove this object from the pending delete list in GUI, do nothing in
113 // wxBase
114 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
115
116 #if wxUSE_SOCKETS
117 // return table of GUI callbacks for GSocket code or NULL in wxBase
118 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
119
120 // return a new GSocket with the EventLoop_* stuff implemented.
121 // or at least stubbed (i.e. wxBase)
122 virtual GSocketBSD* CreateGSocket() = 0;
123 #endif
124
125
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
133 virtual wxToolkitInfo& GetToolkitInfo() = 0;
134 };
135
136 // ----------------------------------------------------------------------------
137 // include the platform-specific version of the class
138 // ----------------------------------------------------------------------------
139
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)
142 #if defined(__WXMSW__)
143 #include "wx/msw/apptbase.h"
144 #elif defined(__UNIX__) && !defined(__EMX__)
145 #include "wx/unix/apptbase.h"
146 #elif defined(__WXMAC__)
147 #include "wx/mac/apptbase.h"
148 #elif defined(__OS2__)
149 #include "wx/os2/apptbase.h"
150 #else // no platform-specific methods to add to wxAppTraits
151 // wxAppTraits must be a class because it was forward declared as class
152 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
153 {
154 };
155 #endif // platform
156
157 // ============================================================================
158 // standard traits for console and GUI applications
159 // ============================================================================
160
161 // ----------------------------------------------------------------------------
162 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
163 // ----------------------------------------------------------------------------
164
165 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
166 {
167 public:
168 #if wxUSE_LOG
169 virtual wxLog *CreateLogTarget();
170 #endif // wxUSE_LOG
171 virtual wxMessageOutput *CreateMessageOutput();
172 #if wxUSE_FONTMAP
173 virtual wxFontMapper *CreateFontMapper();
174 #endif // wxUSE_FONTMAP
175 virtual wxRendererNative *CreateRenderer();
176 #if wxUSE_SOCKETS
177 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
178 virtual GSocketBSD* CreateGSocket();
179 #endif
180
181 #ifdef __WXDEBUG__
182 virtual bool ShowAssertDialog(const wxString& msg);
183 #endif // __WXDEBUG__
184 virtual bool HasStderr();
185
186 virtual void ScheduleForDestroy(wxObject *object);
187 virtual void RemoveFromPendingDelete(wxObject *object);
188 };
189
190 // ----------------------------------------------------------------------------
191 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
192 // ----------------------------------------------------------------------------
193
194 #if wxUSE_GUI
195
196 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
197 {
198 public:
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
206 virtual wxRendererNative *CreateRenderer();
207 #if wxUSE_SOCKETS
208 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
209 // return a new GSocket with the EventLoop_* stuff implemented.
210 // TODO: Remove this because each GUI should implement it separately
211 virtual GSocketBSD* CreateGSocket();
212 #endif
213
214 #ifdef __WXDEBUG__
215 virtual bool ShowAssertDialog(const wxString& msg);
216 #endif // __WXDEBUG__
217 virtual bool HasStderr();
218
219 virtual void ScheduleForDestroy(wxObject *object);
220 virtual void RemoveFromPendingDelete(wxObject *object);
221 };
222
223 #endif // wxUSE_GUI
224
225 // ----------------------------------------------------------------------------
226 // include the platform-specific version of the classes above
227 // ----------------------------------------------------------------------------
228
229 #if defined(__WXMSW__)
230 #include "wx/msw/apptrait.h"
231 #elif defined(__UNIX__) && !defined(__EMX__)
232 #include "wx/unix/apptrait.h"
233 #elif defined(__WXMAC__)
234 #include "wx/mac/apptrait.h"
235 #elif defined(__WXPM__)
236 #include "wx/os2/apptrait.h"
237 #else
238 // at least, we need an implementation of GetToolkitInfo !
239 #if wxUSE_GUI
240 class wxGUIAppTraits : public wxGUIAppTraitsBase
241 {
242 virtual wxToolkitInfo& GetToolkitInfo();
243 };
244 #endif // wxUSE_GUI
245 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
246 {
247 virtual wxToolkitInfo& GetToolkitInfo();
248 };
249 #endif // platform
250
251 #endif // _WX_APPTRAIT_H_
252