]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
added wxprec.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
23 // ----------------------------------------------------------------------------
24 // wxAppTraits: this class defines various configurable aspects of wxApp
25 // ----------------------------------------------------------------------------
26
27 class WXDLLIMPEXP_BASE wxAppTraitsBase
28 {
29 public:
30 // hooks for creating the global objects, may be overridden by the user
31 // ------------------------------------------------------------------------
32
33 #if wxUSE_LOG
34 // create the default log target
35 virtual wxLog *CreateLogTarget() = 0;
36 #endif // wxUSE_LOG
37
38 // create the global object used for printing out messages
39 virtual wxMessageOutput *CreateMessageOutput() = 0;
40
41 #if wxUSE_FONTMAP
42 // create the global font mapper object used for encodings/charset mapping
43 virtual wxFontMapper *CreateFontMapper() = 0;
44 #endif // wxUSE_FONTMAP
45
46
47 // functions abstracting differences between GUI and console modes
48 // ------------------------------------------------------------------------
49
50 #ifdef __WXDEBUG__
51 // show the assert dialog with the specified message in GUI or just print
52 // the string to stderr in console mode
53 //
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.
56 //
57 // return true to suppress subsequent asserts, false to continue as before
58 virtual bool ShowAssertDialog(const wxString& msg) = 0;
59 #endif // __WXDEBUG__
60
61 // return true if fprintf(stderr) goes somewhere, false otherwise
62 virtual bool HasStderr() = 0;
63
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
68 // operations
69
70 // add the object to the pending delete list in GUI, delete it immediately
71 // in wxBase
72 virtual void ScheduleForDestroy(wxObject *object) = 0;
73
74 // remove this object from the pending delete list in GUI, do nothing in
75 // wxBase
76 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
77
78
79 // other miscellaneous helpers
80 // ---------------------------
81
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;
86 };
87
88 // ----------------------------------------------------------------------------
89 // include the platform-specific version of the class
90 // ----------------------------------------------------------------------------
91
92 #if defined(__WXMSW__)
93 #include "wx/msw/apptbase.h"
94 #elif defined(__UNIX__)
95 #include "wx/unix/apptbase.h"
96 #else // no platform-specific methods to add to wxAppTraits
97 typedef
98 // wxAppTraits must be a class because it was forward declared as class
99 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
100 {
101 };
102 #endif // platform
103
104 // ============================================================================
105 // standard traits for console and GUI applications
106 // ============================================================================
107
108 // ----------------------------------------------------------------------------
109 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
110 // ----------------------------------------------------------------------------
111
112 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
113 {
114 public:
115 #if wxUSE_LOG
116 virtual wxLog *CreateLogTarget();
117 #endif // wxUSE_LOG
118 virtual wxMessageOutput *CreateMessageOutput();
119 #if wxUSE_FONTMAP
120 virtual wxFontMapper *CreateFontMapper();
121 #endif // wxUSE_FONTMAP
122
123 #ifdef __WXDEBUG__
124 virtual bool ShowAssertDialog(const wxString& msg);
125 #endif // __WXDEBUG__
126 virtual bool HasStderr();
127
128 virtual void ScheduleForDestroy(wxObject *object);
129 virtual void RemoveFromPendingDelete(wxObject *object);
130 };
131
132 // ----------------------------------------------------------------------------
133 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
134 // ----------------------------------------------------------------------------
135
136 #if wxUSE_GUI
137
138 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
139 {
140 public:
141 #if wxUSE_LOG
142 virtual wxLog *CreateLogTarget();
143 #endif // wxUSE_LOG
144 virtual wxMessageOutput *CreateMessageOutput();
145 #if wxUSE_FONTMAP
146 virtual wxFontMapper *CreateFontMapper();
147 #endif // wxUSE_FONTMAP
148
149 #ifdef __WXDEBUG__
150 virtual bool ShowAssertDialog(const wxString& msg);
151 #endif // __WXDEBUG__
152 virtual bool HasStderr();
153
154 virtual void ScheduleForDestroy(wxObject *object);
155 virtual void RemoveFromPendingDelete(wxObject *object);
156 };
157
158 #endif // wxUSE_GUI
159
160 // ----------------------------------------------------------------------------
161 // include the platform-specific version of the classes above
162 // ----------------------------------------------------------------------------
163
164 #if defined(__WXMSW__)
165 #include "wx/msw/apptrait.h"
166 #elif defined(__UNIX__)
167 #include "wx/unix/apptrait.h"
168 #else // no platform-specific methods to add to wxAppTraits
169 #if wxUSE_GUI
170 typedef wxGUIAppTraitsBase wxGUIAppTraits;
171 #endif // wxUSE_GUI
172 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
173 #endif // platform
174
175 #endif // _WX_APPTRAIT_H_
176