]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
disable Borland C++ warnings
[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$
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
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
VS
26
27// ----------------------------------------------------------------------------
28// toolkit information
29// ----------------------------------------------------------------------------
30
31// Information about the toolkit that the app is running under (e.g. wxMSW):
32struct WXDLLIMPEXP_BASE wxToolkitInfo
33{
34 // Short name of the toolkit (e.g. "msw" or "mswuniv"); empty for console:
35 wxString shortName;
36 // Descriptive name of the toolkit, human readable (e.g. "wxMSW" or
37 // "wxMSW/Universal"); "wxBase" for console apps:
38 wxString name;
39 // Version of the underlying toolkit or of the OS for console apps:
40 int versionMajor, versionMinor;
41 // OS mnenomics, e.g. wxGTK or wxMSW:
42 int os;
43};
44
e2478fde
VZ
45
46// ----------------------------------------------------------------------------
47// wxAppTraits: this class defines various configurable aspects of wxApp
48// ----------------------------------------------------------------------------
49
7af1b539 50class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
51{
52public:
e2478fde
VZ
53 // hooks for creating the global objects, may be overridden by the user
54 // ------------------------------------------------------------------------
55
56#if wxUSE_LOG
57 // create the default log target
58 virtual wxLog *CreateLogTarget() = 0;
59#endif // wxUSE_LOG
60
61 // create the global object used for printing out messages
62 virtual wxMessageOutput *CreateMessageOutput() = 0;
63
64#if wxUSE_FONTMAP
65 // create the global font mapper object used for encodings/charset mapping
66 virtual wxFontMapper *CreateFontMapper() = 0;
67#endif // wxUSE_FONTMAP
68
f0244295
VZ
69 // get the renderer to use for drawing the generic controls (return value
70 // may be NULL in which case the default renderer for the current platform
71 // is used); this is used in GUI only and always returns NULL in console
72 //
73 // NB: returned pointer will be deleted by the caller
74 virtual wxRendererNative *CreateRenderer() = 0;
75
e2478fde
VZ
76
77 // functions abstracting differences between GUI and console modes
78 // ------------------------------------------------------------------------
79
80#ifdef __WXDEBUG__
81 // show the assert dialog with the specified message in GUI or just print
82 // the string to stderr in console mode
83 //
84 // base class version has an implementation (in spite of being pure
85 // virtual) in base/appbase.cpp which can be called as last resort.
86 //
87 // return true to suppress subsequent asserts, false to continue as before
88 virtual bool ShowAssertDialog(const wxString& msg) = 0;
89#endif // __WXDEBUG__
90
91 // return true if fprintf(stderr) goes somewhere, false otherwise
92 virtual bool HasStderr() = 0;
93
94 // managing "pending delete" list: in GUI mode we can't immediately delete
95 // some objects because there may be unprocessed events for them and so we
96 // only do it during the next idle loop iteration while this is, of course,
97 // unnecessary in wxBase, so we have a few functions to abstract these
98 // operations
99
100 // add the object to the pending delete list in GUI, delete it immediately
101 // in wxBase
102 virtual void ScheduleForDestroy(wxObject *object) = 0;
103
104 // remove this object from the pending delete list in GUI, do nothing in
105 // wxBase
106 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
2739d4f0
VZ
107
108
a8eaaeb2
VS
109 // return information about what toolkit is running; we need for two things
110 // that are both contained in wxBase:
111 // - wxGetOsVersion() behaves differently in GUI and non-GUI builds under
112 // Unix: in the former case it returns the information about the toolkit
113 // and in the latter -- about the OS, so we need to virtualize it
114 // - wxDynamicLibrary::CanonicalizePluginName() must embed toolkit
115 // signature in DLL name
324899f6 116 virtual wxToolkitInfo& GetToolkitInfo() = 0;
e2478fde
VZ
117};
118
119// ----------------------------------------------------------------------------
120// include the platform-specific version of the class
121// ----------------------------------------------------------------------------
122
29c99ad3
VZ
123// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
124// Unix code (and otherwise __UNIX__ wouldn't be defined)
e2478fde
VZ
125#if defined(__WXMSW__)
126 #include "wx/msw/apptbase.h"
2d2d4fc7
VZ
127#elif defined(__UNIX__)
128 #include "wx/unix/apptbase.h"
29c99ad3
VZ
129#elif defined(__WXMAC__)
130 #include "wx/mac/apptbase.h"
46446cc2 131#else // no platform-specific methods to add to wxAppTraits
e2478fde 132 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 133 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
134 {
135 };
136#endif // platform
137
138// ============================================================================
139// standard traits for console and GUI applications
140// ============================================================================
141
142// ----------------------------------------------------------------------------
143// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
144// ----------------------------------------------------------------------------
145
7af1b539 146class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
147{
148public:
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
f0244295 156 virtual wxRendererNative *CreateRenderer();
e2478fde
VZ
157
158#ifdef __WXDEBUG__
159 virtual bool ShowAssertDialog(const wxString& msg);
160#endif // __WXDEBUG__
161 virtual bool HasStderr();
162
163 virtual void ScheduleForDestroy(wxObject *object);
164 virtual void RemoveFromPendingDelete(wxObject *object);
165};
166
167// ----------------------------------------------------------------------------
168// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
169// ----------------------------------------------------------------------------
170
171#if wxUSE_GUI
172
94826170 173class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
174{
175public:
176#if wxUSE_LOG
177 virtual wxLog *CreateLogTarget();
178#endif // wxUSE_LOG
179 virtual wxMessageOutput *CreateMessageOutput();
180#if wxUSE_FONTMAP
181 virtual wxFontMapper *CreateFontMapper();
182#endif // wxUSE_FONTMAP
f0244295 183 virtual wxRendererNative *CreateRenderer();
e2478fde
VZ
184
185#ifdef __WXDEBUG__
186 virtual bool ShowAssertDialog(const wxString& msg);
187#endif // __WXDEBUG__
188 virtual bool HasStderr();
189
190 virtual void ScheduleForDestroy(wxObject *object);
191 virtual void RemoveFromPendingDelete(wxObject *object);
192};
193
194#endif // wxUSE_GUI
195
196// ----------------------------------------------------------------------------
197// include the platform-specific version of the classes above
198// ----------------------------------------------------------------------------
199
200#if defined(__WXMSW__)
201 #include "wx/msw/apptrait.h"
2d2d4fc7
VZ
202#elif defined(__UNIX__)
203 #include "wx/unix/apptrait.h"
29c99ad3
VZ
204#elif defined(__WXMAC__)
205 #include "wx/mac/apptrait.h"
e2478fde
VZ
206#else // no platform-specific methods to add to wxAppTraits
207 #if wxUSE_GUI
208 typedef wxGUIAppTraitsBase wxGUIAppTraits;
209 #endif // wxUSE_GUI
210 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
211#endif // platform
212
213#endif // _WX_APPTRAIT_H_
214