X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e933b5bc365e0907a4f0fd15b4c49e4c96c2b59f..76e7cfab8fdb0c7862fd07e427af54181717fc62:/src/x11/region.cpp?ds=inline diff --git a/src/x11/region.cpp b/src/x11/region.cpp index 518af38e74..ee429864e2 100644 --- a/src/x11/region.cpp +++ b/src/x11/region.cpp @@ -3,7 +3,6 @@ // Purpose: Region class // Author: Julian Smart, Robert Roebling // Created: Fri Oct 24 10:46:34 MET 1997 -// RCS-ID: $Id$ // Copyright: (c) 1997 Julian Smart, Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,8 +11,11 @@ #include "wx/wxprec.h" #include "wx/region.h" -#include "wx/gdicmn.h" -#include "wx/log.h" + +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/gdicmn.h" +#endif #ifdef __VMS__ #pragma message disable nosimpint @@ -28,7 +30,7 @@ // wxRegionRefData: private class containing the information about the region // ---------------------------------------------------------------------------- -class wxRegionRefData : public wxObjectRefData +class wxRegionRefData : public wxGDIRefData { public: wxRegionRefData() @@ -42,7 +44,7 @@ public: XUnionRegion( refData.m_region, m_region, m_region ); } - ~wxRegionRefData() + virtual ~wxRegionRefData() { if (m_region) XDestroyRegion( m_region ); @@ -81,7 +83,7 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h) XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region ); } -wxRegion::wxRegion( size_t WXUNUSED(n), const wxPoint *WXUNUSED(points), int WXUNUSED(fillStyle) ) +wxRegion::wxRegion( size_t WXUNUSED(n), const wxPoint *WXUNUSED(points), wxPolygonFillMode WXUNUSED(fillStyle) ) { #if 0 XPoint *xpoints = new XPoint[n]; @@ -112,12 +114,12 @@ wxRegion::~wxRegion() // m_refData unrefed in ~wxObject } -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); } @@ -126,13 +128,8 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const // wxRegion comparison // ---------------------------------------------------------------------------- -bool wxRegion::operator==( const wxRegion& region ) const +bool wxRegion::DoIsEqual(const wxRegion& region) const { - if (m_refData == region.m_refData) return true; - - if (!m_refData || !region.m_refData) return false; - - // compare the regions themselves, not the pointers to ref data! return XEqualRegion( M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region ) == True; } @@ -146,45 +143,38 @@ void wxRegion::Clear() UnRef(); } -bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +bool wxRegion::DoUnionWithRect(const wxRect& r) { // work around for XUnionRectWithRegion() bug: taking a union with an empty // rect results in an empty region (at least XFree 3.3.6 and 4.0 have this // problem) - if ( !width || !height ) + if ( r.IsEmpty() ) return true; XRectangle rect; - rect.x = (short)x; - rect.y = (short)y; - rect.width = (unsigned short)width; - rect.height = (unsigned short)height; + rect.x = (short)r.x; + rect.y = (short)r.y; + rect.width = (unsigned short)r.width; + rect.height = (unsigned short)r.height; if (!m_refData) { m_refData = new wxRegionRefData(); M_REGIONDATA->m_region = XCreateRegion(); - XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region ); } else { AllocExclusive(); - - XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region ); } - return true; -} + XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region ); -bool wxRegion::Union( const wxRect& rect ) -{ - return Union( rect.x, rect.y, rect.width, rect.height ); + return true; } -bool wxRegion::Union( const wxRegion& region ) +bool wxRegion::DoUnionWithRegion( const wxRegion& region ) { - if (region.IsNull()) - return false; + wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") ); if (!m_refData) { @@ -203,24 +193,9 @@ bool wxRegion::Union( const wxRegion& region ) return true; } -bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +bool wxRegion::DoIntersect( const wxRegion& region ) { - wxRegion reg( x, y, width, height ); - - return Intersect( reg ); -} - -bool wxRegion::Intersect( const wxRect& rect ) -{ - wxRegion reg( rect ); - - return Intersect( reg ); -} - -bool wxRegion::Intersect( const wxRegion& region ) -{ - if (region.IsNull()) - return false; + wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") ); if (!m_refData) { @@ -242,22 +217,9 @@ bool wxRegion::Intersect( const wxRegion& region ) return true; } -bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) +bool wxRegion::DoSubtract( const wxRegion& region ) { - wxRegion reg( x, y, width, height ); - return Subtract( reg ); -} - -bool wxRegion::Subtract( const wxRect& rect ) -{ - wxRegion reg( rect ); - return Subtract( reg ); -} - -bool wxRegion::Subtract( const wxRegion& region ) -{ - if (region.IsNull()) - return false; + wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") ); if (!m_refData) { @@ -276,22 +238,9 @@ bool wxRegion::Subtract( const wxRegion& region ) return true; } -bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxRegion reg( x, y, width, height ); - return Xor( reg ); -} - -bool wxRegion::Xor( const wxRect& rect ) -{ - wxRegion reg( rect ); - return Xor( reg ); -} - -bool wxRegion::Xor( const wxRegion& region ) +bool wxRegion::DoXor( const wxRegion& region ) { - if (region.IsNull()) - return false; + wxCHECK_MSG( region.IsOk(), false, wxT("invalid region") ); if (!m_refData) { @@ -314,7 +263,7 @@ bool wxRegion::Xor( const wxRegion& region ) // wxRegion tests // ---------------------------------------------------------------------------- -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) { @@ -324,6 +273,8 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const y = rect.y; w = rect.width; h = rect.height; + + return true; } else { @@ -331,17 +282,12 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const y = 0; w = -1; h = -1; - } -} -wxRect wxRegion::GetBox() const -{ - wxCoord x, y, w, h; - GetBox( x, y, w, h ); - return wxRect( x, y, w, h ); + return false; + } } -bool wxRegion::Offset( wxCoord x, wxCoord y ) +bool wxRegion::DoOffset( wxCoord x, wxCoord y ) { if (!m_refData) return false; @@ -353,7 +299,7 @@ bool wxRegion::Offset( wxCoord x, wxCoord y ) return true; } -bool wxRegion::Empty() const +bool wxRegion::IsEmpty() const { if (!m_refData) return true; @@ -361,7 +307,7 @@ bool wxRegion::Empty() const return XEmptyRegion( M_REGIONDATA->m_region ) == True; } -wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const +wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const { if (!m_refData) return wxOutRegion; @@ -372,12 +318,12 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const return wxOutRegion; } -wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const +wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const { if (!m_refData) return wxOutRegion; - int res = XRectInRegion( M_REGIONDATA->m_region, x, y, w, h ); + int res = XRectInRegion(M_REGIONDATA->m_region, r.x, r.y, r.width, r.height); switch (res) { case RectangleIn: return wxInRegion; @@ -387,20 +333,10 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) return wxOutRegion; } -wxRegionContain wxRegion::Contains(const wxPoint& pt) const -{ - return Contains( pt.x, pt.y ); -} - -wxRegionContain wxRegion::Contains(const wxRect& rect) const -{ - return Contains( rect.x, rect.y, rect.width, rect.height ); -} - WXRegion *wxRegion::GetX11Region() const { if (!m_refData) - return (WXRegion*) NULL; + return NULL; return (WXRegion*) M_REGIONDATA->m_region; } @@ -424,12 +360,12 @@ struct _XRegion { _XBox *rects, extents; }; -class wxRIRefData: public wxObjectRefData +class wxRIRefData: public wxGDIRefData { public: wxRIRefData() : m_rects(0), m_numRects(0){} - ~wxRIRefData(); + virtual ~wxRIRefData(); wxRect *m_rects; size_t m_numRects;