#include "wx/window.h"
#include "wx/msw/private.h"
- IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
- IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
+IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
//-----------------------------------------------------------------------------
// wxRegionRefData implementation
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);
*/
wxRegion::wxRegion()
{
- m_refData = new wxRegionRefData;
- M_REGION = ::CreateRectRgn(0, 0, 0, 0);
+ m_refData = (wxRegionRefData *)NULL;
}
wxRegion::wxRegion(WXHRGN hRegion)
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
}
/*
// Outer bounds of region
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;
}
}
// Is region empty?
bool wxRegion::Empty() const
{
- if (M_REGION == 0)
- return TRUE;
wxCoord x, y, w, h;
GetBox(x, y, w, h);
- return ((w == 0) && (h == 0));
+ return (w == 0) && (h == 0);
}
//-----------------------------------------------------------------------------