public:
// Default constructor initializes nothing
REGION() {}
+
REGION(const wxRect& rect)
{
rects = &extents;
extents.y2 = rect.y + rect.height;
size = 1;
}
- BoxPtr GetBox(int i) { if(i<numRects) return rects+i; else return NULL; }
+
+ BoxPtr GetBox(int i)
+ {
+ return i < numRects ? rects + i : NULL;
+ }
// X.org methods
static bool XClipBox(
// ========================================================================
// wxRegionRefData
// ========================================================================
-class wxRegionRefData : public wxObjectRefData, public REGION
+
+class wxRegionRefData : public wxObjectRefData,
+ public REGION
{
public:
wxRegionRefData()
- /* XCreateRegion */
- { size = 1;
+ : wxObjectRefData(),
+ REGION()
+ {
+ size = 1;
numRects = 0;
rects = ( BOX * )malloc( (unsigned) sizeof( BOX ));
extents.x1 = 0;
extents.y1 = 0;
extents.y2 = 0;
}
+
wxRegionRefData(const wxPoint& topLeft, const wxPoint& bottomRight)
- : wxObjectRefData()
- , REGION()
- { rects = (BOX*)malloc(sizeof(BOX));
+ : wxObjectRefData(),
+ REGION()
+ {
+ rects = (BOX*)malloc(sizeof(BOX));
size = 1;
numRects = 1;
extents.x1 = topLeft.x;
extents.y2 = bottomRight.y;
*rects = extents;
}
+
wxRegionRefData(const wxRect& rect)
- : wxObjectRefData()
- , REGION(rect)
- { rects = (BOX*)malloc(sizeof(BOX));
+ : wxObjectRefData(),
+ REGION(rect)
+ {
+ rects = (BOX*)malloc(sizeof(BOX));
*rects = extents;
}
+
wxRegionRefData(const wxRegionRefData& refData)
- : wxObjectRefData()
- , REGION()
+ : wxObjectRefData(),
+ REGION()
{
size = refData.size;
numRects = refData.numRects;
rects = (Box*)malloc(numRects*sizeof(Box));
+ memcpy(rects, refData.rects, numRects*sizeof(Box));
extents = refData.extents;
}
+
~wxRegionRefData()
{
free(rects);
}
+
private:
// Don't allow this
wxRegionRefData(const REGION&);
// ========================================================================
// wxRegionGeneric
// ========================================================================
-//IMPLEMENT_DYNAMIC_CLASS(wxRegionGeneric, wxGDIObject);
+//IMPLEMENT_DYNAMIC_CLASS(wxRegionGeneric, wxGDIObject)
#define M_REGIONDATA ((wxRegionRefData *)m_refData)
#define M_REGIONDATA_OF(rgn) ((wxRegionRefData *)(rgn.m_refData))
return new wxRegionRefData(*(wxRegionRefData *)data);
}
-bool wxRegionGeneric::operator== (const wxRegionGeneric& region)
+bool wxRegionGeneric::operator== (const wxRegionGeneric& region) const
{
wxASSERT(m_refData && region.m_refData);
return REGION::XEqualRegion(M_REGIONDATA,M_REGIONDATA_OF(region));
// ========================================================================
// wxRegionIteratorGeneric
// ========================================================================
-//IMPLEMENT_DYNAMIC_CLASS(wxRegionIteratorGeneric,wxObject);
+//IMPLEMENT_DYNAMIC_CLASS(wxRegionIteratorGeneric,wxObject)
wxRegionIteratorGeneric::wxRegionIteratorGeneric()
{
wxRect wxRegionIteratorGeneric::GetRect() const
{
- wxASSERT(m_refData);
+ wxASSERT(m_region.m_refData);
const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current);
wxASSERT(box);
return wxRect
long wxRegionIteratorGeneric::GetX() const
{
- wxASSERT(m_refData);
+ wxASSERT(m_region.m_refData);
const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current);
wxASSERT(box);
return box->x1;
long wxRegionIteratorGeneric::GetY() const
{
- wxASSERT(m_refData);
+ wxASSERT(m_region.m_refData);
const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current);
wxASSERT(box);
return box->y1;
long wxRegionIteratorGeneric::GetW() const
{
- wxASSERT(m_refData);
+ wxASSERT(m_region.m_refData);
const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current);
wxASSERT(box);
return box->x2 - box->x1;
long wxRegionIteratorGeneric::GetH() const
{
- wxASSERT(m_refData);
+ wxASSERT(m_region.m_refData);
const Box *box = M_REGIONDATA_OF(m_region)->GetBox(m_current);
wxASSERT(box);
return box->y2 - box->y1;