]>
git.saurik.com Git - wxWidgets.git/blob - interface/platinfo.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPlatformInfo
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This class holds informations about the operating system and the toolkit that
14 the application is running under and some basic architecture info of the machine
20 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
23 <b>Data structures:</b>
25 The following are the operating systems which are recognized by wxWidgets and
26 whose version can be detected at run-time.
27 The values of the constants are chosen so that they can be combined as flags;
28 this allows to check for operating system families like
29 e.g. wxOS_MAC and wxOS_UNIX.
33 enum wxOperatingSystemId
35 wxOS_UNKNOWN = 0, // returned on error
37 wxOS_MAC_OS = 1 << 0, // Apple Mac OS 8/9/X with Mac paths
38 wxOS_MAC_OSX_DARWIN = 1 << 1, // Apple Mac OS X with Unix paths
39 wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,
41 wxOS_WINDOWS_9X = 1 << 2, // Windows 9x family (95/98/ME)
42 wxOS_WINDOWS_NT = 1 << 3, // Windows NT family (NT/2000/XP)
43 wxOS_WINDOWS_MICRO = 1 << 4, // MicroWindows
44 wxOS_WINDOWS_CE = 1 << 5, // Windows CE (Window Mobile)
45 wxOS_WINDOWS = wxOS_WINDOWS_9X |
50 wxOS_UNIX_LINUX = 1 << 6, // Linux
51 wxOS_UNIX_FREEBSD = 1 << 7, // FreeBSD
52 wxOS_UNIX_OPENBSD = 1 << 8, // OpenBSD
53 wxOS_UNIX_NETBSD = 1 << 9, // NetBSD
54 wxOS_UNIX_SOLARIS = 1 << 10, // SunOS
55 wxOS_UNIX_AIX = 1 << 11, // AIX
56 wxOS_UNIX_HPUX = 1 << 12, // HP/UX
57 wxOS_UNIX = wxOS_UNIX_LINUX |
65 wxOS_DOS = 1 << 15, // Microsoft DOS
66 wxOS_OS2 = 1 << 16 // OS/2
71 The list of wxWidgets ports.
72 Some of them can be used with more than a single (native) toolkit;
73 e.g. wxWinCE port sources can be used with smartphones, pocket PCs
74 and handheld devices SDKs.
80 wxPORT_UNKNOWN = 0, // returned on error
82 wxPORT_BASE = 1 << 0, // wxBase, no native toolkit used
84 wxPORT_MSW = 1 << 1, // wxMSW, native toolkit is Windows API
85 wxPORT_MOTIF = 1 << 2, // wxMotif, using [Open]Motif or Lesstif
86 wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
87 wxPORT_MGL = 1 << 4, // wxMGL, using wxUniversal
88 wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
89 wxPORT_OS2 = 1 << 6, // wxOS2, using OS/2 Presentation Manager
90 wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
91 wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
92 wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
93 wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
94 wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
99 The architecture of the operating system
100 (regardless of the build environment of wxWidgets library
101 - see wxIsPlatform64bit documentation for more info).
107 wxARCH_INVALID = -1, // returned on error
117 The endian-ness of the machine.
123 wxENDIAN_INVALID = -1, // returned on error
125 wxENDIAN_BIG, // 4321
126 wxENDIAN_LITTLE, // 1234
127 wxENDIAN_PDP, // 3412
136 class wxPlatformInfo
: public wxObject
141 Initializes the instance with the values corresponding to the currently
144 This is a fast operation because it only requires to copy the values
145 internally cached for the currently running platform.
152 Initializes the object using given values.
154 wxPlatformInfo(wxPortId pid
= wxPORT_UNKNOWN
,
157 wxOperatingSystemId id
= wxOS_UNKNOWN
,
160 wxArchitecture arch
= wxARCH_INVALID
,
161 wxEndianness endian
= wxENDIAN_INVALID
);
165 Returns @true if the OS version is at least @c major.minor.
167 @see GetOSMajorVersion(), GetOSMinorVersion(),
168 CheckToolkitVersion()
170 bool CheckOSVersion(int major
, int minor
) const;
173 Returns @true if the toolkit version is at least @c major.minor.
175 @see GetToolkitMajorVersion(),
176 GetToolkitMinorVersion(), CheckOSVersion()
178 bool CheckToolkitVersion(int major
, int minor
) const;
181 Returns the global wxPlatformInfo object, initialized with the values
182 for the currently running platform.
184 static const wxPlatformInfo
Get();
187 Converts the given string to a wxArchitecture enum value or to
188 @c wxARCH_INVALID if the given string is not a valid architecture string
189 (i.e. does not contain nor @c 32 nor @c 64 strings).
191 static wxArchitecture
GetArch(const wxString
& arch
);
194 Returns the name for the given wxArchitecture enumeration value.
196 static wxString
GetArchName(wxArchitecture arch
) const;
199 Returns the name for the architecture of this wxPlatformInfo instance.
201 wxString
GetArchName() const;
204 Returns the architecture ID of this wxPlatformInfo instance.
206 wxArchitecture
GetArchitecture() const;
209 Converts the given string to a wxEndianness enum value or to
210 @c wxENDIAN_INVALID if the given string is not a valid endianness
211 string (i.e. does not contain nor little nor big strings).
213 static wxEndianness
GetEndianness(const wxString
& end
) const;
216 Returns the endianness ID of this wxPlatformInfo instance.
218 wxEndianness
GetEndianness() const;
221 Returns name for the given wxEndianness enumeration value.
223 static wxString
GetEndiannessName(wxEndianness end
) const;
226 Returns the name for the endianness of this wxPlatformInfo instance.
228 wxString
GetEndiannessName() const;
231 Returns the run-time major version of the OS associated with this
232 wxPlatformInfo instance.
234 @see ::wxGetOsVersion(), CheckOSVersion()
236 int GetOSMajorVersion() const;
239 Returns the run-time minor version of the OS associated with this
240 wxPlatformInfo instance.
242 @see ::wxGetOsVersion(), CheckOSVersion()
244 int GetOSMinorVersion() const;
247 Returns the operating system family name for the given wxOperatingSystemId
248 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
249 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
251 static wxString
GetOperatingSystemFamilyName(wxOperatingSystemId os
) const;
254 Returns the operating system family name of the OS associated with this
255 wxPlatformInfo instance.
257 wxString
GetOperatingSystemFamilyName() const;
260 Converts the given string to a wxOperatingSystemId enum value or to @c
261 wxOS_UNKNOWN if the given string is not a valid operating system name.
263 static wxOperatingSystemId
GetOperatingSystemId(const wxString
& name
) const;
266 Returns the operating system ID of this wxPlatformInfo instance.
268 wxOperatingSystemId
GetOperatingSystemId() const;
271 Returns the name for the given operating system ID value.
273 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
274 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
276 static wxString
GetOperatingSystemIdName(wxOperatingSystemId os
) const;
279 Returns the operating system name of the OS associated with this wxPlatformInfo
282 wxString
GetOperatingSystemIdName() const;
286 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
287 if the given string does not match any of the wxWidgets canonical name ports
288 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
290 static wxPortId
GetPortId(const wxString
& portname
) const;
293 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
295 wxPortId
GetPortId() const;
298 Returns the name of the given wxWidgets port ID value.
299 The @a usingUniversal argument specifies whether the port is in its native
300 or wxUniversal variant.
302 The returned string always starts with the "wx" prefix and is a mixed-case string.
304 static wxString
GetPortIdName(wxPortId port
, bool usingUniversal
) const;
307 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
310 wxString
GetPortIdName() const;
313 Returns the short name of the given wxWidgets port ID value.
314 The @a usingUniversal argument specifies whether the port is in its native
315 or wxUniversal variant.
317 The returned string does not start with the "wx" prefix and is always lower
320 static wxString
GetPortIdShortName(wxPortId port
,
321 bool usingUniversal
) const;
324 Returns the short name of the wxWidgets port ID associated with this
325 wxPlatformInfo instance.
327 wxString
GetPortIdShortName() const;
330 Returns the run-time major version of the toolkit associated with this
331 wxPlatformInfo instance.
333 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
334 (unless externally modified with SetToolkitVersion()); that is, no native
336 See wxAppTraits::GetToolkitVersion() for more info.
338 @see CheckToolkitVersion()
340 int GetToolkitMajorVersion() const;
343 Returns the run-time minor version of the toolkit associated with this
344 wxPlatformInfo instance.
346 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
347 (unless externally modified with SetToolkitVersion()); that is, no native
349 See wxAppTraits::GetToolkitVersion() for more info.
351 @see CheckToolkitVersion()
353 int GetToolkitMinorVersion() const;
356 Returns @true if this instance is fully initialized with valid values.
361 Returns @true if this wxPlatformInfo describes wxUniversal build.
363 bool IsUsingUniversalWidgets() const;
366 Sets the architecture enum value associated with this wxPlatformInfo instance.
368 void SetArchitecture(wxArchitecture n
);
371 Sets the endianness enum value associated with this wxPlatformInfo instance.
373 void SetEndianness(wxEndianness n
);
376 Sets the version of the operating system associated with this wxPlatformInfo
379 void SetOSVersion(int major
, int minor
);
382 Sets the operating system associated with this wxPlatformInfo instance.
384 void SetOperatingSystemId(wxOperatingSystemId n
);
387 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
389 void SetPortId(wxPortId n
);
392 Sets the version of the toolkit associated with this wxPlatformInfo instance.
394 void SetToolkitVersion(int major
, int minor
);
397 Inequality operator. Tests all class' internal variables.
399 bool operator!=(const wxPlatformInfo
& t
) const;
402 Equality operator. Tests all class' internal variables.
404 bool operator==(const wxPlatformInfo
& t
) const;