]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
corrected comments for wxMac compilation
[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 // ----------------------------------------------------------------------------
33 // toolkit information
34 // ----------------------------------------------------------------------------
35
36 // Information about the toolkit that the app is running under (e.g. wxMSW):
37 struct WXDLLIMPEXP_BASE wxToolkitInfo
38 {
39 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
40 wxString shortName;
41 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
42 // "wxMSW/Universal"); "wxBase" for console apps:
43 wxString name;
44 // Version of the underlying toolkit or of the OS for console apps:
45 int versionMajor, versionMinor;
46 // OS mnenomics, e.g. wxGTK or wxMSW:
47 int os;
48 };
49
50
51 // ----------------------------------------------------------------------------
52 // wxAppTraits: this class defines various configurable aspects of wxApp
53 // ----------------------------------------------------------------------------
54
55 class WXDLLIMPEXP_BASE wxAppTraitsBase
56 {
57 public:
58 // hooks for creating the global objects, may be overridden by the user
59 // ------------------------------------------------------------------------
60
61 #if wxUSE_LOG
62 // create the default log target
63 virtual wxLog *CreateLogTarget() = 0;
64 #endif // wxUSE_LOG
65
66 // create the global object used for printing out messages
67 virtual wxMessageOutput *CreateMessageOutput() = 0;
68
69 #if wxUSE_FONTMAP
70 // create the global font mapper object used for encodings/charset mapping
71 virtual wxFontMapper *CreateFontMapper() = 0;
72 #endif // wxUSE_FONTMAP
73
74 // get the renderer to use for drawing the generic controls (return value
75 // may be NULL in which case the default renderer for the current platform
76 // is used); this is used in GUI only and always returns NULL in console
77 //
78 // NB: returned pointer will be deleted by the caller
79 virtual wxRendererNative *CreateRenderer() = 0;
80
81
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;
112
113 #if wxUSE_SOCKETS
114 // return table of GUI callbacks for GSocket code or NULL in wxBase
115 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
116 #endif
117
118
119 // return information about what toolkit is running; we need for two things
120 // that are both contained in wxBase:
121 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
122 // Unix: in the former case it returns the information about the toolkit
123 // and in the latter -- about the OS, so we need to virtualize it
124 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
125 // signature in DLL name
126 virtual wxToolkitInfo& GetToolkitInfo() = 0;
127 };
128
129 // ----------------------------------------------------------------------------
130 // include the platform-specific version of the class
131 // ----------------------------------------------------------------------------
132
133 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
134 // Unix code (and otherwise __UNIX__ wouldn't be defined)
135 #if defined(__WXMSW__)
136 #include "wx/msw/apptbase.h"
137 #elif defined(__UNIX__) && !defined(__EMX__)
138 #include "wx/unix/apptbase.h"
139 #elif defined(__WXMAC__)
140 #include "wx/mac/apptbase.h"
141 #elif defined(__OS2__)
142 #include "wx/os2/apptbase.h"
143 #else // no platform-specific methods to add to wxAppTraits
144 // wxAppTraits must be a class because it was forward declared as class
145 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
146 {
147 };
148 #endif // platform
149
150 // ============================================================================
151 // standard traits for console and GUI applications
152 // ============================================================================
153
154 // ----------------------------------------------------------------------------
155 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
156 // ----------------------------------------------------------------------------
157
158 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
159 {
160 public:
161 #if wxUSE_LOG
162 virtual wxLog *CreateLogTarget();
163 #endif // wxUSE_LOG
164 virtual wxMessageOutput *CreateMessageOutput();
165 #if wxUSE_FONTMAP
166 virtual wxFontMapper *CreateFontMapper();
167 #endif // wxUSE_FONTMAP
168 virtual wxRendererNative *CreateRenderer();
169 #if wxUSE_SOCKETS
170 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
171 #endif
172
173 #ifdef __WXDEBUG__
174 virtual bool ShowAssertDialog(const wxString& msg);
175 #endif // __WXDEBUG__
176 virtual bool HasStderr();
177
178 virtual void ScheduleForDestroy(wxObject *object);
179 virtual void RemoveFromPendingDelete(wxObject *object);
180 };
181
182 // ----------------------------------------------------------------------------
183 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
184 // ----------------------------------------------------------------------------
185
186 #if wxUSE_GUI
187
188 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
189 {
190 public:
191 #if wxUSE_LOG
192 virtual wxLog *CreateLogTarget();
193 #endif // wxUSE_LOG
194 virtual wxMessageOutput *CreateMessageOutput();
195 #if wxUSE_FONTMAP
196 virtual wxFontMapper *CreateFontMapper();
197 #endif // wxUSE_FONTMAP
198 virtual wxRendererNative *CreateRenderer();
199 #if wxUSE_SOCKETS
200 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
201 #endif
202
203 #ifdef __WXDEBUG__
204 virtual bool ShowAssertDialog(const wxString& msg);
205 #endif // __WXDEBUG__
206 virtual bool HasStderr();
207
208 virtual void ScheduleForDestroy(wxObject *object);
209 virtual void RemoveFromPendingDelete(wxObject *object);
210 };
211
212 #endif // wxUSE_GUI
213
214 // ----------------------------------------------------------------------------
215 // include the platform-specific version of the classes above
216 // ----------------------------------------------------------------------------
217
218 #if defined(__WXMSW__)
219 #include "wx/msw/apptrait.h"
220 #elif defined(__UNIX__) && !defined(__EMX__)
221 #include "wx/unix/apptrait.h"
222 #elif defined(__WXMAC__)
223 #include "wx/mac/apptrait.h"
224 #elif defined(__WXPM__)
225 #include "wx/os2/apptrait.h"
226 #else
227 // at least, we need an implementation of GetToolkitInfo !
228 #if wxUSE_GUI
229 class wxGUIAppTraits : public wxGUIAppTraitsBase
230 {
231 virtual wxToolkitInfo& GetToolkitInfo();
232 };
233 #endif // wxUSE_GUI
234 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
235 {
236 virtual wxToolkitInfo& GetToolkitInfo();
237 };
238 #endif // platform
239
240 #endif // _WX_APPTRAIT_H_
241