this is nasty but required compilation fix, otherwise we get dllimport/dllexport...
[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 #if wxUSE_BASE
28 class WXDLLIMPEXP_BASE wxAppTraitsBase
29 #else
30 class WXDLLIMPEXP_CORE wxAppTraitsBase
31 #endif
32 {
33 public:
34 // wxAppTraits is an ABC, but we also provide 2 standard implementations of
35 // it, one for the console apps and the other for the GUI ones
36 static wxAppTraits *CreateConsole();
37 #if wxUSE_GUI
38 static wxAppTraits *CreateGUI();
39 #endif // wxUSE_GUI
40
41
42 // hooks for creating the global objects, may be overridden by the user
43 // ------------------------------------------------------------------------
44
45 #if wxUSE_LOG
46 // create the default log target
47 virtual wxLog *CreateLogTarget() = 0;
48 #endif // wxUSE_LOG
49
50 // create the global object used for printing out messages
51 virtual wxMessageOutput *CreateMessageOutput() = 0;
52
53 #if wxUSE_FONTMAP
54 // create the global font mapper object used for encodings/charset mapping
55 virtual wxFontMapper *CreateFontMapper() = 0;
56 #endif // wxUSE_FONTMAP
57
58
59 // functions abstracting differences between GUI and console modes
60 // ------------------------------------------------------------------------
61
62 #ifdef __WXDEBUG__
63 // show the assert dialog with the specified message in GUI or just print
64 // the string to stderr in console mode
65 //
66 // base class version has an implementation (in spite of being pure
67 // virtual) in base/appbase.cpp which can be called as last resort.
68 //
69 // return true to suppress subsequent asserts, false to continue as before
70 virtual bool ShowAssertDialog(const wxString& msg) = 0;
71 #endif // __WXDEBUG__
72
73 // return true if fprintf(stderr) goes somewhere, false otherwise
74 virtual bool HasStderr() = 0;
75
76 // managing "pending delete" list: in GUI mode we can't immediately delete
77 // some objects because there may be unprocessed events for them and so we
78 // only do it during the next idle loop iteration while this is, of course,
79 // unnecessary in wxBase, so we have a few functions to abstract these
80 // operations
81
82 // add the object to the pending delete list in GUI, delete it immediately
83 // in wxBase
84 virtual void ScheduleForDestroy(wxObject *object) = 0;
85
86 // remove this object from the pending delete list in GUI, do nothing in
87 // wxBase
88 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
89
90
91 // other miscellaneous helpers
92 // ---------------------------
93
94 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
95 // Unix: in the former case it returns the information about the toolkit
96 // and in the latter -- about the OS, so we need to virtualize it
97 virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
98 };
99
100 // ----------------------------------------------------------------------------
101 // include the platform-specific version of the class
102 // ----------------------------------------------------------------------------
103
104 #if defined(__WXMSW__)
105 #include "wx/msw/apptbase.h"
106 #elif defined(__UNIX__)
107 #include "wx/unix/apptbase.h"
108 #else // no platform-specific methods to add to wxAppTraits
109 typedef
110 // wxAppTraits must be a class because it was forward declared as class
111 class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
112 {
113 };
114 #endif // platform
115
116 // ============================================================================
117 // standard traits for console and GUI applications
118 // ============================================================================
119
120 // ----------------------------------------------------------------------------
121 // wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
122 // ----------------------------------------------------------------------------
123
124 class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
125 {
126 public:
127 #if wxUSE_LOG
128 virtual wxLog *CreateLogTarget();
129 #endif // wxUSE_LOG
130 virtual wxMessageOutput *CreateMessageOutput();
131 #if wxUSE_FONTMAP
132 virtual wxFontMapper *CreateFontMapper();
133 #endif // wxUSE_FONTMAP
134
135 #ifdef __WXDEBUG__
136 virtual bool ShowAssertDialog(const wxString& msg);
137 #endif // __WXDEBUG__
138 virtual bool HasStderr();
139
140 virtual void ScheduleForDestroy(wxObject *object);
141 virtual void RemoveFromPendingDelete(wxObject *object);
142 };
143
144 // ----------------------------------------------------------------------------
145 // wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
146 // ----------------------------------------------------------------------------
147
148 #if wxUSE_GUI
149
150 class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
151 {
152 public:
153 #if wxUSE_LOG
154 virtual wxLog *CreateLogTarget();
155 #endif // wxUSE_LOG
156 virtual wxMessageOutput *CreateMessageOutput();
157 #if wxUSE_FONTMAP
158 virtual wxFontMapper *CreateFontMapper();
159 #endif // wxUSE_FONTMAP
160
161 #ifdef __WXDEBUG__
162 virtual bool ShowAssertDialog(const wxString& msg);
163 #endif // __WXDEBUG__
164 virtual bool HasStderr();
165
166 virtual void ScheduleForDestroy(wxObject *object);
167 virtual void RemoveFromPendingDelete(wxObject *object);
168 };
169
170 #endif // wxUSE_GUI
171
172 // ----------------------------------------------------------------------------
173 // include the platform-specific version of the classes above
174 // ----------------------------------------------------------------------------
175
176 #if defined(__WXMSW__)
177 #include "wx/msw/apptrait.h"
178 #elif defined(__UNIX__)
179 #include "wx/unix/apptrait.h"
180 #else // no platform-specific methods to add to wxAppTraits
181 #if wxUSE_GUI
182 typedef wxGUIAppTraitsBase wxGUIAppTraits;
183 #endif // wxUSE_GUI
184 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
185 #endif // platform
186
187 #endif // _WX_APPTRAIT_H_
188