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 class WXDLLEXPORT wxObject
;
16 class WXDLLEXPORT wxAppTraits
;
18 class WXDLLEXPORT wxFontMapper
;
19 #endif // wxUSE_FONTMAP
20 class WXDLLEXPORT wxLog
;
21 class WXDLLEXPORT wxMessageOutput
;
22 class WXDLLEXPORT wxRendererNative
;
23 class WXDLLEXPORT wxString
;
25 // ----------------------------------------------------------------------------
26 // wxAppTraits: this class defines various configurable aspects of wxApp
27 // ----------------------------------------------------------------------------
29 class WXDLLIMPEXP_BASE wxAppTraitsBase
32 // hooks for creating the global objects, may be overridden by the user
33 // ------------------------------------------------------------------------
36 // create the default log target
37 virtual wxLog
*CreateLogTarget() = 0;
40 // create the global object used for printing out messages
41 virtual wxMessageOutput
*CreateMessageOutput() = 0;
44 // create the global font mapper object used for encodings/charset mapping
45 virtual wxFontMapper
*CreateFontMapper() = 0;
46 #endif // wxUSE_FONTMAP
48 // get the renderer to use for drawing the generic controls (return value
49 // may be NULL in which case the default renderer for the current platform
50 // is used); this is used in GUI only and always returns NULL in console
52 // NB: returned pointer will be deleted by the caller
53 virtual wxRendererNative
*CreateRenderer() = 0;
56 // functions abstracting differences between GUI and console modes
57 // ------------------------------------------------------------------------
60 // show the assert dialog with the specified message in GUI or just print
61 // the string to stderr in console mode
63 // base class version has an implementation (in spite of being pure
64 // virtual) in base/appbase.cpp which can be called as last resort.
66 // return true to suppress subsequent asserts, false to continue as before
67 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
70 // return true if fprintf(stderr) goes somewhere, false otherwise
71 virtual bool HasStderr() = 0;
73 // managing "pending delete" list: in GUI mode we can't immediately delete
74 // some objects because there may be unprocessed events for them and so we
75 // only do it during the next idle loop iteration while this is, of course,
76 // unnecessary in wxBase, so we have a few functions to abstract these
79 // add the object to the pending delete list in GUI, delete it immediately
81 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
83 // remove this object from the pending delete list in GUI, do nothing in
85 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
88 // other miscellaneous helpers
89 // ---------------------------
91 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
92 // Unix: in the former case it returns the information about the toolkit
93 // and in the latter -- about the OS, so we need to virtualize it
94 virtual int GetOSVersion(int *verMaj
, int *verMin
) = 0;
97 // ----------------------------------------------------------------------------
98 // include the platform-specific version of the class
99 // ----------------------------------------------------------------------------
101 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
102 // Unix code (and otherwise __UNIX__ wouldn't be defined)
103 #if defined(__WXMSW__)
104 #include "wx/msw/apptbase.h"
105 #elif defined(__UNIX__)
106 #include "wx/unix/apptbase.h"
107 #elif defined(__WXMAC__)
108 #include "wx/mac/apptbase.h"
109 #else // no platform-specific methods to add to wxAppTraits
110 // wxAppTraits must be a class because it was forward declared as class
111 class WXDLLIMPEXP_BASE wxAppTraits
: public wxAppTraitsBase
116 // ============================================================================
117 // standard traits for console and GUI applications
118 // ============================================================================
120 // ----------------------------------------------------------------------------
121 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
122 // ----------------------------------------------------------------------------
124 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase
: public wxAppTraits
128 virtual wxLog
*CreateLogTarget();
130 virtual wxMessageOutput
*CreateMessageOutput();
132 virtual wxFontMapper
*CreateFontMapper();
133 #endif // wxUSE_FONTMAP
134 virtual wxRendererNative
*CreateRenderer();
137 virtual bool ShowAssertDialog(const wxString
& msg
);
138 #endif // __WXDEBUG__
139 virtual bool HasStderr();
141 virtual void ScheduleForDestroy(wxObject
*object
);
142 virtual void RemoveFromPendingDelete(wxObject
*object
);
145 // ----------------------------------------------------------------------------
146 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
147 // ----------------------------------------------------------------------------
151 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
155 virtual wxLog
*CreateLogTarget();
157 virtual wxMessageOutput
*CreateMessageOutput();
159 virtual wxFontMapper
*CreateFontMapper();
160 #endif // wxUSE_FONTMAP
161 virtual wxRendererNative
*CreateRenderer();
164 virtual bool ShowAssertDialog(const wxString
& msg
);
165 #endif // __WXDEBUG__
166 virtual bool HasStderr();
168 virtual void ScheduleForDestroy(wxObject
*object
);
169 virtual void RemoveFromPendingDelete(wxObject
*object
);
174 // ----------------------------------------------------------------------------
175 // include the platform-specific version of the classes above
176 // ----------------------------------------------------------------------------
178 #if defined(__WXMSW__)
179 #include "wx/msw/apptrait.h"
180 #elif defined(__UNIX__)
181 #include "wx/unix/apptrait.h"
182 #elif defined(__WXMAC__)
183 #include "wx/mac/apptrait.h"
184 #else // no platform-specific methods to add to wxAppTraits
186 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
188 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
191 #endif // _WX_APPTRAIT_H_