X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b20ca9976d1e6aeb1a1854fae362d3d68464433a..ca77701441e39245dcbfce903049e76f166979e5:/include/wx/platinfo.h diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h index 913a08d182..39a5099be0 100644 --- a/include/wx/platinfo.h +++ b/include/wx/platinfo.h @@ -6,7 +6,7 @@ // Created: 07.07.2006 (based on wxToolkitInfo) // RCS-ID: $Id$ // Copyright: (c) 2006 Francesco Montorsi -// License: wxWindows license +// Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// #ifndef _WX_PLATINFO_H_ @@ -15,7 +15,7 @@ #include "wx/string.h" // ---------------------------------------------------------------------------- -// wxPlatformInfo +// wxPlatformInfo enums & structs // ---------------------------------------------------------------------------- // VERY IMPORTANT: when changing these enum values, also change the relative @@ -72,13 +72,14 @@ enum wxPortId 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_DFB = 1 << 4, // wxDFB, 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_PM = 1 << 6, // wxOS2, using OS/2 Presentation Manager + wxPORT_OS2 = wxPORT_PM, // wxOS2, using OS/2 Presentation Manager + wxPORT_MAC = 1 << 7, // wxOSX (former wxMac), using Cocoa, Carbon or iPhone API + wxPORT_OSX = wxPORT_MAC, // wxOSX, using Cocoa, Carbon or iPhone 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_WINCE = 1 << 9 // wxWinCE, toolkit is WinCE SDK API }; // architecture of the operating system @@ -107,6 +108,31 @@ enum wxEndianness wxENDIAN_MAX }; +// informations about a linux distro returned by the lsb_release utility +struct wxLinuxDistributionInfo +{ + wxString Id; + wxString Release; + wxString CodeName; + wxString Description; + + bool operator==(const wxLinuxDistributionInfo& ldi) const + { + return Id == ldi.Id && + Release == ldi.Release && + CodeName == ldi.CodeName && + Description == ldi.Description; + } + + bool operator!=(const wxLinuxDistributionInfo& ldi) const + { return !(*this == ldi); } +}; + + +// ---------------------------------------------------------------------------- +// wxPlatformInfo +// ---------------------------------------------------------------------------- + // Information about the toolkit that the app is running under and some basic // platform and architecture info class WXDLLIMPEXP_BASE wxPlatformInfo @@ -118,7 +144,8 @@ public: wxOperatingSystemId id = wxOS_UNKNOWN, int osMajor = -1, int osMinor = -1, wxArchitecture arch = wxARCH_INVALID, - wxEndianness endian = wxENDIAN_INVALID); + wxEndianness endian = wxENDIAN_INVALID, + bool usingUniversal = false); // default copy ctor, assignment operator and dtor are ok @@ -127,6 +154,11 @@ public: bool operator!=(const wxPlatformInfo &t) const { return !(*this == t); } + // Gets a wxPlatformInfo already initialized with the values for + // the currently running platform. + static const wxPlatformInfo& Get(); + + // string -> enum conversions // --------------------------------- @@ -142,12 +174,13 @@ public: static wxString GetOperatingSystemFamilyName(wxOperatingSystemId os); static wxString GetOperatingSystemIdName(wxOperatingSystemId os); - static wxString GetPortIdName(wxPortId port); - static wxString GetPortIdShortName(wxPortId port); + static wxString GetPortIdName(wxPortId port, bool usingUniversal); + static wxString GetPortIdShortName(wxPortId port, bool usingUniversal); static wxString GetArchName(wxArchitecture arch); static wxString GetEndiannessName(wxEndianness end); + // getters // ----------------- @@ -156,13 +189,35 @@ public: int GetOSMinorVersion() const { return m_osVersionMinor; } + // return true if the OS version >= major.minor + bool CheckOSVersion(int major, int minor) const + { + return DoCheckVersion(GetOSMajorVersion(), + GetOSMinorVersion(), + major, + minor); + } + int GetToolkitMajorVersion() const { return m_tkVersionMajor; } int GetToolkitMinorVersion() const { return m_tkVersionMinor; } + bool CheckToolkitVersion(int major, int minor) const + { + return DoCheckVersion(GetToolkitMajorVersion(), + GetToolkitMinorVersion(), + major, + minor); + } + + bool IsUsingUniversalWidgets() const + { return m_usingUniversal; } + wxOperatingSystemId GetOperatingSystemId() const { return m_os; } + wxLinuxDistributionInfo GetLinuxDistributionInfo() const + { return m_ldi; } wxPortId GetPortId() const { return m_port; } wxArchitecture GetArchitecture() const @@ -179,13 +234,23 @@ public: wxString GetOperatingSystemIdName() const { return GetOperatingSystemIdName(m_os); } wxString GetPortIdName() const - { return GetPortIdName(m_port); } + { return GetPortIdName(m_port, m_usingUniversal); } wxString GetPortIdShortName() const - { return GetPortIdShortName(m_port); } + { return GetPortIdShortName(m_port, m_usingUniversal); } wxString GetArchName() const { return GetArchName(m_arch); } wxString GetEndiannessName() const { return GetEndiannessName(m_endian); } + wxString GetOperatingSystemDescription() const + { return m_osDesc; } + wxString GetDesktopEnvironment() const + { return m_desktopEnv; } + + 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 + // wxGetOSDirectory() and is here just to make it easier for the user to + // find it that feature (global functions can be difficult to find in the docs) // setters // ----------------- @@ -196,13 +261,21 @@ public: { m_tkVersionMajor=major; m_tkVersionMinor=minor; } void SetOperatingSystemId(wxOperatingSystemId n) - { m_os=n; } + { m_os = n; } + void SetOperatingSystemDescription(const wxString& desc) + { m_osDesc = desc; } void SetPortId(wxPortId n) - { m_port=n; } + { m_port = n; } void SetArchitecture(wxArchitecture n) - { m_arch=n; } + { m_arch = n; } void SetEndianness(wxEndianness n) - { m_endian=n; } + { m_endian = n; } + + void SetDesktopEnvironment(const wxString& de) + { m_desktopEnv = de; } + void SetLinuxDistributionInfo(const wxLinuxDistributionInfo& di) + { m_ldi = di; } + // miscellaneous // ----------------- @@ -211,32 +284,46 @@ public: { return m_osVersionMajor != -1 && m_osVersionMinor != -1 && m_os != wxOS_UNKNOWN && + !m_osDesc.IsEmpty() && m_tkVersionMajor != -1 && m_tkVersionMinor != -1 && m_port != wxPORT_UNKNOWN && - m_arch != wxARCH_INVALID && m_endian != wxENDIAN_INVALID; + m_arch != wxARCH_INVALID && + m_endian != wxENDIAN_INVALID; + + // do not check linux-specific info; it's ok to have them empty } - static bool IsUsingUniversalWidgets() + +protected: + static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor) { - #ifdef __WXUNIVERSAL__ - return true; - #else - return false; - #endif + return majorCur > major || (majorCur == major && minorCur >= minor); } + void InitForCurrentPlatform(); + -protected: // OS stuff // ----------------- // Version of the OS; valid if m_os != wxOS_UNKNOWN // (-1 means not initialized yet). - int m_osVersionMajor, m_osVersionMinor; + int m_osVersionMajor, + m_osVersionMinor; // Operating system ID. wxOperatingSystemId m_os; + // Operating system description. + wxString m_osDesc; + + + // linux-specific + // ----------------- + + wxString m_desktopEnv; + wxLinuxDistributionInfo m_ldi; + // toolkit // ----------------- @@ -248,11 +335,14 @@ protected: // name of the wxWidgets port wxPortId m_port; + // is using wxUniversal widgets? + bool m_usingUniversal; + // others // ----------------- - // architecture of the OS + // architecture of the OS/machine wxArchitecture m_arch; // endianness of the machine @@ -270,9 +360,7 @@ protected: #define wxWinCE wxOS_WINDOWS_CE #define wxWIN32S wxOS_WINDOWS_9X - #define wxPalmOS wxPORT_PALMOS #define wxOS2 wxPORT_OS2 - #define wxMGL wxPORT_MGL #define wxCocoa wxPORT_MAC #define wxMac wxPORT_MAC #define wxMotif wxPORT_MOTIF