]>
Commit | Line | Data |
---|---|---|
8bb6b2c0 VZ |
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 | ||
b20ca997 | 15 | #include "wx/string.h" |
8bb6b2c0 VZ |
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 | |
027fe16c VZ |
61 | wxOS_OS2 = 1 << 16, // OS/2 |
62 | ||
63 | wxOS_PALM_OS = 1 << 17, // Pure Palm OS | |
64 | wxOS_PALM_LINUX = 1 << 18, // Palm over linux | |
65 | wxOS_PALM = wxOS_PALM_OS | wxOS_PALM_LINUX, | |
8bb6b2c0 VZ |
66 | }; |
67 | ||
68 | // list of wxWidgets ports - some of them can be used with more than | |
69 | // a single toolkit. | |
70 | enum wxPortId | |
71 | { | |
72 | wxPORT_UNKNOWN = 0, // returned on error | |
73 | ||
74 | wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used | |
75 | ||
76 | wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API | |
77 | wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif | |
78 | wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo | |
79 | wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal | |
80 | wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal | |
8ab09e65 SN |
81 | wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager |
82 | wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager | |
8bb6b2c0 VZ |
83 | wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API |
84 | wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API | |
85 | wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API | |
b3c86150 VS |
86 | wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API |
87 | wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal | |
8bb6b2c0 VZ |
88 | }; |
89 | ||
90 | // architecture of the operating system | |
91 | // (regardless of the build environment of wxWidgets library - see | |
92 | // wxIsPlatform64bit documentation for more info) | |
93 | enum wxArchitecture | |
94 | { | |
95 | wxARCH_INVALID = -1, // returned on error | |
96 | ||
97 | wxARCH_32, // 32 bit | |
98 | wxARCH_64, | |
99 | ||
100 | wxARCH_MAX | |
101 | }; | |
102 | ||
103 | ||
104 | // endian-ness of the machine | |
105 | enum wxEndianness | |
106 | { | |
107 | wxENDIAN_INVALID = -1, // returned on error | |
108 | ||
109 | wxENDIAN_BIG, // 4321 | |
110 | wxENDIAN_LITTLE, // 1234 | |
111 | wxENDIAN_PDP, // 3412 | |
112 | ||
113 | wxENDIAN_MAX | |
114 | }; | |
115 | ||
116 | // Information about the toolkit that the app is running under and some basic | |
117 | // platform and architecture info | |
118 | class WXDLLIMPEXP_BASE wxPlatformInfo | |
119 | { | |
120 | public: | |
121 | wxPlatformInfo(); | |
122 | wxPlatformInfo(wxPortId pid, | |
123 | int tkMajor = -1, int tkMinor = -1, | |
124 | wxOperatingSystemId id = wxOS_UNKNOWN, | |
125 | int osMajor = -1, int osMinor = -1, | |
126 | wxArchitecture arch = wxARCH_INVALID, | |
b98bd6af VS |
127 | wxEndianness endian = wxENDIAN_INVALID, |
128 | bool usingUniversal = false); | |
8bb6b2c0 VZ |
129 | |
130 | // default copy ctor, assignment operator and dtor are ok | |
131 | ||
132 | bool operator==(const wxPlatformInfo &t) const; | |
133 | ||
134 | bool operator!=(const wxPlatformInfo &t) const | |
135 | { return !(*this == t); } | |
136 | ||
449090b5 VZ |
137 | // Gets a wxPlatformInfo already initialized with the values for |
138 | // the currently running platform. | |
139 | static const wxPlatformInfo& Get(); | |
140 | ||
141 | ||
8bb6b2c0 VZ |
142 | |
143 | // string -> enum conversions | |
144 | // --------------------------------- | |
145 | ||
146 | static wxOperatingSystemId GetOperatingSystemId(const wxString &name); | |
147 | static wxPortId GetPortId(const wxString &portname); | |
148 | ||
149 | static wxArchitecture GetArch(const wxString &arch); | |
150 | static wxEndianness GetEndianness(const wxString &end); | |
151 | ||
152 | // enum -> string conversions | |
153 | // --------------------------------- | |
154 | ||
155 | static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os); | |
156 | static wxString GetOperatingSystemIdName(wxOperatingSystemId os); | |
b98bd6af VS |
157 | static wxString GetPortIdName(wxPortId port, bool usingUniversal); |
158 | static wxString GetPortIdShortName(wxPortId port, bool usingUniversal); | |
8bb6b2c0 VZ |
159 | |
160 | static wxString GetArchName(wxArchitecture arch); | |
161 | static wxString GetEndiannessName(wxEndianness end); | |
162 | ||
163 | // getters | |
164 | // ----------------- | |
165 | ||
166 | int GetOSMajorVersion() const | |
167 | { return m_osVersionMajor; } | |
168 | int GetOSMinorVersion() const | |
169 | { return m_osVersionMinor; } | |
170 | ||
a24db82d VZ |
171 | // return true if the OS version >= major.minor |
172 | bool CheckOSVersion(int major, int minor) const | |
173 | { | |
174 | return DoCheckVersion(GetOSMajorVersion(), | |
175 | GetOSMinorVersion(), | |
176 | major, | |
177 | minor); | |
178 | } | |
179 | ||
8bb6b2c0 VZ |
180 | int GetToolkitMajorVersion() const |
181 | { return m_tkVersionMajor; } | |
182 | int GetToolkitMinorVersion() const | |
183 | { return m_tkVersionMinor; } | |
184 | ||
a24db82d VZ |
185 | bool CheckToolkitVersion(int major, int minor) const |
186 | { | |
187 | return DoCheckVersion(GetToolkitMajorVersion(), | |
188 | GetToolkitMinorVersion(), | |
189 | major, | |
190 | minor); | |
191 | } | |
192 | ||
b98bd6af VS |
193 | bool IsUsingUniversalWidgets() const |
194 | { return m_usingUniversal; } | |
195 | ||
8bb6b2c0 VZ |
196 | wxOperatingSystemId GetOperatingSystemId() const |
197 | { return m_os; } | |
198 | wxPortId GetPortId() const | |
199 | { return m_port; } | |
200 | wxArchitecture GetArchitecture() const | |
201 | { return m_arch; } | |
202 | wxEndianness GetEndianness() const | |
203 | { return m_endian; } | |
204 | ||
205 | ||
206 | // string getters | |
207 | // ----------------- | |
208 | ||
209 | wxString GetOperatingSystemFamilyName() const | |
210 | { return GetOperatingSystemFamilyName(m_os); } | |
211 | wxString GetOperatingSystemIdName() const | |
212 | { return GetOperatingSystemIdName(m_os); } | |
213 | wxString GetPortIdName() const | |
b98bd6af | 214 | { return GetPortIdName(m_port, m_usingUniversal); } |
8bb6b2c0 | 215 | wxString GetPortIdShortName() const |
b98bd6af | 216 | { return GetPortIdShortName(m_port, m_usingUniversal); } |
8bb6b2c0 VZ |
217 | wxString GetArchName() const |
218 | { return GetArchName(m_arch); } | |
219 | wxString GetEndiannessName() const | |
220 | { return GetEndiannessName(m_endian); } | |
221 | ||
222 | // setters | |
223 | // ----------------- | |
224 | ||
225 | void SetOSVersion(int major, int minor) | |
226 | { m_osVersionMajor=major; m_osVersionMinor=minor; } | |
227 | void SetToolkitVersion(int major, int minor) | |
228 | { m_tkVersionMajor=major; m_tkVersionMinor=minor; } | |
229 | ||
230 | void SetOperatingSystemId(wxOperatingSystemId n) | |
a24db82d | 231 | { m_os = n; } |
8bb6b2c0 | 232 | void SetPortId(wxPortId n) |
a24db82d | 233 | { m_port = n; } |
8bb6b2c0 | 234 | void SetArchitecture(wxArchitecture n) |
a24db82d | 235 | { m_arch = n; } |
8bb6b2c0 | 236 | void SetEndianness(wxEndianness n) |
a24db82d | 237 | { m_endian = n; } |
8bb6b2c0 VZ |
238 | |
239 | // miscellaneous | |
240 | // ----------------- | |
241 | ||
242 | bool IsOk() const | |
243 | { | |
244 | return m_osVersionMajor != -1 && m_osVersionMinor != -1 && | |
245 | m_os != wxOS_UNKNOWN && | |
246 | m_tkVersionMajor != -1 && m_tkVersionMinor != -1 && | |
247 | m_port != wxPORT_UNKNOWN && | |
248 | m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID; | |
249 | } | |
250 | ||
8bb6b2c0 VZ |
251 | |
252 | protected: | |
a24db82d VZ |
253 | static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor) |
254 | { | |
255 | return majorCur > major || (majorCur == major && minorCur >= minor); | |
256 | } | |
257 | ||
449090b5 VZ |
258 | void InitForCurrentPlatform(); |
259 | ||
260 | ||
8bb6b2c0 VZ |
261 | // OS stuff |
262 | // ----------------- | |
263 | ||
264 | // Version of the OS; valid if m_os != wxOS_UNKNOWN | |
265 | // (-1 means not initialized yet). | |
a24db82d VZ |
266 | int m_osVersionMajor, |
267 | m_osVersionMinor; | |
8bb6b2c0 VZ |
268 | |
269 | // Operating system ID. | |
270 | wxOperatingSystemId m_os; | |
271 | ||
272 | ||
273 | // toolkit | |
274 | // ----------------- | |
275 | ||
276 | // Version of the underlying toolkit | |
277 | // (-1 means not initialized yet; zero means no toolkit). | |
278 | int m_tkVersionMajor, m_tkVersionMinor; | |
279 | ||
280 | // name of the wxWidgets port | |
281 | wxPortId m_port; | |
282 | ||
b98bd6af VS |
283 | // is using wxUniversal widgets? |
284 | bool m_usingUniversal; | |
285 | ||
8bb6b2c0 VZ |
286 | |
287 | // others | |
288 | // ----------------- | |
289 | ||
290 | // architecture of the OS | |
291 | wxArchitecture m_arch; | |
292 | ||
293 | // endianness of the machine | |
294 | wxEndianness m_endian; | |
295 | }; | |
296 | ||
297 | ||
298 | #if WXWIN_COMPATIBILITY_2_6 | |
299 | #define wxUNKNOWN_PLATFORM wxOS_UNKNOWN | |
300 | #define wxUnix wxOS_UNIX | |
301 | #define wxWin95 wxOS_WINDOWS_9X | |
302 | #define wxWIN95 wxOS_WINDOWS_9X | |
303 | #define wxWINDOWS_NT wxOS_WINDOWS_NT | |
304 | #define wxMSW wxOS_WINDOWS | |
305 | #define wxWinCE wxOS_WINDOWS_CE | |
306 | #define wxWIN32S wxOS_WINDOWS_9X | |
307 | ||
308 | #define wxPalmOS wxPORT_PALMOS | |
309 | #define wxOS2 wxPORT_OS2 | |
310 | #define wxMGL wxPORT_MGL | |
311 | #define wxCocoa wxPORT_MAC | |
312 | #define wxMac wxPORT_MAC | |
313 | #define wxMotif wxPORT_MOTIF | |
314 | #define wxGTK wxPORT_GTK | |
315 | #endif // WXWIN_COMPATIBILITY_2_6 | |
316 | ||
317 | #endif // _WX_PLATINFO_H_ |