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 wxAppTraits
;
17 class WXDLLEXPORT wxFontMapper
;
18 #endif // wxUSE_FONTMAP
19 class WXDLLEXPORT wxLog
;
20 class WXDLLEXPORT wxMessageOutput
;
22 // ----------------------------------------------------------------------------
23 // wxAppTraits: this class defines various configurable aspects of wxApp
24 // ----------------------------------------------------------------------------
26 class WXDLLEXPORT wxAppTraitsBase
29 // wxAppTraits is an ABC, but we also provide 2 standard implementations of
30 // it, one for the console apps and the other for the GUI ones
31 static wxAppTraits
*CreateConsole();
33 static wxAppTraits
*CreateGUI();
37 // hooks for creating the global objects, may be overridden by the user
38 // ------------------------------------------------------------------------
41 // create the default log target
42 virtual wxLog
*CreateLogTarget() = 0;
45 // create the global object used for printing out messages
46 virtual wxMessageOutput
*CreateMessageOutput() = 0;
49 // create the global font mapper object used for encodings/charset mapping
50 virtual wxFontMapper
*CreateFontMapper() = 0;
51 #endif // wxUSE_FONTMAP
54 // functions abstracting differences between GUI and console modes
55 // ------------------------------------------------------------------------
58 // show the assert dialog with the specified message in GUI or just print
59 // the string to stderr in console mode
61 // base class version has an implementation (in spite of being pure
62 // virtual) in base/appbase.cpp which can be called as last resort.
64 // return true to suppress subsequent asserts, false to continue as before
65 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
68 // return true if fprintf(stderr) goes somewhere, false otherwise
69 virtual bool HasStderr() = 0;
71 // managing "pending delete" list: in GUI mode we can't immediately delete
72 // some objects because there may be unprocessed events for them and so we
73 // only do it during the next idle loop iteration while this is, of course,
74 // unnecessary in wxBase, so we have a few functions to abstract these
77 // add the object to the pending delete list in GUI, delete it immediately
79 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
81 // remove this object from the pending delete list in GUI, do nothing in
83 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
86 // other miscellaneous helpers
87 // ---------------------------
89 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
90 // Unix: in the former case it returns the information about the toolkit
91 // and in the latter -- about the OS, so we need to virtualize it
92 virtual int GetOSVersion(int *verMaj
, int *verMin
) = 0;
95 // ----------------------------------------------------------------------------
96 // include the platform-specific version of the class
97 // ----------------------------------------------------------------------------
99 #if defined(__WXMSW__)
100 #include "wx/msw/apptbase.h"
101 #elif defined(__UNIX__)
102 #include "wx/unix/apptbase.h"
103 #else // no platform-specific methods to add to wxAppTraits
105 // wxAppTraits must be a class because it was forward declared as class
106 class WXDLLEXPORT wxAppTraits
: public wxAppTraitsBase
111 // ============================================================================
112 // standard traits for console and GUI applications
113 // ============================================================================
115 // ----------------------------------------------------------------------------
116 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
117 // ----------------------------------------------------------------------------
119 class WXDLLEXPORT wxConsoleAppTraitsBase
: public wxAppTraits
123 virtual wxLog
*CreateLogTarget();
125 virtual wxMessageOutput
*CreateMessageOutput();
127 virtual wxFontMapper
*CreateFontMapper();
128 #endif // wxUSE_FONTMAP
131 virtual bool ShowAssertDialog(const wxString
& msg
);
132 #endif // __WXDEBUG__
133 virtual bool HasStderr();
135 virtual void ScheduleForDestroy(wxObject
*object
);
136 virtual void RemoveFromPendingDelete(wxObject
*object
);
139 // ----------------------------------------------------------------------------
140 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
141 // ----------------------------------------------------------------------------
145 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
149 virtual wxLog
*CreateLogTarget();
151 virtual wxMessageOutput
*CreateMessageOutput();
153 virtual wxFontMapper
*CreateFontMapper();
154 #endif // wxUSE_FONTMAP
157 virtual bool ShowAssertDialog(const wxString
& msg
);
158 #endif // __WXDEBUG__
159 virtual bool HasStderr();
161 virtual void ScheduleForDestroy(wxObject
*object
);
162 virtual void RemoveFromPendingDelete(wxObject
*object
);
167 // ----------------------------------------------------------------------------
168 // include the platform-specific version of the classes above
169 // ----------------------------------------------------------------------------
171 #if defined(__WXMSW__)
172 #include "wx/msw/apptrait.h"
173 #elif defined(__UNIX__)
174 #include "wx/unix/apptrait.h"
175 #else // no platform-specific methods to add to wxAppTraits
177 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
179 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
182 #endif // _WX_APPTRAIT_H_