diff --git a/README.md b/README.md index d551a94f92..b224a9f8db 100644 --- a/README.md +++ b/README.md @@ -22,13 +22,13 @@ Platforms wxWidgets currently supports the following primary platforms: -- Windows XP, Vista, 7 and 8 (32/64 bits). +- Windows XP, Vista, 7, 8 and 10 (32/64 bits). - Most Unix variants using the GTK+ toolkit (version 2.6 or newer or 3.x). - Mac OS X (10.7 or newer) using Cocoa (32/64 bits) or Carbon (32 only). Most popular C++ compilers are supported including but not limited to: -- Microsoft Visual C++ 2003 or later (up to 2013). +- Microsoft Visual C++ 2003 or later (up to 2015). - g++ 3.4 or later, including MinGW/MinGW-64/TDM under Windows. - Clang under OS X and Linux. - Intel icc compiler. diff --git a/docs/readme.txt b/docs/readme.txt index c2f4bcac9b..713fc96d50 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -45,9 +45,9 @@ Platforms supported wxWidgets currently supports the following primary platforms: -- Windows XP, Vista, 7 and 8 (32/64 bits). +- Windows XP, Vista, 7, 8 and 10 (32/64 bits). - Most Unix variants using the GTK+ toolkit (version 2.6 or newer) -- Mac OS X (10.6 or newer) using Cocoa (32/64 bits) or Carbon (32 only) +- Mac OS X (10.7 or newer) using Cocoa (32/64 bits) or Carbon (32 only) There is some support for the following platforms: diff --git a/include/wx/osx/cocoa/dataview.h b/include/wx/osx/cocoa/dataview.h index 540b66a56c..65fc99c2b3 100644 --- a/include/wx/osx/cocoa/dataview.h +++ b/include/wx/osx/cocoa/dataview.h @@ -249,7 +249,7 @@ private: // owned by the set. Furthermore, children of the last parent are stored // in a linear list. // -@interface wxCocoaOutlineDataSource : NSObject wxOSX_10_6_AND_LATER() +@interface wxCocoaOutlineDataSource : NSObject { // descriptors specifying the sorting (currently the array only holds one // object only) @@ -395,7 +395,7 @@ private: // wxCocoaOutlineView // ============================================================================ -@interface wxCocoaOutlineView : NSOutlineView wxOSX_10_6_AND_LATER() +@interface wxCocoaOutlineView : NSOutlineView { @private // column and row of the cell being edited or -1 if none diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 83cd34d41e..cc929ae6bf 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -336,7 +336,7 @@ public: - (void) setTextField:(NSTextField*) field; @end - @interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER() + @interface wxNSTextField : NSTextField { wxNSTextFieldEditor* fieldEditor; } @@ -346,14 +346,14 @@ public: @end - @interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER() + @interface wxNSSecureTextField : NSSecureTextField { } @end - @interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER() + @interface wxNSTextView : NSTextView { } @@ -432,7 +432,7 @@ public: #ifdef __LP64__ WXEXPORT #endif // 64 bit builds - @interface wxNSAppController : NSObject wxOSX_10_6_AND_LATER() + @interface wxNSAppController : NSObject { } diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index c52a8e5af2..9b1c371562 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -20,17 +20,6 @@ #include "wx/osx/core/cfstring.h" #include "wx/osx/core/cfdataref.h" -// Define helper macros allowing to insert small snippets of code to be -// compiled for high enough OS X version only: this shouldn't be abused for -// anything big but it's handy for e.g. specifying OS X 10.6-only protocols in -// the Objective C classes declarations when they're not supported under the -// previous versions -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - #define wxOSX_10_6_AND_LATER(x) x -#else - #define wxOSX_10_6_AND_LATER(x) -#endif - // platform specific Clang analyzer support #ifndef NS_RETURNS_RETAINED # if WX_HAS_CLANG_FEATURE(attribute_ns_returns_retained) diff --git a/include/wx/platform.h b/include/wx/platform.h index c398f119d3..03c695bc90 100644 --- a/include/wx/platform.h +++ b/include/wx/platform.h @@ -35,6 +35,9 @@ # ifndef MAC_OS_X_VERSION_10_9 # define MAC_OS_X_VERSION_10_9 1090 # endif +# ifndef MAC_OS_X_VERSION_10_10 +# define MAC_OS_X_VERSION_10_10 101000 +# endif # include "wx/osx/config_xcode.h" # ifndef __WXOSX__ # define __WXOSX__ 1 @@ -534,6 +537,9 @@ # ifndef MAC_OS_X_VERSION_10_9 # define MAC_OS_X_VERSION_10_9 1090 # endif +# ifndef MAC_OS_X_VERSION_10_10 +# define MAC_OS_X_VERSION_10_10 101000 +# endif # else # error "only mach-o configurations are supported" # endif diff --git a/include/wx/platinfo.h b/include/wx/platinfo.h index 33cd2c58ca..3166f82804 100644 --- a/include/wx/platinfo.h +++ b/include/wx/platinfo.h @@ -190,13 +190,7 @@ public: { return m_osVersionMinor; } // return true if the OS version >= major.minor - bool CheckOSVersion(int major, int minor) const - { - return DoCheckVersion(GetOSMajorVersion(), - GetOSMinorVersion(), - major, - minor); - } + bool CheckOSVersion(int major, int minor) const; int GetToolkitMajorVersion() const { return m_tkVersionMajor; } @@ -300,6 +294,8 @@ protected: return majorCur > major || (majorCur == major && minorCur >= minor); } + bool m_initializedForCurrentPlatform; + void InitForCurrentPlatform(); diff --git a/include/wx/utils.h b/include/wx/utils.h index 3461821b46..e29c131697 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -143,6 +143,9 @@ WXDLLIMPEXP_BASE wxString wxGetOsDescription(); WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL, int *minorVsn = NULL); +// Check is OS version is at least the specified major and minor version +WXDLLIMPEXP_BASE bool wxCheckOsVersion(int majorVsn, int minorVsn = 0); + // Get platform endianness WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); diff --git a/interface/wx/utils.h b/interface/wx/utils.h index bce6a30dcf..0dd2a30d73 100644 --- a/interface/wx/utils.h +++ b/interface/wx/utils.h @@ -733,10 +733,6 @@ wxString wxGetHomeDir(); note that the returned name is @e not fully qualified, i.e. it does not include the domain name. - Under Windows or NT, this function first looks in the environment variable - SYSTEM_NAME; if this is not found, the entry @b HostName in the wxWidgets - section of the WIN.INI file is tried. - @return The hostname if successful or an empty string otherwise. @see wxGetFullHostName() @@ -835,7 +831,7 @@ bool wxGetUserName(char* buf, int sz); /** Returns the string containing the description of the current platform in a user-readable form. For example, this function may return strings like - "Windows NT Version 4.0" or "Linux 2.2.2 i386". + "Windows 10 (build 10240), 64-bit edition" or "Linux 4.1.4 i386". @see wxGetOsVersion() @@ -851,16 +847,21 @@ wxString wxGetOsDescription(); For Unix-like systems (@c wxOS_UNIX) the major and minor version integers will contain the kernel major and minor version numbers (as returned by the - 'uname -r' command); e.g. "2" and "6" if the machine is using kernel 2.6.19. + 'uname -r' command); e.g. "4" and "1" if the machine is using kernel 4.1.4. For Mac OS X systems (@c wxOS_MAC) the major and minor version integers are the - natural version numbers associated with the OS; e.g. "10" and "6" if the machine - is using Mac OS X Snow Leopard. + natural version numbers associated with the OS; e.g. "10" and "11" if the machine + is using Mac OS X El Capitan. For Windows-like systems (@c wxOS_WINDOWS) the major and minor version integers will contain the following values: @beginTable @row3col{Windows OS name, Major version, Minor version} + @row3col{Windows 10, 10, 0} + @row3col{Windows 8.1, 6, 3} + @row3col{Windows Server 2012 R2, 6, 3} + @row3col{Windows 8, 6, 2} + @row3col{Windows Server 2012, 6, 2} @row3col{Windows 7, 6, 1} @row3col{Windows Server 2008 R2, 6, 1} @row3col{Windows Server 2008, 6, 0} @@ -868,7 +869,6 @@ wxString wxGetOsDescription(); @row3col{Windows Server 2003 R2, 5, 2} @row3col{Windows Server 2003, 5, 2} @row3col{Windows XP, 5, 1} - @row3col{Windows 2000, 5, 0} @endDefList See the MSDN for more info about the values above. @@ -879,6 +879,18 @@ wxString wxGetOsDescription(); */ wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL); +/** + Returns @true the version of the operating system on which the program + is running under is the same or later than the given version. + + @since 3.1.0 + + @see wxGetOsVersion(), wxPlatformInfo + + @header{wx/utils.h} +*/ +bool wxCheckOsVersion(int majorVsn, int minorVsn = 0); + /** Returns @true if the operating system the program is running under is 64 bit. The check is performed at run-time and may differ from the value diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 18cd9ef682..3027b4f575 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1679,15 +1679,6 @@ static bool wxCheckWin32Permission(const wxString& path, DWORD access) return false; } - if ( wxGetOsVersion() == wxOS_WINDOWS_9X ) - { - // FAT directories always allow all access, even if they have the - // readonly flag set, and FAT files can only be read-only - return (dwAttr & FILE_ATTRIBUTE_DIRECTORY) || - (access != GENERIC_WRITE || - !(dwAttr & FILE_ATTRIBUTE_READONLY)); - } - HANDLE h = ::CreateFile ( path.t_str(), diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 0d6ed2f169..70f131f45b 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -2606,13 +2606,6 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess, int flags; if ( IsDir() ) { - if ( wxGetOsVersion() == wxOS_WINDOWS_9X ) - { - wxLogError(_("Setting directory access times is not supported " - "under this OS version")); - return false; - } - path = GetPath(); flags = FILE_FLAG_BACKUP_SEMANTICS; } diff --git a/src/common/platinfo.cpp b/src/common/platinfo.cpp index 268d51273e..41fd0c23db 100644 --- a/src/common/platinfo.cpp +++ b/src/common/platinfo.cpp @@ -135,6 +135,8 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor, wxEndianness endian, bool usingUniversal) { + m_initializedForCurrentPlatform = false; + m_tkVersionMajor = tkMajor; m_tkVersionMinor = tkMinor; m_port = pid; @@ -166,6 +168,8 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const void wxPlatformInfo::InitForCurrentPlatform() { + m_initializedForCurrentPlatform = true; + // autodetect all informations const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; if ( !traits ) @@ -294,6 +298,19 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end) return wxEndiannessNames[end]; } +bool wxPlatformInfo::CheckOSVersion(int major, int minor) 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 + // number check if supported by the platform + if (m_initializedForCurrentPlatform) + return wxCheckOsVersion(major, minor); + else + return DoCheckVersion(GetOSMajorVersion(), + GetOSMinorVersion(), + major, + minor); +} // ---------------------------------------------------------------------------- // wxPlatformInfo - string -> enum conversions diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index aee711a689..5f5f451529 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -996,12 +996,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent, const wxString& name ) { #ifdef __WXMAC__ - int major, minor; - wxGetOsVersion(&major, &minor); - - if (major < 10) - style |= wxTR_ROW_LINES; - if (style & wxTR_HAS_BUTTONS) style |= wxTR_NO_LINES; #endif // __WXMAC__ diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index a41e4ddf83..843cc88c26 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -300,19 +300,6 @@ bool wxPenRefData::Alloc() const COLORREF col = m_colour.GetPixel(); #ifdef wxHAVE_EXT_CREATE_PEN - // Only NT can display dashed or dotted lines with width > 1 - static const int os = wxGetOsVersion(); - if ( os != wxOS_WINDOWS_NT && - (m_style == wxPENSTYLE_DOT || - m_style == wxPENSTYLE_LONG_DASH || - m_style == wxPENSTYLE_SHORT_DASH || - m_style == wxPENSTYLE_DOT_DASH || - m_style == wxPENSTYLE_USER_DASH) && - m_width > 1 ) - { - m_width = 1; - } - // check if it's a standard kind of pen which can be created with just // CreatePen() if ( m_join == wxJOIN_ROUND && diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index f275bb5c10..02f28bb566 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -1341,15 +1341,7 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha) bool wxTopLevelWindowMSW::CanSetTransparent() { - // The API is available on win2k and above - - static int os_type = -1; - static int ver_major = -1; - - if (os_type == -1) - os_type = ::wxGetOsVersion(&ver_major); - - return (os_type == wxOS_WINDOWS_NT && ver_major >= 5); + return true; } void wxTopLevelWindowMSW::DoFreeze() diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 974534be61..aedbb78841 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -891,36 +891,33 @@ bool wxShutdown(int WXUNUSED_IN_WINCE(flags)) #else bool bOK = true; - if ( wxGetOsVersion(NULL, NULL) == wxOS_WINDOWS_NT ) // if is NT or 2K + // Get a token for this process. + HANDLE hToken; + bOK = ::OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, + &hToken) != 0; + if ( bOK ) { - // Get a token for this process. - HANDLE hToken; - bOK = ::OpenProcessToken(GetCurrentProcess(), - TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, - &hToken) != 0; + TOKEN_PRIVILEGES tkp; + + // Get the LUID for the shutdown privilege. + bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, + &tkp.Privileges[0].Luid) != 0; + if ( bOK ) { - TOKEN_PRIVILEGES tkp; + tkp.PrivilegeCount = 1; // one privilege to set + tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - // Get the LUID for the shutdown privilege. - bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, - &tkp.Privileges[0].Luid) != 0; + // Get the shutdown privilege for this process. + ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, + (PTOKEN_PRIVILEGES)NULL, 0); - if ( bOK ) - { - tkp.PrivilegeCount = 1; // one privilege to set - tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - // Get the shutdown privilege for this process. - ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, - (PTOKEN_PRIVILEGES)NULL, 0); - - // Cannot test the return value of AdjustTokenPrivileges. - bOK = ::GetLastError() == ERROR_SUCCESS; - } - - ::CloseHandle(hToken); + // Cannot test the return value of AdjustTokenPrivileges. + bOK = ::GetLastError() == ERROR_SUCCESS; } + + ::CloseHandle(hToken); } if ( bOK ) @@ -1330,6 +1327,21 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin) return s_version.os; } +bool wxCheckOsVersion(int majorVsn, int minorVsn) +{ + OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 }; + DWORDLONG const dwlConditionMask = + ::VerSetConditionMask( + ::VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL); + + osvi.dwMajorVersion = majorVsn; + osvi.dwMinorVersion = minorVsn; + + return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE; +} + wxWinVersion wxGetWinVersion() { int verMaj, diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index a0fbc92115..dedc3f547a 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -761,8 +761,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler, DWORD dwFlags = CREATE_SUSPENDED; #ifndef __WXWINCE__ - if ( (flags & wxEXEC_MAKE_GROUP_LEADER) && - (wxGetOsVersion() == wxOS_WINDOWS_NT) ) + if ( (flags & wxEXEC_MAKE_GROUP_LEADER) ) dwFlags |= CREATE_NEW_PROCESS_GROUP; dwFlags |= CREATE_DEFAULT_ERROR_MODE ; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index a29b0b75bd..4ceb1b076c 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -917,22 +917,9 @@ void wxWindowMSW::WarpPointer(int x, int y) void wxWindowMSW::MSWUpdateUIState(int action, int state) { - // WM_CHANGEUISTATE only appeared in Windows 2000 so it can do us no good - // to use it on older systems -- and could possibly do some harm - static int s_needToUpdate = -1; - if ( s_needToUpdate == -1 ) - { - int verMaj, verMin; - s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxOS_WINDOWS_NT && - verMaj >= 5; - } - - if ( s_needToUpdate ) - { - // we send WM_CHANGEUISTATE so if nothing needs changing then the system - // won't send WM_UPDATEUISTATE - ::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0); - } + // we send WM_CHANGEUISTATE so if nothing needs changing then the system + // won't send WM_UPDATEUISTATE + ::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0); } // --------------------------------------------------------------------------- diff --git a/src/osx/carbon/colordlgosx.mm b/src/osx/carbon/colordlgosx.mm index a818dde360..a22a2cc44b 100644 --- a/src/osx/carbon/colordlgosx.mm +++ b/src/osx/carbon/colordlgosx.mm @@ -41,7 +41,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog); // wxCPWCDelegate - Window Closed delegate // --------------------------------------------------------------------------- -@interface wxCPWCDelegate : NSObject wxOSX_10_6_AND_LATER() +@interface wxCPWCDelegate : NSObject { bool m_bIsClosed; } diff --git a/src/osx/carbon/utilscocoa.mm b/src/osx/carbon/utilscocoa.mm index 60c03445e0..489aeaba56 100644 --- a/src/osx/carbon/utilscocoa.mm +++ b/src/osx/carbon/utilscocoa.mm @@ -494,12 +494,7 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns double wxOSXGetMainScreenContentScaleFactor() { -#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) - if ( [ [NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)] ) - return [[NSScreen mainScreen] backingScaleFactor]; - else -#endif - return 1.0; + return [[NSScreen mainScreen] backingScaleFactor]; } CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr ) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index fbaec3fb74..0a4acd1190 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -24,7 +24,7 @@ // work in progress -@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER() +@interface wxNSTableDataSource : NSObject { wxNSComboBoxControl* impl; } diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index bdfa9c9be0..540358f757 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -52,33 +52,7 @@ // then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to // be implemented -namespace -{ - -bool HasAppKit_10_6() -{ - // Even if we require 10.6, we might be loaded by an application that - // was linked against 10.5. setAllowedFileTypes will still be ignored - // in this case. From NSSavePanel.h: - // NSOpenPanel: On versions less than 10.6, this property is ignored. - // For applications that link against 10.6 and higher, this property will - // determine which files should be enabled in the open panel. - int32_t version = NSVersionOfLinkTimeLibrary("AppKit"); - if (version == -1) - { - // If we're loaded by an application that doesn't link against AppKit, - // use the runtime version instead. This check will not work for the - // case above. - version = NSVersionOfRunTimeLibrary("AppKit"); - } - - // Notice that this still works correctly even if version is -1. - return version >= 0x40e2400 /* version of 10.6 AppKit */; -} - -} // anonymous namespace - -@interface wxOpenPanelDelegate : NSObject wxOSX_10_6_AND_LATER() +@interface wxOpenPanelDelegate : NSObject { wxFileDialog* _dialog; } diff --git a/src/osx/cocoa/listbox.mm b/src/osx/cocoa/listbox.mm index 0eb49dd569..7966d70223 100644 --- a/src/osx/cocoa/listbox.mm +++ b/src/osx/cocoa/listbox.mm @@ -30,7 +30,7 @@ class wxListWidgetCocoaImpl; -@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER() +@interface wxNSTableDataSource : NSObject { wxListWidgetCocoaImpl* impl; } @@ -50,7 +50,7 @@ class wxListWidgetCocoaImpl; @end -@interface wxNSTableView : NSTableView wxOSX_10_6_AND_LATER() +@interface wxNSTableView : NSTableView { } diff --git a/src/osx/cocoa/menu.mm b/src/osx/cocoa/menu.mm index 562efe75d4..eb52113acc 100644 --- a/src/osx/cocoa/menu.mm +++ b/src/osx/cocoa/menu.mm @@ -58,7 +58,7 @@ // and under 10.4, we are not getting a 'close' event however... #define wxOSX_USE_NEEDSUPDATE_HOOK 1 -@interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER() +@interface wxNSMenuController : NSObject { } diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index a13efdabbf..97186983b1 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -91,19 +91,11 @@ bool shouldHandleSelector(SEL selector) } - -#define wxHAS_FULL_SCREEN_API (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) - -#if wxHAS_FULL_SCREEN_API - static bool IsUsingFullScreenApi(WXWindow macWindow) { - return [macWindow respondsToSelector:@selector(toggleFullScreen:)] - && ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary); + return ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary); } -#endif - // // wx category for NSWindow (our own and wrapped instances) // @@ -313,7 +305,7 @@ static NSResponder* s_formerFirstResponder = NULL; // controller // -@interface wxNonOwnedWindowController : NSObject wxOSX_10_6_AND_LATER() +@interface wxNonOwnedWindowController : NSObject { } @@ -326,9 +318,7 @@ static NSResponder* s_formerFirstResponder = NULL; - (void)windowDidDeminiaturize:(NSNotification *)notification; - (BOOL)windowShouldClose:(id)window; - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; -#if wxHAS_FULL_SCREEN_API - (void)windowWillEnterFullScreen:(NSNotification *)notification; -#endif @end @@ -585,8 +575,6 @@ extern int wxOSXGetIdFromSelector(SEL action ); return true; } -#if wxHAS_FULL_SCREEN_API - // work around OS X bug, on a secondary monitor an already fully sized window // (eg maximized) will not be correctly put to full screen size and keeps a 22px // title band at the top free, therefore we force the correct content size @@ -607,8 +595,6 @@ extern int wxOSXGetIdFromSelector(SEL action ); } } -#endif - @end wxIMPLEMENT_DYNAMIC_CLASS(wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl); @@ -1000,44 +986,32 @@ typedef struct bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const { -#if wxHAS_FULL_SCREEN_API if ( IsUsingFullScreenApi(m_macWindow) ) { return [m_macWindow styleMask] & NSFullScreenWindowMask; } -#endif return m_macFullScreenData != NULL ; } bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable) { -#if wxHAS_FULL_SCREEN_API - if ( [ m_macWindow respondsToSelector:@selector(setCollectionBehavior:) ] ) + NSUInteger collectionBehavior = [m_macWindow collectionBehavior]; + if (enable) { - NSUInteger collectionBehavior = [m_macWindow collectionBehavior]; - if (enable) - { - collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; - } - else - { - collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; - } - [m_macWindow setCollectionBehavior: collectionBehavior]; - - return true; + collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; } -#else - wxUnusedVar(enable); -#endif + else + { + collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; + } + [m_macWindow setCollectionBehavior: collectionBehavior]; - return false; + return true; } bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style)) { -#if wxHAS_FULL_SCREEN_API if ( IsUsingFullScreenApi(m_macWindow) ) { if ( show != IsFullScreen() ) @@ -1047,7 +1021,6 @@ bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style)) return true; } -#endif if ( show ) { diff --git a/src/osx/cocoa/notebook.mm b/src/osx/cocoa/notebook.mm index 33b773b117..ead8978b54 100644 --- a/src/osx/cocoa/notebook.mm +++ b/src/osx/cocoa/notebook.mm @@ -29,7 +29,7 @@ // controller // -@interface wxTabViewController : NSObject wxOSX_10_6_AND_LATER() +@interface wxTabViewController : NSObject { } diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 22fc4e7681..cb12954e4b 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -827,7 +827,7 @@ wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer, void wxNSTextFieldControl::Init(WXWidget w) { - NSTextField wxOSX_10_6_AND_LATER() *tf = (NSTextField wxOSX_10_6_AND_LATER()*) w; + NSTextField *tf = (NSTextField *) w; m_textField = tf; [m_textField setDelegate: tf]; m_selStart = m_selEnd = 0; diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index 243b0c4d42..e5f918dbad 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -301,7 +301,7 @@ private: @end -@interface wxNSToolbarDelegate : NSObject wxOSX_10_6_AND_LATER() +@interface wxNSToolbarDelegate : NSObject { bool m_isSelectable; } diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 4f81cc473e..d3418d9433 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -412,7 +412,7 @@ bool wxApp::DoInitGui() } appcontroller = OSXCreateAppController(); - [[NSApplication sharedApplication] setDelegate:(id wxOSX_10_6_AND_LATER())appcontroller]; + [[NSApplication sharedApplication] setDelegate:(id )appcontroller]; [NSColor setIgnoresAlpha:NO]; // calling finishLaunching so early before running the loop seems to trigger some 'MenuManager compatibility' which leads @@ -618,4 +618,67 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const #endif // wxUSE_GUI +// 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 ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) + { + NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion; + + if ( majorVsn != NULL ) + *majorVsn = osVer.majorVersion; + + if ( minorVsn != NULL ) + *minorVsn = osVer.minorVersion; + } + else +#endif + { + // On OS X versions prior to 10.10 NSProcessInfo does not provide the OS version + SInt32 maj, min; + Gestalt(gestaltSystemVersionMajor, &maj); + Gestalt(gestaltSystemVersionMinor, &min); + + if ( majorVsn != NULL ) + *majorVsn = maj; + + if ( minorVsn != NULL ) + *minorVsn = min; + } + + return wxOS_MAC_OSX_DARWIN; +} + +bool wxCheckOsVersion(int majorVsn, int minorVsn) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 + if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)]) + { + NSOperatingSystemVersion osVer; + osVer.majorVersion = majorVsn; + osVer.minorVersion = minorVsn; + osVer.patchVersion = 0; + + return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:osVer] != NO; + } + else +#endif + { + int majorCur, minorCur; + wxGetOsVersion(&majorCur, &minorCur); + + return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn); + } +} + +wxString wxGetOsDescription() +{ + NSString* osDesc = [NSProcessInfo processInfo].operatingSystemVersionString; + wxCFStringRef cf(wxCFRetain(osDesc)); + + return wxString::Format(wxT("Mac OS X %s"), + cf.AsString()); +} + #endif // wxOSX_USE_COCOA diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 91e02ed9e5..e2ead70efe 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1755,9 +1755,7 @@ void wxOSXCocoaClassAddWXMethods(Class c) wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" ) -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@") -#endif wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" ) @@ -1870,13 +1868,8 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) double wxWidgetCocoaImpl::GetContentScaleFactor() const { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 NSWindow* tlw = [m_osxView window]; - if ( [ tlw respondsToSelector:@selector(backingScaleFactor) ] ) - return [tlw backingScaleFactor]; - else -#endif - return 1.0; + return [tlw backingScaleFactor]; } // ---------------------------------------------------------------------------- @@ -1884,7 +1877,7 @@ double wxWidgetCocoaImpl::GetContentScaleFactor() const // ---------------------------------------------------------------------------- // define a delegate used to refresh the window during animation -@interface wxNSAnimationDelegate : NSObject wxOSX_10_6_AND_LATER() +@interface wxNSAnimationDelegate : NSObject { wxWindow *m_win; bool m_isDone; diff --git a/src/osx/core/utilsexc_base.cpp b/src/osx/core/utilsexc_base.cpp index 22b9f43302..3f325b3683 100644 --- a/src/osx/core/utilsexc_base.cpp +++ b/src/osx/core/utilsexc_base.cpp @@ -53,7 +53,7 @@ extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF; wxSocketManager *wxOSXSocketManagerCF = NULL; #endif // wxUSE_SOCKETS -#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON +#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_CARBON // our OS version is the same in non GUI and GUI cases wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) @@ -70,16 +70,6 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) if ( minorVsn != NULL ) *minorVsn = min; -#if 0 - SInt32 theSystem; - Gestalt(gestaltSystemVersion, &theSystem); - - if ( majorVsn != NULL ) - *majorVsn = (theSystem >> 8); - - if ( minorVsn != NULL ) - *minorVsn = (theSystem & 0xFF); -#endif return wxOS_MAC_OSX_DARWIN; } @@ -95,6 +85,10 @@ wxString wxGetOsDescription() wxString::FromAscii(name.machine).c_str()); } +#endif // wxOSX_USE_CARBON + +#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON + //=========================================================================== // IMPLEMENTATION //=========================================================================== diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index f7e63d2856..2a403b1a4d 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1148,6 +1148,14 @@ wxString wxGetOsDescription() return wxGetCommandOutput(wxT("uname -s -r -m")); } +bool wxCheckOsVersion(int majorVsn, int minorVsn) +{ + int majorCur, minorCur; + wxGetOsVersion(&majorCur, &minorCur); + + return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn); +} + #endif // !__DARWIN__ unsigned long wxGetProcessId()