Use __builtin_available() when available in wxMac builds

The advantage of using this compiler builtin instead of our own platform
checks is that the compiler will warn us (if -Wunguarded-availability is
turned on for APIs introduced before 10.13 or by default for later ones)
if a check is forgotten, which is not the case for the manual checks.

Update the code to use WX_IS_MACOS_AVAILABLE() macro, which expands to
__builtin_available() when supported, and also use API_AVAILABLE() where
it makes sense to avoid having too many checks.
This commit is contained in:
Vadim Zeitlin 2019-04-17 23:35:08 +02:00
parent a8262abc11
commit fe311b9cc5
16 changed files with 174 additions and 63 deletions

View File

@ -148,13 +148,21 @@ public :
virtual bool SetupCursor(NSEvent* event);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
virtual void PanGestureEvent(NSPanGestureRecognizer *panGestureRecognizer);
virtual void ZoomGestureEvent(NSMagnificationGestureRecognizer *magnificationGestureRecognizer);
virtual void RotateGestureEvent(NSRotationGestureRecognizer *rotationGestureRecognizer);
virtual void LongPressEvent(NSPressGestureRecognizer *pressGestureRecognizer);
virtual void TouchesBegan(NSEvent *event);
virtual void TouchesMoved(NSEvent *event);
virtual void TouchesEnded(NSEvent *event);
#ifdef API_AVAILABLE
#define WX_AVAILABLE_10_10 API_AVAILABLE(macos(10.10))
#else
#define WX_AVAILABLE_10_10
#endif
WX_AVAILABLE_10_10 virtual void PanGestureEvent(NSPanGestureRecognizer *panGestureRecognizer);
WX_AVAILABLE_10_10 virtual void ZoomGestureEvent(NSMagnificationGestureRecognizer *magnificationGestureRecognizer);
WX_AVAILABLE_10_10 virtual void RotateGestureEvent(NSRotationGestureRecognizer *rotationGestureRecognizer);
WX_AVAILABLE_10_10 virtual void LongPressEvent(NSPressGestureRecognizer *pressGestureRecognizer);
WX_AVAILABLE_10_10 virtual void TouchesBegan(NSEvent *event);
WX_AVAILABLE_10_10 virtual void TouchesMoved(NSEvent *event);
WX_AVAILABLE_10_10 virtual void TouchesEnded(NSEvent *event);
#undef WX_AVAILABLE_10_10
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
#if !wxOSX_USE_NATIVE_FLIPPED

View File

@ -0,0 +1,34 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/osx/private/available.h
// Purpose: Helper for checking API availability under macOS.
// Author: Vadim Zeitlin
// Created: 2019-04-17
// Copyright: (c) 2019 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_OSX_PRIVATE_AVAILABLE_H_
#define _WX_OSX_PRIVATE_AVAILABLE_H_
// Xcode 9 adds new @available keyword and the corresponding __builtin_available
// builtin which should be used instead of manually checks for API availability
// as using this builtin suppresses the compiler -Wunguarded-availability
// warnings, so use it if possible for the implementation of our own macro.
#if defined(__clang__) && __has_builtin(__builtin_available)
#define WX_IS_MACOS_AVAILABLE(major, minor) \
__builtin_available(macOS major ## . ## minor, *)
// Note that we can't easily forward to API_AVAILABLE macro here, so go
// directly to its expansion instead.
#define WX_API_AVAILABLE_MACOS(major, minor) \
__attribute__((availability(macos,introduced=major ## . ## minor)))
#else // Not clang or old clang version without __builtin_available
#include "wx/platinfo.h"
#define WX_IS_MACOS_AVAILABLE(major, minor) \
wxPlatformInfo::Get().CheckOSVersion(major, minor)
#define WX_API_AVAILABLE_MACOS(major, minor)
#endif
#endif // _WX_OSX_PRIVATE_AVAILABLE_H_

View File

@ -33,6 +33,7 @@
#include "wx/splitter.h"
#include "wx/time.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#ifdef wxHAS_DRAW_TITLE_BAR_BITMAP
#include "wx/image.h"
@ -172,7 +173,7 @@ int wxRendererMac::DrawHeaderButton( wxWindow *win,
wxHeaderSortIconType sortArrow,
wxHeaderButtonParams* params )
{
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14) )
if ( WX_IS_MACOS_AVAILABLE(10, 14) )
{
if ( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW).Red() < 128 )
return wxRendererNative::GetGeneric().DrawHeaderButton(win, dc, rect, flags, sortArrow, params);
@ -339,7 +340,15 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
wxOrientation orient,
int WXUNUSED(flags) )
{
bool hasMetal = win->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL && !wxPlatformInfo::Get().CheckOSVersion(10, 14);
// Note that we can't use ternary ?: operator or any other construct with
// logical operators here, WX_IS_MACOS_AVAILABLE() must appear inside an
// "if" statement to avoid -Wunsupported-availability-guard with Xcode 10.
bool hasMetal;
if (WX_IS_MACOS_AVAILABLE(10, 14))
hasMetal = false;
else
hasMetal = win->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL;
SInt32 height;
height = wxRendererNative::Get().GetSplitterParams(win).widthSash;
@ -382,7 +391,13 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win,
if ( win->HasFlag(wxSP_3DSASH) )
{
if ( !wxPlatformInfo::Get().CheckOSVersion(10, 14) || wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW).Red() > 128 )
bool doDraw;
if ( WX_IS_MACOS_AVAILABLE(10, 14) )
doDraw = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW).Red() > 128;
else
doDraw = true;
if ( doDraw )
{
HIThemeSplitterDrawInfo drawInfo;
drawInfo.version = 0;

View File

@ -24,6 +24,7 @@
#endif
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
// Margin between the field text and the field rect
#define wxFIELD_TEXT_MARGIN 2
@ -75,33 +76,9 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
void wxStatusBarMac::InitColours()
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
if ( !wxPlatformInfo::Get().CheckOSVersion(10, 10) )
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
{
// 10.9 Mavericks and older:
m_textActive = wxColour(0x2F, 0x2F, 0x2F);
m_textInactive = wxColour(0x4D, 0x4D, 0x4D);
m_bgActiveFrom = wxColour(0xDA, 0xDA, 0xDA);
m_bgActiveTo = wxColour(0xA0, 0xA0, 0xA0);
m_borderActive = wxColour(0x6E, 0x6E, 0x6E);
m_borderInactive = wxColour(0xA3, 0xA3, 0xA3);
SetBackgroundColour(wxColour(0xE1, 0xE1, 0xE1)); // inactive bg
}
else
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 101000
{
if (!wxPlatformInfo::Get().CheckOSVersion(10, 14))
{
// 10.10 Yosemite to 10.13 :
m_textActive = wxColour(0x40, 0x40, 0x40);
m_textInactive = wxColour(0x4B, 0x4B, 0x4B);
m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA);
m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE);
m_borderActive = wxColour(0xBA, 0xB8, 0xBB);
m_borderInactive = wxColour(0xC3, 0xC3, 0xC3);
SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg
}
else
if ( WX_IS_MACOS_AVAILABLE(10, 14) )
{
// FIXME: None of this is correct and is only very loose
// approximation. 10.14's dark mode uses dynamic colors that
@ -129,7 +106,31 @@ void wxStatusBarMac::InitColours()
}
SetBackgroundColour(bg); // inactive bg
}
else
{
// 10.10 Yosemite to 10.13 :
m_textActive = wxColour(0x40, 0x40, 0x40);
m_textInactive = wxColour(0x4B, 0x4B, 0x4B);
m_bgActiveFrom = wxColour(0xE9, 0xE7, 0xEA);
m_bgActiveTo = wxColour(0xCD, 0xCB, 0xCE);
m_borderActive = wxColour(0xBA, 0xB8, 0xBB);
m_borderInactive = wxColour(0xC3, 0xC3, 0xC3);
SetBackgroundColour(wxColour(0xF4, 0xF4, 0xF4)); // inactive bg
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
else
{
// 10.9 Mavericks and older:
m_textActive = wxColour(0x2F, 0x2F, 0x2F);
m_textInactive = wxColour(0x4D, 0x4D, 0x4D);
m_bgActiveFrom = wxColour(0xDA, 0xDA, 0xDA);
m_bgActiveTo = wxColour(0xA0, 0xA0, 0xA0);
m_borderActive = wxColour(0x6E, 0x6E, 0x6E);
m_borderInactive = wxColour(0xA3, 0xA3, 0xA3);
SetBackgroundColour(wxColour(0xE1, 0xE1, 0xE1)); // inactive bg
}
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 101000
}
void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int textHeight)

View File

@ -23,6 +23,7 @@
#ifdef __WXMAC__
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#endif
#include "wx/fontutil.h"
@ -624,7 +625,7 @@ NSString* wxNSStringWithWxString(const wxString &wxstring)
wxOSXEffectiveAppearanceSetter::wxOSXEffectiveAppearanceSetter()
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
{
formerAppearance = NSAppearance.currentAppearance;
NSAppearance.currentAppearance = NSApp.effectiveAppearance;
@ -637,7 +638,7 @@ wxOSXEffectiveAppearanceSetter::wxOSXEffectiveAppearanceSetter()
wxOSXEffectiveAppearanceSetter::~wxOSXEffectiveAppearanceSetter()
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
NSAppearance.currentAppearance = (NSAppearance*) formerAppearance;
#endif
}

View File

@ -12,6 +12,7 @@
#include "wx/colour.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
class wxNSColorRefData : public wxColourRefData
{
@ -104,7 +105,7 @@ bool wxNSColorRefData::IsSolid() const
CGColorRef wxNSColorRefData::GetCGColor() const
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
if (wxPlatformInfo::Get().CheckOSVersion(10, 8)) {
if ( WX_IS_MACOS_AVAILABLE(10, 8) ) {
wxOSXEffectiveAppearanceSetter helper;
return [m_nsColour CGColor];
}

View File

@ -25,6 +25,7 @@
#endif
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#include "wx/osx/cocoa/dataview.h"
#include "wx/renderer.h"
#include "wx/stopwatch.h"
@ -2956,14 +2957,14 @@ bool wxDataViewTextRenderer::MacRender()
// Tightening looks very ugly when combined with non-tightened rows,
// so disabled it on OS X version where it's used:
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_11)
if ( WX_IS_MACOS_AVAILABLE(10, 11) )
{
[par setAllowsDefaultTighteningForTruncation:NO];
}
else
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_10)
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
{
[par setTighteningFactorForTruncation:0.0];
}

View File

@ -31,6 +31,7 @@
#include "wx/mediactrl.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#if wxOSX_USE_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 && defined(__LP64__)
#define wxOSX_USE_AVKIT 1
@ -276,6 +277,7 @@ private:
#if wxOSX_USE_AVKIT
WX_API_AVAILABLE_MACOS(10, 10)
@interface wxAVPlayerView : AVPlayerView
{
}
@ -395,7 +397,7 @@ bool wxAVMediaBackend::CreateControl(wxControl* inctrl, wxWindow* parent,
WXWidget view = NULL;
#if wxOSX_USE_AVKIT
if ( NSClassFromString(@"AVPlayerView") )
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
{
view = [[wxAVPlayerView alloc] initWithFrame: r player:m_player];
[(wxAVPlayerView*) view setControlsStyle:AVPlayerViewControlsStyleNone];
@ -563,14 +565,17 @@ bool wxAVMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
void wxAVMediaBackend::DoShowPlayerControls(wxMediaCtrlPlayerControls flags)
{
#if wxOSX_USE_AVKIT
NSView* view = m_ctrl->GetHandle();
if ( [view isKindOfClass:[wxAVPlayerView class]] )
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
{
wxAVPlayerView* playerView = (wxAVPlayerView*) view;
if (flags == wxMEDIACTRLPLAYERCONTROLS_NONE )
playerView.controlsStyle = AVPlayerViewControlsStyleNone;
else
playerView.controlsStyle = AVPlayerViewControlsStyleDefault;
NSView* view = m_ctrl->GetHandle();
if ( [view isKindOfClass:[wxAVPlayerView class]] )
{
wxAVPlayerView* playerView = (wxAVPlayerView*) view;
if (flags == wxMEDIACTRLPLAYERCONTROLS_NONE )
playerView.controlsStyle = AVPlayerViewControlsStyleNone;
else
playerView.controlsStyle = AVPlayerViewControlsStyleDefault;
}
}
#endif
}

View File

@ -31,6 +31,7 @@
#endif // WX_PRECOMP
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#include "wx/generic/notifmsg.h"
#include "wx/private/notifmsg.h"
#include "wx/generic/private/notifmsg.h"
@ -43,6 +44,7 @@
#include "wx/utils.h"
#include <map>
WX_API_AVAILABLE_MACOS(10, 8)
@interface wxUserNotificationHandler : NSObject <NSUserNotificationCenterDelegate>
@end
@ -51,7 +53,7 @@
// wxUserNotificationMsgImpl
// ----------------------------------------------------------------------------
class wxUserNotificationMsgImpl : public wxNotificationMessageImpl
class WX_API_AVAILABLE_MACOS(10, 8) wxUserNotificationMsgImpl : public wxNotificationMessageImpl
{
public:
wxUserNotificationMsgImpl(wxNotificationMessageBase* notification) :
@ -121,7 +123,7 @@ public:
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
// Additional icon in the notification is only supported on OS X 10.9+
if ([NSUserNotification instancesRespondToSelector:@selector(setContentImage:)])
if ( WX_IS_MACOS_AVAILABLE(10, 9) )
m_notif.contentImage = icon.GetNSImage();
#endif
}
@ -247,7 +249,7 @@ void wxNotificationMessage::Init()
{
// Native notifications are not available prior to 10.8, fallback
// to generic ones on 10.7
if (wxPlatformInfo::Get().CheckOSVersion(10, 8))
if ( WX_IS_MACOS_AVAILABLE(10, 8) )
m_impl = new wxUserNotificationMsgImpl(this);
else
m_impl = new wxGenericNotificationMessageImpl(this);

View File

@ -15,8 +15,8 @@
#include "wx/power.h"
#include "wx/atomic.h"
#include "wx/platinfo.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#include <IOKit/pwr_mgt/IOPMLib.h>
@ -38,7 +38,7 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason)
cfreason = wxString("User Activity");
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
if ( WX_IS_MACOS_AVAILABLE(10, 9) )
{
// Use NSProcessInfo for 10.9 and newer
if ( !g_processInfoActivity )
@ -83,7 +83,7 @@ bool UpdatePowerResourceUsage(wxPowerResourceKind kind, const wxString& reason)
{
// Release power assertion
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
if ( WX_IS_MACOS_AVAILABLE(10, 9) )
{
// Use NSProcessInfo for 10.9 and newer
if ( g_processInfoActivity )

View File

@ -19,6 +19,7 @@
#include "wx/osx/core/private.h"
#include "wx/osx/cocoa/private.h"
#include "wx/osx/private/available.h"
#import <AppKit/NSColor.h>
#import <Foundation/Foundation.h>
@ -79,7 +80,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
sysColor = [NSColor controlBackgroundColor];
break;
case wxSYS_COLOUR_BTNFACE:
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
sysColor = [NSColor windowBackgroundColor];
else
sysColor = [NSColor controlColor];

View File

@ -19,6 +19,7 @@
#include "wx/toolbar.h"
#include "wx/app.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#include "wx/geometry.h"
#include "wx/sysopt.h"
@ -1674,8 +1675,14 @@ void wxToolBar::OnPaint(wxPaintEvent& event)
wxRect rect(0,0,w,h);
// TODO determine whether to use flat appearance in earlier system
if ( !wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
{
// No gradient.
}
else
{
dc.GradientFillLinear( rect , wxColour( 0xCC,0xCC,0xCC ), wxColour( 0xA8,0xA8,0xA8 ) , wxSOUTH );
}
dc.SetPen( wxPen( wxColour( 0x51,0x51,0x51 ) ) );
if ( HasFlag(wxTB_LEFT) )

View File

@ -26,6 +26,7 @@
#include "wx/apptrait.h"
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#if wxUSE_GUI
#if wxOSX_USE_COCOA_OR_CARBON
@ -349,7 +350,7 @@ void wxBell()
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
if ( wxPlatformInfo::Get().CheckOSVersion(10, 9) )
if ( WX_IS_MACOS_AVAILABLE(10, 9) )
{
[[NSRunningApplication currentApplication] activateWithOptions:
(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)];

View File

@ -32,6 +32,13 @@
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
{
#ifdef wxHAS_NSPROCESSINFO
// Note: we don't use WX_IS_MACOS_AVAILABLE() here because these properties
// are only officially supported since 10.10, but are actually available
// under 10.9 too, so we prefer to check for them explicitly and suppress
// the warnings that using without a __builtin_available() check around
// them generates.
wxCLANG_WARNING_SUPPRESS(unguarded-availability)
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
{
NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion;
@ -45,6 +52,9 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro)
if ( verMicro != NULL )
*verMicro = osVer.patchVersion;
}
wxCLANG_WARNING_RESTORE(unguarded-availability)
else
#endif
{
@ -79,6 +89,10 @@ wxGCC_WARNING_RESTORE()
bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn)
{
#ifdef wxHAS_NSPROCESSINFO
// As above, this API is effectively available earlier than its
// availability attribute indicates, so check for it manually.
wxCLANG_WARNING_SUPPRESS(unguarded-availability)
if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)])
{
NSOperatingSystemVersion osVer;
@ -88,6 +102,9 @@ bool wxCheckOsVersion(int majorVsn, int minorVsn, int microVsn)
return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:osVer] != NO;
}
wxCLANG_WARNING_RESTORE(unguarded-availability)
else
#endif
{

View File

@ -21,6 +21,7 @@
#ifdef __WXMAC__
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
#endif
#include "wx/evtloop.h"
@ -1092,6 +1093,7 @@ void wxOSX_insertText(NSView* self, SEL _cmd, NSString* text)
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_panGestureEvent(NSView* self, SEL _cmd, NSPanGestureRecognizer* panGestureRecognizer)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1101,6 +1103,7 @@ void wxOSX_panGestureEvent(NSView* self, SEL _cmd, NSPanGestureRecognizer* panGe
impl->PanGestureEvent(panGestureRecognizer);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_zoomGestureEvent(NSView* self, SEL _cmd, NSMagnificationGestureRecognizer* magnificationGestureRecognizer)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1110,6 +1113,7 @@ void wxOSX_zoomGestureEvent(NSView* self, SEL _cmd, NSMagnificationGestureRecogn
impl->ZoomGestureEvent(magnificationGestureRecognizer);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_rotateGestureEvent(NSView* self, SEL _cmd, NSRotationGestureRecognizer* rotationGestureRecognizer)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1119,6 +1123,7 @@ void wxOSX_rotateGestureEvent(NSView* self, SEL _cmd, NSRotationGestureRecognize
impl->RotateGestureEvent(rotationGestureRecognizer);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_longPressEvent(NSView* self, SEL _cmd, NSPressGestureRecognizer* pressGestureRecognizer)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1128,6 +1133,7 @@ void wxOSX_longPressEvent(NSView* self, SEL _cmd, NSPressGestureRecognizer* pres
impl->LongPressEvent(pressGestureRecognizer);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_touchesBegan(NSView* self, SEL _cmd, NSEvent *event)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1137,6 +1143,7 @@ void wxOSX_touchesBegan(NSView* self, SEL _cmd, NSEvent *event)
impl->TouchesBegan(event);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_touchesMoved(NSView* self, SEL _cmd, NSEvent *event)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1146,6 +1153,7 @@ void wxOSX_touchesMoved(NSView* self, SEL _cmd, NSEvent *event)
impl->TouchesMoved(event);
}
WX_API_AVAILABLE_MACOS(10, 10)
void wxOSX_touchesEnded(NSView* self, SEL _cmd, NSEvent *event)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@ -1545,7 +1553,7 @@ void wxWidgetCocoaImpl::keyEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
// Class containing data used for gestures support.
class wxCocoaGesturesImpl
class WX_API_AVAILABLE_MACOS(10, 10) wxCocoaGesturesImpl
{
public:
wxCocoaGesturesImpl(wxWidgetCocoaImpl* impl, NSView* view, int eventsMask)
@ -1669,6 +1677,12 @@ private:
// itself because most windows don't need it and it seems wasteful to
// always increase their size unnecessarily.
// wxCocoaGesturesImpl is only used under 10.10+ and so clang warns about
// wxCocoaGesturesImplMap not having 10.10 availability attribute, but there is
// no simple way to make it pass through the macro, so just suppress the
// warning instead.
wxCLANG_WARNING_SUPPRESS(unguarded-availability)
#include "wx/hashmap.h"
WX_DECLARE_HASH_MAP(wxWidgetCocoaImpl*, wxCocoaGesturesImpl*,
wxPointerHash, wxPointerEqual,
@ -1679,6 +1693,8 @@ typedef wxExternalField<wxWidgetCocoaImpl,
wxCocoaGesturesImpl,
wxCocoaGesturesImplMap> wxCocoaGestures;
wxCLANG_WARNING_RESTORE(unguarded-availability)
void wxWidgetCocoaImpl::PanGestureEvent(NSPanGestureRecognizer* panGestureRecognizer)
{
NSGestureRecognizerState gestureState;
@ -2578,7 +2594,7 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible )
// trigger redraw upon shown for layer-backed views
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
if( !m_osxView.isHiddenOrHasHiddenAncestor )
SetNeedsDisplay(NULL);
#endif
@ -3056,7 +3072,7 @@ void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where )
// their children implicitly redrawn with the parent. For compatibility,
// do it manually here:
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) )
if ( WX_IS_MACOS_AVAILABLE(10, 14 ) )
SetSubviewsNeedDisplay(m_osxView);
#endif
}
@ -3525,7 +3541,7 @@ void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
bool wxWidgetCocoaImpl::EnableTouchEvents(int eventsMask)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
if ( wxPlatformInfo::Get().CheckOSVersion(10, 10) )
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
{
if ( HasUserMouseHandling() )
{

View File

@ -17,6 +17,7 @@
#endif
#include "wx/osx/private.h"
#include "wx/osx/private/available.h"
CGColorSpaceRef wxMacGetGenericRGBColorSpace();
@ -118,7 +119,7 @@ wxCGColorRefData::wxCGColorRefData(CGColorRef col)
else if (model != kCGColorSpaceModelRGB)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_11
if (wxPlatformInfo::Get().CheckOSVersion(10, 11))
if ( WX_IS_MACOS_AVAILABLE(10, 11) )
{
rgbacol = CGColorCreateCopyByMatchingToColorSpace(wxMacGetGenericRGBColorSpace(), kCGRenderingIntentDefault, col, NULL);
noComp = CGColorGetNumberOfComponents(rgbacol);