]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
DoPrepareDC needs the dc.
[wxWidgets.git] / include / wx / apptrait.h
CommitLineData
e2478fde
VZ
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$
77ffb593 8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 9// Licence: wxWindows licence
e2478fde
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_APPTRAIT_H_
13#define _WX_APPTRAIT_H_
14
a8eaaeb2
VS
15#include "wx/string.h"
16
17class WXDLLIMPEXP_BASE wxObject;
e2478fde
VZ
18class WXDLLEXPORT wxAppTraits;
19#if wxUSE_FONTMAP
20 class WXDLLEXPORT wxFontMapper;
21#endif // wxUSE_FONTMAP
a8eaaeb2
VS
22class WXDLLIMPEXP_BASE wxLog;
23class WXDLLIMPEXP_BASE wxMessageOutput;
f0244295 24class WXDLLEXPORT wxRendererNative;
a8eaaeb2 25class WXDLLIMPEXP_BASE wxString;
a8eaaeb2 26
f46f68d9
VS
27extern "C"
28{
29 struct GSocketGUIFunctionsTable;
30}
38bb138f 31
a8eaaeb2
VS
32// ----------------------------------------------------------------------------
33// toolkit information
34// ----------------------------------------------------------------------------
35
36// Information about the toolkit that the app is running under (e.g. wxMSW):
37struct WXDLLIMPEXP_BASE wxToolkitInfo
38{
39 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
40 wxString shortName;
41 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
42 // "wxMSW/Universal"); "wxBase" for console apps:
43 wxString name;
44 // Version of the underlying toolkit or of the OS for console apps:
45 int versionMajor, versionMinor;
46 // OS mnenomics, e.g. wxGTK or wxMSW:
47 int os;
48};
49
e2478fde
VZ
50
51// ----------------------------------------------------------------------------
52// wxAppTraits: this class defines various configurable aspects of wxApp
53// ----------------------------------------------------------------------------
54
7af1b539 55class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
56{
57public:
e2478fde
VZ
58 // hooks for creating the global objects, may be overridden by the user
59 // ------------------------------------------------------------------------
60
61#if wxUSE_LOG
62 // create the default log target
63 virtual wxLog *CreateLogTarget() = 0;
64#endif // wxUSE_LOG
65
66 // create the global object used for printing out messages
67 virtual wxMessageOutput *CreateMessageOutput() = 0;
68
69#if wxUSE_FONTMAP
70 // create the global font mapper object used for encodings/charset mapping
71 virtual wxFontMapper *CreateFontMapper() = 0;
72#endif // wxUSE_FONTMAP
73
f0244295
VZ
74 // get the renderer to use for drawing the generic controls (return value
75 // may be NULL in which case the default renderer for the current platform
76 // is used); this is used in GUI only and always returns NULL in console
77 //
78 // NB: returned pointer will be deleted by the caller
79 virtual wxRendererNative *CreateRenderer() = 0;
80
e2478fde
VZ
81
82 // functions abstracting differences between GUI and console modes
83 // ------------------------------------------------------------------------
84
85#ifdef __WXDEBUG__
86 // show the assert dialog with the specified message in GUI or just print
87 // the string to stderr in console mode
88 //
89 // base class version has an implementation (in spite of being pure
90 // virtual) in base/appbase.cpp which can be called as last resort.
91 //
92 // return true to suppress subsequent asserts, false to continue as before
93 virtual bool ShowAssertDialog(const wxString& msg) = 0;
94#endif // __WXDEBUG__
95
96 // return true if fprintf(stderr) goes somewhere, false otherwise
97 virtual bool HasStderr() = 0;
98
99 // managing "pending delete" list: in GUI mode we can't immediately delete
100 // some objects because there may be unprocessed events for them and so we
101 // only do it during the next idle loop iteration while this is, of course,
102 // unnecessary in wxBase, so we have a few functions to abstract these
103 // operations
104
105 // add the object to the pending delete list in GUI, delete it immediately
106 // in wxBase
107 virtual void ScheduleForDestroy(wxObject *object) = 0;
108
109 // remove this object from the pending delete list in GUI, do nothing in
110 // wxBase
111 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
2739d4f0 112
38bb138f 113#if wxUSE_SOCKETS
321b8029
VS
114 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
115 // is needed because networking classes are in their own library and so
116 // they can't directly call GUI functions (the same net library can be
117 // used in both GUI and base apps). To complicate it further, GUI library
118 // ("wxCore") doesn't depend on networking library and so only a functions
119 // table can be passed around
38bb138f
VS
120 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
121#endif
122
2739d4f0 123
a8eaaeb2
VS
124 // return information about what toolkit is running; we need for two things
125 // that are both contained in wxBase:
126 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
127 // Unix: in the former case it returns the information about the toolkit
128 // and in the latter -- about the OS, so we need to virtualize it
129 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
130 // signature in DLL name
324899f6 131 virtual wxToolkitInfo& GetToolkitInfo() = 0;
e2478fde
VZ
132};
133
134// ----------------------------------------------------------------------------
135// include the platform-specific version of the class
136// ----------------------------------------------------------------------------
137
29c99ad3
VZ
138// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
139// Unix code (and otherwise __UNIX__ wouldn't be defined)
e2478fde
VZ
140#if defined(__WXMSW__)
141 #include "wx/msw/apptbase.h"
621ccd8a 142#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 143 #include "wx/unix/apptbase.h"
29c99ad3
VZ
144#elif defined(__WXMAC__)
145 #include "wx/mac/apptbase.h"
9fc852b7
SN
146#elif defined(__OS2__)
147 #include "wx/os2/apptbase.h"
46446cc2 148#else // no platform-specific methods to add to wxAppTraits
e2478fde 149 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 150 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
151 {
152 };
153#endif // platform
154
155// ============================================================================
156// standard traits for console and GUI applications
157// ============================================================================
158
159// ----------------------------------------------------------------------------
160// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
161// ----------------------------------------------------------------------------
162
7af1b539 163class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
164{
165public:
166#if wxUSE_LOG
167 virtual wxLog *CreateLogTarget();
168#endif // wxUSE_LOG
169 virtual wxMessageOutput *CreateMessageOutput();
170#if wxUSE_FONTMAP
171 virtual wxFontMapper *CreateFontMapper();
172#endif // wxUSE_FONTMAP
f0244295 173 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
174#if wxUSE_SOCKETS
175 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
176#endif
e2478fde
VZ
177
178#ifdef __WXDEBUG__
179 virtual bool ShowAssertDialog(const wxString& msg);
180#endif // __WXDEBUG__
181 virtual bool HasStderr();
182
183 virtual void ScheduleForDestroy(wxObject *object);
184 virtual void RemoveFromPendingDelete(wxObject *object);
185};
186
187// ----------------------------------------------------------------------------
188// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
189// ----------------------------------------------------------------------------
190
191#if wxUSE_GUI
192
94826170 193class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
194{
195public:
196#if wxUSE_LOG
197 virtual wxLog *CreateLogTarget();
198#endif // wxUSE_LOG
199 virtual wxMessageOutput *CreateMessageOutput();
200#if wxUSE_FONTMAP
201 virtual wxFontMapper *CreateFontMapper();
202#endif // wxUSE_FONTMAP
f0244295 203 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
204#if wxUSE_SOCKETS
205 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
206#endif
e2478fde
VZ
207
208#ifdef __WXDEBUG__
209 virtual bool ShowAssertDialog(const wxString& msg);
210#endif // __WXDEBUG__
211 virtual bool HasStderr();
212
213 virtual void ScheduleForDestroy(wxObject *object);
214 virtual void RemoveFromPendingDelete(wxObject *object);
215};
216
217#endif // wxUSE_GUI
218
219// ----------------------------------------------------------------------------
220// include the platform-specific version of the classes above
221// ----------------------------------------------------------------------------
222
223#if defined(__WXMSW__)
224 #include "wx/msw/apptrait.h"
621ccd8a 225#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 226 #include "wx/unix/apptrait.h"
29c99ad3
VZ
227#elif defined(__WXMAC__)
228 #include "wx/mac/apptrait.h"
7332d96b 229#elif defined(__WXPM__)
a637417c 230 #include "wx/os2/apptrait.h"
621ccd8a
SN
231#else
232 // at least, we need an implementation of GetToolkitInfo !
e2478fde 233 #if wxUSE_GUI
621ccd8a
SN
234 class wxGUIAppTraits : public wxGUIAppTraitsBase
235 {
236 virtual wxToolkitInfo& GetToolkitInfo();
237 };
e2478fde 238 #endif // wxUSE_GUI
621ccd8a
SN
239 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
240 {
241 virtual wxToolkitInfo& GetToolkitInfo();
242 };
e2478fde
VZ
243#endif // platform
244
245#endif // _WX_APPTRAIT_H_
246