X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5549e9f76fb5cbfb2a2190980983bcebea132a2e..e7300ec6d9ebbd1cfa2fcf12c0ce6e5aee85a152:/src/msw/region.cpp diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 0d1b81aace..ec84dd0205 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -105,6 +105,10 @@ wxRegion::wxRegion(const wxRect& rect) 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 ( @@ -112,16 +116,24 @@ wxRegion::wxRegion(size_t n, const wxPoint *points, int fillStyle) 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 //----------------------------------------------------------------------------- @@ -132,18 +144,30 @@ void wxRegion::Clear() 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); @@ -159,7 +183,11 @@ bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRe 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); @@ -172,14 +200,7 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) 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)