]> git.saurik.com Git - wxWidgets.git/blob - include/wx/apptrait.h
renamed WXDLLEXPORT_BASE/CORE to WXDLLIMPEXP_BASE/CORE
[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 WXDLLEXPORT wxAppTraitsBase
28 {
29 public:
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();
33 #if wxUSE_GUI
34 static wxAppTraits *CreateGUI();
35 #endif // wxUSE_GUI
36
37
38 // hooks for creating the global objects, may be overridden by the user
39 // ------------------------------------------------------------------------
40
41 #if wxUSE_LOG
42 // create the default log target
43 virtual wxLog *CreateLogTarget() = 0;
44 #endif // wxUSE_LOG
45
46 // create the global object used for printing out messages
47 virtual wxMessageOutput *CreateMessageOutput() = 0;
48
49 #if wxUSE_FONTMAP
50 // create the global font mapper object used for encodings/charset mapping
51 virtual wxFontMapper *CreateFontMapper() = 0;
52 #endif // wxUSE_FONTMAP
53
54
55 // functions abstracting differences between GUI and console modes
56 // ------------------------------------------------------------------------
57
58 #ifdef __WXDEBUG__
59 // show the assert dialog with the specified message in GUI or just print
60 // the string to stderr in console mode
61 //
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.
64 //
65 // return true to suppress subsequent asserts, false to continue as before
66 virtual bool ShowAssertDialog(const wxString& msg) = 0;
67 #endif // __WXDEBUG__
68
69 // return true if fprintf(stderr) goes somewhere, false otherwise
70 virtual bool HasStderr() = 0;
71
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
76 // operations
77
78 // add the object to the pending delete list in GUI, delete it immediately
79 // in wxBase
80 virtual void ScheduleForDestroy(wxObject *object) = 0;
81
82 // remove this object from the pending delete list in GUI, do nothing in
83 // wxBase
84 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
85
86
87 // other miscellaneous helpers
88 // ---------------------------
89
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;
94 };
95
96 // ----------------------------------------------------------------------------
97 // include the platform-specific version of the class
98 // ----------------------------------------------------------------------------
99
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
105 typedef
106 // wxAppTraits must be a class because it was forward declared as class
107 class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
108 {
109 };
110 #endif // platform
111
112 // ============================================================================
113 // standard traits for console and GUI applications
114 // ============================================================================
115
116 // ----------------------------------------------------------------------------
117 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
118 // ----------------------------------------------------------------------------
119
120 class WXDLLEXPORT wxConsoleAppTraitsBase : public wxAppTraits
121 {
122 public:
123 #if wxUSE_LOG
124 virtual wxLog *CreateLogTarget();
125 #endif // wxUSE_LOG
126 virtual wxMessageOutput *CreateMessageOutput();
127 #if wxUSE_FONTMAP
128 virtual wxFontMapper *CreateFontMapper();
129 #endif // wxUSE_FONTMAP
130
131 #ifdef __WXDEBUG__
132 virtual bool ShowAssertDialog(const wxString& msg);
133 #endif // __WXDEBUG__
134 virtual bool HasStderr();
135
136 virtual void ScheduleForDestroy(wxObject *object);
137 virtual void RemoveFromPendingDelete(wxObject *object);
138 };
139
140 // ----------------------------------------------------------------------------
141 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
142 // ----------------------------------------------------------------------------
143
144 #if wxUSE_GUI
145
146 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
147 {
148 public:
149 #if wxUSE_LOG
150 virtual wxLog *CreateLogTarget();
151 #endif // wxUSE_LOG
152 virtual wxMessageOutput *CreateMessageOutput();
153 #if wxUSE_FONTMAP
154 virtual wxFontMapper *CreateFontMapper();
155 #endif // wxUSE_FONTMAP
156
157 #ifdef __WXDEBUG__
158 virtual bool ShowAssertDialog(const wxString& msg);
159 #endif // __WXDEBUG__
160 virtual bool HasStderr();
161
162 virtual void ScheduleForDestroy(wxObject *object);
163 virtual void RemoveFromPendingDelete(wxObject *object);
164 };
165
166 #endif // wxUSE_GUI
167
168 // ----------------------------------------------------------------------------
169 // include the platform-specific version of the classes above
170 // ----------------------------------------------------------------------------
171
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
177 #if wxUSE_GUI
178 typedef wxGUIAppTraitsBase wxGUIAppTraits;
179 #endif // wxUSE_GUI
180 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
181 #endif // platform
182
183 #endif // _WX_APPTRAIT_H_
184