/////////////////////////////////////////////////////////////////////////////
-// Name: msw/region.cpp
+// Name: src/msw/region.cpp
// Purpose: wxRegion implementation using Win32 API
// Author: Vadim Zeitlin
// Modified by:
// Created: Fri Oct 24 10:46:34 MET 1997
// RCS-ID: $Id$
-// Copyright: (c) 1997-2002 wxWindows team
+// Copyright: (c) 1997-2002 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
- #pragma implementation "region.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/region.h"
-#include "wx/gdicmn.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/gdicmn.h"
+#endif
#include "wx/msw/private.h"
m_region = 0;
}
- wxRegionRefData(const wxRegionRefData& data)
+ wxRegionRefData(const wxRegionRefData& data) : wxGDIRefData()
{
#if defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
DWORD noBytes = ::GetRegionData(data.m_region, 0, NULL);
wxRegion::wxRegion(size_t n, const wxPoint *points, int fillStyle)
{
#if defined(__WXMICROWIN__) || defined(__WXWINCE__)
+ wxUnusedVar(n);
+ wxUnusedVar(points);
+ wxUnusedVar(fillStyle);
m_refData = NULL;
M_REGION = NULL;
#else
UnRef();
}
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
- wxCHECK_MSG( M_REGION, FALSE, _T("invalid wxRegion") );
+ wxCHECK_MSG( M_REGION, false, _T("invalid wxRegion") );
if ( !x && !y )
{
// nothing to do
- return TRUE;
+ return true;
}
AllocExclusive();
{
wxLogLastError(_T("OffsetRgn"));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// combine another region with this one
-bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op)
+bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op)
{
// we can't use the API functions if we don't have a valid region handle
if ( !m_refData )
case wxRGN_AND:
case wxRGN_DIFF:
// leave empty/invalid
- return FALSE;
+ return false;
}
}
else // we have a valid region
{
wxLogLastError(_T("CombineRgn"));
- return FALSE;
+ 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)
-{
- return Combine(wxRegion(x, y, width, height), op);
-}
-
-bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
-{
- return Combine(rect.GetLeft(), rect.GetTop(),
- rect.GetWidth(), rect.GetHeight(), op);
+ return true;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Outer bounds of region
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
+bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
if (m_refData)
{
y = rect.top;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
+
+ return true;
}
else
{
x = y = w = h = 0;
- }
-}
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox(x, y, w, h);
- return wxRect(x, y, w, h);
+ return false;
+ }
}
// Is region empty?
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return (w == 0) && (h == 0);
}
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ return ::EqualRgn(M_REGION, M_REGION_OF(region)) != 0;
+}
+
// ----------------------------------------------------------------------------
// wxRegion hit testing
// ----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
if (!m_refData)
return wxOutRegion;
return ::PtInRegion(M_REGION, (int) x, (int) y) ? wxInRegion : wxOutRegion;
}
-// Does the region contain the point pt?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
-{
- return Contains(pt.x, pt.y);
-}
-
// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y,
- wxCoord w, wxCoord h) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{
if (!m_refData)
return wxOutRegion;
- RECT rect;
- rect.left = x;
- rect.top = y;
- rect.right = x + w;
- rect.bottom = y + h;
+ RECT rc;
+ wxCopyRectToRECT(rect, rc);
- return ::RectInRegion(M_REGION, &rect) ? wxInRegion : wxOutRegion;
-}
-
-// Does the region contain the rectangle rect
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
-{
- return Contains(rect.x, rect.y, rect.width, rect.height);
+ return ::RectInRegion(M_REGION, &rc) ? wxInRegion : wxOutRegion;
}
// Get internal region handle
m_numRects = 0;
else
{
-#if defined(__WIN32__)
DWORD noBytes = ::GetRegionData(((wxRegionRefData*)region.m_refData)->m_region, 0, NULL);
RGNDATA *rgnData = (RGNDATA*) new char[noBytes];
::GetRegionData(((wxRegionRefData*)region.m_refData)->m_region, noBytes, rgnData);
m_numRects = header->nCount;
delete[] (char*) rgnData;
-#else // Win16
- RECT rect;
- ::GetRgnBox(((wxRegionRefData*)region.m_refData)->m_region, &rect);
- m_rects = new wxRect[1];
- m_rects[0].x = rect.left;
- m_rects[0].y = rect.top;
- m_rects[0].width = rect.right - rect.left;
- m_rects[0].height = rect.bottom - rect.top;
-
- m_numRects = 1;
-#endif // Win32/16
}
}
return m_rects[m_current].height;
}
-