2006-08-13 21:00:32 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/platinfo.h
|
|
|
|
// Purpose: declaration of the wxPlatformInfo class
|
|
|
|
// Author: Francesco Montorsi
|
|
|
|
// Modified by:
|
|
|
|
// Created: 07.07.2006 (based on wxToolkitInfo)
|
|
|
|
// Copyright: (c) 2006 Francesco Montorsi
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2006-08-13 21:00:32 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_PLATINFO_H_
|
|
|
|
#define _WX_PLATINFO_H_
|
|
|
|
|
2006-08-15 03:16:29 +00:00
|
|
|
#include "wx/string.h"
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2009-06-02 13:01:41 +00:00
|
|
|
// wxPlatformInfo enums & structs
|
2006-08-13 21:00:32 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// VERY IMPORTANT: when changing these enum values, also change the relative
|
|
|
|
// string tables in src/common/platinfo.cpp
|
|
|
|
|
|
|
|
|
|
|
|
// families & sub-families of operating systems
|
|
|
|
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,
|
|
|
|
|
2016-02-21 08:39:19 +00:00
|
|
|
wxOS_WINDOWS_9X = 1 << 2, // obsolete
|
|
|
|
wxOS_WINDOWS_NT = 1 << 3, // obsolete
|
|
|
|
wxOS_WINDOWS_MICRO = 1 << 4, // obsolete
|
|
|
|
wxOS_WINDOWS_CE = 1 << 5, // obsolete
|
2006-08-13 21:00:32 +00:00
|
|
|
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,
|
|
|
|
|
|
|
|
// 1<<13 and 1<<14 available for other Unix flavours
|
|
|
|
|
2016-02-21 08:39:19 +00:00
|
|
|
wxOS_DOS = 1 << 15, // obsolete
|
|
|
|
wxOS_OS2 = 1 << 16 // obsolete
|
2006-08-13 21:00:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// list of wxWidgets ports - some of them can be used with more than
|
|
|
|
// a single toolkit.
|
|
|
|
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
|
2016-02-21 08:39:19 +00:00
|
|
|
wxPORT_GTK = 1 << 3, // wxGTK, using GTK+ 1.x, 2.x, 3.x
|
2012-01-15 14:46:41 +00:00
|
|
|
wxPORT_DFB = 1 << 4, // wxDFB, using wxUniversal
|
2006-08-13 21:00:32 +00:00
|
|
|
wxPORT_X11 = 1 << 5, // wxX11, using wxUniversal
|
2016-02-21 08:39:19 +00:00
|
|
|
wxPORT_PM = 1 << 6, // obsolete
|
|
|
|
wxPORT_OS2 = wxPORT_PM, // obsolete
|
2016-01-22 14:40:58 +00:00
|
|
|
wxPORT_MAC = 1 << 7, // wxOSX (former wxMac), using Cocoa or iPhone API
|
|
|
|
wxPORT_OSX = wxPORT_MAC, // wxOSX, using Cocoa or iPhone API
|
2006-08-13 21:00:32 +00:00
|
|
|
wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
|
2016-02-21 08:39:19 +00:00
|
|
|
wxPORT_WINCE = 1 << 9, // obsolete
|
2019-09-18 00:17:21 +00:00
|
|
|
wxPORT_QT = 1 << 10 // wxQT, using Qt 5+
|
2006-08-13 21:00:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// endian-ness of the machine
|
|
|
|
enum wxEndianness
|
|
|
|
{
|
|
|
|
wxENDIAN_INVALID = -1, // returned on error
|
|
|
|
|
|
|
|
wxENDIAN_BIG, // 4321
|
|
|
|
wxENDIAN_LITTLE, // 1234
|
|
|
|
wxENDIAN_PDP, // 3412
|
|
|
|
|
|
|
|
wxENDIAN_MAX
|
|
|
|
};
|
|
|
|
|
2016-04-12 15:02:14 +00:00
|
|
|
// information about a linux distro returned by the lsb_release utility
|
2009-06-02 13:01:41 +00:00
|
|
|
struct wxLinuxDistributionInfo
|
|
|
|
{
|
|
|
|
wxString Id;
|
|
|
|
wxString Release;
|
|
|
|
wxString CodeName;
|
|
|
|
wxString Description;
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
bool operator==(const wxLinuxDistributionInfo& ldi) const
|
2009-08-21 10:41:26 +00:00
|
|
|
{
|
2009-06-02 13:01:41 +00:00
|
|
|
return Id == ldi.Id &&
|
|
|
|
Release == ldi.Release &&
|
|
|
|
CodeName == ldi.CodeName &&
|
|
|
|
Description == ldi.Description;
|
|
|
|
}
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
bool operator!=(const wxLinuxDistributionInfo& ldi) const
|
|
|
|
{ return !(*this == ldi); }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxPlatformInfo
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
// Information about the toolkit that the app is running under and some basic
|
|
|
|
// platform and architecture info
|
|
|
|
class WXDLLIMPEXP_BASE wxPlatformInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxPlatformInfo();
|
|
|
|
wxPlatformInfo(wxPortId pid,
|
|
|
|
int tkMajor = -1, int tkMinor = -1,
|
|
|
|
wxOperatingSystemId id = wxOS_UNKNOWN,
|
|
|
|
int osMajor = -1, int osMinor = -1,
|
|
|
|
wxArchitecture arch = wxARCH_INVALID,
|
2006-08-16 17:18:34 +00:00
|
|
|
wxEndianness endian = wxENDIAN_INVALID,
|
|
|
|
bool usingUniversal = false);
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// default copy ctor, assignment operator and dtor are ok
|
|
|
|
|
|
|
|
bool operator==(const wxPlatformInfo &t) const;
|
|
|
|
|
|
|
|
bool operator!=(const wxPlatformInfo &t) const
|
|
|
|
{ return !(*this == t); }
|
|
|
|
|
2006-10-09 15:58:56 +00:00
|
|
|
// Gets a wxPlatformInfo already initialized with the values for
|
|
|
|
// the currently running platform.
|
|
|
|
static const wxPlatformInfo& Get();
|
|
|
|
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// string -> enum conversions
|
|
|
|
// ---------------------------------
|
|
|
|
|
|
|
|
static wxOperatingSystemId GetOperatingSystemId(const wxString &name);
|
|
|
|
static wxPortId GetPortId(const wxString &portname);
|
|
|
|
|
|
|
|
static wxArchitecture GetArch(const wxString &arch);
|
|
|
|
static wxEndianness GetEndianness(const wxString &end);
|
|
|
|
|
|
|
|
// enum -> string conversions
|
|
|
|
// ---------------------------------
|
|
|
|
|
|
|
|
static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os);
|
|
|
|
static wxString GetOperatingSystemIdName(wxOperatingSystemId os);
|
2006-08-16 17:18:34 +00:00
|
|
|
static wxString GetPortIdName(wxPortId port, bool usingUniversal);
|
|
|
|
static wxString GetPortIdShortName(wxPortId port, bool usingUniversal);
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
static wxString GetArchName(wxArchitecture arch);
|
|
|
|
static wxString GetEndiannessName(wxEndianness end);
|
|
|
|
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
// getters
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
int GetOSMajorVersion() const
|
|
|
|
{ return m_osVersionMajor; }
|
|
|
|
int GetOSMinorVersion() const
|
|
|
|
{ return m_osVersionMinor; }
|
2015-06-24 04:00:02 +00:00
|
|
|
int GetOSMicroVersion() const
|
|
|
|
{ return m_osVersionMicro; }
|
2006-08-13 21:00:32 +00:00
|
|
|
|
2006-09-16 00:38:36 +00:00
|
|
|
// return true if the OS version >= major.minor
|
2015-06-24 04:00:02 +00:00
|
|
|
bool CheckOSVersion(int major, int minor, int micro = 0) const;
|
2006-09-16 00:38:36 +00:00
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
int GetToolkitMajorVersion() const
|
|
|
|
{ return m_tkVersionMajor; }
|
|
|
|
int GetToolkitMinorVersion() const
|
|
|
|
{ return m_tkVersionMinor; }
|
2015-06-24 04:54:34 +00:00
|
|
|
int GetToolkitMicroVersion() const
|
|
|
|
{ return m_tkVersionMicro; }
|
2006-08-13 21:00:32 +00:00
|
|
|
|
2015-06-24 04:54:34 +00:00
|
|
|
bool CheckToolkitVersion(int major, int minor, int micro = 0) const
|
2006-09-16 00:38:36 +00:00
|
|
|
{
|
|
|
|
return DoCheckVersion(GetToolkitMajorVersion(),
|
|
|
|
GetToolkitMinorVersion(),
|
2015-06-24 04:54:34 +00:00
|
|
|
GetToolkitMicroVersion(),
|
2006-09-16 00:38:36 +00:00
|
|
|
major,
|
2015-06-24 04:00:02 +00:00
|
|
|
minor,
|
2015-06-24 04:54:34 +00:00
|
|
|
micro);
|
2006-09-16 00:38:36 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 17:18:34 +00:00
|
|
|
bool IsUsingUniversalWidgets() const
|
|
|
|
{ return m_usingUniversal; }
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
wxOperatingSystemId GetOperatingSystemId() const
|
|
|
|
{ return m_os; }
|
2009-06-02 13:01:41 +00:00
|
|
|
wxLinuxDistributionInfo GetLinuxDistributionInfo() const
|
|
|
|
{ return m_ldi; }
|
2006-08-13 21:00:32 +00:00
|
|
|
wxPortId GetPortId() const
|
|
|
|
{ return m_port; }
|
|
|
|
wxArchitecture GetArchitecture() const
|
|
|
|
{ return m_arch; }
|
|
|
|
wxEndianness GetEndianness() const
|
|
|
|
{ return m_endian; }
|
|
|
|
|
|
|
|
|
|
|
|
// string getters
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
wxString GetOperatingSystemFamilyName() const
|
|
|
|
{ return GetOperatingSystemFamilyName(m_os); }
|
|
|
|
wxString GetOperatingSystemIdName() const
|
|
|
|
{ return GetOperatingSystemIdName(m_os); }
|
|
|
|
wxString GetPortIdName() const
|
2006-08-16 17:18:34 +00:00
|
|
|
{ return GetPortIdName(m_port, m_usingUniversal); }
|
2006-08-13 21:00:32 +00:00
|
|
|
wxString GetPortIdShortName() const
|
2006-08-16 17:18:34 +00:00
|
|
|
{ return GetPortIdShortName(m_port, m_usingUniversal); }
|
2006-08-13 21:00:32 +00:00
|
|
|
wxString GetArchName() const
|
|
|
|
{ return GetArchName(m_arch); }
|
|
|
|
wxString GetEndiannessName() const
|
|
|
|
{ return GetEndiannessName(m_endian); }
|
2009-06-02 13:01:41 +00:00
|
|
|
wxString GetOperatingSystemDescription() const
|
|
|
|
{ return m_osDesc; }
|
|
|
|
wxString GetDesktopEnvironment() const
|
|
|
|
{ return m_desktopEnv; }
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
static wxString GetOperatingSystemDirectory();
|
|
|
|
// doesn't make sense to store inside wxPlatformInfo the OS directory,
|
|
|
|
// thus this function is static; note that this function simply calls
|
2009-08-21 10:41:26 +00:00
|
|
|
// wxGetOSDirectory() and is here just to make it easier for the user to
|
2009-06-02 13:01:41 +00:00
|
|
|
// find it that feature (global functions can be difficult to find in the docs)
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// setters
|
|
|
|
// -----------------
|
|
|
|
|
2015-06-24 04:00:02 +00:00
|
|
|
void SetOSVersion(int major, int minor, int micro = 0)
|
|
|
|
{
|
|
|
|
m_osVersionMajor = major;
|
|
|
|
m_osVersionMinor = minor;
|
|
|
|
m_osVersionMicro = micro;
|
|
|
|
}
|
|
|
|
|
2015-06-24 04:54:34 +00:00
|
|
|
void SetToolkitVersion(int major, int minor, int micro = 0)
|
|
|
|
{
|
|
|
|
m_tkVersionMajor = major;
|
|
|
|
m_tkVersionMinor = minor;
|
|
|
|
m_tkVersionMicro = micro;
|
|
|
|
}
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
void SetOperatingSystemId(wxOperatingSystemId n)
|
2006-09-16 00:38:36 +00:00
|
|
|
{ m_os = n; }
|
2009-06-02 13:01:41 +00:00
|
|
|
void SetOperatingSystemDescription(const wxString& desc)
|
|
|
|
{ m_osDesc = desc; }
|
2006-08-13 21:00:32 +00:00
|
|
|
void SetPortId(wxPortId n)
|
2006-09-16 00:38:36 +00:00
|
|
|
{ m_port = n; }
|
2006-08-13 21:00:32 +00:00
|
|
|
void SetArchitecture(wxArchitecture n)
|
2006-09-16 00:38:36 +00:00
|
|
|
{ m_arch = n; }
|
2006-08-13 21:00:32 +00:00
|
|
|
void SetEndianness(wxEndianness n)
|
2006-09-16 00:38:36 +00:00
|
|
|
{ m_endian = n; }
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
void SetDesktopEnvironment(const wxString& de)
|
|
|
|
{ m_desktopEnv = de; }
|
|
|
|
void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di)
|
|
|
|
{ m_ldi = di; }
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// miscellaneous
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
bool IsOk() const
|
|
|
|
{
|
|
|
|
return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
|
2015-06-24 04:00:02 +00:00
|
|
|
m_osVersionMicro != -1 &&
|
2006-08-13 21:00:32 +00:00
|
|
|
m_os != wxOS_UNKNOWN &&
|
2009-06-02 13:01:41 +00:00
|
|
|
!m_osDesc.IsEmpty() &&
|
2006-08-13 21:00:32 +00:00
|
|
|
m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
|
2015-06-24 04:54:34 +00:00
|
|
|
m_tkVersionMicro != -1 &&
|
2006-08-13 21:00:32 +00:00
|
|
|
m_port != wxPORT_UNKNOWN &&
|
2009-08-21 10:41:26 +00:00
|
|
|
m_arch != wxARCH_INVALID &&
|
2009-06-02 13:01:41 +00:00
|
|
|
m_endian != wxENDIAN_INVALID;
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
// do not check linux-specific info; it's ok to have them empty
|
2006-08-13 21:00:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
2015-06-24 04:00:02 +00:00
|
|
|
static bool DoCheckVersion(int majorCur, int minorCur, int microCur,
|
|
|
|
int major, int minor, int micro)
|
2006-09-16 00:38:36 +00:00
|
|
|
{
|
2015-06-24 04:00:02 +00:00
|
|
|
return majorCur > major
|
|
|
|
|| (majorCur == major && minorCur > minor)
|
|
|
|
|| (majorCur == major && minorCur == minor && microCur >= micro);
|
2006-09-16 00:38:36 +00:00
|
|
|
}
|
|
|
|
|
2015-08-06 09:32:38 +00:00
|
|
|
bool m_initializedForCurrentPlatform;
|
|
|
|
|
2006-10-09 15:58:56 +00:00
|
|
|
void InitForCurrentPlatform();
|
|
|
|
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
// OS stuff
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
// Version of the OS; valid if m_os != wxOS_UNKNOWN
|
|
|
|
// (-1 means not initialized yet).
|
2006-09-16 00:38:36 +00:00
|
|
|
int m_osVersionMajor,
|
2015-06-24 04:00:02 +00:00
|
|
|
m_osVersionMinor,
|
|
|
|
m_osVersionMicro;
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// Operating system ID.
|
|
|
|
wxOperatingSystemId m_os;
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
// Operating system description.
|
|
|
|
wxString m_osDesc;
|
2009-08-21 10:41:26 +00:00
|
|
|
|
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
// linux-specific
|
|
|
|
// -----------------
|
2009-08-21 10:41:26 +00:00
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
wxString m_desktopEnv;
|
|
|
|
wxLinuxDistributionInfo m_ldi;
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
// toolkit
|
|
|
|
// -----------------
|
|
|
|
|
|
|
|
// Version of the underlying toolkit
|
|
|
|
// (-1 means not initialized yet; zero means no toolkit).
|
2015-06-24 04:54:34 +00:00
|
|
|
int m_tkVersionMajor, m_tkVersionMinor, m_tkVersionMicro;
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// name of the wxWidgets port
|
|
|
|
wxPortId m_port;
|
|
|
|
|
2006-08-16 17:18:34 +00:00
|
|
|
// is using wxUniversal widgets?
|
|
|
|
bool m_usingUniversal;
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
|
|
|
|
// others
|
|
|
|
// -----------------
|
|
|
|
|
2009-06-02 13:01:41 +00:00
|
|
|
// architecture of the OS/machine
|
2006-08-13 21:00:32 +00:00
|
|
|
wxArchitecture m_arch;
|
|
|
|
|
|
|
|
// endianness of the machine
|
|
|
|
wxEndianness m_endian;
|
|
|
|
};
|
|
|
|
|
2014-08-24 01:50:11 +00:00
|
|
|
|
|
|
|
|
2006-08-13 21:00:32 +00:00
|
|
|
#endif // _WX_PLATINFO_H_
|