// wxRegionRefData
// ========================================================================
-class wxRegionRefData : public wxObjectRefData,
+class wxRegionRefData : public wxGDIRefData,
public REGION
{
public:
wxRegionRefData()
- : wxObjectRefData(),
+ : wxGDIRefData(),
REGION()
{
size = 1;
}
wxRegionRefData(const wxPoint& topLeft, const wxPoint& bottomRight)
- : wxObjectRefData(),
+ : wxGDIRefData(),
REGION()
{
rects = (BOX*)malloc(sizeof(BOX));
}
wxRegionRefData(const wxRect& rect)
- : wxObjectRefData(),
+ : wxGDIRefData(),
REGION(rect)
{
rects = (BOX*)malloc(sizeof(BOX));
}
wxRegionRefData(const wxRegionRefData& refData)
- : wxObjectRefData(),
+ : wxGDIRefData(),
REGION()
{
size = refData.size;
extents = refData.extents;
}
- ~wxRegionRefData()
+ virtual ~wxRegionRefData()
{
free(rects);
}
m_refData = new wxRegionRefData(topLeft, bottomRight);
}
+wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp)
+{
+ wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp)");
+}
+
+wxRegionGeneric::wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle)
+{
+ wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(size_t n, const wxPoint *points, wxPolygonFillMode fillStyle)");
+}
+
+wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance)
+{
+ wxFAIL_MSG("NOT IMPLEMENTED: wxRegionGeneric::wxRegionGeneric(const wxBitmap& bmp, const wxColour& transp, int tolerance)");
+}
+
void wxRegionGeneric::Clear()
{
UnRef();
+ if (!m_refData)
+ m_refData = new wxRegionRefData(wxRect(0,0,0,0));
}
-wxObjectRefData *wxRegionGeneric::CreateRefData() const
+wxGDIRefData *wxRegionGeneric::CreateGDIRefData() const
{
return new wxRegionRefData;
}
-wxObjectRefData *wxRegionGeneric::CloneRefData(const wxObjectRefData *data) const
+wxGDIRefData *wxRegionGeneric::CloneGDIRefData(const wxGDIRefData *data) const
{
return new wxRegionRefData(*(wxRegionRefData *)data);
}
-bool wxRegionGeneric::operator== (const wxRegionGeneric& region) const
+bool wxRegionGeneric::DoIsEqual(const wxRegion& region) const
{
- wxASSERT(m_refData && region.m_refData);
return REGION::XEqualRegion(M_REGIONDATA,M_REGIONDATA_OF(region));
}
-wxRect wxRegionGeneric::GetBox() const
+bool wxRegionGeneric::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
- wxASSERT(m_refData);
- wxRect rect;
- REGION::XClipBox(M_REGIONDATA,&rect);
- return rect;
-}
+ if ( !m_refData )
+ return false;
-void wxRegionGeneric::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
-{
- wxASSERT(m_refData);
wxRect rect;
REGION::XClipBox(M_REGIONDATA,&rect);
x = rect.x;
y = rect.y;
w = rect.width;
h = rect.height;
+ return true;
}
// ----------------------------------------------------------------------------
// wxRegionGeneric operations
// ----------------------------------------------------------------------------
-bool wxRegionGeneric::Union(const wxRect& rect)
-/* XUnionRectWithRegion */
+bool wxRegionGeneric::DoUnionWithRect(const wxRect& rect)
{
- if (!rect.width || !rect.height)
- return false;
+ if ( rect.IsEmpty() )
+ {
+ // nothing to do
+ return true;
+ }
AllocExclusive();
REGION region(rect);
return REGION::XUnionRegion(®ion,M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Union(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoUnionWithRegion(const wxRegion& region)
{
AllocExclusive();
return REGION::XUnionRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Intersect(const wxRect& rect)
-{
- if (!rect.width || !rect.height)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XIntersectRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
-
-bool wxRegionGeneric::Intersect(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoIntersect(const wxRegion& region)
{
AllocExclusive();
return REGION::XIntersectRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Subtract(const wxRect& rect)
+bool wxRegionGeneric::DoSubtract(const wxRegion& region)
{
- if (!rect.width || !rect.height)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XSubtractRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
+ if ( region.IsEmpty() )
+ {
+ // nothing to do
+ return true;
+ }
-bool wxRegionGeneric::Subtract(const wxRegionGeneric& region)
-{
return REGION::XSubtractRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Xor(const wxRect& rect)
-{
- if (!rect.width || !rect.height)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XXorRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
-
-bool wxRegionGeneric::Xor(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoXor(const wxRegion& region)
{
AllocExclusive();
return REGION::XXorRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Offset(wxCoord x, wxCoord y)
+bool wxRegionGeneric::DoOffset(wxCoord x, wxCoord y)
{
AllocExclusive();
return REGION::XOffsetRegion(M_REGIONDATA, x, y);
// wxRegionGeneric comparison
// ----------------------------------------------------------------------------
-bool wxRegionGeneric::Empty() const
+bool wxRegionGeneric::IsEmpty() const
{
wxASSERT(m_refData);
return REGION::XEmptyRegion(M_REGIONDATA);
}
// Does the region contain the point (x,y)?
-wxRegionContain wxRegionGeneric::Contains(long x, long y) const
-{
- wxASSERT(m_refData);
- return REGION::XPointInRegion(M_REGIONDATA,x,y)?wxInRegion:wxOutRegion;
-}
-
-// Does the region contain the point pt?
-wxRegionContain wxRegionGeneric::Contains(const wxPoint& pt) const
-{
- wxASSERT(m_refData);
- return REGION::XPointInRegion(M_REGIONDATA,pt.x,pt.y)?wxInRegion:wxOutRegion;
-}
-
-// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegionGeneric::Contains(long x, long y, long w, long h) const
+wxRegionContain wxRegionGeneric::DoContainsPoint(wxCoord x, wxCoord y) const
{
wxASSERT(m_refData);
- return REGION::XRectInRegion(M_REGIONDATA,x,y,w,h);
+ return REGION::XPointInRegion(M_REGIONDATA,x,y) ? wxInRegion : wxOutRegion;
}
// Does the region contain the rectangle rect?
-wxRegionContain wxRegionGeneric::Contains(const wxRect& rect) const
+wxRegionContain wxRegionGeneric::DoContainsRect(const wxRect& rect) const
{
wxASSERT(m_refData);
return REGION::XRectInRegion(M_REGIONDATA,rect.x,rect.y,rect.width,rect.height);
if (!temp->rects)
{
- free((char *) temp);
+ delete temp;
return (Region) NULL;
}
temp->numRects = 0;
pExtents->x2 = pBoxEnd->x2;
pExtents->y2 = pBoxEnd->y2;
- assert(pExtents->y1 < pExtents->y2);
+ wxASSERT_LEVEL_2(pExtents->y1 < pExtents->y2);
while (pBox <= pBoxEnd)
{
if (pBox->x1 < pExtents->x1)
}
pBox++;
}
- assert(pExtents->x1 < pExtents->x2);
+ wxASSERT_LEVEL_2(pExtents->x1 < pExtents->x2);
}
bool REGION::
*/
if (x1 < x2)
{
- assert(y1<y2);
+ wxASSERT_LEVEL_2(y1<y2);
MEMCHECK(pReg, pNextRect, pReg->rects);
pNextRect->x1 = x1;
pNextRect->y2 = y2;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects <= pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects <= pReg->size);
}
/*
pNextRect = &pReg->rects[pReg->numRects];
- assert(y1 < y2);
+ wxASSERT_LEVEL_2(y1 < y2);
while (r != rEnd)
{
- assert(r->x1 < r->x2);
+ wxASSERT_LEVEL_2(r->x1 < r->x2);
MEMCHECK(pReg, pNextRect, pReg->rects);
pNextRect->x1 = r->x1;
pNextRect->y1 = y1;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects<=pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);
r++;
}
return 0; /* lint */
if (pNextRect[-1].x2 < r->x2) \
{ \
pNextRect[-1].x2 = r->x2; \
- assert(pNextRect[-1].x1<pNextRect[-1].x2); \
+ wxASSERT_LEVEL_2(pNextRect[-1].x1<pNextRect[-1].x2); \
} \
} \
else \
pReg->numRects += 1; \
pNextRect += 1; \
} \
- assert(pReg->numRects<=pReg->size);\
+ wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);\
r++;
- assert (y1<y2);
+ wxASSERT_LEVEL_2 (y1<y2);
while ((r1 != r1End) && (r2 != r2End))
{
if (r1->x1 < r2->x1)
pNextRect = &pReg->rects[pReg->numRects];
- assert(y1<y2);
+ wxASSERT_LEVEL_2(y1<y2);
while (r != rEnd)
{
- assert(r->x1<r->x2);
+ wxASSERT_LEVEL_2(r->x1<r->x2);
MEMCHECK(pReg, pNextRect, pReg->rects);
pNextRect->x1 = r->x1;
pNextRect->y1 = y1;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects <= pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects <= pReg->size);
r++;
}
x1 = r1->x1;
- assert(y1<y2);
+ wxASSERT_LEVEL_2(y1<y2);
pNextRect = &pReg->rects[pReg->numRects];
while ((r1 != r1End) && (r2 != r2End))
* Left part of subtrahend covers part of minuend: add uncovered
* part of minuend to region and skip to next subtrahend.
*/
- assert(x1<r2->x1);
+ wxASSERT_LEVEL_2(x1<r2->x1);
MEMCHECK(pReg, pNextRect, pReg->rects);
pNextRect->x1 = x1;
pNextRect->y1 = y1;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects<=pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);
x1 = r2->x2;
if (x1 >= r1->x2)
pNextRect->y2 = y2;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects<=pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);
}
r1++;
if (r1 != r1End)
*/
while (r1 != r1End)
{
- assert(x1<r1->x2);
+ wxASSERT_LEVEL_2(x1<r1->x2);
MEMCHECK(pReg, pNextRect, pReg->rects);
pNextRect->x1 = x1;
pNextRect->y1 = y1;
pReg->numRects += 1;
pNextRect++;
- assert(pReg->numRects<=pReg->size);
+ wxASSERT_LEVEL_2(pReg->numRects<=pReg->size);
r1++;
if (r1 != r1End)