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