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