X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1abfa172c547a37751e598084fb8d541071471a3..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/src/mac/carbon/region.cpp?ds=sidebyside diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index 3a4fea178e..20d5d46b7d 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) ); + { + m_macRgn.reset( HIShapeCreateMutableCopy(hRegion) ); } - + 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; @@ -85,8 +85,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 +97,12 @@ wxRegion::wxRegion(const wxRect& rect) wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) { + wxUnusedVar(n); + wxUnusedVar(points); + +#if 0 // ndef __LP64__ m_refData = new wxRegionRefData; -#ifndef __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 @@ -138,6 +141,9 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) ::SetGWorld( oldWorld, oldGDHandle ); } +#else + wxFAIL_MSG( "not implemented" ); + m_refData = NULL; #endif } @@ -165,7 +171,7 @@ bool wxRegion::DoOffset(wxCoord x, wxCoord y) // nothing to do return true; - HIShapeOffset( M_REGION , x , y ) ; + verify_noerr( HIShapeOffset( M_REGION , x , y ) ) ; return true ; } @@ -191,11 +197,11 @@ bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op) switch (op) { case wxRGN_AND: - HIShapeIntersect( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; + verify_noerr( HIShapeIntersect( M_REGION , OTHER_M_REGION(region) , M_REGION ) ); break ; case wxRGN_OR: - HIShapeUnion( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; + verify_noerr( HIShapeUnion( M_REGION , OTHER_M_REGION(region) , M_REGION ) ); break ; case wxRGN_XOR: @@ -203,12 +209,12 @@ bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op) // XOR is defined as the difference between union and intersection wxCFRef< HIShapeRef > unionshape( HIShapeCreateUnion( M_REGION , OTHER_M_REGION(region) ) ); wxCFRef< HIShapeRef > intersectionshape( HIShapeCreateIntersection( M_REGION , OTHER_M_REGION(region) ) ); - HIShapeDifference( unionshape, intersectionshape, M_REGION ); + verify_noerr( HIShapeDifference( unionshape, intersectionshape, M_REGION ) ); } break ; case wxRGN_DIFF: - HIShapeDifference( M_REGION , OTHER_M_REGION(region) , M_REGION ) ; + verify_noerr( HIShapeDifference( M_REGION , OTHER_M_REGION(region) , M_REGION ) ) ; break ; case wxRGN_COPY: @@ -238,10 +244,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,11 +301,13 @@ 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 + else if ( HIShapeIsEmpty( intersect ) ) return wxOutRegion; + else + return wxPartRegion; } /////////////////////////////////////////////////////////////////////////////// @@ -438,14 +446,15 @@ 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 = NewHandle(); - - err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects); + RgnHandle rgn = NewRgn(); + HIShapeGetAsQDRgn(OTHER_M_REGION(region), rgn); + + err = QDRegionToRects (rgn, kQDParseRegionFromTopLeft, proc, (void*)&m_numRects); if (err == noErr) { proc = (RegionToRectsUPP) wxMacRegionToRectsSetterCallback; @@ -453,12 +462,13 @@ void wxRegionIterator::Reset(const wxRegion& region) RegionToRectsCallbackData data ; data.m_rects = m_rects ; data.m_current = 0 ; - QDRegionToRects( OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&data ); + QDRegionToRects( rgn , kQDParseRegionFromTopLeft, proc, (void*)&data ); } else { m_numRects = 0; } + DisposeRgn( rgn ); #endif } }