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
;
27 // ----------------------------------------------------------------------------
28 // toolkit information
29 // ----------------------------------------------------------------------------
31 // Information about the toolkit that the app is running under (e.g. wxMSW):
32 struct WXDLLIMPEXP_BASE wxToolkitInfo
34 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
36 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
37 // "wxMSW/Universal"); "wxBase" for console apps:
39 // Version of the underlying toolkit or of the OS for console apps:
40 int versionMajor
, versionMinor
;
41 // OS mnenomics, e.g. wxGTK or wxMSW:
46 // ----------------------------------------------------------------------------
47 // wxAppTraits: this class defines various configurable aspects of wxApp
48 // ----------------------------------------------------------------------------
50 class WXDLLIMPEXP_BASE wxAppTraitsBase
53 // hooks for creating the global objects, may be overridden by the user
54 // ------------------------------------------------------------------------
57 // create the default log target
58 virtual wxLog
*CreateLogTarget() = 0;
61 // create the global object used for printing out messages
62 virtual wxMessageOutput
*CreateMessageOutput() = 0;
65 // create the global font mapper object used for encodings/charset mapping
66 virtual wxFontMapper
*CreateFontMapper() = 0;
67 #endif // wxUSE_FONTMAP
69 // get the renderer to use for drawing the generic controls (return value
70 // may be NULL in which case the default renderer for the current platform
71 // is used); this is used in GUI only and always returns NULL in console
73 // NB: returned pointer will be deleted by the caller
74 virtual wxRendererNative
*CreateRenderer() = 0;
77 // functions abstracting differences between GUI and console modes
78 // ------------------------------------------------------------------------
81 // show the assert dialog with the specified message in GUI or just print
82 // the string to stderr in console mode
84 // base class version has an implementation (in spite of being pure
85 // virtual) in base/appbase.cpp which can be called as last resort.
87 // return true to suppress subsequent asserts, false to continue as before
88 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
91 // return true if fprintf(stderr) goes somewhere, false otherwise
92 virtual bool HasStderr() = 0;
94 // managing "pending delete" list: in GUI mode we can't immediately delete
95 // some objects because there may be unprocessed events for them and so we
96 // only do it during the next idle loop iteration while this is, of course,
97 // unnecessary in wxBase, so we have a few functions to abstract these
100 // add the object to the pending delete list in GUI, delete it immediately
102 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
104 // remove this object from the pending delete list in GUI, do nothing in
106 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
109 // return information about what toolkit is running; we need for two things
110 // that are both contained in wxBase:
111 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
112 // Unix: in the former case it returns the information about the toolkit
113 // and in the latter -- about the OS, so we need to virtualize it
114 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
115 // signature in DLL name
116 virtual wxToolkitInfo
& GetToolkitInfo() = 0;
119 // ----------------------------------------------------------------------------
120 // include the platform-specific version of the class
121 // ----------------------------------------------------------------------------
123 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
124 // Unix code (and otherwise __UNIX__ wouldn't be defined)
125 #if defined(__WXMSW__)
126 #include "wx/msw/apptbase.h"
127 #elif defined(__UNIX__)
128 #include "wx/unix/apptbase.h"
129 #elif defined(__WXMAC__)
130 #include "wx/mac/apptbase.h"
131 #else // no platform-specific methods to add to wxAppTraits
132 // wxAppTraits must be a class because it was forward declared as class
133 class WXDLLIMPEXP_BASE wxAppTraits
: public wxAppTraitsBase
138 // ============================================================================
139 // standard traits for console and GUI applications
140 // ============================================================================
142 // ----------------------------------------------------------------------------
143 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
144 // ----------------------------------------------------------------------------
146 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase
: public wxAppTraits
150 virtual wxLog
*CreateLogTarget();
152 virtual wxMessageOutput
*CreateMessageOutput();
154 virtual wxFontMapper
*CreateFontMapper();
155 #endif // wxUSE_FONTMAP
156 virtual wxRendererNative
*CreateRenderer();
159 virtual bool ShowAssertDialog(const wxString
& msg
);
160 #endif // __WXDEBUG__
161 virtual bool HasStderr();
163 virtual void ScheduleForDestroy(wxObject
*object
);
164 virtual void RemoveFromPendingDelete(wxObject
*object
);
167 // ----------------------------------------------------------------------------
168 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
169 // ----------------------------------------------------------------------------
173 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
177 virtual wxLog
*CreateLogTarget();
179 virtual wxMessageOutput
*CreateMessageOutput();
181 virtual wxFontMapper
*CreateFontMapper();
182 #endif // wxUSE_FONTMAP
183 virtual wxRendererNative
*CreateRenderer();
186 virtual bool ShowAssertDialog(const wxString
& msg
);
187 #endif // __WXDEBUG__
188 virtual bool HasStderr();
190 virtual void ScheduleForDestroy(wxObject
*object
);
191 virtual void RemoveFromPendingDelete(wxObject
*object
);
196 // ----------------------------------------------------------------------------
197 // include the platform-specific version of the classes above
198 // ----------------------------------------------------------------------------
200 #if defined(__WXMSW__)
201 #include "wx/msw/apptrait.h"
202 #elif defined(__UNIX__)
203 #include "wx/unix/apptrait.h"
204 #elif defined(__WXMAC__)
205 #include "wx/mac/apptrait.h"
206 #else // no platform-specific methods to add to wxAppTraits
208 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
210 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
213 #endif // _WX_APPTRAIT_H_