]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
Added --use-stl to cnfigure, wxUSE_STL to setup0.h
[wxWidgets.git] / include / wx / apptrait.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/apptrait.h
3 // Purpose: declaration of wxAppTraits and derived classes
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 19.06.2003
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_APPTRAIT_H_
13 #define _WX_APPTRAIT_H_
14
15 class WXDLLEXPORT wxObject;
16 class WXDLLEXPORT wxAppTraits;
17 #if wxUSE_FONTMAP
18 class WXDLLEXPORT wxFontMapper;
19 #endif // wxUSE_FONTMAP
20 class WXDLLEXPORT wxLog;
21 class WXDLLEXPORT wxMessageOutput;
22 class WXDLLEXPORT wxString;
23
24 // ----------------------------------------------------------------------------
25 // wxAppTraits: this class defines various configurable aspects of wxApp
26 // ----------------------------------------------------------------------------
27
28 class WXDLLIMPEXP_BASE wxAppTraitsBase
29 {
30 public:
31 // hooks for creating the global objects, may be overridden by the user
32 // ------------------------------------------------------------------------
33
34 #if wxUSE_LOG
35 // create the default log target
36 virtual wxLog *CreateLogTarget() = 0;
37 #endif // wxUSE_LOG
38
39 // create the global object used for printing out messages
40 virtual wxMessageOutput *CreateMessageOutput() = 0;
41
42 #if wxUSE_FONTMAP
43 // create the global font mapper object used for encodings/charset mapping
44 virtual wxFontMapper *CreateFontMapper() = 0;
45 #endif // wxUSE_FONTMAP
46
47
48 // functions abstracting differences between GUI and console modes
49 // ------------------------------------------------------------------------
50
51 #ifdef __WXDEBUG__
52 // show the assert dialog with the specified message in GUI or just print
53 // the string to stderr in console mode
54 //
55 // base class version has an implementation (in spite of being pure
56 // virtual) in base/appbase.cpp which can be called as last resort.
57 //
58 // return true to suppress subsequent asserts, false to continue as before
59 virtual bool ShowAssertDialog(const wxString& msg) = 0;
60 #endif // __WXDEBUG__
61
62 // return true if fprintf(stderr) goes somewhere, false otherwise
63 virtual bool HasStderr() = 0;
64
65 // managing "pending delete" list: in GUI mode we can't immediately delete
66 // some objects because there may be unprocessed events for them and so we
67 // only do it during the next idle loop iteration while this is, of course,
68 // unnecessary in wxBase, so we have a few functions to abstract these
69 // operations
70
71 // add the object to the pending delete list in GUI, delete it immediately
72 // in wxBase
73 virtual void ScheduleForDestroy(wxObject *object) = 0;
74
75 // remove this object from the pending delete list in GUI, do nothing in
76 // wxBase
77 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
78
79
80 // other miscellaneous helpers
81 // ---------------------------
82
83 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
84 // Unix: in the former case it returns the information about the toolkit
85 // and in the latter -- about the OS, so we need to virtualize it
86 virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
87 };
88
89 // ----------------------------------------------------------------------------
90 // include the platform-specific version of the class
91 // ----------------------------------------------------------------------------
92
93 #if defined(__WXMSW__)
94 #include "wx/msw/apptbase.h"
95 #elif defined(__UNIX__)
96 #include "wx/unix/apptbase.h"
97 #elif defined(__WXMAC__)
98 #include "wx/mac/apptbase.h"
99 #else // no platform-specific methods to add to wxAppTraits
100 typedef
101 // wxAppTraits must be a class because it was forward declared as class
102 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
103 {
104 };
105 #endif // platform
106
107 // ============================================================================
108 // standard traits for console and GUI applications
109 // ============================================================================
110
111 // ----------------------------------------------------------------------------
112 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
113 // ----------------------------------------------------------------------------
114
115 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
116 {
117 public:
118 #if wxUSE_LOG
119 virtual wxLog *CreateLogTarget();
120 #endif // wxUSE_LOG
121 virtual wxMessageOutput *CreateMessageOutput();
122 #if wxUSE_FONTMAP
123 virtual wxFontMapper *CreateFontMapper();
124 #endif // wxUSE_FONTMAP
125
126 #ifdef __WXDEBUG__
127 virtual bool ShowAssertDialog(const wxString& msg);
128 #endif // __WXDEBUG__
129 virtual bool HasStderr();
130
131 virtual void ScheduleForDestroy(wxObject *object);
132 virtual void RemoveFromPendingDelete(wxObject *object);
133 };
134
135 // ----------------------------------------------------------------------------
136 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
137 // ----------------------------------------------------------------------------
138
139 #if wxUSE_GUI
140
141 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
142 {
143 public:
144 #if wxUSE_LOG
145 virtual wxLog *CreateLogTarget();
146 #endif // wxUSE_LOG
147 virtual wxMessageOutput *CreateMessageOutput();
148 #if wxUSE_FONTMAP
149 virtual wxFontMapper *CreateFontMapper();
150 #endif // wxUSE_FONTMAP
151
152 #ifdef __WXDEBUG__
153 virtual bool ShowAssertDialog(const wxString& msg);
154 #endif // __WXDEBUG__
155 virtual bool HasStderr();
156
157 virtual void ScheduleForDestroy(wxObject *object);
158 virtual void RemoveFromPendingDelete(wxObject *object);
159 };
160
161 #endif // wxUSE_GUI
162
163 // ----------------------------------------------------------------------------
164 // include the platform-specific version of the classes above
165 // ----------------------------------------------------------------------------
166
167 #if defined(__WXMSW__)
168 #include "wx/msw/apptrait.h"
169 #elif defined(__UNIX__)
170 #include "wx/unix/apptrait.h"
171 #elif defined(__WXMAC__)
172 #include "wx/mac/apptrait.h"
173 #else // no platform-specific methods to add to wxAppTraits
174 #if wxUSE_GUI
175 typedef wxGUIAppTraitsBase wxGUIAppTraits;
176 #endif // wxUSE_GUI
177 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
178 #endif // platform
179
180 #endif // _WX_APPTRAIT_H_
181