X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b3c861501a451503b31c075ccb59d16b0ae01e99..64ea838d8f4d1853b7d850db93ee565e901d099a:/src/dfb/region.cpp?ds=sidebyside diff --git a/src/dfb/region.cpp b/src/dfb/region.cpp index e2788df22e..d07fd09a5d 100644 --- a/src/dfb/region.cpp +++ b/src/dfb/region.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mgl/region.cpp +// Name: src/dfb/region.cpp // Purpose: Region handling for wxWidgets/DFB // Author: Vaclav Slavik // Created: 2006-08-08 @@ -33,6 +33,8 @@ public: ~wxRegionRefData() {} + // default assignment and comparison operators are OK + wxRect m_rect; }; @@ -43,12 +45,12 @@ public: // wxRegion //----------------------------------------------------------------------------- -wxObjectRefData *wxRegion::CreateRefData() const +wxGDIRefData *wxRegion::CreateGDIRefData() const { return new wxRegionRefData; } -wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const +wxGDIRefData *wxRegion::CloneGDIRefData(const wxGDIRefData *data) const { return new wxRegionRefData(*(wxRegionRefData *)data); } @@ -78,39 +80,30 @@ wxRegion::~wxRegion() // m_refData unrefed in ~wxObject } -bool wxRegion::operator==(const wxRegion& region) const -{ - if ( m_refData != region.m_refData ) - return false; - - if ( !Ok() ) - return true; // both invalid - - return M_REGION->m_rect == M_REGION_OF(region)->m_rect; -} - //----------------------------------------------------------------------------- // Information about the region //----------------------------------------------------------------------------- -void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const +bool wxRegion::DoIsEqual(const wxRegion& region) const { - wxRect r = GetBox(); + return M_REGION->m_rect == M_REGION_OF(region)->m_rect; +} + +bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const +{ + if ( !m_refData ) + return false; + + const wxRect& r = M_REGION->m_rect; x = r.GetX(); y = r.GetY(); w = r.GetWidth(); h = r.GetHeight(); -} -wxRect wxRegion::GetBox() const -{ - if (m_refData) - return M_REGION->m_rect; - else - return wxRect(); + return true; } -bool wxRegion::Empty() const +bool wxRegion::IsEmpty() const { if (!m_refData) return true; @@ -127,57 +120,56 @@ void wxRegion::Clear() UnRef(); } -bool wxRegion::Offset(wxCoord x, wxCoord y) +bool wxRegion::DoOffset(wxCoord x, wxCoord y) { AllocExclusive(); M_REGION->m_rect.Offset(x, y); return true; } -bool wxRegion::Union(const wxRect& rect) +bool wxRegion::DoUnionWithRect(const wxRect& rect) { AllocExclusive(); - if ( M_REGION->m_rect.Inside(rect) ) + if ( M_REGION->m_rect.Contains(rect) ) { return true; } - else if ( rect.Inside(M_REGION->m_rect) ) + else if ( rect.Contains(M_REGION->m_rect) ) { M_REGION->m_rect = rect; return true; } else { - wxFAIL_MSG( _T("only rectangular regions are supported") ); + wxFAIL_MSG( "only rectangular regions are supported" ); return false; } } -bool wxRegion::Union(const wxRegion& region) +bool wxRegion::DoUnionWithRegion(const wxRegion& region) { - wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); - return Union(M_REGION_OF(region)->m_rect); + wxCHECK_MSG( region.IsOk(), false, "invalid region" ); + return DoUnionWithRect(M_REGION_OF(region)->m_rect); } -bool wxRegion::Intersect(const wxRect& rect) +bool wxRegion::DoIntersect(const wxRegion& region) { + wxCHECK_MSG( region.IsOk(), false, "invalid region" ); + AllocExclusive(); - M_REGION->m_rect.Intersect(rect); + M_REGION->m_rect.Intersect(M_REGION_OF(region)->m_rect); return true; } -bool wxRegion::Intersect(const wxRegion& region) +bool wxRegion::DoSubtract(const wxRegion& region) { - wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); - return Intersect(M_REGION_OF(region)->m_rect); -} + wxCHECK_MSG( region.IsOk(), false, "invalid region" ); + wxCHECK_MSG( IsOk(), false, "invalid region" ); -bool wxRegion::Subtract(const wxRect& rect) -{ - wxCHECK_MSG( Ok(), false, _T("invalid region") ); + const wxRect& rect = M_REGION_OF(region)->m_rect; - if ( rect.Inside(M_REGION->m_rect) ) + if ( rect.Contains(M_REGION->m_rect) ) { // subtracted rectangle contains this one, so the result is empty // rectangle @@ -186,55 +178,44 @@ bool wxRegion::Subtract(const wxRect& rect) } else if ( !M_REGION->m_rect.Intersects(rect) ) { - // the rectangles are disjoint, so substracting has no effect + // the rectangles are disjoint, so subtracting has no effect return true; } else { - wxFAIL_MSG( _T("only rectangular regions implemented") ); + wxFAIL_MSG( "only rectangular regions implemented" ); return false; } } -bool wxRegion::Subtract(const wxRegion& region) +bool wxRegion::DoXor(const wxRegion& region) { - wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); - return Subtract(M_REGION_OF(region)->m_rect); -} - -bool wxRegion::Xor(const wxRect& rect) -{ - wxFAIL_MSG( _T("Xor not implemented") ); + wxCHECK_MSG( region.IsOk(), false, "invalid region" ); + wxFAIL_MSG( "Xor not implemented" ); return false; } -bool wxRegion::Xor(const wxRegion& region) -{ - wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); - return Xor(M_REGION_OF(region)->m_rect); -} - //----------------------------------------------------------------------------- // Tests //----------------------------------------------------------------------------- -wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const +wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const { - wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") ); + wxCHECK_MSG( IsOk(), wxOutRegion, "invalid region" ); - if (M_REGION->m_rect.Inside(x, y)) + if (M_REGION->m_rect.Contains(x, y)) return wxInRegion; else return wxOutRegion; } -wxRegionContain wxRegion::Contains(const wxRect& rect) const +wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const { - wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") ); + wxCHECK_MSG( IsOk(), wxOutRegion, "invalid region" ); // 1) is the rectangle entirely covered by the region? - if (M_REGION->m_rect.Inside(rect)) + if (M_REGION->m_rect.Contains(rect)) return wxInRegion; // 2) is the rectangle completely outside the region?