]>
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 /////////////////////////////////////////////////////////////////////////////
11 The following are the operating systems which are recognized by wxWidgets and
12 whose version can be detected at run-time.
14 The values of the constants are chosen so that they can be combined as flags;
15 this allows to check for operating system families like e.g. wxOS_MAC and wxOS_UNIX.
17 enum wxOperatingSystemId
19 wxOS_UNKNOWN
= 0, //!< returned on error
21 wxOS_MAC_OS
= 1 << 0, //!< Apple Mac OS 8/9/X with Mac paths
22 wxOS_MAC_OSX_DARWIN
= 1 << 1, //!< Apple Mac OS X with Unix paths
23 wxOS_MAC
= wxOS_MAC_OS
|wxOS_MAC_OSX_DARWIN
,
25 wxOS_WINDOWS_9X
= 1 << 2, //!< Windows 9x family (95/98/ME)
26 wxOS_WINDOWS_NT
= 1 << 3, //!< Windows NT family (NT/2000/XP)
27 wxOS_WINDOWS_MICRO
= 1 << 4, //!< MicroWindows
28 wxOS_WINDOWS_CE
= 1 << 5, //!< Windows CE (Window Mobile)
29 wxOS_WINDOWS
= wxOS_WINDOWS_9X
|
34 wxOS_UNIX_LINUX
= 1 << 6, //!< Linux
35 wxOS_UNIX_FREEBSD
= 1 << 7, //!< FreeBSD
36 wxOS_UNIX_OPENBSD
= 1 << 8, //!< OpenBSD
37 wxOS_UNIX_NETBSD
= 1 << 9, //!< NetBSD
38 wxOS_UNIX_SOLARIS
= 1 << 10, //!< SunOS
39 wxOS_UNIX_AIX
= 1 << 11, //!< AIX
40 wxOS_UNIX_HPUX
= 1 << 12, //!< HP/UX
41 wxOS_UNIX
= wxOS_UNIX_LINUX
|
49 wxOS_DOS
= 1 << 15, //!< Microsoft DOS
50 wxOS_OS2
= 1 << 16 //!< OS/2
54 The list of wxWidgets ports.
56 Some of them can be used with more than a single (native) toolkit;
57 e.g. wxWinCE port sources can be used with smartphones, pocket PCs
58 and handheld devices SDKs.
62 wxPORT_UNKNOWN
= 0, //!< returned on error
64 wxPORT_BASE
= 1 << 0, //!< wxBase, no native toolkit used
66 wxPORT_MSW
= 1 << 1, //!< wxMSW, native toolkit is Windows API
67 wxPORT_MOTIF
= 1 << 2, //!< wxMotif, using [Open]Motif or Lesstif
68 wxPORT_GTK
= 1 << 3, //!< wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
69 wxPORT_MGL
= 1 << 4, //!< wxMGL, using wxUniversal
70 wxPORT_X11
= 1 << 5, //!< wxX11, using wxUniversal
71 wxPORT_OS2
= 1 << 6, //!< wxOS2, using OS/2 Presentation Manager
72 wxPORT_MAC
= 1 << 7, //!< wxMac, using Carbon or Classic Mac API
73 wxPORT_COCOA
= 1 << 8, //!< wxCocoa, using Cocoa NextStep/Mac API
74 wxPORT_WINCE
= 1 << 9, //!< wxWinCE, toolkit is WinCE SDK API
75 wxPORT_PALMOS
= 1 << 10, //!< wxPalmOS, toolkit is PalmOS API
76 wxPORT_DFB
= 1 << 11 //!< wxDFB, using wxUniversal
81 The architecture of the operating system
82 (regardless of the build environment of wxWidgets library
83 - see ::wxIsPlatform64bit documentation for more info).
87 wxARCH_INVALID
= -1, //!< returned on error
89 wxARCH_32
, //!< 32 bit
97 The endian-ness of the machine.
101 wxENDIAN_INVALID
= -1, //!< returned on error
103 wxENDIAN_BIG
, //!< 4321
104 wxENDIAN_LITTLE
, //!< 1234
105 wxENDIAN_PDP
, //!< 3412
112 @class wxPlatformInfo
113 @wxheader{platinfo.h}
115 This class holds informations about the operating system and the toolkit that
116 the application is running under and some basic architecture info of the machine
122 @see ::wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(),
125 class wxPlatformInfo
: public wxObject
130 Initializes the instance with the values corresponding to the currently
133 This is a fast operation because it only requires to copy the values
134 internally cached for the currently running platform.
141 Initializes the object using given values.
143 wxPlatformInfo(wxPortId pid
= wxPORT_UNKNOWN
,
146 wxOperatingSystemId id
= wxOS_UNKNOWN
,
149 wxArchitecture arch
= wxARCH_INVALID
,
150 wxEndianness endian
= wxENDIAN_INVALID
);
154 Returns @true if the OS version is at least @c major.minor.
156 @see GetOSMajorVersion(), GetOSMinorVersion(),
157 CheckToolkitVersion()
159 bool CheckOSVersion(int major
, int minor
) const;
162 Returns @true if the toolkit version is at least @c major.minor.
164 @see GetToolkitMajorVersion(),
165 GetToolkitMinorVersion(), CheckOSVersion()
167 bool CheckToolkitVersion(int major
, int minor
) const;
170 Returns the global wxPlatformInfo object, initialized with the values
171 for the currently running platform.
173 static const wxPlatformInfo
Get();
176 Converts the given string to a wxArchitecture enum value or to
177 @c wxARCH_INVALID if the given string is not a valid architecture string
178 (i.e. does not contain nor @c 32 nor @c 64 strings).
180 static wxArchitecture
GetArch(const wxString
& arch
);
183 Returns the name for the given wxArchitecture enumeration value.
185 static wxString
GetArchName(wxArchitecture arch
) const;
188 Returns the name for the architecture of this wxPlatformInfo instance.
190 wxString
GetArchName() const;
193 Returns the architecture ID of this wxPlatformInfo instance.
195 wxArchitecture
GetArchitecture() const;
198 Converts the given string to a wxEndianness enum value or to
199 @c wxENDIAN_INVALID if the given string is not a valid endianness
200 string (i.e. does not contain nor little nor big strings).
202 static wxEndianness
GetEndianness(const wxString
& end
) const;
205 Returns the endianness ID of this wxPlatformInfo instance.
207 wxEndianness
GetEndianness() const;
210 Returns name for the given wxEndianness enumeration value.
212 static wxString
GetEndiannessName(wxEndianness end
) const;
215 Returns the name for the endianness of this wxPlatformInfo instance.
217 wxString
GetEndiannessName() const;
220 Returns the run-time major version of the OS associated with this
221 wxPlatformInfo instance.
223 @see ::wxGetOsVersion(), CheckOSVersion()
225 int GetOSMajorVersion() const;
228 Returns the run-time minor version of the OS associated with this
229 wxPlatformInfo instance.
231 @see ::wxGetOsVersion(), CheckOSVersion()
233 int GetOSMinorVersion() const;
236 Returns the operating system family name for the given wxOperatingSystemId
237 enumeration value: @c Unix for @c wxOS_UNIX, @c Macintosh for @c wxOS_MAC,
238 @c Windows for @c wxOS_WINDOWS, @c DOS for @c wxOS_DOS, @c OS/2 for @c wxOS_OS2.
240 static wxString
GetOperatingSystemFamilyName(wxOperatingSystemId os
) const;
243 Returns the operating system family name of the OS associated with this
244 wxPlatformInfo instance.
246 wxString
GetOperatingSystemFamilyName() const;
249 Converts the given string to a wxOperatingSystemId enum value or to @c
250 wxOS_UNKNOWN if the given string is not a valid operating system name.
252 static wxOperatingSystemId
GetOperatingSystemId(const wxString
& name
) const;
255 Returns the operating system ID of this wxPlatformInfo instance.
257 wxOperatingSystemId
GetOperatingSystemId() const;
260 Returns the name for the given operating system ID value.
262 This can be a long name (e.g. <tt>Microsoft Windows NT</tt>);
263 use GetOperatingSystemFamilyName() to retrieve a short, generic name.
265 static wxString
GetOperatingSystemIdName(wxOperatingSystemId os
) const;
268 Returns the operating system name of the OS associated with this wxPlatformInfo
271 wxString
GetOperatingSystemIdName() const;
275 Converts the given string to a wxWidgets port ID value or to @c wxPORT_UNKNOWN
276 if the given string does not match any of the wxWidgets canonical name ports
277 ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).
279 static wxPortId
GetPortId(const wxString
& portname
) const;
282 Returns the wxWidgets port ID associated with this wxPlatformInfo instance.
284 wxPortId
GetPortId() const;
287 Returns the name of the given wxWidgets port ID value.
288 The @a usingUniversal argument specifies whether the port is in its native
289 or wxUniversal variant.
291 The returned string always starts with the "wx" prefix and is a mixed-case string.
293 static wxString
GetPortIdName(wxPortId port
, bool usingUniversal
) const;
296 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo
299 wxString
GetPortIdName() const;
302 Returns the short name of the given wxWidgets port ID value.
303 The @a usingUniversal argument specifies whether the port is in its native
304 or wxUniversal variant.
306 The returned string does not start with the "wx" prefix and is always lower case.
308 static wxString
GetPortIdShortName(wxPortId port
,
309 bool usingUniversal
) const;
312 Returns the short name of the wxWidgets port ID associated with this
313 wxPlatformInfo instance.
315 wxString
GetPortIdShortName() const;
318 Returns the run-time major version of the toolkit associated with this
319 wxPlatformInfo instance.
321 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
322 (unless externally modified with SetToolkitVersion()); that is, no native
324 See wxAppTraits::GetToolkitVersion() for more info.
326 @see CheckToolkitVersion()
328 int GetToolkitMajorVersion() const;
331 Returns the run-time minor version of the toolkit associated with this
332 wxPlatformInfo instance.
334 Note that if GetPortId() returns @c wxPORT_BASE, then this value is zero
335 (unless externally modified with SetToolkitVersion()); that is, no native
337 See wxAppTraits::GetToolkitVersion() for more info.
339 @see CheckToolkitVersion()
341 int GetToolkitMinorVersion() const;
344 Returns @true if this instance is fully initialized with valid values.
349 Returns @true if this wxPlatformInfo describes wxUniversal build.
351 bool IsUsingUniversalWidgets() const;
354 Sets the architecture enum value associated with this wxPlatformInfo instance.
356 void SetArchitecture(wxArchitecture n
);
359 Sets the endianness enum value associated with this wxPlatformInfo instance.
361 void SetEndianness(wxEndianness n
);
364 Sets the version of the operating system associated with this wxPlatformInfo
367 void SetOSVersion(int major
, int minor
);
370 Sets the operating system associated with this wxPlatformInfo instance.
372 void SetOperatingSystemId(wxOperatingSystemId n
);
375 Sets the wxWidgets port ID associated with this wxPlatformInfo instance.
377 void SetPortId(wxPortId n
);
380 Sets the version of the toolkit associated with this wxPlatformInfo instance.
382 void SetToolkitVersion(int major
, int minor
);
385 Inequality operator. Tests all class' internal variables.
387 bool operator!=(const wxPlatformInfo
& t
) const;
390 Equality operator. Tests all class' internal variables.
392 bool operator==(const wxPlatformInfo
& t
) const;