From a1682a45684d48806eb3896fdf481a8f409f8725 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 9 Aug 2016 20:53:13 +0200 Subject: [PATCH] Revert to the legacy implementation of setting clipping region given in device coordinates for WXOSX Solution with full conversion from device to logical coordinates in wxGCDCImpl::DoSetDeviceClippingRegion doesn't seem to work under WXOSX (wxMacCoreGraphics) so we have to use for this port legacy implementation without full conversion of coordinates. Only offset of the origin is taken into account in this case (but not e.g. scale) but this should be enough for simple cases. Closes #17609 --- src/common/dcgraph.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index e9519b4a80..546033894c 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -303,6 +303,19 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion ) // region is in device coordinates wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") ); +#ifdef __WXOSX__ + // This is a legacy implementation without + // full conversion from device to logical coordinates + // (only offset of the origin is taken into account, + // but e.g. scale is not). + // Solution with full conversion doesn't seem to work under WXOSX. + // TODO: check wxMacCoreGraphics + wxRegion logRegion(region); + + logRegion.Offset(DeviceToLogicalX(0), DeviceToLogicalY(0)); + m_graphicContext->Clip(logRegion); + wxRect newRegion = logRegion.GetBox(); +#else // Because graphics context works with logical coordinates // and clipping region is given in device coordinates // we need temporarily reset graphics context's coordinate system @@ -331,6 +344,7 @@ void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion ) DeviceToLogicalYRel(newRegion.GetHeight())); newRegion.SetPosition(logPos); newRegion.SetSize(logSize); +#endif // __WXOSX__ / !__WXOSX__ wxRect clipRegion; if ( m_clipping )