From 6bf035a9940e7e323fe4884e6d895c94a2d93314 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Thu, 11 Feb 2016 10:17:00 +0100 Subject: [PATCH] Use common version of wxGetOsVersion, wxCheckOsVersion for iOS and OS X. --- src/osx/cocoa/utils_base.mm | 14 ++++++++++-- src/osx/iphone/utils.mm | 44 ------------------------------------- 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/src/osx/cocoa/utils_base.mm b/src/osx/cocoa/utils_base.mm index 853f09927c..504a9a0673 100644 --- a/src/osx/cocoa/utils_base.mm +++ b/src/osx/cocoa/utils_base.mm @@ -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()) diff --git a/src/osx/iphone/utils.mm b/src/osx/iphone/utils.mm index 4bffe8d63a..b85cb437e0 100644 --- a/src/osx/iphone/utils.mm +++ b/src/osx/iphone/utils.mm @@ -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