]> git.saurik.com Git - wxWidgets.git/blob - include/wx/platinfo.h
Avoid conflict between new transparency API and old background support.
[wxWidgets.git] / include / wx / platinfo.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/platinfo.h
3 // Purpose: declaration of the wxPlatformInfo class
4 // Author: Francesco Montorsi
5 // Modified by:
6 // Created: 07.07.2006 (based on wxToolkitInfo)
7 // RCS-ID: $Id$
8 // Copyright: (c) 2006 Francesco Montorsi
9 // License: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PLATINFO_H_
13 #define _WX_PLATINFO_H_
14
15 #include "wx/string.h"
16
17 // ----------------------------------------------------------------------------
18 // wxPlatformInfo
19 // ----------------------------------------------------------------------------
20
21 // VERY IMPORTANT: when changing these enum values, also change the relative
22 // string tables in src/common/platinfo.cpp
23
24
25 // families & sub-families of operating systems
26 enum wxOperatingSystemId
27 {
28 wxOS_UNKNOWN = 0, // returned on error
29
30 wxOS_MAC_OS = 1 << 0, // Apple Mac OS 8/9/X with Mac paths
31 wxOS_MAC_OSX_DARWIN = 1 << 1, // Apple Mac OS X with Unix paths
32 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
33
34 wxOS_WINDOWS_9X = 1 << 2, // Windows 9x family (95/98/ME)
35 wxOS_WINDOWS_NT = 1 << 3, // Windows NT family (NT/2000/XP)
36 wxOS_WINDOWS_MICRO = 1 << 4, // MicroWindows
37 wxOS_WINDOWS_CE = 1 << 5, // Windows CE (Window Mobile)
38 wxOS_WINDOWS = wxOS_WINDOWS_9X |
39 wxOS_WINDOWS_NT |
40 wxOS_WINDOWS_MICRO |
41 wxOS_WINDOWS_CE,
42
43 wxOS_UNIX_LINUX = 1 << 6, // Linux
44 wxOS_UNIX_FREEBSD = 1 << 7, // FreeBSD
45 wxOS_UNIX_OPENBSD = 1 << 8, // OpenBSD
46 wxOS_UNIX_NETBSD = 1 << 9, // NetBSD
47 wxOS_UNIX_SOLARIS = 1 << 10, // SunOS
48 wxOS_UNIX_AIX = 1 << 11, // AIX
49 wxOS_UNIX_HPUX = 1 << 12, // HP/UX
50 wxOS_UNIX = wxOS_UNIX_LINUX |
51 wxOS_UNIX_FREEBSD |
52 wxOS_UNIX_OPENBSD |
53 wxOS_UNIX_NETBSD |
54 wxOS_UNIX_SOLARIS |
55 wxOS_UNIX_AIX |
56 wxOS_UNIX_HPUX,
57
58 // 1<<13 and 1<<14 available for other Unix flavours
59
60 wxOS_DOS = 1 << 15, // Microsoft DOS
61 wxOS_OS2 = 1 << 16 // OS/2
62 };
63
64 // list of wxWidgets ports - some of them can be used with more than
65 // a single toolkit.
66 enum wxPortId
67 {
68 wxPORT_UNKNOWN = 0, // returned on error
69
70 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
71
72 wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API
73 wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif
74 wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
75 wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal
76 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
77 wxPORT_OS2 = 1 << 6, // wxOS2, using OS/2 Presentation Manager
78 wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
79 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
80 wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
81 wxPORT_PALMOS = 1 << 10 // wxPalmOS, toolkit is PalmOS API
82 };
83
84 // architecture of the operating system
85 // (regardless of the build environment of wxWidgets library - see
86 // wxIsPlatform64bit documentation for more info)
87 enum wxArchitecture
88 {
89 wxARCH_INVALID = -1, // returned on error
90
91 wxARCH_32, // 32 bit
92 wxARCH_64,
93
94 wxARCH_MAX
95 };
96
97
98 // endian-ness of the machine
99 enum wxEndianness
100 {
101 wxENDIAN_INVALID = -1, // returned on error
102
103 wxENDIAN_BIG, // 4321
104 wxENDIAN_LITTLE, // 1234
105 wxENDIAN_PDP, // 3412
106
107 wxENDIAN_MAX
108 };
109
110 // Information about the toolkit that the app is running under and some basic
111 // platform and architecture info
112 class WXDLLIMPEXP_BASE wxPlatformInfo
113 {
114 public:
115 wxPlatformInfo();
116 wxPlatformInfo(wxPortId pid,
117 int tkMajor = -1, int tkMinor = -1,
118 wxOperatingSystemId id = wxOS_UNKNOWN,
119 int osMajor = -1, int osMinor = -1,
120 wxArchitecture arch = wxARCH_INVALID,
121 wxEndianness endian = wxENDIAN_INVALID,
122 bool usingUniversal = false);
123
124 // default copy ctor, assignment operator and dtor are ok
125
126 bool operator==(const wxPlatformInfo &t) const;
127
128 bool operator!=(const wxPlatformInfo &t) const
129 { return !(*this == t); }
130
131
132 // string -> enum conversions
133 // ---------------------------------
134
135 static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
136 static wxPortId GetPortId(const wxString &portname);
137
138 static wxArchitecture GetArch(const wxString &arch);
139 static wxEndianness GetEndianness(const wxString &end);
140
141 // enum -> string conversions
142 // ---------------------------------
143
144 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
145 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
146 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
147 static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
148
149 static wxString GetArchName(wxArchitecture arch);
150 static wxString GetEndiannessName(wxEndianness end);
151
152 // getters
153 // -----------------
154
155 int GetOSMajorVersion() const
156 { return m_osVersionMajor; }
157 int GetOSMinorVersion() const
158 { return m_osVersionMinor; }
159
160 int GetToolkitMajorVersion() const
161 { return m_tkVersionMajor; }
162 int GetToolkitMinorVersion() const
163 { return m_tkVersionMinor; }
164
165 bool IsUsingUniversalWidgets() const
166 { return m_usingUniversal; }
167
168 wxOperatingSystemId GetOperatingSystemId() const
169 { return m_os; }
170 wxPortId GetPortId() const
171 { return m_port; }
172 wxArchitecture GetArchitecture() const
173 { return m_arch; }
174 wxEndianness GetEndianness() const
175 { return m_endian; }
176
177
178 // string getters
179 // -----------------
180
181 wxString GetOperatingSystemFamilyName() const
182 { return GetOperatingSystemFamilyName(m_os); }
183 wxString GetOperatingSystemIdName() const
184 { return GetOperatingSystemIdName(m_os); }
185 wxString GetPortIdName() const
186 { return GetPortIdName(m_port, m_usingUniversal); }
187 wxString GetPortIdShortName() const
188 { return GetPortIdShortName(m_port, m_usingUniversal); }
189 wxString GetArchName() const
190 { return GetArchName(m_arch); }
191 wxString GetEndiannessName() const
192 { return GetEndiannessName(m_endian); }
193
194 // setters
195 // -----------------
196
197 void SetOSVersion(int major, int minor)
198 { m_osVersionMajor=major; m_osVersionMinor=minor; }
199 void SetToolkitVersion(int major, int minor)
200 { m_tkVersionMajor=major; m_tkVersionMinor=minor; }
201
202 void SetOperatingSystemId(wxOperatingSystemId n)
203 { m_os=n; }
204 void SetPortId(wxPortId n)
205 { m_port=n; }
206 void SetArchitecture(wxArchitecture n)
207 { m_arch=n; }
208 void SetEndianness(wxEndianness n)
209 { m_endian=n; }
210
211 // miscellaneous
212 // -----------------
213
214 bool IsOk() const
215 {
216 return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
217 m_os != wxOS_UNKNOWN &&
218 m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
219 m_port != wxPORT_UNKNOWN &&
220 m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID;
221 }
222
223
224 protected:
225 // OS stuff
226 // -----------------
227
228 // Version of the OS; valid if m_os != wxOS_UNKNOWN
229 // (-1 means not initialized yet).
230 int m_osVersionMajor, m_osVersionMinor;
231
232 // Operating system ID.
233 wxOperatingSystemId m_os;
234
235
236 // toolkit
237 // -----------------
238
239 // Version of the underlying toolkit
240 // (-1 means not initialized yet; zero means no toolkit).
241 int m_tkVersionMajor, m_tkVersionMinor;
242
243 // name of the wxWidgets port
244 wxPortId m_port;
245
246 // is using wxUniversal widgets?
247 bool m_usingUniversal;
248
249
250 // others
251 // -----------------
252
253 // architecture of the OS
254 wxArchitecture m_arch;
255
256 // endianness of the machine
257 wxEndianness m_endian;
258 };
259
260
261 #if WXWIN_COMPATIBILITY_2_6
262 #define wxUNKNOWN_PLATFORM wxOS_UNKNOWN
263 #define wxUnix wxOS_UNIX
264 #define wxWin95 wxOS_WINDOWS_9X
265 #define wxWIN95 wxOS_WINDOWS_9X
266 #define wxWINDOWS_NT wxOS_WINDOWS_NT
267 #define wxMSW wxOS_WINDOWS
268 #define wxWinCE wxOS_WINDOWS_CE
269 #define wxWIN32S wxOS_WINDOWS_9X
270
271 #define wxPalmOS wxPORT_PALMOS
272 #define wxOS2 wxPORT_OS2
273 #define wxMGL wxPORT_MGL
274 #define wxCocoa wxPORT_MAC
275 #define wxMac wxPORT_MAC
276 #define wxMotif wxPORT_MOTIF
277 #define wxGTK wxPORT_GTK
278 #endif // WXWIN_COMPATIBILITY_2_6
279
280 #endif // _WX_PLATINFO_H_