Use common version of wxGetOsVersion, wxCheckOsVersion for iOS and OS X.

This commit is contained in:
Tobias Taschner
2016-02-11 10:17:00 +01:00
parent 1908c41f36
commit 6bf035a994
2 changed files with 12 additions and 46 deletions

View File

@@ -25,7 +25,7 @@
// our OS version is the same in non GUI and GUI cases
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 || defined(__WXOSX_IPHONE__)
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
{
NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion;
@@ -43,8 +43,13 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
// Deprecated Gestalt calls are required instead
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
SInt32 maj, min;
#ifdef __WXOSX_IPHONE__
maj = 7;
min = 0;
#else
Gestalt(gestaltSystemVersionMajor, &maj);
Gestalt(gestaltSystemVersionMinor, &min);
#endif
wxGCC_WARNING_RESTORE()
if ( majorVsn != NULL )
@@ -59,7 +64,7 @@ wxGCC_WARNING_RESTORE()
bool wxCheckOsVersion(int majorVsn, int minorVsn)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 || defined(__WXOSX_IPHONE__)
if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)])
{
NSOperatingSystemVersion osVer;
@@ -85,6 +90,7 @@ wxString wxGetOsDescription()
int majorVer, minorVer;
wxGetOsVersion(&majorVer, &minorVer);
#ifndef __WXOSX_IPHONE__
// Notice that neither the OS name itself nor the code names seem to be
// ever translated, OS X itself uses the English words even for the
// languages not using Roman alphabet.
@@ -113,6 +119,10 @@ wxString wxGetOsDescription()
break;
};
}
#else
wxString osBrand = "iOS";
wxString osName;
#endif
wxString osDesc = osBrand;
if (!osName.empty())

View File

@@ -317,48 +317,4 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
#endif // wxUSE_GUI
// TODO move these into a BASE file
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
{
// get OS version
int major, minor;
wxString release = wxCFStringRef( wxCFRetain( [ [UIDevice currentDevice] systemVersion] ) ).AsString() ;
if ( release.empty() ||
// TODO use wx method
scanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 )
{
// failed to get version string or unrecognized format
major =
minor = -1;
}
if ( verMaj )
*verMaj = major;
if ( verMin )
*verMin = minor;
return wxOS_MAC_OSX_DARWIN;
}
wxString wxGetOsDescription()
{
wxString release = wxCFStringRef( wxCFRetain([ [UIDevice currentDevice] systemName] )).AsString() ;
return release;
}
// FIXME: This duplicates the function in src/unix/utilsunx.cpp, we should just
// reuse it instead of there is no iOS-specific implementation of this.
bool wxCheckOsVersion(int majorVsn, int minorVsn)
{
int majorCur, minorCur;
wxGetOsVersion(&majorCur, &minorCur);
return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn);
}
#endif // wxOSX_USE_IPHONE