wxRegion::wxRegion(size_t n, const wxPoint *points, int fillStyle)
{
+#ifdef __WXMICROWIN__
+ m_refData = NULL;
+ M_REGION = NULL;
+#else
m_refData = new wxRegionRefData;
M_REGION = ::CreatePolygonRgn
(
n,
fillStyle == wxODDEVEN_RULE ? ALTERNATE : WINDING
);
+#endif
}
-/*
- * Destroy the region.
- */
wxRegion::~wxRegion()
{
// m_refData unrefed in ~wxObject
}
+wxObjectRefData *wxRegion::CreateRefData() const
+{
+ return new wxRegionRefData;
+}
+
+wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxRegionRefData(*(wxRegionRefData *)data);
+}
+
//-----------------------------------------------------------------------------
// Modify region
//-----------------------------------------------------------------------------
UnRef();
}
+bool wxRegion::Offset(wxCoord x, wxCoord y)
+{
+ if ( !x && !y )
+ {
+ // nothing to do
+ return TRUE;
+ }
+
+ AllocExclusive();
+
+ if ( ::OffsetRgn(GetHrgn(), x, y) == ERROR )
+ {
+ wxLogLastError(_T("OffsetRgn"));
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
// Combine rectangle (x, y, w, h) with this.
bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord 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);
- }
- // If ref count is 1, that means it's 'ours' anyway so no action.
+ AllocExclusive();
HRGN rectRegion = ::CreateRectRgn(x, y, x + width, y + height);
mode = RGN_COPY; break ;
}
- bool success = (ERROR != ::CombineRgn(M_REGION, M_REGION, rectRegion, mode));
+ bool success = ::CombineRgn(M_REGION, M_REGION, rectRegion, mode) != ERROR;
+ if ( !success )
+ {
+ wxLogLastError(_T("CombineRgn"));
+ }
::DeleteObject(rectRegion);
if (region.Empty())
return FALSE;
- // 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);
- }
+ AllocExclusive();
int mode = 0;
switch (op)