fixed wxRegionRefData copy ctor (patch 1274403)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35347 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-08-28 15:37:54 +00:00
parent 3e7cd2f52b
commit 44bf7fe3d0

View File

@@ -28,6 +28,7 @@ struct REGION
public: public:
// Default constructor initializes nothing // Default constructor initializes nothing
REGION() {} REGION() {}
REGION(const wxRect& rect) REGION(const wxRect& rect)
{ {
rects = &extents; rects = &extents;
@@ -38,7 +39,11 @@ public:
extents.y2 = rect.y + rect.height; extents.y2 = rect.y + rect.height;
size = 1; 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 // X.org methods
static bool XClipBox( static bool XClipBox(
@@ -159,12 +164,16 @@ protected:
// ======================================================================== // ========================================================================
// wxRegionRefData // wxRegionRefData
// ======================================================================== // ========================================================================
class wxRegionRefData : public wxObjectRefData, public REGION
class wxRegionRefData : public wxObjectRefData,
public REGION
{ {
public: public:
wxRegionRefData() wxRegionRefData()
/* XCreateRegion */ : wxObjectRefData(),
{ size = 1; REGION()
{
size = 1;
numRects = 0; numRects = 0;
rects = ( BOX * )malloc( (unsigned) sizeof( BOX )); rects = ( BOX * )malloc( (unsigned) sizeof( BOX ));
extents.x1 = 0; extents.x1 = 0;
@@ -172,10 +181,12 @@ public:
extents.y1 = 0; extents.y1 = 0;
extents.y2 = 0; extents.y2 = 0;
} }
wxRegionRefData(const wxPoint& topLeft, const wxPoint& bottomRight) wxRegionRefData(const wxPoint& topLeft, const wxPoint& bottomRight)
: wxObjectRefData() : wxObjectRefData(),
, REGION() REGION()
{ rects = (BOX*)malloc(sizeof(BOX)); {
rects = (BOX*)malloc(sizeof(BOX));
size = 1; size = 1;
numRects = 1; numRects = 1;
extents.x1 = topLeft.x; extents.x1 = topLeft.x;
@@ -184,25 +195,31 @@ public:
extents.y2 = bottomRight.y; extents.y2 = bottomRight.y;
*rects = extents; *rects = extents;
} }
wxRegionRefData(const wxRect& rect) wxRegionRefData(const wxRect& rect)
: wxObjectRefData() : wxObjectRefData(),
, REGION(rect) REGION(rect)
{ rects = (BOX*)malloc(sizeof(BOX)); {
rects = (BOX*)malloc(sizeof(BOX));
*rects = extents; *rects = extents;
} }
wxRegionRefData(const wxRegionRefData& refData) wxRegionRefData(const wxRegionRefData& refData)
: wxObjectRefData() : wxObjectRefData(),
, REGION() REGION()
{ {
size = refData.size; size = refData.size;
numRects = refData.numRects; numRects = refData.numRects;
rects = (Box*)malloc(numRects*sizeof(Box)); rects = (Box*)malloc(numRects*sizeof(Box));
memcpy(rects, refData.rects, numRects*sizeof(Box));
extents = refData.extents; extents = refData.extents;
} }
~wxRegionRefData() ~wxRegionRefData()
{ {
free(rects); free(rects);
} }
private: private:
// Don't allow this // Don't allow this
wxRegionRefData(const REGION&); wxRegionRefData(const REGION&);