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
;
23 // ----------------------------------------------------------------------------
24 // wxAppTraits: this class defines various configurable aspects of wxApp
25 // ----------------------------------------------------------------------------
28 class WXDLLIMPEXP_BASE wxAppTraitsBase
30 class WXDLLIMPEXP_CORE wxAppTraitsBase
34 // wxAppTraits is an ABC, but we also provide 2 standard implementations of
35 // it, one for the console apps and the other for the GUI ones
36 static wxAppTraits
*CreateConsole();
38 static wxAppTraits
*CreateGUI();
42 // hooks for creating the global objects, may be overridden by the user
43 // ------------------------------------------------------------------------
46 // create the default log target
47 virtual wxLog
*CreateLogTarget() = 0;
50 // create the global object used for printing out messages
51 virtual wxMessageOutput
*CreateMessageOutput() = 0;
54 // create the global font mapper object used for encodings/charset mapping
55 virtual wxFontMapper
*CreateFontMapper() = 0;
56 #endif // wxUSE_FONTMAP
59 // functions abstracting differences between GUI and console modes
60 // ------------------------------------------------------------------------
63 // show the assert dialog with the specified message in GUI or just print
64 // the string to stderr in console mode
66 // base class version has an implementation (in spite of being pure
67 // virtual) in base/appbase.cpp which can be called as last resort.
69 // return true to suppress subsequent asserts, false to continue as before
70 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
73 // return true if fprintf(stderr) goes somewhere, false otherwise
74 virtual bool HasStderr() = 0;
76 // managing "pending delete" list: in GUI mode we can't immediately delete
77 // some objects because there may be unprocessed events for them and so we
78 // only do it during the next idle loop iteration while this is, of course,
79 // unnecessary in wxBase, so we have a few functions to abstract these
82 // add the object to the pending delete list in GUI, delete it immediately
84 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
86 // remove this object from the pending delete list in GUI, do nothing in
88 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
91 // other miscellaneous helpers
92 // ---------------------------
94 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
95 // Unix: in the former case it returns the information about the toolkit
96 // and in the latter -- about the OS, so we need to virtualize it
97 virtual int GetOSVersion(int *verMaj
, int *verMin
) = 0;
100 // ----------------------------------------------------------------------------
101 // include the platform-specific version of the class
102 // ----------------------------------------------------------------------------
104 #if defined(__WXMSW__)
105 #include "wx/msw/apptbase.h"
106 #elif defined(__UNIX__)
107 #include "wx/unix/apptbase.h"
108 #else // no platform-specific methods to add to wxAppTraits
110 // wxAppTraits must be a class because it was forward declared as class
111 class WXDLLEXPORT 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
136 virtual bool ShowAssertDialog(const wxString
& msg
);
137 #endif // __WXDEBUG__
138 virtual bool HasStderr();
140 virtual void ScheduleForDestroy(wxObject
*object
);
141 virtual void RemoveFromPendingDelete(wxObject
*object
);
144 // ----------------------------------------------------------------------------
145 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
146 // ----------------------------------------------------------------------------
150 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
154 virtual wxLog
*CreateLogTarget();
156 virtual wxMessageOutput
*CreateMessageOutput();
158 virtual wxFontMapper
*CreateFontMapper();
159 #endif // wxUSE_FONTMAP
162 virtual bool ShowAssertDialog(const wxString
& msg
);
163 #endif // __WXDEBUG__
164 virtual bool HasStderr();
166 virtual void ScheduleForDestroy(wxObject
*object
);
167 virtual void RemoveFromPendingDelete(wxObject
*object
);
172 // ----------------------------------------------------------------------------
173 // include the platform-specific version of the classes above
174 // ----------------------------------------------------------------------------
176 #if defined(__WXMSW__)
177 #include "wx/msw/apptrait.h"
178 #elif defined(__UNIX__)
179 #include "wx/unix/apptrait.h"
180 #else // no platform-specific methods to add to wxAppTraits
182 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
184 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
187 #endif // _WX_APPTRAIT_H_