]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
Avoid warnings from VC++ 5.0
[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 15#include "wx/string.h"
8bb6b2c0 16#include "wx/platinfo.h"
a8eaaeb2
VS
17
18class WXDLLIMPEXP_BASE wxObject;
e2478fde
VZ
19class WXDLLEXPORT wxAppTraits;
20#if wxUSE_FONTMAP
21 class WXDLLEXPORT wxFontMapper;
22#endif // wxUSE_FONTMAP
a8eaaeb2
VS
23class WXDLLIMPEXP_BASE wxLog;
24class WXDLLIMPEXP_BASE wxMessageOutput;
f0244295 25class WXDLLEXPORT wxRendererNative;
a8eaaeb2 26class WXDLLIMPEXP_BASE wxString;
a8eaaeb2 27
3e1400ac 28class GSocketGUIFunctionsTable;
38bb138f 29
e2478fde
VZ
30
31// ----------------------------------------------------------------------------
32// wxAppTraits: this class defines various configurable aspects of wxApp
33// ----------------------------------------------------------------------------
34
fc480dc1
DE
35class WXDLLIMPEXP_BASE wxStandardPathsBase;
36
7af1b539 37class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
38{
39public:
ed62f740
VZ
40 // needed since this class declares virtual members
41 virtual ~wxAppTraitsBase() { }
42
e2478fde
VZ
43 // hooks for creating the global objects, may be overridden by the user
44 // ------------------------------------------------------------------------
45
46#if wxUSE_LOG
47 // create the default log target
48 virtual wxLog *CreateLogTarget() = 0;
49#endif // wxUSE_LOG
50
51 // create the global object used for printing out messages
52 virtual wxMessageOutput *CreateMessageOutput() = 0;
53
54#if wxUSE_FONTMAP
55 // create the global font mapper object used for encodings/charset mapping
56 virtual wxFontMapper *CreateFontMapper() = 0;
57#endif // wxUSE_FONTMAP
58
f0244295
VZ
59 // get the renderer to use for drawing the generic controls (return value
60 // may be NULL in which case the default renderer for the current platform
61 // is used); this is used in GUI only and always returns NULL in console
62 //
63 // NB: returned pointer will be deleted by the caller
64 virtual wxRendererNative *CreateRenderer() = 0;
65
07158944 66#if wxUSE_STDPATHS
fc480dc1
DE
67 // wxStandardPaths object is normally the same for wxBase and wxGUI
68 // except in the case of wxMac and wxCocoa
69 virtual wxStandardPathsBase& GetStandardPaths();
07158944 70#endif // wxUSE_STDPATHS
e2478fde
VZ
71
72 // functions abstracting differences between GUI and console modes
73 // ------------------------------------------------------------------------
74
75#ifdef __WXDEBUG__
76 // show the assert dialog with the specified message in GUI or just print
77 // the string to stderr in console mode
78 //
79 // base class version has an implementation (in spite of being pure
80 // virtual) in base/appbase.cpp which can be called as last resort.
81 //
82 // return true to suppress subsequent asserts, false to continue as before
83 virtual bool ShowAssertDialog(const wxString& msg) = 0;
84#endif // __WXDEBUG__
85
86 // return true if fprintf(stderr) goes somewhere, false otherwise
87 virtual bool HasStderr() = 0;
88
89 // managing "pending delete" list: in GUI mode we can't immediately delete
90 // some objects because there may be unprocessed events for them and so we
91 // only do it during the next idle loop iteration while this is, of course,
92 // unnecessary in wxBase, so we have a few functions to abstract these
93 // operations
94
95 // add the object to the pending delete list in GUI, delete it immediately
96 // in wxBase
97 virtual void ScheduleForDestroy(wxObject *object) = 0;
98
99 // remove this object from the pending delete list in GUI, do nothing in
100 // wxBase
101 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
2739d4f0 102
38bb138f 103#if wxUSE_SOCKETS
321b8029 104 // return table of GUI callbacks for GSocket code or NULL in wxBase. This
4629016d 105 // is needed because networking classes are in their own library and so
321b8029
VS
106 // they can't directly call GUI functions (the same net library can be
107 // used in both GUI and base apps). To complicate it further, GUI library
108 // ("wxCore") doesn't depend on networking library and so only a functions
109 // table can be passed around
38bb138f
VS
110 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
111#endif
112
8bb6b2c0
VZ
113 // return information about the (native) toolkit currently used;
114 // returns wxPORT_BASE for console applications and one of the remaining
115 // wxPORT_* values for GUI applications.
116 virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
e2478fde
VZ
117};
118
119// ----------------------------------------------------------------------------
120// include the platform-specific version of the class
121// ----------------------------------------------------------------------------
122
532d575b
WS
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)
125// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 126#if defined(__WXPALMOS__)
ffecfa5a 127 #include "wx/palmos/apptbase.h"
532d575b 128#elif defined(__WIN32__)
e2478fde 129 #include "wx/msw/apptbase.h"
621ccd8a 130#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 131 #include "wx/unix/apptbase.h"
29c99ad3
VZ
132#elif defined(__WXMAC__)
133 #include "wx/mac/apptbase.h"
9fc852b7
SN
134#elif defined(__OS2__)
135 #include "wx/os2/apptbase.h"
46446cc2 136#else // no platform-specific methods to add to wxAppTraits
e2478fde 137 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 138 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
139 {
140 };
141#endif // platform
142
143// ============================================================================
144// standard traits for console and GUI applications
145// ============================================================================
146
147// ----------------------------------------------------------------------------
148// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
149// ----------------------------------------------------------------------------
150
7af1b539 151class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
152{
153public:
154#if wxUSE_LOG
155 virtual wxLog *CreateLogTarget();
156#endif // wxUSE_LOG
157 virtual wxMessageOutput *CreateMessageOutput();
158#if wxUSE_FONTMAP
159 virtual wxFontMapper *CreateFontMapper();
160#endif // wxUSE_FONTMAP
f0244295 161 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
162#if wxUSE_SOCKETS
163 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
164#endif
e2478fde
VZ
165
166#ifdef __WXDEBUG__
167 virtual bool ShowAssertDialog(const wxString& msg);
168#endif // __WXDEBUG__
169 virtual bool HasStderr();
170
171 virtual void ScheduleForDestroy(wxObject *object);
172 virtual void RemoveFromPendingDelete(wxObject *object);
8bb6b2c0
VZ
173
174 // the GetToolkitVersion for console application is always the same
175 wxPortId GetToolkitVersion(int *verMaj, int *verMin) const
176 {
177 // no toolkits (wxBase is for console applications without GUI support)
178 // NB: zero means "no toolkit", -1 means "not initialized yet"
179 // so we must use zero here!
180 if (verMaj) *verMaj = 0;
181 if (verMin) *verMin = 0;
182 return wxPORT_BASE;
183 }
e2478fde
VZ
184};
185
186// ----------------------------------------------------------------------------
187// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
188// ----------------------------------------------------------------------------
189
190#if wxUSE_GUI
191
94826170 192class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
193{
194public:
195#if wxUSE_LOG
196 virtual wxLog *CreateLogTarget();
197#endif // wxUSE_LOG
198 virtual wxMessageOutput *CreateMessageOutput();
199#if wxUSE_FONTMAP
200 virtual wxFontMapper *CreateFontMapper();
201#endif // wxUSE_FONTMAP
f0244295 202 virtual wxRendererNative *CreateRenderer();
38bb138f
VS
203#if wxUSE_SOCKETS
204 virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
205#endif
e2478fde
VZ
206
207#ifdef __WXDEBUG__
208 virtual bool ShowAssertDialog(const wxString& msg);
209#endif // __WXDEBUG__
210 virtual bool HasStderr();
211
212 virtual void ScheduleForDestroy(wxObject *object);
213 virtual void RemoveFromPendingDelete(wxObject *object);
214};
215
216#endif // wxUSE_GUI
217
218// ----------------------------------------------------------------------------
219// include the platform-specific version of the classes above
220// ----------------------------------------------------------------------------
221
532d575b 222// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
4055ed82 223#if defined(__WXPALMOS__)
ffecfa5a 224 #include "wx/palmos/apptrait.h"
532d575b 225#elif defined(__WIN32__)
e2478fde 226 #include "wx/msw/apptrait.h"
621ccd8a 227#elif defined(__UNIX__) && !defined(__EMX__)
2d2d4fc7 228 #include "wx/unix/apptrait.h"
29c99ad3
VZ
229#elif defined(__WXMAC__)
230 #include "wx/mac/apptrait.h"
7332d96b 231#elif defined(__WXPM__)
a637417c 232 #include "wx/os2/apptrait.h"
4629016d 233#else
e2478fde 234 #if wxUSE_GUI
621ccd8a
SN
235 class wxGUIAppTraits : public wxGUIAppTraitsBase
236 {
621ccd8a 237 };
e2478fde 238 #endif // wxUSE_GUI
4629016d 239 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
621ccd8a 240 {
621ccd8a 241 };
e2478fde
VZ
242#endif // platform
243
244#endif // _WX_APPTRAIT_H_
245