X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/81f94bb54ef82056e0170b23af4b2595f3503aa3..47e175a24f862aa8b7ca7dd4a2bb5957991e7f2d:/src/osx/carbon/region.cpp diff --git a/src/osx/carbon/region.cpp b/src/osx/carbon/region.cpp index f19be2230c..28e78cf999 100644 --- a/src/osx/carbon/region.cpp +++ b/src/osx/carbon/region.cpp @@ -169,6 +169,21 @@ bool wxRegion::DoOffset(wxCoord x, wxCoord y) return true ; } +bool wxRegion::DoUnionWithRect(const wxRect& rect) +{ + if ( !m_refData ) + { + m_refData = new wxRegionRefData(rect.x , rect.y , rect.width , rect.height); + return true; + } + + AllocExclusive(); + + CGRect r = CGRectMake(rect.x , rect.y , rect.width , rect.height); + HIShapeUnionWithRect(M_REGION , &r); + + return true; +} //! Union /e region with this. bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op) @@ -406,40 +421,6 @@ public : long m_current ; }; -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - -OSStatus wxMacRegionToRectsCounterCallback( - UInt16 message, RgnHandle WXUNUSED(region), const Rect *WXUNUSED(rect), void *data ) -{ - long *m_numRects = (long*) data ; - if ( message == kQDRegionToRectsMsgInit ) - { - (*m_numRects) = 0 ; - } - else if (message == kQDRegionToRectsMsgParse) - { - (*m_numRects) += 1 ; - } - - return noErr; -} - -OSStatus wxMacRegionToRectsSetterCallback( - UInt16 message, RgnHandle WXUNUSED(region), const Rect *rect, void *data ) -{ - if (message == kQDRegionToRectsMsgParse) - { - RegionToRectsCallbackData *cb = (RegionToRectsCallbackData*) data ; - cb->m_rects[cb->m_current++] = wxRect( rect->left , rect->top , rect->right - rect->left , rect->bottom - rect->top ) ; - } - - return noErr; -} - -#endif - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - OSStatus wxOSXRegionToRectsCounterCallback( int message, HIShapeRef WXUNUSED(region), const CGRect *WXUNUSED(rect), void *data ) { @@ -468,8 +449,6 @@ OSStatus wxOSXRegionToRectsSetterCallback( return noErr; } -#endif - void wxRegionIterator::Reset(const wxRegion& region) { m_current = 0; @@ -490,51 +469,20 @@ void wxRegionIterator::Reset(const wxRegion& region) m_rects = new wxRect[m_numRects]; m_rects[0] = m_region.GetBox(); #endif - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if ( HIShapeEnumerate != NULL ) + OSStatus err = HIShapeEnumerate (OTHER_M_REGION(region), kHIShapeParseFromTopLeft, wxOSXRegionToRectsCounterCallback, + (void*)&m_numRects); + if (err == noErr) { - OSStatus err = HIShapeEnumerate (OTHER_M_REGION(region), kHIShapeParseFromTopLeft, wxOSXRegionToRectsCounterCallback, - (void*)&m_numRects); - if (err == noErr) - { - m_rects = new wxRect[m_numRects]; - RegionToRectsCallbackData data ; - data.m_rects = m_rects ; - data.m_current = 0 ; - HIShapeEnumerate( OTHER_M_REGION(region), kHIShapeParseFromTopLeft, wxOSXRegionToRectsSetterCallback, - (void*)&data ); - } - else - { - m_numRects = 0; - } + m_rects = new wxRect[m_numRects]; + RegionToRectsCallbackData data ; + data.m_rects = m_rects ; + data.m_current = 0 ; + HIShapeEnumerate( OTHER_M_REGION(region), kHIShapeParseFromTopLeft, wxOSXRegionToRectsSetterCallback, + (void*)&data ); } else -#endif { -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 - OSStatus err = noErr; - RgnHandle rgn = NewRgn(); - HIShapeGetAsQDRgn(OTHER_M_REGION(region), rgn); - - err = QDRegionToRects (rgn, kQDParseRegionFromTopLeft, wxMacRegionToRectsCounterCallback - , (void*)&m_numRects); - if (err == noErr) - { - m_rects = new wxRect[m_numRects]; - RegionToRectsCallbackData data ; - data.m_rects = m_rects ; - data.m_current = 0 ; - QDRegionToRects( rgn , kQDParseRegionFromTopLeft, wxMacRegionToRectsSetterCallback, - (void*)&data ); - } - else - { - m_numRects = 0; - } - DisposeRgn( rgn ); -#endif + m_numRects = 0; } } }