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 WXDLLEXPORT wxAppTraitsBase
30 // wxAppTraits is an ABC, but we also provide 2 standard implementations of
31 // it, one for the console apps and the other for the GUI ones
32 static wxAppTraits
*CreateConsole();
34 static wxAppTraits
*CreateGUI();
38 // hooks for creating the global objects, may be overridden by the user
39 // ------------------------------------------------------------------------
42 // create the default log target
43 virtual wxLog
*CreateLogTarget() = 0;
46 // create the global object used for printing out messages
47 virtual wxMessageOutput
*CreateMessageOutput() = 0;
50 // create the global font mapper object used for encodings/charset mapping
51 virtual wxFontMapper
*CreateFontMapper() = 0;
52 #endif // wxUSE_FONTMAP
55 // functions abstracting differences between GUI and console modes
56 // ------------------------------------------------------------------------
59 // show the assert dialog with the specified message in GUI or just print
60 // the string to stderr in console mode
62 // base class version has an implementation (in spite of being pure
63 // virtual) in base/appbase.cpp which can be called as last resort.
65 // return true to suppress subsequent asserts, false to continue as before
66 virtual bool ShowAssertDialog(const wxString
& msg
) = 0;
69 // return true if fprintf(stderr) goes somewhere, false otherwise
70 virtual bool HasStderr() = 0;
72 // managing "pending delete" list: in GUI mode we can't immediately delete
73 // some objects because there may be unprocessed events for them and so we
74 // only do it during the next idle loop iteration while this is, of course,
75 // unnecessary in wxBase, so we have a few functions to abstract these
78 // add the object to the pending delete list in GUI, delete it immediately
80 virtual void ScheduleForDestroy(wxObject
*object
) = 0;
82 // remove this object from the pending delete list in GUI, do nothing in
84 virtual void RemoveFromPendingDelete(wxObject
*object
) = 0;
87 // other miscellaneous helpers
88 // ---------------------------
90 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
91 // Unix: in the former case it returns the information about the toolkit
92 // and in the latter -- about the OS, so we need to virtualize it
93 virtual int GetOSVersion(int *verMaj
, int *verMin
) = 0;
96 // ----------------------------------------------------------------------------
97 // include the platform-specific version of the class
98 // ----------------------------------------------------------------------------
100 #if defined(__WXMSW__)
101 #include "wx/msw/apptbase.h"
102 #elif defined(__UNIX__)
103 #include "wx/unix/apptbase.h"
104 #else // no platform-specific methods to add to wxAppTraits
106 // wxAppTraits must be a class because it was forward declared as class
107 class WXDLLEXPORT wxAppTraits
: public wxAppTraitsBase
112 // ============================================================================
113 // standard traits for console and GUI applications
114 // ============================================================================
116 // ----------------------------------------------------------------------------
117 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
118 // ----------------------------------------------------------------------------
120 class WXDLLEXPORT wxConsoleAppTraitsBase
: public wxAppTraits
124 virtual wxLog
*CreateLogTarget();
126 virtual wxMessageOutput
*CreateMessageOutput();
128 virtual wxFontMapper
*CreateFontMapper();
129 #endif // wxUSE_FONTMAP
132 virtual bool ShowAssertDialog(const wxString
& msg
);
133 #endif // __WXDEBUG__
134 virtual bool HasStderr();
136 virtual void ScheduleForDestroy(wxObject
*object
);
137 virtual void RemoveFromPendingDelete(wxObject
*object
);
140 // ----------------------------------------------------------------------------
141 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
142 // ----------------------------------------------------------------------------
146 class WXDLLEXPORT wxGUIAppTraitsBase
: public wxAppTraits
150 virtual wxLog
*CreateLogTarget();
152 virtual wxMessageOutput
*CreateMessageOutput();
154 virtual wxFontMapper
*CreateFontMapper();
155 #endif // wxUSE_FONTMAP
158 virtual bool ShowAssertDialog(const wxString
& msg
);
159 #endif // __WXDEBUG__
160 virtual bool HasStderr();
162 virtual void ScheduleForDestroy(wxObject
*object
);
163 virtual void RemoveFromPendingDelete(wxObject
*object
);
168 // ----------------------------------------------------------------------------
169 // include the platform-specific version of the classes above
170 // ----------------------------------------------------------------------------
172 #if defined(__WXMSW__)
173 #include "wx/msw/apptrait.h"
174 #elif defined(__UNIX__)
175 #include "wx/unix/apptrait.h"
176 #else // no platform-specific methods to add to wxAppTraits
178 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
180 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
183 #endif // _WX_APPTRAIT_H_