X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/789295bf7bd4b58b0270800fb689fce0786dae15..8e9ff8157389edec60f1e86bca2139dc0e635ebc:/src/msw/region.cpp diff --git a/src/msw/region.cpp b/src/msw/region.cpp index 128a6eb3b1..c91f276350 100644 --- a/src/msw/region.cpp +++ b/src/msw/region.cpp @@ -23,12 +23,11 @@ #include "wx/msw/region.h" #include "wx/gdicmn.h" +#include "wx/window.h" #include "wx/msw/private.h" -#if !USE_SHARED_LIBRARY - IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) - IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) -#endif +IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject) //----------------------------------------------------------------------------- // wxRegionRefData implementation @@ -44,7 +43,7 @@ public: wxRegionRefData(const wxRegionRefData& data) { -#if defined(__WIN32__) +#if defined(__WIN32__) && !defined(__WXMICROWIN__) DWORD noBytes = ::GetRegionData(data.m_region, 0, NULL); RGNDATA *rgnData = (RGNDATA*) new char[noBytes]; ::GetRegionData(data.m_region, noBytes, rgnData); @@ -77,8 +76,7 @@ public: */ wxRegion::wxRegion() { - m_refData = new wxRegionRefData; - M_REGION = ::CreateRectRgn(0, 0, 0, 0); + m_refData = (wxRegionRefData *)NULL; } wxRegion::wxRegion(WXHRGN hRegion) @@ -87,7 +85,7 @@ wxRegion::wxRegion(WXHRGN hRegion) M_REGION = (HRGN) hRegion; } -wxRegion::wxRegion(long x, long y, long w, long h) +wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) { m_refData = new wxRegionRefData; M_REGION = ::CreateRectRgn(x, y, x + w, y + h); @@ -102,7 +100,23 @@ wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight) wxRegion::wxRegion(const wxRect& rect) { m_refData = new wxRegionRefData; - M_REGION = ::CreateRectRgn(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); + M_REGION = ::CreateRectRgn(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); +} + +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 + ( + (POINT*)points, + n, + fillStyle == wxODDEVEN_RULE ? ALTERNATE : WINDING + ); +#endif } /* @@ -124,7 +138,7 @@ void wxRegion::Clear() } // Combine rectangle (x, y, w, h) with this. -bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) +bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op) { // Don't change shared data if (!m_refData) { @@ -197,23 +211,26 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) //----------------------------------------------------------------------------- // Outer bounds of region -void wxRegion::GetBox(long& x, long& y, long&w, long &h) const +void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const { - if (m_refData) { + if (m_refData) + { RECT rect; ::GetRgnBox(M_REGION, & rect); x = rect.left; y = rect.top; w = rect.right - rect.left; h = rect.bottom - rect.top; - } else { + } + else + { x = y = w = h = 0; } } wxRect wxRegion::GetBox() const { - long x, y, w, h; + wxCoord x, y, w, h; GetBox(x, y, w, h); return wxRect(x, y, w, h); } @@ -221,12 +238,10 @@ wxRect wxRegion::GetBox() const // Is region empty? bool wxRegion::Empty() const { - if (M_REGION == 0) - return TRUE; - long x, y, w, h; + wxCoord x, y, w, h; GetBox(x, y, w, h); - return ((w == 0) && (h == 0)); + return (w == 0) && (h == 0); } //----------------------------------------------------------------------------- @@ -234,7 +249,7 @@ bool wxRegion::Empty() const //----------------------------------------------------------------------------- // Does the region contain the point (x,y)? -wxRegionContain wxRegion::Contains(long x, long y) const +wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const { if (!m_refData) return wxOutRegion; @@ -258,7 +273,7 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const } // Does the region contain the rectangle (x, y, w, h)? -wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const +wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const { if (!m_refData) return wxOutRegion; @@ -281,7 +296,7 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const if (!m_refData) return wxOutRegion; - long x, y, w, h; + wxCoord x, y, w, h; x = rect.x; y = rect.y; w = rect.GetWidth(); @@ -398,28 +413,28 @@ void wxRegionIterator::operator ++ (int) ++m_current; } -long wxRegionIterator::GetX() const +wxCoord wxRegionIterator::GetX() const { if (m_current < m_numRects) return m_rects[m_current].x; return 0; } -long wxRegionIterator::GetY() const +wxCoord wxRegionIterator::GetY() const { if (m_current < m_numRects) return m_rects[m_current].y; return 0; } -long wxRegionIterator::GetW() const +wxCoord wxRegionIterator::GetW() const { if (m_current < m_numRects) return m_rects[m_current].width ; return 0; } -long wxRegionIterator::GetH() const +wxCoord wxRegionIterator::GetH() const { if (m_current < m_numRects) return m_rects[m_current].height;