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 // ----------------------------------------------------------------------------
87 // include the platform-specific version of the class
88 // ----------------------------------------------------------------------------
90 #if defined(__WXMSW__)
91 #include "wx/msw/apptbase.h"
92 #elif defined(__UNIX__)
93 #include "wx/unix/apptbase.h"
94 #else // no platform-specific methods to add to wxAppTraits
96 // wxAppTraits must be a class because it was forward declared as class
97 class WXDLLEXPORT wxAppTraits
: public wxAppTraitsBase
102 // ============================================================================
103 // standard traits for console and GUI applications
104 // ============================================================================
106 // ----------------------------------------------------------------------------
107 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
108 // ----------------------------------------------------------------------------
110 class wxConsoleAppTraitsBase
: public wxAppTraits
114 virtual wxLog
*CreateLogTarget();
116 virtual wxMessageOutput
*CreateMessageOutput();
118 virtual wxFontMapper
*CreateFontMapper();
119 #endif // wxUSE_FONTMAP
122 virtual bool ShowAssertDialog(const wxString
& msg
);
123 #endif // __WXDEBUG__
124 virtual bool HasStderr();
126 virtual void ScheduleForDestroy(wxObject
*object
);
127 virtual void RemoveFromPendingDelete(wxObject
*object
);
130 // ----------------------------------------------------------------------------
131 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
132 // ----------------------------------------------------------------------------
136 class wxGUIAppTraitsBase
: public wxAppTraits
140 virtual wxLog
*CreateLogTarget();
142 virtual wxMessageOutput
*CreateMessageOutput();
144 virtual wxFontMapper
*CreateFontMapper();
145 #endif // wxUSE_FONTMAP
148 virtual bool ShowAssertDialog(const wxString
& msg
);
149 #endif // __WXDEBUG__
150 virtual bool HasStderr();
152 virtual void ScheduleForDestroy(wxObject
*object
);
153 virtual void RemoveFromPendingDelete(wxObject
*object
);
158 // ----------------------------------------------------------------------------
159 // include the platform-specific version of the classes above
160 // ----------------------------------------------------------------------------
162 #if defined(__WXMSW__)
163 #include "wx/msw/apptrait.h"
164 #elif defined(__UNIX__)
165 #include "wx/unix/apptrait.h"
166 #else // no platform-specific methods to add to wxAppTraits
168 typedef wxGUIAppTraitsBase wxGUIAppTraits
;
170 typedef wxConsoleAppTraitsBase wxConsoleAppTraits
;
173 #endif // _WX_APPTRAIT_H_