]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/apptrait.h
don't draw borders for bitmap buttons with wxBORDER_NONE style
[wxWidgets.git] / include / wx / apptrait.h
... / ...
CommitLineData
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@wxwidgets.org>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_APPTRAIT_H_
13#define _WX_APPTRAIT_H_
14
15#include "wx/string.h"
16#include "wx/platinfo.h"
17
18class WXDLLIMPEXP_FWD_BASE wxArrayString;
19class WXDLLIMPEXP_FWD_BASE wxConfigBase;
20class WXDLLIMPEXP_FWD_BASE wxEventLoopBase;
21#if wxUSE_FONTMAP
22 class WXDLLIMPEXP_FWD_CORE wxFontMapper;
23#endif // wxUSE_FONTMAP
24class WXDLLIMPEXP_FWD_BASE wxLog;
25class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
26class WXDLLIMPEXP_FWD_BASE wxObject;
27class WXDLLIMPEXP_FWD_CORE wxRendererNative;
28class WXDLLIMPEXP_FWD_BASE wxStandardPaths;
29class WXDLLIMPEXP_FWD_BASE wxString;
30class WXDLLIMPEXP_FWD_BASE wxTimer;
31class WXDLLIMPEXP_FWD_BASE wxTimerImpl;
32
33class wxSocketManager;
34
35
36// ----------------------------------------------------------------------------
37// wxAppTraits: this class defines various configurable aspects of wxApp
38// ----------------------------------------------------------------------------
39
40class WXDLLIMPEXP_BASE wxAppTraitsBase
41{
42public:
43 // needed since this class declares virtual members
44 virtual ~wxAppTraitsBase() { }
45
46 // hooks for working with the global objects, may be overridden by the user
47 // ------------------------------------------------------------------------
48
49#if wxUSE_CONFIG
50 // create the default configuration object (base class version is
51 // implemented in config.cpp and creates wxRegConfig for wxMSW and
52 // wxFileConfig for all the other platforms)
53 virtual wxConfigBase *CreateConfig();
54#endif // wxUSE_CONFIG
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
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
76 // wxStandardPaths object is normally the same for wxBase and wxGUI
77 // except in the case of wxMac and wxCocoa
78 virtual wxStandardPaths& GetStandardPaths();
79
80#if wxUSE_INTL
81 // called during wxApp initialization to set the locale to correspond to
82 // the user default (i.e. system locale under Windows, LC_ALL under Unix)
83 virtual void SetLocale();
84#endif // wxUSE_INTL
85
86
87 // functions abstracting differences between GUI and console modes
88 // ------------------------------------------------------------------------
89
90 // show the assert dialog with the specified message in GUI or just print
91 // the string to stderr in console mode
92 //
93 // base class version has an implementation (in spite of being pure
94 // virtual) in base/appbase.cpp which can be called as last resort.
95 //
96 // return true to suppress subsequent asserts, false to continue as before
97 virtual bool ShowAssertDialog(const wxString& msg) = 0;
98
99 // return true if fprintf(stderr) goes somewhere, false otherwise
100 virtual bool HasStderr() = 0;
101
102 // managing "pending delete" list: in GUI mode we can't immediately delete
103 // some objects because there may be unprocessed events for them and so we
104 // only do it during the next idle loop iteration while this is, of course,
105 // unnecessary in wxBase, so we have a few functions to abstract these
106 // operations
107
108 // add the object to the pending delete list in GUI, delete it immediately
109 // in wxBase
110 virtual void ScheduleForDestroy(wxObject *object) = 0;
111
112 // remove this object from the pending delete list in GUI, do nothing in
113 // wxBase
114 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
115
116#if wxUSE_SOCKETS
117 // this function is used by wxNet library to set the default socket manager
118 // to use: doing it like this allows us to keep all socket-related code in
119 // wxNet instead of having to pull it in wxBase itself as we'd have to do
120 // if we really implemented wxSocketManager here
121 //
122 // we don't take ownership of this pointer, it should have a lifetime
123 // greater than that of any socket (e.g. be a pointer to a static object)
124 static void SetDefaultSocketManager(wxSocketManager *manager)
125 {
126 ms_manager = manager;
127 }
128
129 // return socket manager: this is usually different for console and GUI
130 // applications (although some ports use the same implementation for both)
131 virtual wxSocketManager *GetSocketManager() { return ms_manager; }
132#endif
133
134 // create a new, port specific, instance of the event loop used by wxApp
135 virtual wxEventLoopBase *CreateEventLoop() = 0;
136
137#if wxUSE_TIMER
138 // return platform and toolkit dependent wxTimer implementation
139 virtual wxTimerImpl *CreateTimerImpl(wxTimer *timer) = 0;
140#endif
141
142#if wxUSE_THREADS
143 virtual void MutexGuiEnter();
144 virtual void MutexGuiLeave();
145#endif
146
147 // functions returning port-specific information
148 // ------------------------------------------------------------------------
149
150 // return information about the (native) toolkit currently used and its
151 // runtime (not compile-time) version.
152 // returns wxPORT_BASE for console applications and one of the remaining
153 // wxPORT_* values for GUI applications.
154 virtual wxPortId GetToolkitVersion(int *majVer = NULL, int *minVer = NULL) const = 0;
155
156 // return true if the port is using wxUniversal for the GUI, false if not
157 virtual bool IsUsingUniversalWidgets() const = 0;
158
159 // return the name of the Desktop Environment such as
160 // "KDE" or "GNOME". May return an empty string.
161 virtual wxString GetDesktopEnvironment() const = 0;
162
163 // returns a short string to identify the block of the standard command
164 // line options parsed automatically by current port: if this string is
165 // empty, there are no such options, otherwise the function also fills
166 // passed arrays with the names and the descriptions of those options.
167 virtual wxString GetStandardCmdLineOptions(wxArrayString& names,
168 wxArrayString& desc) const
169 {
170 wxUnusedVar(names);
171 wxUnusedVar(desc);
172
173 return wxEmptyString;
174 }
175
176
177protected:
178#if wxUSE_STACKWALKER
179 // utility function: returns the stack frame as a plain wxString
180 virtual wxString GetAssertStackTrace();
181#endif
182
183private:
184 static wxSocketManager *ms_manager;
185};
186
187// ----------------------------------------------------------------------------
188// include the platform-specific version of the class
189// ----------------------------------------------------------------------------
190
191// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
192// Unix code (and otherwise __UNIX__ wouldn't be defined)
193// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
194#if defined(__WXPALMOS__)
195 #include "wx/palmos/apptbase.h"
196#elif defined(__WIN32__)
197 #include "wx/msw/apptbase.h"
198#elif defined(__UNIX__) && !defined(__EMX__)
199 #include "wx/unix/apptbase.h"
200#elif defined(__OS2__)
201 #include "wx/os2/apptbase.h"
202#else // no platform-specific methods to add to wxAppTraits
203 // wxAppTraits must be a class because it was forward declared as class
204 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
205 {
206 };
207#endif // platform
208
209// ============================================================================
210// standard traits for console and GUI applications
211// ============================================================================
212
213// ----------------------------------------------------------------------------
214// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
215// ----------------------------------------------------------------------------
216
217class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
218{
219public:
220#if !wxUSE_CONSOLE_EVENTLOOP
221 virtual wxEventLoopBase *CreateEventLoop() { return NULL; }
222#endif // !wxUSE_CONSOLE_EVENTLOOP
223
224#if wxUSE_LOG
225 virtual wxLog *CreateLogTarget();
226#endif // wxUSE_LOG
227 virtual wxMessageOutput *CreateMessageOutput();
228#if wxUSE_FONTMAP
229 virtual wxFontMapper *CreateFontMapper();
230#endif // wxUSE_FONTMAP
231 virtual wxRendererNative *CreateRenderer();
232
233 virtual bool ShowAssertDialog(const wxString& msg);
234 virtual bool HasStderr();
235
236 virtual void ScheduleForDestroy(wxObject *object);
237 virtual void RemoveFromPendingDelete(wxObject *object);
238
239 // the GetToolkitVersion for console application is always the same
240 virtual wxPortId GetToolkitVersion(int *verMaj = NULL, int *verMin = NULL) const
241 {
242 // no toolkits (wxBase is for console applications without GUI support)
243 // NB: zero means "no toolkit", -1 means "not initialized yet"
244 // so we must use zero here!
245 if (verMaj) *verMaj = 0;
246 if (verMin) *verMin = 0;
247 return wxPORT_BASE;
248 }
249
250 virtual bool IsUsingUniversalWidgets() const { return false; }
251 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
252};
253
254// ----------------------------------------------------------------------------
255// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
256// ----------------------------------------------------------------------------
257
258#if wxUSE_GUI
259
260class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits
261{
262public:
263#if wxUSE_LOG
264 virtual wxLog *CreateLogTarget();
265#endif // wxUSE_LOG
266 virtual wxMessageOutput *CreateMessageOutput();
267#if wxUSE_FONTMAP
268 virtual wxFontMapper *CreateFontMapper();
269#endif // wxUSE_FONTMAP
270 virtual wxRendererNative *CreateRenderer();
271
272 virtual bool ShowAssertDialog(const wxString& msg);
273 virtual bool HasStderr();
274
275 virtual void ScheduleForDestroy(wxObject *object);
276 virtual void RemoveFromPendingDelete(wxObject *object);
277
278 virtual bool IsUsingUniversalWidgets() const
279 {
280 #ifdef __WXUNIVERSAL__
281 return true;
282 #else
283 return false;
284 #endif
285 }
286
287 virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
288};
289
290#endif // wxUSE_GUI
291
292// ----------------------------------------------------------------------------
293// include the platform-specific version of the classes above
294// ----------------------------------------------------------------------------
295
296// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port
297#if defined(__WXPALMOS__)
298 #include "wx/palmos/apptrait.h"
299#elif defined(__WIN32__)
300 #include "wx/msw/apptrait.h"
301#elif defined(__OS2__)
302 #include "wx/os2/apptrait.h"
303#elif defined(__UNIX__)
304 #include "wx/unix/apptrait.h"
305#elif defined(__DOS__)
306 #include "wx/msdos/apptrait.h"
307#else
308 #if wxUSE_GUI
309 class wxGUIAppTraits : public wxGUIAppTraitsBase
310 {
311 };
312 #endif // wxUSE_GUI
313 class wxConsoleAppTraits: public wxConsoleAppTraitsBase
314 {
315 };
316#endif // platform
317
318#endif // _WX_APPTRAIT_H_
319