X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5fa7a49ce395b2a84d0c5d405fdb13277402e95f..a201463482dc4417592ee014ff1a9706e8971dd6:/src/mac/carbon/region.cpp diff --git a/src/mac/carbon/region.cpp b/src/mac/carbon/region.cpp index 751177afde..b8147e5db8 100644 --- a/src/mac/carbon/region.cpp +++ b/src/mac/carbon/region.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// File: region.cpp +// File: src/mac/carbon/region.cpp // Purpose: Region class // Author: Stefan Csomor // Created: Fri Oct 24 10:46:34 MET 1997 @@ -11,7 +11,11 @@ #include "wx/wxprec.h" #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) @@ -34,7 +38,7 @@ public: CopyRgn( data.m_macRgn , m_macRgn ); } - ~wxRegionRefData() + virtual ~wxRegionRefData() { DisposeRgn( m_macRgn ); } RgnHandle m_macRgn; @@ -83,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 @@ -120,6 +126,7 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int WXUNUSED(fillStyle)) ::SetGWorld( oldWorld, oldGDHandle ); } +#endif } wxRegion::~wxRegion() @@ -138,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") ); @@ -152,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) @@ -244,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) { @@ -264,25 +225,24 @@ 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 { - return EmptyRgn( M_REGION ) ; + if ( m_refData ) + return EmptyRgn( M_REGION ) ; + else + return true ; } const WXHRGN wxRegion::GetWXHRGN() const @@ -294,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; @@ -321,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 // @@ -472,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 ; @@ -497,7 +440,9 @@ void wxRegionIterator::Reset(const wxRegion& region) m_numRects = 0; } +#ifndef __MACH__ DisposeRegionToRectsUPP( proc ); +#endif } } @@ -509,7 +454,7 @@ wxRegionIterator& wxRegionIterator::operator ++ () { if (m_current < m_numRects) ++m_current; - + return *this; } @@ -558,4 +503,3 @@ long wxRegionIterator::GetH() const return 0; } -