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
;
26 struct WXDLLIMPEXP_BASE wxToolkitInfo
;
28 // ----------------------------------------------------------------------------
29 // toolkit information
30 // ----------------------------------------------------------------------------
32 // Information about the toolkit that the app is running under (e.g. wxMSW):
33 struct WXDLLIMPEXP_BASE wxToolkitInfo
35 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
37 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
38 // "wxMSW/Universal"); "wxBase" for console apps:
40 // Version of the underlying toolkit or of the OS for console apps:
41 int versionMajor
, versionMinor
;
42 // OS mnenomics, e.g. wxGTK or wxMSW:
47 // ----------------------------------------------------------------------------
48 // wxAppTraits: this class defines various configurable aspects of wxApp
49 // ----------------------------------------------------------------------------
51 class WXDLLIMPEXP_BASE wxAppTraitsBase
54 // hooks for creating the global objects, may be overridden by the user
55 // ------------------------------------------------------------------------
58 // create the default log target
59 virtual wxLog
*CreateLogTarget() = 0;
62 // create the global object used for printing out messages
63 virtual wxMessageOutput
*CreateMessageOutput() = 0;
66 // create the global font mapper object used for encodings/charset mapping
67 virtual wxFontMapper
*CreateFontMapper() = 0;
68 #endif // wxUSE_FONTMAP
70 // get the renderer to use for drawing the generic controls (return value
71 // may be NULL in which case the default renderer for the current platform
72 // is used); this is used in GUI only and always returns NULL in console
74 // NB: returned pointer will be deleted by the caller
75 virtual wxRendererNative
*CreateRenderer() = 0;
78 // functions abstracting differences between GUI and console modes
79 // ------------------------------------------------------------------------
82 // show the assert dialog with the specified message in GUI or just print
83 // the string to stderr in console mode
85 // base class version has an implementation (in spite of being pure
86 // virtual) in base/appbase.cpp which can be called as last resort.
88 // return true to suppress subsequent asserts, false to continue as before
89 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
92 // return true if fprintf(stderr) goes somewhere, false otherwise
93 virtual bool HasStderr() = 0;
95 // managing "pending delete" list: in GUI mode we can't immediately delete
96 // some objects because there may be unprocessed events for them and so we
97 // only do it during the next idle loop iteration while this is, of course,
98 // unnecessary in wxBase, so we have a few functions to abstract these
101 // add the object to the pending delete list in GUI, delete it immediately
103 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
105 // remove this object from the pending delete list in GUI, do nothing in
107 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
110 // return information about what toolkit is running; we need for two things
111 // that are both contained in wxBase:
112 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
113 // Unix: in the former case it returns the information about the toolkit
114 // and in the latter -- about the OS, so we need to virtualize it
115 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
116 // signature in DLL name
117 virtual wxToolkitInfo
*GetToolkitInfo() = 0;
120 // ----------------------------------------------------------------------------
121 // include the platform-specific version of the class
122 // ----------------------------------------------------------------------------
124 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
125 // Unix code (and otherwise __UNIX__ wouldn't be defined)
126 #if defined(__WXMSW__)
127 #include "wx/msw/apptbase.h"
128 #elif defined(__UNIX__)
129 #include "wx/unix/apptbase.h"
130 #elif defined(__WXMAC__)
131 #include "wx/mac/apptbase.h"
132 #else // no platform-specific methods to add to wxAppTraits
133 // wxAppTraits must be a class because it was forward declared as class
134 class WXDLLIMPEXP_BASE wxAppTraits
: public wxAppTraitsBase
139 // ============================================================================
140 // standard traits for console and GUI applications
141 // ============================================================================
143 // ----------------------------------------------------------------------------
144 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
145 // ----------------------------------------------------------------------------
147 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase
: public wxAppTraits
151 virtual wxLog
*CreateLogTarget();
153 virtual wxMessageOutput
*CreateMessageOutput();
155 virtual wxFontMapper
*CreateFontMapper();
156 #endif // wxUSE_FONTMAP
157 virtual wxRendererNative
*CreateRenderer();
160 virtual bool ShowAssertDialog(const wxString
& msg
);
161 #endif // __WXDEBUG__
162 virtual bool HasStderr();
164 virtual void ScheduleForDestroy(wxObject
*object
);
165 virtual void RemoveFromPendingDelete(wxObject
*object
);
168 // ----------------------------------------------------------------------------
169 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
170 // ----------------------------------------------------------------------------
174 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
178 virtual wxLog
*CreateLogTarget();
180 virtual wxMessageOutput
*CreateMessageOutput();
182 virtual wxFontMapper
*CreateFontMapper();
183 #endif // wxUSE_FONTMAP
184 virtual wxRendererNative
*CreateRenderer();
187 virtual bool ShowAssertDialog(const wxString
& msg
);
188 #endif // __WXDEBUG__
189 virtual bool HasStderr();
191 virtual void ScheduleForDestroy(wxObject
*object
);
192 virtual void RemoveFromPendingDelete(wxObject
*object
);
197 // ----------------------------------------------------------------------------
198 // include the platform-specific version of the classes above
199 // ----------------------------------------------------------------------------
201 #if defined(__WXMSW__)
202 #include "wx/msw/apptrait.h"
203 #elif defined(__UNIX__)
204 #include "wx/unix/apptrait.h"
205 #elif defined(__WXMAC__)
206 #include "wx/mac/apptrait.h"
207 #else // no platform-specific methods to add to wxAppTraits
209 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
211 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
214 #endif // _WX_APPTRAIT_H_