Contents Up Previous Next

wxPlatformInfo

This class holds informations about the operating system and the toolkit that the application is running under and some basic architecture info of the machine where it's running.

Derived from

wxObject

Include files

<wx/platinfo.h>

See also

wxGetOSVersion, wxIsPlatformLittleEndian, wxIsPlatform64Bit, wxAppTraits

Data structures

The following are the operating systems which are recognized by wxWidgets and whose version can be detected at run-time. The values of the constants are chosen so that they can be combined as flags; this allows to check for operating system families like e.g. wxOS_MAC and wxOS_UNIX.

enum wxOperatingSystemId
{
    wxOS_UNKNOWN = 0,                 // returned on error

    wxOS_MAC_OS         = 1 << 0,     // Apple Mac OS 8/9/X with Mac paths
    wxOS_MAC_OSX_DARWIN = 1 << 1,     // Apple Mac OS X with Unix paths
    wxOS_MAC = wxOS_MAC_OS|wxOS_MAC_OSX_DARWIN,

    wxOS_WINDOWS_9X     = 1 << 2,     // Windows 9x family (95/98/ME)
    wxOS_WINDOWS_NT     = 1 << 3,     // Windows NT family (NT/2000/XP)
    wxOS_WINDOWS_MICRO  = 1 << 4,     // MicroWindows
    wxOS_WINDOWS_CE     = 1 << 5,     // Windows CE (Window Mobile)
    wxOS_WINDOWS = wxOS_WINDOWS_9X      |
                   wxOS_WINDOWS_NT      |
                   wxOS_WINDOWS_MICRO   |
                   wxOS_WINDOWS_CE,

    wxOS_UNIX_LINUX     = 1 << 6,       // Linux
    wxOS_UNIX_FREEBSD   = 1 << 7,       // FreeBSD
    wxOS_UNIX_OPENBSD   = 1 << 8,       // OpenBSD
    wxOS_UNIX_NETBSD    = 1 << 9,       // NetBSD
    wxOS_UNIX_SOLARIS   = 1 << 10,      // SunOS
    wxOS_UNIX_AIX       = 1 << 11,      // AIX
    wxOS_UNIX_HPUX      = 1 << 12,      // HP/UX
    wxOS_UNIX = wxOS_UNIX_LINUX     |
                wxOS_UNIX_FREEBSD   |
                wxOS_UNIX_OPENBSD   |
                wxOS_UNIX_NETBSD    |
                wxOS_UNIX_SOLARIS   |
                wxOS_UNIX_AIX       |
                wxOS_UNIX_HPUX,

    wxOS_DOS            = 1 << 15,      // Microsoft DOS
    wxOS_OS2            = 1 << 16       // OS/2
};
The list of wxWidgets ports. Some of them can be used with more than a single (native) toolkit; e.g. wxWinCE port sources can be used with smartphones, pocket PCs and handheld devices SDKs.

enum wxPortId
{
    wxPORT_UNKNOWN  = 0,            // returned on error

    wxPORT_BASE     = 1 << 0,       // wxBase, no native toolkit used

    wxPORT_MSW      = 1 << 1,       // wxMSW, native toolkit is Windows API
    wxPORT_MOTIF    = 1 << 2,       // wxMotif, using [Open]Motif or Lesstif
    wxPORT_GTK      = 1 << 3,       // wxGTK, using GTK+ 1.x, 2.x, GPE or Maemo
    wxPORT_MGL      = 1 << 4,       // wxMGL, using wxUniversal
    wxPORT_X11      = 1 << 5,       // wxX11, using wxUniversal
    wxPORT_OS2      = 1 << 6,       // wxOS2, using OS/2 Presentation Manager
    wxPORT_MAC      = 1 << 7,       // wxMac, using Carbon or Classic Mac API
    wxPORT_COCOA    = 1 << 8,       // wxCocoa, using Cocoa NextStep/Mac API
    wxPORT_WINCE    = 1 << 9,       // wxWinCE, toolkit is WinCE SDK API
    wxPORT_PALMOS   = 1 << 10,      // wxPalmOS, toolkit is PalmOS API
    wxPORT_DFB      = 1 << 11       // wxDFB, using wxUniversal
};
The architecture of the operating system (regardless of the build environment of wxWidgets library - see wxIsPlatform64bit documentation for more info).

enum wxArchitecture
{
    wxARCH_INVALID = -1,        // returned on error

    wxARCH_32,                  // 32 bit
    wxARCH_64,

    wxARCH_MAX
}
The endian-ness of the machine.

enum wxEndianness
{
    wxENDIAN_INVALID = -1,      // returned on error

    wxENDIAN_BIG,               // 4321
    wxENDIAN_LITTLE,            // 1234
    wxENDIAN_PDP,               // 3412

    wxENDIAN_MAX
}
Members

wxPlatformInfo::wxPlatformInfo
wxPlatformInfo::CheckOSVersion
wxPlatformInfo::CheckToolkitVersion
wxPlatformInfo::Get
wxPlatformInfo::GetArch
wxPlatformInfo::GetArchName
wxPlatformInfo::GetArchitecture
wxPlatformInfo::GetEndianness
wxPlatformInfo::GetEndiannessName
wxPlatformInfo::GetOSMajorVersion
wxPlatformInfo::GetOSMinorVersion
wxPlatformInfo::GetOperatingSystemFamilyName
wxPlatformInfo::GetOperatingSystemId
wxPlatformInfo::GetOperatingSystemIdName
wxPlatformInfo::GetPortId
wxPlatformInfo::GetPortIdName
wxPlatformInfo::GetPortIdShortName
wxPlatformInfo::GetToolkitMajorVersion
wxPlatformInfo::GetToolkitMinorVersion
wxPlatformInfo::IsOk
wxPlatformInfo::IsUsingUniversalWidgets
wxPlatformInfo::SetArchitecture
wxPlatformInfo::SetEndianness
wxPlatformInfo::SetOSVersion
wxPlatformInfo::SetOperatingSystemId
wxPlatformInfo::SetPortId
wxPlatformInfo::SetToolkitVersion
wxPlatformInfo::operator!=
wxPlatformInfo::operator==


wxPlatformInfo::wxPlatformInfo

wxPlatformInfo()

Initializes the instance with the values corresponding to the currently running platform. This is a fast operation because it only requires to copy the values internally cached for the currently running platform (see also Get).

wxPlatformInfo(wxPortId pid = wxPORT_UNKNOWN, int tkMajor = -1, int tkMinor = -1, wxOperatingSystemId id = wxOS_UNKNOWN, int osMajor = -1, int osMinor = -1, wxArchitecture arch = wxARCH_INVALID, wxEndianness endian = wxENDIAN_INVALID)

Initializes the object using given values.


wxPlatformInfo::CheckOSVersion

bool CheckOSVersion(int major, int minor) const

Returns true if the OS version is at least major.minor.

See also

GetOSMajorVersion, GetOSMinorVersion, CheckToolkitVersion


wxPlatformInfo::CheckToolkitVersion

bool CheckToolkitVersion(int major, int minor) const

Returns true if the toolkit version is at least major.minor.

See also

GetToolkitMajorVersion, GetToolkitMinorVersion, CheckOSVersion


wxPlatformInfo::Get

static const wxPlatformInfo& Get()

Returns the global wxPlatformInfo object, initialized with the values for the currently running platform.


wxPlatformInfo::GetArch

static wxArchitecture GetArch(const wxString& arch)

Converts the given string to a wxArchitecture enum value or to wxARCH_INVALID if the given string is not a valid architecture string (i.e. does not contain nor 32 nor 64 strings).


wxPlatformInfo::GetArchName

static wxString GetArchName(wxArchitecture arch)

Returns the name for the given wxArchitecture enumeration value.

wxString GetArchName() const

Returns the name for the architecture of this wxPlatformInfo instance.


wxPlatformInfo::GetArchitecture

wxArchitecture GetArchitecture() const

Returns the architecture ID of this wxPlatformInfo instance.


wxPlatformInfo::GetEndianness

static wxEndianness GetEndianness(const wxString& end)

Converts the given string to a wxEndianness enum value or to wxENDIAN_INVALID if the given string is not a valid endianness string (i.e. does not contain nor little nor big strings).

wxEndianness GetEndianness() const

Returns the endianness ID of this wxPlatformInfo instance.


wxPlatformInfo::GetEndiannessName

static wxString GetEndiannessName(wxEndianness end)

Returns name for the given wxEndianness enumeration value.

wxString GetEndiannessName() const

Returns the name for the endianness of this wxPlatformInfo instance.


wxPlatformInfo::GetOSMajorVersion

int GetOSMajorVersion() const

Returns the run-time major version of the OS associated with this wxPlatformInfo instance. See wxGetOsVersion for more info.

See also

CheckOSVersion


wxPlatformInfo::GetOSMinorVersion

int GetOSMinorVersion() const

Returns the run-time minor version of the OS associated with this wxPlatformInfo instance. See wxGetOsVersion for more info.

See also

CheckOSVersion


wxPlatformInfo::GetOperatingSystemFamilyName

static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os)

Returns the operating system family name for the given wxOperatingSystemId enumeration value: Unix for wxOS_UNIX, Macintosh for wxOS_MAC, Windows for wxOS_WINDOWS, DOS for wxOS_DOS, OS/2 for wxOS_OS2.

wxString GetOperatingSystemFamilyName() const

Returns the operating system family name of the OS associated with this wxPlatformInfo instance.


wxPlatformInfo::GetOperatingSystemId

static wxOperatingSystemId GetOperatingSystemId(const wxString& name)

Converts the given string to a wxOperatingSystemId enum value or to wxOS_UNKNOWN if the given string is not a valid operating system name.

wxOperatingSystemId GetOperatingSystemId() const

Returns the operating system ID of this wxPlatformInfo instance.


wxPlatformInfo::GetOperatingSystemIdName

static wxString GetOperatingSystemIdName(wxOperatingSystemId os)

Returns the name for the given operating system ID value. This can be a long name (e.g. Microsoft Windows NT); use GetOperatingSystemFamilyName to retrieve a short, generic name.

wxString GetOperatingSystemIdName() const

Returns the operating system name of the OS associated with this wxPlatformInfo instance.


wxPlatformInfo::GetPortId

static wxPortId GetPortId(const wxString& portname)

Converts the given string to a wxWidgets port ID value or to wxPORT_UNKNOWN if the given string does not match any of the wxWidgets canonical name ports ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).

wxPortId GetPortId() const

Returns the wxWidgets port ID associated with this wxPlatformInfo instance.


wxPlatformInfo::GetPortIdName

static wxString GetPortIdName(wxPortId port, bool usingUniversal)

Returns the name of the given wxWidgets port ID value. The usingUniversal argument specifies whether the port is in its native or wxUniversal variant.

The returned string always starts with the "wx" prefix and is a mixed-case string.

wxString GetPortIdName() const

Returns the name of the wxWidgets port ID associated with this wxPlatformInfo instance.


wxPlatformInfo::GetPortIdShortName

static wxString GetPortIdShortName(wxPortId port, bool usingUniversal)

Returns the short name of the given wxWidgets port ID value. The usingUniversal argument specifies whether the port is in its native or wxUniversal variant.

The returned string does not start with the "wx" prefix and is always lower case.

wxString GetPortIdShortName() const

Returns the short name of the wxWidgets port ID associated with this wxPlatformInfo instance.


wxPlatformInfo::GetToolkitMajorVersion

int GetToolkitMajorVersion() const

Returns the run-time major version of the toolkit associated with this wxPlatformInfo instance. Note that if GetPortId returns wxPORT_BASE, then this value is zero (unless externally modified with SetToolkitVersion); that is, no native toolkit is in use.

See wxAppTraits::GetToolkitVersion for more info.

See also

CheckToolkitVersion


wxPlatformInfo::GetToolkitMinorVersion

int GetToolkitMinorVersion() const

Returns the run-time minor version of the toolkit associated with this wxPlatformInfo instance. Note that if GetPortId returns wxPORT_BASE, then this value is zero (unless externally modified with SetToolkitVersion); that is, no native toolkit is in use.

See wxAppTraits::GetToolkitVersion for more info.

See also

CheckToolkitVersion


wxPlatformInfo::IsOk

bool IsOk() const

Returns true if this instance is fully initialized with valid values.


wxPlatformInfo::IsUsingUniversalWidgets

bool IsUsingUniversalWidgets() const

Returns true if this wxPlatformInfo describes wxUniversal build.


wxPlatformInfo::SetArchitecture

void SetArchitecture(wxArchitecture n)

Sets the architecture enum value associated with this wxPlatformInfo instance.


wxPlatformInfo::SetEndianness

void SetEndianness(wxEndianness n)

Sets the endianness enum value associated with this wxPlatformInfo instance.


wxPlatformInfo::SetOSVersion

void SetOSVersion(int major, int minor)

Sets the version of the operating system associated with this wxPlatformInfo instance.


wxPlatformInfo::SetOperatingSystemId

void SetOperatingSystemId(wxOperatingSystemId n)

Sets the operating system associated with this wxPlatformInfo instance.


wxPlatformInfo::SetPortId

void SetPortId(wxPortId n)

Sets the wxWidgets port ID associated with this wxPlatformInfo instance.


wxPlatformInfo::SetToolkitVersion

void SetToolkitVersion(int major, int minor)

Sets the version of the toolkit associated with this wxPlatformInfo instance.


wxPlatformInfo::operator!=

bool operator!=(const wxPlatformInfo& t) const

Inequality operator. Tests all class' internal variables.


wxPlatformInfo::operator==

bool operator==(const wxPlatformInfo& t) const

Equality operator. Tests all class' internal variables.