X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3a44e057b5183acdf2cf133f059cf94c7884738..4ff9366dc1332abc371902059b71ea7d59aa2055:/src/mac/carbon/region.cpp diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index a123e2a647..b8147e5db8 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -12,7 +12,10 @@ #include "wx/region.h" -#include "wx/gdicmn.h" +#ifndef WX_PRECOMP + #include "wx/gdicmn.h" +#endif + #include "wx/mac/uma.h" IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) @@ -35,7 +38,7 @@ public: CopyRgn( data.m_macRgn , m_macRgn ); } - ~wxRegionRefData() + virtual ~wxRegionRefData() { DisposeRgn( m_macRgn ); } RgnHandle m_macRgn; @@ -84,6 +87,8 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) { 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 @@ -121,6 +126,7 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) ::SetGWorld( oldWorld, oldGDHandle ); } +#endif } wxRegion::~wxRegion() @@ -139,7 +145,7 @@ void wxRegion::Clear() } // Move the region -bool wxRegion::Offset(wxCoord x, wxCoord y) +bool wxRegion::DoOffset(wxCoord x, wxCoord y) { wxCHECK_MSG( M_REGION, false, _T("invalid wxRegion") ); @@ -153,58 +159,10 @@ bool wxRegion::Offset(wxCoord x, wxCoord y) } -//! Combine rectangle (x, y, w, h) with this. -bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) -{ - // Don't change shared data - if (!m_refData) - { - m_refData = new wxRegionRefData(); - } - else if (m_refData->GetRefCount() > 1) - { - wxRegionRefData* ref = (wxRegionRefData*)m_refData; - UnRef(); - m_refData = new wxRegionRefData( *ref ); - } - - RgnHandle rgn = NewRgn() ; - SetRectRgn( rgn , x , y, x + width, y + height ) ; - - switch (op) - { - case wxRGN_AND: - SectRgn( M_REGION , rgn , M_REGION ) ; - break ; - - case wxRGN_OR: - UnionRgn( M_REGION , rgn , M_REGION ) ; - break ; - - case wxRGN_XOR: - XorRgn( M_REGION , rgn , M_REGION ) ; - break ; - - case wxRGN_DIFF: - DiffRgn( M_REGION , rgn , M_REGION ) ; - break ; - - case wxRGN_COPY: - default: - CopyRgn( rgn , M_REGION ) ; - break ; - } - - DisposeRgn( rgn ) ; - - return true; -} - //! Union /e region with this. -bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) +bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op) { - if (region.Empty()) - return false; + wxCHECK_MSG( region.Ok(), false, _T("invalid wxRegion") ); // Don't change shared data if (!m_refData) @@ -245,17 +203,19 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) return true; } -bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) -{ - return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op); -} - //----------------------------------------------------------------------------- //# Information on region //----------------------------------------------------------------------------- +bool wxRegion::DoIsEqual(const wxRegion& region) const +{ + wxFAIL_MSG( _T("not implemented") ); + + return false; +} + // Outer bounds of region -void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const +bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const { if (m_refData) { @@ -265,23 +225,19 @@ void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const y = box.top ; w = box.right - box.left ; h = box.bottom - box.top ; + + return true; } else { x = y = w = h = 0; - } -} - -wxRect wxRegion::GetBox() const -{ - wxCoord x, y, w, h; - GetBox(x, y, w, h); - return wxRect(x, y, w, h); + return false; + } } // Is region empty? -bool wxRegion::Empty() const +bool wxRegion::IsEmpty() const { if ( m_refData ) return EmptyRgn( M_REGION ) ; @@ -298,26 +254,13 @@ const WXHRGN wxRegion::GetWXHRGN() const //# Tests //----------------------------------------------------------------------------- -// Does the region contain the point (x,y)? -wxRegionContain wxRegion::Contains(long x, long y) const -{ - if (!m_refData) - return wxOutRegion; - - // TODO. Return wxInRegion if within region. -// if (0) -// return wxInRegion; - - return wxOutRegion; -} - // Does the region contain the point? -wxRegionContain wxRegion::Contains(const wxPoint& pt) const +wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const { if (!m_refData) return wxOutRegion; - Point p = { pt.y , pt.x } ; + Point p = { y , x } ; if (PtInRgn( p , M_REGION ) ) return wxInRegion; @@ -325,34 +268,18 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const } // Does the region contain the rectangle (x, y, w, h)? -wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const +wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const { if (!m_refData) return wxOutRegion; - Rect rect = { y , x , y + h , x + w } ; + Rect rect = { r.y , r.x , r.y + r.height , r.x + r.width } ; if (RectInRgn( &rect , M_REGION ) ) return wxInRegion; else return wxOutRegion; } -// Does the region contain the rectangle rect -wxRegionContain wxRegion::Contains(const wxRect& rect) const -{ - if (!m_refData) - return wxOutRegion; - - long x, y, w, h; - - x = rect.x; - y = rect.y; - w = rect.GetWidth(); - h = rect.GetHeight(); - - return Contains(x, y, w, h); -} - /////////////////////////////////////////////////////////////////////////////// // // // wxRegionIterator // @@ -476,20 +403,32 @@ void wxRegionIterator::Reset(const wxRegion& region) m_rects = NULL; } - if (m_region.Empty()) + if (m_region.IsEmpty()) { m_numRects = 0; } else { - RegionToRectsUPP proc = NewRegionToRectsUPP( wxMacRegionToRectsCounterCallback ); + RegionToRectsUPP proc = +#ifdef __MACH__ + (RegionToRectsUPP) wxMacRegionToRectsCounterCallback; +#else + NewRegionToRectsUPP( wxMacRegionToRectsCounterCallback ); +#endif OSStatus err = noErr; err = QDRegionToRects (OTHER_M_REGION( region ) , kQDParseRegionFromTopLeft, proc, (void*)&m_numRects); if (err == noErr) { +#ifndef __MACH__ DisposeRegionToRectsUPP (proc); - proc = NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback); +#endif + proc = +#ifdef __MACH__ + (RegionToRectsUPP) wxMacRegionToRectsSetterCallback; +#else + NewRegionToRectsUPP (wxMacRegionToRectsSetterCallback); +#endif m_rects = new wxRect[m_numRects]; RegionToRectsCallbackData data ; data.m_rects = m_rects ; @@ -501,7 +440,9 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; } +#ifndef __MACH__ DisposeRegionToRectsUPP( proc ); +#endif } }