]> git.saurik.com Git - wxWidgets.git/blame - include/wx/platinfo.h
Several fixes for wxAffineMatrix2D transformations.
[wxWidgets.git] / include / wx / platinfo.h
CommitLineData
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
526954c5 9// Licence: wxWindows licence
8bb6b2c0
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PLATINFO_H_
13#define _WX_PLATINFO_H_
14
b20ca997 15#include "wx/string.h"
8bb6b2c0
VZ
16
17// ----------------------------------------------------------------------------
23790a2a 18// wxPlatformInfo enums & structs
8bb6b2c0
VZ
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
26enum 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
bd362275 61 wxOS_OS2 = 1 << 16 // OS/2
8bb6b2c0
VZ
62};
63
64// list of wxWidgets ports - some of them can be used with more than
65// a single toolkit.
66enum 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
0e1f8ea4 75 wxPORT_DFB = 1 << 4, // wxDFB, using wxUniversal
8bb6b2c0 76 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
8ab09e65
SN
77 wxPORT_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager
78 wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager
ac9e3f1f
SC
79 wxPORT_MAC = 1 << 7, // wxOSX (former wxMac), using Cocoa, Carbon or iPhone API
80 wxPORT_OSX = wxPORT_MAC, // wxOSX, using Cocoa, Carbon or iPhone API
8bb6b2c0 81 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
0e1f8ea4 82 wxPORT_WINCE = 1 << 9 // wxWinCE, toolkit is WinCE SDK API
8bb6b2c0
VZ
83};
84
85// architecture of the operating system
86// (regardless of the build environment of wxWidgets library - see
87// wxIsPlatform64bit documentation for more info)
88enum wxArchitecture
89{
90 wxARCH_INVALID = -1, // returned on error
91
92 wxARCH_32, // 32 bit
93 wxARCH_64,
94
95 wxARCH_MAX
96};
97
98
99// endian-ness of the machine
100enum wxEndianness
101{
102 wxENDIAN_INVALID = -1, // returned on error
103
104 wxENDIAN_BIG, // 4321
105 wxENDIAN_LITTLE, // 1234
106 wxENDIAN_PDP, // 3412
107
108 wxENDIAN_MAX
109};
110
23790a2a
FM
111// informations about a linux distro returned by the lsb_release utility
112struct wxLinuxDistributionInfo
113{
114 wxString Id;
115 wxString Release;
116 wxString CodeName;
117 wxString Description;
03647350 118
23790a2a 119 bool operator==(const wxLinuxDistributionInfo& ldi) const
03647350 120 {
23790a2a
FM
121 return Id == ldi.Id &&
122 Release == ldi.Release &&
123 CodeName == ldi.CodeName &&
124 Description == ldi.Description;
125 }
03647350 126
23790a2a
FM
127 bool operator!=(const wxLinuxDistributionInfo& ldi) const
128 { return !(*this == ldi); }
129};
130
131
132// ----------------------------------------------------------------------------
133// wxPlatformInfo
134// ----------------------------------------------------------------------------
135
8bb6b2c0
VZ
136// Information about the toolkit that the app is running under and some basic
137// platform and architecture info
138class WXDLLIMPEXP_BASE wxPlatformInfo
139{
140public:
141 wxPlatformInfo();
142 wxPlatformInfo(wxPortId pid,
143 int tkMajor = -1, int tkMinor = -1,
144 wxOperatingSystemId id = wxOS_UNKNOWN,
145 int osMajor = -1, int osMinor = -1,
146 wxArchitecture arch = wxARCH_INVALID,
b98bd6af
VS
147 wxEndianness endian = wxENDIAN_INVALID,
148 bool usingUniversal = false);
8bb6b2c0
VZ
149
150 // default copy ctor, assignment operator and dtor are ok
151
152 bool operator==(const wxPlatformInfo &t) const;
153
154 bool operator!=(const wxPlatformInfo &t) const
155 { return !(*this == t); }
156
449090b5
VZ
157 // Gets a wxPlatformInfo already initialized with the values for
158 // the currently running platform.
159 static const wxPlatformInfo& Get();
160
161
8bb6b2c0
VZ
162
163 // string -> enum conversions
164 // ---------------------------------
165
166 static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
167 static wxPortId GetPortId(const wxString &portname);
168
169 static wxArchitecture GetArch(const wxString &arch);
170 static wxEndianness GetEndianness(const wxString &end);
171
172 // enum -> string conversions
173 // ---------------------------------
174
175 static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
176 static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
b98bd6af
VS
177 static wxString GetPortIdName(wxPortId port, bool usingUniversal);
178 static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
8bb6b2c0
VZ
179
180 static wxString GetArchName(wxArchitecture arch);
181 static wxString GetEndiannessName(wxEndianness end);
182
03647350 183
8bb6b2c0
VZ
184 // getters
185 // -----------------
186
187 int GetOSMajorVersion() const
188 { return m_osVersionMajor; }
189 int GetOSMinorVersion() const
190 { return m_osVersionMinor; }
191
a24db82d
VZ
192 // return true if the OS version >= major.minor
193 bool CheckOSVersion(int major, int minor) const
194 {
195 return DoCheckVersion(GetOSMajorVersion(),
196 GetOSMinorVersion(),
197 major,
198 minor);
199 }
200
8bb6b2c0
VZ
201 int GetToolkitMajorVersion() const
202 { return m_tkVersionMajor; }
203 int GetToolkitMinorVersion() const
204 { return m_tkVersionMinor; }
205
a24db82d
VZ
206 bool CheckToolkitVersion(int major, int minor) const
207 {
208 return DoCheckVersion(GetToolkitMajorVersion(),
209 GetToolkitMinorVersion(),
210 major,
211 minor);
212 }
213
b98bd6af
VS
214 bool IsUsingUniversalWidgets() const
215 { return m_usingUniversal; }
216
8bb6b2c0
VZ
217 wxOperatingSystemId GetOperatingSystemId() const
218 { return m_os; }
23790a2a
FM
219 wxLinuxDistributionInfo GetLinuxDistributionInfo() const
220 { return m_ldi; }
8bb6b2c0
VZ
221 wxPortId GetPortId() const
222 { return m_port; }
223 wxArchitecture GetArchitecture() const
224 { return m_arch; }
225 wxEndianness GetEndianness() const
226 { return m_endian; }
227
228
229 // string getters
230 // -----------------
231
232 wxString GetOperatingSystemFamilyName() const
233 { return GetOperatingSystemFamilyName(m_os); }
234 wxString GetOperatingSystemIdName() const
235 { return GetOperatingSystemIdName(m_os); }
236 wxString GetPortIdName() const
b98bd6af 237 { return GetPortIdName(m_port, m_usingUniversal); }
8bb6b2c0 238 wxString GetPortIdShortName() const
b98bd6af 239 { return GetPortIdShortName(m_port, m_usingUniversal); }
8bb6b2c0
VZ
240 wxString GetArchName() const
241 { return GetArchName(m_arch); }
242 wxString GetEndiannessName() const
243 { return GetEndiannessName(m_endian); }
23790a2a
FM
244 wxString GetOperatingSystemDescription() const
245 { return m_osDesc; }
246 wxString GetDesktopEnvironment() const
247 { return m_desktopEnv; }
03647350 248
23790a2a
FM
249 static wxString GetOperatingSystemDirectory();
250 // doesn't make sense to store inside wxPlatformInfo the OS directory,
251 // thus this function is static; note that this function simply calls
03647350 252 // wxGetOSDirectory() and is here just to make it easier for the user to
23790a2a 253 // find it that feature (global functions can be difficult to find in the docs)
8bb6b2c0
VZ
254
255 // setters
256 // -----------------
257
258 void SetOSVersion(int major, int minor)
259 { m_osVersionMajor=major; m_osVersionMinor=minor; }
260 void SetToolkitVersion(int major, int minor)
261 { m_tkVersionMajor=major; m_tkVersionMinor=minor; }
262
263 void SetOperatingSystemId(wxOperatingSystemId n)
a24db82d 264 { m_os = n; }
23790a2a
FM
265 void SetOperatingSystemDescription(const wxString& desc)
266 { m_osDesc = desc; }
8bb6b2c0 267 void SetPortId(wxPortId n)
a24db82d 268 { m_port = n; }
8bb6b2c0 269 void SetArchitecture(wxArchitecture n)
a24db82d 270 { m_arch = n; }
8bb6b2c0 271 void SetEndianness(wxEndianness n)
a24db82d 272 { m_endian = n; }
03647350 273
23790a2a
FM
274 void SetDesktopEnvironment(const wxString& de)
275 { m_desktopEnv = de; }
276 void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di)
277 { m_ldi = di; }
278
8bb6b2c0
VZ
279
280 // miscellaneous
281 // -----------------
282
283 bool IsOk() const
284 {
285 return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
286 m_os != wxOS_UNKNOWN &&
23790a2a 287 !m_osDesc.IsEmpty() &&
8bb6b2c0
VZ
288 m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
289 m_port != wxPORT_UNKNOWN &&
03647350 290 m_arch != wxARCH_INVALID &&
23790a2a 291 m_endian != wxENDIAN_INVALID;
03647350 292
23790a2a 293 // do not check linux-specific info; it's ok to have them empty
8bb6b2c0
VZ
294 }
295
8bb6b2c0
VZ
296
297protected:
a24db82d
VZ
298 static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor)
299 {
300 return majorCur > major || (majorCur == major && minorCur >= minor);
301 }
302
449090b5
VZ
303 void InitForCurrentPlatform();
304
305
8bb6b2c0
VZ
306 // OS stuff
307 // -----------------
308
309 // Version of the OS; valid if m_os != wxOS_UNKNOWN
310 // (-1 means not initialized yet).
a24db82d
VZ
311 int m_osVersionMajor,
312 m_osVersionMinor;
8bb6b2c0
VZ
313
314 // Operating system ID.
315 wxOperatingSystemId m_os;
03647350 316
23790a2a
FM
317 // Operating system description.
318 wxString m_osDesc;
03647350
VZ
319
320
23790a2a
FM
321 // linux-specific
322 // -----------------
03647350 323
23790a2a
FM
324 wxString m_desktopEnv;
325 wxLinuxDistributionInfo m_ldi;
8bb6b2c0
VZ
326
327
328 // toolkit
329 // -----------------
330
331 // Version of the underlying toolkit
332 // (-1 means not initialized yet; zero means no toolkit).
333 int m_tkVersionMajor, m_tkVersionMinor;
334
335 // name of the wxWidgets port
336 wxPortId m_port;
337
b98bd6af
VS
338 // is using wxUniversal widgets?
339 bool m_usingUniversal;
340
8bb6b2c0
VZ
341
342 // others
343 // -----------------
344
23790a2a 345 // architecture of the OS/machine
8bb6b2c0
VZ
346 wxArchitecture m_arch;
347
348 // endianness of the machine
349 wxEndianness m_endian;
350};
351
352
353#if WXWIN_COMPATIBILITY_2_6
354 #define wxUNKNOWN_PLATFORM wxOS_UNKNOWN
355 #define wxUnix wxOS_UNIX
356 #define wxWin95 wxOS_WINDOWS_9X
357 #define wxWIN95 wxOS_WINDOWS_9X
358 #define wxWINDOWS_NT wxOS_WINDOWS_NT
359 #define wxMSW wxOS_WINDOWS
360 #define wxWinCE wxOS_WINDOWS_CE
361 #define wxWIN32S wxOS_WINDOWS_9X
362
8bb6b2c0 363 #define wxOS2 wxPORT_OS2
8bb6b2c0
VZ
364 #define wxCocoa wxPORT_MAC
365 #define wxMac wxPORT_MAC
366 #define wxMotif wxPORT_MOTIF
367 #define wxGTK wxPORT_GTK
368#endif // WXWIN_COMPATIBILITY_2_6
369
370#endif // _WX_PLATINFO_H_