g_rect.height = rect.height;
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &g_rect );
gdk_region_destroy( reg );
-
- wxNode *node = M_REGIONDATA->m_rects.First();
- while (node)
- {
- wxRect *r = (wxRect*)node->Data();
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(r->x,r->y,r->width,r->height) );
- node = node->Next();
- }
+ M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
}
wxRegion::wxRegion()
{
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
wxRegion::~wxRegion()
void wxRegion::Clear()
{
UnRef();
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y;
rect.width = width;
rect.height = height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ GdkRegion *reg = gdk_region_new();
+ M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
+ gdk_region_destroy( reg );
+ }
+ else
+ {
+ GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
+ gdk_region_destroy( M_REGIONDATA->m_region );
+ M_REGIONDATA->m_region = reg;
+ }
+
M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(x,y,width,height) );
+
return TRUE;
}
bool wxRegion::Union( const wxRect& rect )
{
- GdkRectangle g_rect;
- g_rect.x = rect.x;
- g_rect.y = rect.y;
- g_rect.width = rect.width;
- g_rect.height = rect.height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &g_rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
- return TRUE;
+ return Union( rect.x, rect.y, rect.width, rect.height );
}
bool wxRegion::Union( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ return TRUE;
+ }
+
GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
return TRUE;
}
-void wxRegion::GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const
+void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
{
x = 0;
y = 0;
w = -1;
h = -1;
+ if (!m_refData)
+ return;
+
GdkRectangle rect;
gdk_region_get_clipbox( M_REGIONDATA->m_region, &rect );
x = rect.x;
bool wxRegion::Empty() const
{
+ if (!m_refData)
+ return TRUE;
+
return gdk_region_empty( M_REGIONDATA->m_region );
}
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
if (gdk_region_point_in( M_REGIONDATA->m_region, x, y ))
return wxInRegion;
else
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
GdkRectangle rect;
rect.x = x;
rect.y = y;
GdkRegion *wxRegion::GetRegion() const
{
+ if (!m_refData)
+ return (GdkRegion*) NULL;
+
return M_REGIONDATA->m_region;
}
wxList *wxRegion::GetRectList() const
{
+ if (!m_refData)
+ return (wxList*) NULL;
+
return &(M_REGIONDATA->m_rects);
}
wxRegionIterator::operator bool () const
{
- return m_current < m_region.GetRectList()->Number();
+ return m_current < (size_t)m_region.GetRectList()->Number();
}
bool wxRegionIterator::HaveRects() const
{
- return m_current < m_region.GetRectList()->Number();
+ return m_current < (size_t)m_region.GetRectList()->Number();
}
void wxRegionIterator::operator ++ ()
{
- if (m_current < m_region.GetRectList()->Number()) ++m_current;
+ if (m_current < (size_t)m_region.GetRectList()->Number()) ++m_current;
}
void wxRegionIterator::operator ++ (int)
{
- if (m_current < m_region.GetRectList()->Number()) ++m_current;
+ if (m_current < (size_t)m_region.GetRectList()->Number()) ++m_current;
}
wxCoord wxRegionIterator::GetX() const