X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/85baeafb621ac8b20d96db8f6287f4d0afe7e3c6..6cef0db28018fd2644ee4e38af715872e5242459:/src/mac/carbon/region.cpp diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index 3ee709f722..d08fd4984c 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -29,22 +29,22 @@ class WXDLLEXPORT wxRegionRefData : public wxGDIRefData { public: wxRegionRefData() - { - m_macRgn.reset( HIShapeCreateMutable() ); + { + m_macRgn.reset( HIShapeCreateMutable() ); } - wxRegionRefData(HIShapeRef hRegion) - { - m_macRgn.reset( HIShapeCreateMutableCopy(hRegion) ); + wxRegionRefData(wxCFRef ®ion) + { + m_macRgn.reset( HIShapeCreateMutableCopy(region) ); } - + wxRegionRefData(long x, long y, long w, long h) { CGRect r = CGRectMake(x,y,w,h); wxCFRef rect(HIShapeCreateWithRect(&r)); - m_macRgn.reset( HIShapeCreateMutableCopy(rect) ); + m_macRgn.reset( HIShapeCreateMutableCopy(rect) ); } - + wxRegionRefData(const wxRegionRefData& data) : wxGDIRefData() { @@ -52,7 +52,7 @@ public: } virtual ~wxRegionRefData() - { + { } wxCFRef m_macRgn; @@ -75,7 +75,8 @@ wxRegion::wxRegion() wxRegion::wxRegion(WXHRGN hRegion ) { - m_refData = new wxRegionRefData(hRegion); + wxCFRef< HIShapeRef > shape( (HIShapeRef) hRegion ); + m_refData = new wxRegionRefData(shape); } wxRegion::wxRegion(long x, long y, long w, long h) @@ -85,8 +86,8 @@ wxRegion::wxRegion(long x, long y, long w, long h) wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight) { - m_refData = new wxRegionRefData(topLeft.x , topLeft.y , - topLeft.x - bottomRight.x , + m_refData = new wxRegionRefData(topLeft.x , topLeft.y , + topLeft.x - bottomRight.x , topLeft.y - bottomRight.y); } @@ -97,9 +98,11 @@ wxRegion::wxRegion(const wxRect& rect) wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) { - m_refData = new wxRegionRefData; + wxUnusedVar(n); + wxUnusedVar(points); + +#ifndef __LP64__ -#if 0 // ndef __LP64__ // TODO : any APIs ? // OS X somehow does not collect the region invisibly as before, so sometimes things // get drawn on screen instead of just being combined into a region, therefore we allocate a temp gworld now @@ -134,10 +137,21 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) if ( x1 != x2 || y1 != y2 ) ::LineTo( x1, y1 ) ; - CloseRgn( M_REGION ) ; - + RgnHandle tempRgn = NewRgn(); + CloseRgn( tempRgn ) ; + ::SetGWorld( oldWorld, oldGDHandle ); + wxCFRef tempShape( HIShapeCreateWithQDRgn(tempRgn ) ); + m_refData = new wxRegionRefData(tempShape); + DisposeRgn( tempRgn ); + } + else + { + m_refData = new wxRegionRefData; } +#else + wxFAIL_MSG( "not implemented" ); + m_refData = NULL; #endif } @@ -146,6 +160,16 @@ wxRegion::~wxRegion() // m_refData unrefed in ~wxObject } +wxGDIRefData *wxRegion::CreateGDIRefData() const +{ + return new wxRegionRefData; +} + +wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const +{ + return new wxRegionRefData(*wx_static_cast(const wxRegionRefData *, data)); +} + //----------------------------------------------------------------------------- //# Modify region //----------------------------------------------------------------------------- @@ -238,10 +262,10 @@ bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const { CGRect box ; HIShapeGetBounds( M_REGION , &box ) ; - x = box.origin.x ; - y = box.origin.y ; - w = box.size.width ; - h = box.size.height ; + x = wx_static_cast(int, box.origin.x); + y = wx_static_cast(int, box.origin.y); + w = wx_static_cast(int, box.size.width); + h = wx_static_cast(int, box.size.height); return true; } @@ -295,7 +319,7 @@ wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const wxCFRef intersect(HIShapeCreateIntersection(rectshape,M_REGION)); CGRect bounds; HIShapeGetBounds(intersect, &bounds); - + if ( HIShapeIsRectangular(intersect) && CGRectEqualToRect(rect,bounds) ) return wxInRegion; else if ( HIShapeIsEmpty( intersect ) ) @@ -440,14 +464,14 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 1; m_rects = new wxRect[m_numRects]; m_rects[0] = m_region.GetBox(); - + #else RegionToRectsUPP proc = (RegionToRectsUPP) wxMacRegionToRectsCounterCallback; OSStatus err = noErr; RgnHandle rgn = NewRgn(); HIShapeGetAsQDRgn(OTHER_M_REGION(region), rgn); - + err = QDRegionToRects (rgn, kQDParseRegionFromTopLeft, proc, (void*)&m_numRects); if (err == noErr) {