1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of wxAppTraits and derived classes
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_APPTRAIT_H_
13 #define _WX_APPTRAIT_H_
15 #include "wx/string.h"
17 class WXDLLIMPEXP_BASE wxObject
;
18 class WXDLLEXPORT wxAppTraits
;
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
;
29 struct GSocketGUIFunctionsTable
;
32 // FIXME: Eventually unify Mac OS 9
35 // ----------------------------------------------------------------------------
36 // toolkit information
37 // ----------------------------------------------------------------------------
39 // Information about the toolkit that the app is running under (e.g. wxMSW):
40 struct WXDLLIMPEXP_BASE wxToolkitInfo
42 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
44 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
45 // "wxMSW/Universal"); "wxBase" for console apps:
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:
54 // ----------------------------------------------------------------------------
55 // wxAppTraits: this class defines various configurable aspects of wxApp
56 // ----------------------------------------------------------------------------
58 class WXDLLIMPEXP_BASE wxAppTraitsBase
61 // hooks for creating the global objects, may be overridden by the user
62 // ------------------------------------------------------------------------
65 // create the default log target
66 virtual wxLog
*CreateLogTarget() = 0;
69 // create the global object used for printing out messages
70 virtual wxMessageOutput
*CreateMessageOutput() = 0;
73 // create the global font mapper object used for encodings/charset mapping
74 virtual wxFontMapper
*CreateFontMapper() = 0;
75 #endif // wxUSE_FONTMAP
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
81 // NB: returned pointer will be deleted by the caller
82 virtual wxRendererNative
*CreateRenderer() = 0;
85 // functions abstracting differences between GUI and console modes
86 // ------------------------------------------------------------------------
89 // show the assert dialog with the specified message in GUI or just print
90 // the string to stderr in console mode
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.
95 // return true to suppress subsequent asserts, false to continue as before
96 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
99 // return true if fprintf(stderr) goes somewhere, false otherwise
100 virtual bool HasStderr() = 0;
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
108 // add the object to the pending delete list in GUI, delete it immediately
110 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
112 // remove this object from the pending delete list in GUI, do nothing in
114 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
117 // return table of GUI callbacks for GSocket code or NULL in wxBase
118 virtual GSocketGUIFunctionsTable
* GetSocketGUIFunctionsTable() = 0;
120 // return a new GSocket with the EventLoop_* stuff implemented.
121 // or at least stubbed (i.e. wxBase)
122 virtual GSocketBSD
* CreateGSocket() = 0;
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;
136 // ----------------------------------------------------------------------------
137 // include the platform-specific version of the class
138 // ----------------------------------------------------------------------------
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
157 // ============================================================================
158 // standard traits for console and GUI applications
159 // ============================================================================
161 // ----------------------------------------------------------------------------
162 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
163 // ----------------------------------------------------------------------------
165 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase
: public wxAppTraits
169 virtual wxLog
*CreateLogTarget();
171 virtual wxMessageOutput
*CreateMessageOutput();
173 virtual wxFontMapper
*CreateFontMapper();
174 #endif // wxUSE_FONTMAP
175 virtual wxRendererNative
*CreateRenderer();
177 virtual GSocketGUIFunctionsTable
* GetSocketGUIFunctionsTable();
178 virtual GSocketBSD
* CreateGSocket();
182 virtual bool ShowAssertDialog(const wxString
& msg
);
183 #endif // __WXDEBUG__
184 virtual bool HasStderr();
186 virtual void ScheduleForDestroy(wxObject
*object
);
187 virtual void RemoveFromPendingDelete(wxObject
*object
);
190 // ----------------------------------------------------------------------------
191 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
192 // ----------------------------------------------------------------------------
196 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
200 virtual wxLog
*CreateLogTarget();
202 virtual wxMessageOutput
*CreateMessageOutput();
204 virtual wxFontMapper
*CreateFontMapper();
205 #endif // wxUSE_FONTMAP
206 virtual wxRendererNative
*CreateRenderer();
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();
215 virtual bool ShowAssertDialog(const wxString
& msg
);
216 #endif // __WXDEBUG__
217 virtual bool HasStderr();
219 virtual void ScheduleForDestroy(wxObject
*object
);
220 virtual void RemoveFromPendingDelete(wxObject
*object
);
225 // ----------------------------------------------------------------------------
226 // include the platform-specific version of the classes above
227 // ----------------------------------------------------------------------------
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"
238 // at least, we need an implementation of GetToolkitInfo !
240 class wxGUIAppTraits
: public wxGUIAppTraitsBase
242 virtual wxToolkitInfo
& GetToolkitInfo();
245 class wxConsoleAppTraits
: public wxConsoleAppTraitsBase
247 virtual wxToolkitInfo
& GetToolkitInfo();
251 #endif // _WX_APPTRAIT_H_