class WXDLLEXPORT wxRegionRefData : public wxGDIRefData
{
public:
- wxRegionRefData()
- {
- }
+ wxRegionRefData() {}
wxRegionRefData(const wxRegionRefData& data)
{
m_region = data.m_region;
}
- ~wxRegionRefData()
- {
- }
+ ~wxRegionRefData() {}
MGLRegion m_region;
};
// wxRegion
//-----------------------------------------------------------------------------
+wxObjectRefData *wxRegion::CreateRefData() const
+{
+ return new wxRegionRefData;
+}
+
+wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxRegionRefData(*(wxRegionRefData *)data);
+}
+
/*
* Create an empty region.
*/
wxRegion::wxRegion()
{
- m_refData = (wxRegionRefData *)NULL;
+ m_refData = NULL;
}
wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
// Modifications
//-----------------------------------------------------------------------------
+bool wxRegion::Offset(wxCoord x, wxCoord y)
+{
+ AllocExclusive();
+ M_REGION.offset(x, y);
+ return TRUE;
+}
+
// Union rectangle or region with this.
bool wxRegion::Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION += MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Union(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION += M_REGION_OF(region);
return TRUE;
}
// Intersect rectangle or region with this.
bool wxRegion::Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION &= MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Intersect(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION &= M_REGION_OF(region);
return TRUE;
}
// Combines the parts of 'this' that are not part of the second region.
bool wxRegion::Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION -= MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Subtract(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION -= M_REGION_OF(region);
return TRUE;
}
// XOR: the union of two combined regions except for any overlapping areas.
bool wxRegion::Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
MGLRect rect(x, y, x + width, y + height);
MGLRegion rg1 = M_REGION + rect,
rg2 = M_REGION & rect;
bool wxRegion::Xor(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
MGLRegion rg1 = M_REGION + M_REGION_OF(region),
rg2 = M_REGION & M_REGION_OF(region);
M_REGION = rg1 - rg2;
}
-
-void wxRegion::Unshare()
-{
- if (!m_refData)
- {
- m_refData = new wxRegionRefData();
- }
- else
- {
- wxRegionRefData* ref = new wxRegionRefData(*(wxRegionRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
-}
-
-
-
-
-
///////////////////////////////////////////////////////////////////////////////
// wxRegionIterator //
///////////////////////////////////////////////////////////////////////////////
else
return 0;
}
-