From a29e6922cfdf416cc102427678222e7d1d5bc798 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 21 Aug 2016 20:58:56 +0200 Subject: [PATCH] Implement wxGraphicsContext::GetClipBox for Core Graphics --- src/osx/carbon/graphics.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 9919a47a31..fde09c1a47 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -1355,6 +1355,9 @@ public: // resets the clipping to original extent virtual void ResetClip() wxOVERRIDE; + // returns bounding box of the clipping region + virtual void GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) wxOVERRIDE; + virtual void * GetNativeContext() wxOVERRIDE; virtual bool SetAntialiasMode(wxAntialiasMode antialias) wxOVERRIDE; @@ -1964,6 +1967,38 @@ void wxMacCoreGraphicsContext::ResetClip() CheckInvariants(); } +void wxMacCoreGraphicsContext::GetClipBox(wxDouble* x, wxDouble* y, wxDouble* w, wxDouble* h) +{ + // This function is not yet tested. + // TODO: Do the tests. + CGRect r; + + if ( m_cgContext ) + { + r = CGContextGetClipBoundingBox(m_cgContext); + } + else + { +#if wxOSX_USE_COCOA_OR_CARBON + HIShapeGetBounds(m_clipRgn, &r); +#else + r = CGRectMake(0, 0, 0, 0); + // allow usage as measuring context + // wxFAIL_MSG( "Needs a valid context for clipping" ); +#endif + } + CheckInvariants(); + + if ( x ) + *x = r.origin.x; + if ( y ) + *y = r.origin.y; + if ( w ) + *w = r.size.width; + if ( h ) + *h = r.size.height; +} + void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath &path ) { if ( m_pen.IsNull() )