X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3c7fc996a73e9f6a83067bc28a3c5581a3fee65..52af3158e974b042008474268570f3bdb7ce95ee:/src/mac/carbon/region.cpp diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index 1f26fe1575..b8147e5db8 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -87,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 @@ -124,6 +126,7 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) ::SetGWorld( oldWorld, oldGDHandle ); } +#endif } wxRegion::~wxRegion() @@ -142,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") ); @@ -156,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) @@ -248,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) { @@ -268,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 ) ; @@ -301,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; @@ -328,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 // @@ -479,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 ; @@ -504,7 +440,9 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; } +#ifndef __MACH__ DisposeRegionToRectsUPP( proc ); +#endif } }