Add OS micro version information to wxPlatformInfo

Add GetOSMicroVersion and add other micro version references in an
unobtrusive way: don't change wxPlatformInfo's constructor and use
default parameters for CheckOSVersion and SetOSVersion. The only change
that could affect user code is the changed number of parameters for
DoCheckVersion but because that is a protected function it's less likely
to be a problem.
This commit is contained in:
Dimitri Schoolwerth 2015-06-24 08:00:02 +04:00 committed by Tobias Taschner
parent 427750e744
commit ea439c278b
3 changed files with 46 additions and 18 deletions

View File

@ -188,9 +188,11 @@ public:
{ return m_osVersionMajor; }
int GetOSMinorVersion() const
{ return m_osVersionMinor; }
int GetOSMicroVersion() const
{ return m_osVersionMicro; }
// return true if the OS version >= major.minor
bool CheckOSVersion(int major, int minor) const;
bool CheckOSVersion(int major, int minor, int micro = 0) const;
int GetToolkitMajorVersion() const
{ return m_tkVersionMajor; }
@ -201,8 +203,10 @@ public:
{
return DoCheckVersion(GetToolkitMajorVersion(),
GetToolkitMinorVersion(),
0,
major,
minor);
minor,
0);
}
bool IsUsingUniversalWidgets() const
@ -249,8 +253,13 @@ public:
// setters
// -----------------
void SetOSVersion(int major, int minor)
{ m_osVersionMajor=major; m_osVersionMinor=minor; }
void SetOSVersion(int major, int minor, int micro = 0)
{
m_osVersionMajor = major;
m_osVersionMinor = minor;
m_osVersionMicro = micro;
}
void SetToolkitVersion(int major, int minor)
{ m_tkVersionMajor=major; m_tkVersionMinor=minor; }
@ -277,6 +286,7 @@ public:
bool IsOk() const
{
return m_osVersionMajor != -1 && m_osVersionMinor != -1 &&
m_osVersionMicro != -1 &&
m_os != wxOS_UNKNOWN &&
!m_osDesc.IsEmpty() &&
m_tkVersionMajor != -1 && m_tkVersionMinor != -1 &&
@ -289,9 +299,12 @@ public:
protected:
static bool DoCheckVersion(int majorCur, int minorCur, int major, int minor)
static bool DoCheckVersion(int majorCur, int minorCur, int microCur,
int major, int minor, int micro)
{
return majorCur > major || (majorCur == major && minorCur >= minor);
return majorCur > major
|| (majorCur == major && minorCur > minor)
|| (majorCur == major && minorCur == minor && microCur >= micro);
}
bool m_initializedForCurrentPlatform;
@ -305,7 +318,8 @@ protected:
// Version of the OS; valid if m_os != wxOS_UNKNOWN
// (-1 means not initialized yet).
int m_osVersionMajor,
m_osVersionMinor;
m_osVersionMinor,
m_osVersionMicro;
// Operating system ID.
wxOperatingSystemId m_os;

View File

@ -12,11 +12,11 @@
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. @c wxOS_MAC and @c wxOS_UNIX.
Note that you can obtain more detailed information about the current OS
version in use by checking the major and minor version numbers returned
by ::wxGetOsVersion() or by wxPlatformInfo::GetOSMajorVersion(),
wxPlatformInfo::GetOSMinorVersion().
version in use by checking the major, minor, and micro version numbers
returned by ::wxGetOsVersion() or by wxPlatformInfo::GetOSMajorVersion(),
wxPlatformInfo::GetOSMinorVersion(), and wxPlatformInfo::GetOSMicroVersion().
*/
enum wxOperatingSystemId
{
@ -177,12 +177,12 @@ public:
/**
Returns @true if the OS version is at least @c major.minor.
Returns @true if the OS version is at least @c major.minor.micro.
@see GetOSMajorVersion(), GetOSMinorVersion(),
@see GetOSMajorVersion(), GetOSMinorVersion(), GetOSMicroVersion(),
CheckToolkitVersion()
*/
bool CheckOSVersion(int major, int minor) const;
bool CheckOSVersion(int major, int minor, int micro = 0) const;
/**
Returns @true if the toolkit version is at least @c major.minor.
@ -348,6 +348,16 @@ public:
*/
int GetOSMinorVersion() const;
/**
Returns the run-time micro version of the OS associated with this
wxPlatformInfo instance.
@see ::wxGetOsVersion(), CheckOSVersion()
@since 3.1.1
*/
int GetOSMicroVersion() const;
/**
Returns the operating system ID of this wxPlatformInfo instance.
@ -472,7 +482,7 @@ public:
Sets the version of the operating system associated with this wxPlatformInfo
instance.
*/
void SetOSVersion(int major, int minor);
void SetOSVersion(int major, int minor, int micro = 0);
/**
Sets the operating system associated with this wxPlatformInfo instance.

View File

@ -145,6 +145,7 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
m_os = id;
m_osVersionMajor = osMajor;
m_osVersionMinor = osMinor;
m_osVersionMicro = -1;
m_endian = endian;
m_arch = arch;
@ -156,6 +157,7 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
m_tkVersionMinor == t.m_tkVersionMinor &&
m_osVersionMajor == t.m_osVersionMajor &&
m_osVersionMinor == t.m_osVersionMinor &&
m_osVersionMicro == t.m_osVersionMicro &&
m_os == t.m_os &&
m_osDesc == t.m_osDesc &&
m_ldi == t.m_ldi &&
@ -188,7 +190,7 @@ void wxPlatformInfo::InitForCurrentPlatform()
m_desktopEnv = traits->GetDesktopEnvironment();
}
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor);
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor, &m_osVersionMicro);
m_osDesc = wxGetOsDescription();
m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG;
m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32;
@ -298,7 +300,7 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end)
return wxEndiannessNames[end];
}
bool wxPlatformInfo::CheckOSVersion(int major, int minor) const
bool wxPlatformInfo::CheckOSVersion(int major, int minor, int micro) const
{
// If this instance of wxPlatformInfo has been initialized by InitForCurrentPlatform()
// this check gets forwarded to the wxCheckOsVersion which might do more than a simple
@ -308,8 +310,10 @@ bool wxPlatformInfo::CheckOSVersion(int major, int minor) const
else
return DoCheckVersion(GetOSMajorVersion(),
GetOSMinorVersion(),
GetOSMicroVersion(),
major,
minor);
minor,
micro);
}
// ----------------------------------------------------------------------------