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 // ----------------------------------------------------------------------------
27 class WXDLLIMPEXP_BASE wxAppTraitsBase
30 // hooks for creating the global objects, may be overridden by the user
31 // ------------------------------------------------------------------------
34 // create the default log target
35 virtual wxLog
*CreateLogTarget() = 0;
38 // create the global object used for printing out messages
39 virtual wxMessageOutput
*CreateMessageOutput() = 0;
42 // create the global font mapper object used for encodings/charset mapping
43 virtual wxFontMapper
*CreateFontMapper() = 0;
44 #endif // wxUSE_FONTMAP
47 // functions abstracting differences between GUI and console modes
48 // ------------------------------------------------------------------------
51 // show the assert dialog with the specified message in GUI or just print
52 // the string to stderr in console mode
54 // base class version has an implementation (in spite of being pure
55 // virtual) in base/appbase.cpp which can be called as last resort.
57 // return true to suppress subsequent asserts, false to continue as before
58 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
61 // return true if fprintf(stderr) goes somewhere, false otherwise
62 virtual bool HasStderr() = 0;
64 // managing "pending delete" list: in GUI mode we can't immediately delete
65 // some objects because there may be unprocessed events for them and so we
66 // only do it during the next idle loop iteration while this is, of course,
67 // unnecessary in wxBase, so we have a few functions to abstract these
70 // add the object to the pending delete list in GUI, delete it immediately
72 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
74 // remove this object from the pending delete list in GUI, do nothing in
76 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
79 // other miscellaneous helpers
80 // ---------------------------
82 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
83 // Unix: in the former case it returns the information about the toolkit
84 // and in the latter -- about the OS, so we need to virtualize it
85 virtual int GetOSVersion(int *verMaj
, int *verMin
) = 0;
88 // ----------------------------------------------------------------------------
89 // include the platform-specific version of the class
90 // ----------------------------------------------------------------------------
92 #if defined(__WXMSW__)
93 #include "wx/msw/apptbase.h"
94 #elif defined(__UNIX__)
95 #include "wx/unix/apptbase.h"
96 #elif defined(__WXMAC__)
97 #include "wx/mac/apptbase.h"
98 #else // no platform-specific methods to add to wxAppTraits
100 // wxAppTraits must be a class because it was forward declared as class
101 class WXDLLIMPEXP_BASE wxAppTraits
: public wxAppTraitsBase
106 // ============================================================================
107 // standard traits for console and GUI applications
108 // ============================================================================
110 // ----------------------------------------------------------------------------
111 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
112 // ----------------------------------------------------------------------------
114 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase
: public wxAppTraits
118 virtual wxLog
*CreateLogTarget();
120 virtual wxMessageOutput
*CreateMessageOutput();
122 virtual wxFontMapper
*CreateFontMapper();
123 #endif // wxUSE_FONTMAP
126 virtual bool ShowAssertDialog(const wxString
& msg
);
127 #endif // __WXDEBUG__
128 virtual bool HasStderr();
130 virtual void ScheduleForDestroy(wxObject
*object
);
131 virtual void RemoveFromPendingDelete(wxObject
*object
);
134 // ----------------------------------------------------------------------------
135 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
136 // ----------------------------------------------------------------------------
140 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
144 virtual wxLog
*CreateLogTarget();
146 virtual wxMessageOutput
*CreateMessageOutput();
148 virtual wxFontMapper
*CreateFontMapper();
149 #endif // wxUSE_FONTMAP
152 virtual bool ShowAssertDialog(const wxString
& msg
);
153 #endif // __WXDEBUG__
154 virtual bool HasStderr();
156 virtual void ScheduleForDestroy(wxObject
*object
);
157 virtual void RemoveFromPendingDelete(wxObject
*object
);
162 // ----------------------------------------------------------------------------
163 // include the platform-specific version of the classes above
164 // ----------------------------------------------------------------------------
166 #if defined(__WXMSW__)
167 #include "wx/msw/apptrait.h"
168 #elif defined(__UNIX__)
169 #include "wx/unix/apptrait.h"
170 #elif defined(__WXMAC__)
171 #include "wx/mac/apptrait.h"
172 #else // no platform-specific methods to add to wxAppTraits
174 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
176 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
179 #endif // _WX_APPTRAIT_H_