The Great wxRegion Refactoring:

1. added wxRegionBase class and derive all wxRegions from it
2. also added wxRegionWithCombine for the ports providing Combine() method
   (MSW, OS2 and Mac) to reduce code duplication further
3. made sure region comparison works the same way in all ports (except those
   not implementing it) and added IsEqual() method


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41429 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-09-25 11:47:23 +00:00
parent b48f51ca74
commit 8a16d7370e
24 changed files with 751 additions and 1654 deletions

View File

@@ -18,6 +18,7 @@ reference counting, so copying and assignment operations are fast.
\latexignore{\rtfignore{\wxheading{Members}}} \latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxRegion::wxRegion}\label{wxregionctor} \membersection{wxRegion::wxRegion}\label{wxregionctor}
\func{}{wxRegion}{\void} \func{}{wxRegion}{\void}
@@ -52,24 +53,27 @@ provided array. {\it fillStyle} parameter may have values
\func{}{wxRegion}{\param{const wxBitmap\&}{ bmp}, \func{}{wxRegion}{\param{const wxBitmap\&}{ bmp},
\param{const wxColour\&}{ transColour}, \param{const wxColour\&}{ transColour},
\param{int}{ tolerance = 0}} \param{int}{ tolerance = 0}}
Constructs a region using the non-transparent pixels of a bitmap. See Constructs a region using the non-transparent pixels of a bitmap. See
\helpref{Union}{wxregionunion} for more details. \helpref{Union}{wxregionunion} for more details.
\membersection{wxRegion::\destruct{wxRegion}}\label{wxregiondtor} \membersection{wxRegion::\destruct{wxRegion}}\label{wxregiondtor}
\func{}{\destruct{wxRegion}}{\void} \func{}{\destruct{wxRegion}}{\void}
Destructor. Destructor.
\membersection{wxRegion::Clear}\label{wxregionclear} \membersection{wxRegion::Clear}\label{wxregionclear}
\func{void}{Clear}{\void} \func{void}{Clear}{\void}
Clears the current region. Clears the current region.
\membersection{wxRegion::Contains}\label{wxregioncontains} \membersection{wxRegion::Contains}\label{wxregioncontains}
\constfunc{wxRegionContain}{Contains}{\param{long\& }{x}, \param{long\& }{y}} \constfunc{wxRegionContain}{Contains}{\param{long\& }{x}, \param{long\& }{y}}
@@ -95,6 +99,7 @@ The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that
all or some part of the region is contained in this region. all or some part of the region is contained in this region.
\membersection{wxRegion::ConvertToBitmap}\label{wxregionconverttobitmap} \membersection{wxRegion::ConvertToBitmap}\label{wxregionconverttobitmap}
\constfunc{wxBitmap}{ConvertToBitmap}{} \constfunc{wxBitmap}{ConvertToBitmap}{}
@@ -102,6 +107,7 @@ all or some part of the region is contained in this region.
Convert the region to a black and white bitmap with the white pixels Convert the region to a black and white bitmap with the white pixels
being inside the region. being inside the region.
\membersection{wxRegion::GetBox}\label{wxregiongetbox} \membersection{wxRegion::GetBox}\label{wxregiongetbox}
\constfunc{void}{GetBox}{\param{wxCoord\& }{x}, \param{wxCoord\& }{y}, \param{wxCoord\& }{width}, \param{wxCoord\& }{height}} \constfunc{void}{GetBox}{\param{wxCoord\& }{x}, \param{wxCoord\& }{y}, \param{wxCoord\& }{width}, \param{wxCoord\& }{height}}
@@ -112,6 +118,7 @@ Returns the outer bounds of the region.
Returns the outer bounds of the region. Returns the outer bounds of the region.
\membersection{wxRegion::Intersect}\label{wxregionintersect} \membersection{wxRegion::Intersect}\label{wxregionintersect}
\func{bool}{Intersect}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} \func{bool}{Intersect}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
@@ -135,12 +142,23 @@ Finds the intersection of this region and another region.
Creates the intersection of the two regions, that is, the parts which are in both regions. The result Creates the intersection of the two regions, that is, the parts which are in both regions. The result
is stored in this region. is stored in this region.
\membersection{wxRegion::IsEmpty}\label{wxregionisempty} \membersection{wxRegion::IsEmpty}\label{wxregionisempty}
\constfunc{bool}{IsEmpty}{\void} \constfunc{bool}{IsEmpty}{\void}
Returns {\tt true} if the region is empty, {\tt false} otherwise. Returns {\tt true} if the region is empty, {\tt false} otherwise.
\membersection{wxRegion::IsEqual}\label{wxregionisequal}
\constfunc{bool}{IsEqual}{\param{const wxRegion\& }{region}}
Returns {\tt true} if the region is equal to, i.e. covers the same area as,
another one. Note that if both this region and \arg{region} are invalid, they
are considered to be equal.
\membersection{wxRegion::Subtract}\label{wxregionsubtract} \membersection{wxRegion::Subtract}\label{wxregionsubtract}
\func{bool}{Subtract}{\param{const wxRect\&}{ rect}} \func{bool}{Subtract}{\param{const wxRect\&}{ rect}}
@@ -160,10 +178,13 @@ Subtracts a region from this region.
This operation combines the parts of 'this' region that are not part of the second region. This operation combines the parts of 'this' region that are not part of the second region.
The result is stored in this region. The result is stored in this region.
\membersection{wxRegion::Offset}\label{wxregionoffset} \membersection{wxRegion::Offset}\label{wxregionoffset}
\func{bool}{Offset}{\param{wxCoord}{ x}, \param{wxCoord}{ y}} \func{bool}{Offset}{\param{wxCoord}{ x}, \param{wxCoord}{ y}}
\func{bool}{Offset}{\param{const wxPoint\& }{ pt}}
Moves the region by the specified offsets in horizontal and vertical Moves the region by the specified offsets in horizontal and vertical
directions. directions.
@@ -171,6 +192,7 @@ directions.
{\tt true} if successful, {\tt false} otherwise (the region is unchanged then). {\tt true} if successful, {\tt false} otherwise (the region is unchanged then).
\membersection{wxRegion::Union}\label{wxregionunion} \membersection{wxRegion::Union}\label{wxregionunion}
\func{bool}{Union}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} \func{bool}{Union}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
@@ -193,7 +215,7 @@ have a mask, solid rectangle of bitmap's dimensions is used.
\func{bool}{Union}{\param{const wxBitmap\&}{ bmp}, \func{bool}{Union}{\param{const wxBitmap\&}{ bmp},
\param{const wxColour\&}{ transColour}, \param{const wxColour\&}{ transColour},
\param{int}{ tolerance = 0}} \param{int}{ tolerance = 0}}
Finds the union of this region and the non-transparent pixels of a Finds the union of this region and the non-transparent pixels of a
bitmap. Colour to be treated as transparent is specified in the bitmap. Colour to be treated as transparent is specified in the
@@ -209,6 +231,7 @@ optional colour tolerance value.
This operation creates a region that combines all of this region and the second region. This operation creates a region that combines all of this region and the second region.
The result is stored in this region. The result is stored in this region.
\membersection{wxRegion::Xor}\label{wxregionxor} \membersection{wxRegion::Xor}\label{wxregionxor}
\func{bool}{Xor}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} \func{bool}{Xor}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
@@ -232,6 +255,7 @@ Finds the Xor of this region and another region.
This operation creates a region that combines all of this region and the second region, except This operation creates a region that combines all of this region and the second region, except
for any overlapping areas. The result is stored in this region. for any overlapping areas. The result is stored in this region.
\membersection{wxRegion::operator $=$}\label{wxregionassign} \membersection{wxRegion::operator $=$}\label{wxregionassign}
\func{void}{operator $=$}{\param{const wxRegion\&}{ region}} \func{void}{operator $=$}{\param{const wxRegion\&}{ region}}
@@ -262,6 +286,7 @@ See \helpref{wxPaintEvent}{wxpaintevent} for an example of use.
\latexignore{\rtfignore{\wxheading{Members}}} \latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxRegionIterator::wxRegionIterator}\label{wxregioniteratorctor} \membersection{wxRegionIterator::wxRegionIterator}\label{wxregioniteratorctor}
\func{}{wxRegionIterator}{\void} \func{}{wxRegionIterator}{\void}
@@ -272,54 +297,63 @@ Default constructor.
Creates an iterator object given a region. Creates an iterator object given a region.
\membersection{wxRegionIterator::GetX}\label{wxregioniteratorgetx} \membersection{wxRegionIterator::GetX}\label{wxregioniteratorgetx}
\constfunc{wxCoord}{GetX}{\void} \constfunc{wxCoord}{GetX}{\void}
Returns the x value for the current region. Returns the x value for the current region.
\membersection{wxRegionIterator::GetY}\label{wxregioniteratorgety} \membersection{wxRegionIterator::GetY}\label{wxregioniteratorgety}
\constfunc{wxCoord}{GetY}{\void} \constfunc{wxCoord}{GetY}{\void}
Returns the y value for the current region. Returns the y value for the current region.
\membersection{wxRegionIterator::GetW}\label{wxregioniteratorgetw} \membersection{wxRegionIterator::GetW}\label{wxregioniteratorgetw}
\constfunc{wxCoord}{GetW}{\void} \constfunc{wxCoord}{GetW}{\void}
An alias for GetWidth. An alias for GetWidth.
\membersection{wxRegionIterator::GetHeight}\label{wxregioniteratorgetheight} \membersection{wxRegionIterator::GetHeight}\label{wxregioniteratorgetheight}
\constfunc{wxCoord}{GetHeight}{\void} \constfunc{wxCoord}{GetHeight}{\void}
Returns the height value for the current region. Returns the height value for the current region.
\membersection{wxRegionIterator::GetH}\label{wxregioniteratorgeth} \membersection{wxRegionIterator::GetH}\label{wxregioniteratorgeth}
\constfunc{wxCoord}{GetH}{\void} \constfunc{wxCoord}{GetH}{\void}
An alias for GetHeight. An alias for GetHeight.
\membersection{wxRegionIterator::GetRect}\label{wxregioniteratorgetrect} \membersection{wxRegionIterator::GetRect}\label{wxregioniteratorgetrect}
\constfunc{wxRect}{GetRect}{\void} \constfunc{wxRect}{GetRect}{\void}
Returns the current rectangle. Returns the current rectangle.
\membersection{wxRegionIterator::GetWidth}\label{wxregioniteratorgetwidth} \membersection{wxRegionIterator::GetWidth}\label{wxregioniteratorgetwidth}
\constfunc{wxCoord}{GetWidth}{\void} \constfunc{wxCoord}{GetWidth}{\void}
Returns the width value for the current region. Returns the width value for the current region.
\membersection{wxRegionIterator::HaveRects}\label{wxregioniteratorhaverects} \membersection{wxRegionIterator::HaveRects}\label{wxregioniteratorhaverects}
\constfunc{bool}{HaveRects}{\void} \constfunc{bool}{HaveRects}{\void}
Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}. Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}.
\membersection{wxRegionIterator::Reset}\label{wxregioniteratorreset} \membersection{wxRegionIterator::Reset}\label{wxregioniteratorreset}
\func{void}{Reset}{\void} \func{void}{Reset}{\void}
@@ -330,6 +364,7 @@ Resets the iterator to the beginning of the rectangles.
Resets the iterator to the given region. Resets the iterator to the given region.
\membersection{wxRegionIterator::operator $++$}\label{wxregioniteratorinc} \membersection{wxRegionIterator::operator $++$}\label{wxregioniteratorinc}
\func{void}{operator $++$}{\void} \func{void}{operator $++$}{\void}
@@ -338,6 +373,7 @@ Increment operator. Increments the iterator to the next region.
\pythonnote{A wxPython alias for this operator is called {\tt Next}.} \pythonnote{A wxPython alias for this operator is called {\tt Next}.}
\membersection{wxRegionIterator::operator bool}\label{wxregioniteratorbool} \membersection{wxRegionIterator::operator bool}\label{wxregioniteratorbool}
\constfunc{}{operator bool}{\void} \constfunc{}{operator bool}{\void}

View File

@@ -18,7 +18,6 @@ typedef struct _NSRect NSRect;
class WXDLLEXPORT wxRegion : public wxRegionGeneric class WXDLLEXPORT wxRegion : public wxRegionGeneric
{ {
DECLARE_DYNAMIC_CLASS(wxRegion);
public: public:
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
: wxRegionGeneric(x,y,w,h) : wxRegionGeneric(x,y,w,h)
@@ -48,27 +47,8 @@ public:
wxRegion(const NSRect& rect); wxRegion(const NSRect& rect);
wxRegion(const NSRect *rects, int count); wxRegion(const NSRect *rects, int count);
// Use the non-transparent pixels of a wxBitmap for the region to combine private:
// with this region. First version takes transparency from bitmap's mask, DECLARE_DYNAMIC_CLASS(wxRegion);
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
/* And because of function hiding: */
bool Union(long x, long y, long width, long height)
{ return wxRegionGeneric::Union(x,y,width,height); }
bool Union(const wxRect& rect)
{ return wxRegionGeneric::Union(rect); }
bool Union(const wxRegion& region)
{ return wxRegionGeneric::Union(region); }
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
// NOTE: implemented in common/rgncmn.cpp
wxBitmap ConvertToBitmap() const;
}; };
class WXDLLEXPORT wxRegionIterator : public wxRegionIteratorGeneric class WXDLLEXPORT wxRegionIterator : public wxRegionIteratorGeneric

View File

@@ -11,17 +11,10 @@
#ifndef _WX_DFB_REGION_H_ #ifndef _WX_DFB_REGION_H_
#define _WX_DFB_REGION_H_ #define _WX_DFB_REGION_H_
#include "wx/gdiobj.h" class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
#include "wx/gdicmn.h"
#warning "Move these to wx/region.h when common code is moved there"
class WXDLLIMPEXP_CORE wxBitmap;
class WXDLLIMPEXP_CORE wxColour;
class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
{ {
public: public:
wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h); wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
@@ -35,78 +28,11 @@ public:
Union(bmp, transColour, tolerance); Union(bmp, transColour, tolerance);
} }
wxRegion(); virtual ~wxRegion();
~wxRegion();
#warning "FIXME: move this to common code? at least Ok()" // wxRegionBase methods
bool Ok() const { return m_refData != NULL; } virtual void Clear();
virtual bool IsEmpty() const;
bool operator==(const wxRegion& region) const;
bool operator!=(const wxRegion& region) const { return !(*this == region); }
// Clear current region
void Clear();
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ return Union(wxRect(x, y, width, height)); }
bool Union(const wxRect& rect);
bool Union(const wxRegion& region);
// Intersect rectangle or region with this.
bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ return Intersect(wxRect(x, y, width, height)); }
bool Intersect(const wxRect& rect);
bool Intersect(const wxRegion& region);
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ return Subtract(wxRect(x, y, width, height)); }
bool Subtract(const wxRect& rect);
bool Subtract(const wxRegion& region);
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{ return Xor(wxRect(x, y, width, height)); }
bool Xor(const wxRect& rect);
bool Xor(const wxRegion& region);
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const;
// Is region empty?
bool Empty() const;
bool IsEmpty() const { return Empty(); }
// Does the region contain the point (x,y)?
wxRegionContain Contains(wxCoord x, wxCoord y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const
{ return Contains(pt.x, pt.y); }
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const
{ return Contains(wxRect(x, y, w, h)); }
#warning "Move these union versions + ConvertToBitmap to wxRegionBase"
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// NB: implementation detail of DirectFB, should be removed if full // NB: implementation detail of DirectFB, should be removed if full
// (i.e. not rect-only version is implemented) so that all code that // (i.e. not rect-only version is implemented) so that all code that
@@ -118,6 +44,20 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
friend class WXDLLIMPEXP_CORE wxRegionIterator; friend class WXDLLIMPEXP_CORE wxRegionIterator;
DECLARE_DYNAMIC_CLASS(wxRegion); DECLARE_DYNAMIC_CLASS(wxRegion);

View File

@@ -12,16 +12,8 @@
#ifndef _WX_GENERIC_REGION_H__ #ifndef _WX_GENERIC_REGION_H__
#define _WX_GENERIC_REGION_H__ #define _WX_GENERIC_REGION_H__
#include "wx/gdiobj.h" class WXDLLEXPORT wxRegionGeneric : public wxRegionBase
#include "wx/gdicmn.h"
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxPoint;
class WXDLLEXPORT wxRegionGeneric : public wxGDIObject
{ {
// DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
friend class WXDLLEXPORT wxRegionIteratorGeneric;
public: public:
wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h); wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
@@ -29,82 +21,32 @@ public:
wxRegionGeneric(); wxRegionGeneric();
virtual ~wxRegionGeneric(); virtual ~wxRegionGeneric();
bool Ok() const { return m_refData != NULL; } // wxRegionBase pure virtuals
virtual void Clear();
bool operator == ( const wxRegionGeneric& region ) const; virtual bool IsEmpty() const;
bool operator != ( const wxRegionGeneric& region ) const { return !(*this == region); }
//# Modify region
// Clear current region
void Clear();
// Move the region
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(long x, long y, long width, long height)
{ return Union(wxRect(x,y,width,height)); }
bool Union(const wxRect& rect);
bool Union(const wxRegionGeneric& region);
// Intersect rectangle or region with this.
bool Intersect(long x, long y, long width, long height)
{ return Intersect(wxRect(x,y,width,height)); }
bool Intersect(const wxRect& rect);
bool Intersect(const wxRegionGeneric& region);
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(long x, long y, long width, long height)
{ return Subtract(wxRect(x,y,width,height)); }
bool Subtract(const wxRect& rect);
bool Subtract(const wxRegionGeneric& region);
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(long x, long y, long width, long height);
bool Xor(const wxRect& rect);
bool Xor(const wxRegionGeneric& region);
//# Information on region
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const;
// Is region empty?
bool Empty() const;
inline bool IsEmpty() const { return Empty(); }
//# Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(long x, long y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(long x, long y, long w, long h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
protected: protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
friend class WXDLLEXPORT wxRegionIteratorGeneric;
}; };
class WXDLLEXPORT wxRegionIteratorGeneric : public wxObject class WXDLLEXPORT wxRegionIteratorGeneric : public wxObject
{ {
// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
public: public:
wxRegionIteratorGeneric(); wxRegionIteratorGeneric();
wxRegionIteratorGeneric(const wxRegionGeneric& region); wxRegionIteratorGeneric(const wxRegionGeneric& region);
@@ -134,4 +76,4 @@ private:
wxRegionGeneric m_region; wxRegionGeneric m_region;
}; };
#endif //ndef _WX_GENERIC_REGION_H__ #endif // _WX_GENERIC_REGION_H__

View File

@@ -10,28 +10,11 @@
#ifndef _WX_GTK_REGION_H_ #ifndef _WX_GTK_REGION_H_
#define _WX_GTK_REGION_H_ #define _WX_GTK_REGION_H_
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
// So far, for internal use only
enum wxRegionOp
{
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion // wxRegion
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{ {
public: public:
wxRegion() { } wxRegion() { }
@@ -66,55 +49,9 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
bool Ok() const { return m_refData != NULL; } // wxRegionBase methods
virtual void Clear();
bool operator == ( const wxRegion& region ) const; virtual bool IsEmpty() const;
bool operator != ( const wxRegion& region ) const { return !(*this == region); }
void Clear();
bool Offset( wxCoord x, wxCoord y );
bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Union( const wxRect& rect );
bool Union( const wxRegion& region );
bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Intersect( const wxRect& rect );
bool Intersect( const wxRegion& region );
bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Subtract( const wxRect& rect );
bool Subtract( const wxRegion& region );
bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Xor( const wxRect& rect );
bool Xor( const wxRegion& region );
void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
wxRect GetBox() const ;
bool Empty() const;
bool IsEmpty() const { return Empty(); }
wxRegionContain Contains( wxCoord x, wxCoord y ) const;
wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
public: public:
// Init with GdkRegion, set ref count to 2 so that // Init with GdkRegion, set ref count to 2 so that
@@ -128,6 +65,19 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
// common part of ctors for a rectangle region // common part of ctors for a rectangle region
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);

View File

@@ -11,34 +11,12 @@
#define _WX_GTK_REGION_H_ #define _WX_GTK_REGION_H_
#include "wx/list.h" #include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRegion;
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
// So far, for internal use only
enum wxRegionOp
{
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion // wxRegion
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{ {
public: public:
wxRegion() { } wxRegion() { }
@@ -73,55 +51,9 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
bool Ok() const { return m_refData != NULL; } // wxRegionBase methods
virtual void Clear();
bool operator == ( const wxRegion& region ) const; virtual bool IsEmpty() const;
bool operator != ( const wxRegion& region ) const { return !(*this == region); }
void Clear();
bool Offset( wxCoord x, wxCoord y );
bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Union( const wxRect& rect );
bool Union( const wxRegion& region );
bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Intersect( const wxRect& rect );
bool Intersect( const wxRegion& region );
bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Subtract( const wxRect& rect );
bool Subtract( const wxRegion& region );
bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Xor( const wxRect& rect );
bool Xor( const wxRegion& region );
void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
wxRect GetBox() const ;
bool Empty() const;
bool IsEmpty() const { return Empty(); }
wxRegionContain Contains( wxCoord x, wxCoord y ) const;
wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
public: public:
// Init with GdkRegion, set ref count to 2 so that // Init with GdkRegion, set ref count to 2 so that
@@ -135,6 +67,19 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
// common part of ctors for a rectangle region // common part of ctors for a rectangle region
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);

View File

@@ -9,28 +9,13 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_MAC_CARBON_REGION_H_
#define _WX_REGION_H_ #define _WX_MAC_CARBON_REGION_H_
#include "wx/list.h" #include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
class WXDLLEXPORT wxRect; class WXDLLEXPORT wxRegion : public wxRegionWithCombine
class WXDLLEXPORT wxPoint; {
// So far, for internal use only
enum wxRegionOp {
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
class WXDLLEXPORT wxRegion : public wxGDIObject {
DECLARE_DYNAMIC_CLASS(wxRegion)
friend class WXDLLEXPORT wxRegionIterator;
public: public:
wxRegion(long x, long y, long w, long h); wxRegion(long x, long y, long w, long h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
@@ -50,89 +35,29 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
//# Modify region // wxRegionBase methods
// Clear current region virtual void Clear();
void Clear(); virtual bool IsEmpty() const;
// Move the region
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(long x, long y, long width, long height)
{ return Combine(x, y, width, height, wxRGN_OR); }
bool Union(const wxRect& rect)
{ return Combine(rect, wxRGN_OR); }
bool Union(const wxRegion& region)
{ return Combine(region, wxRGN_OR); }
// Intersect rectangle or region with this.
bool Intersect(long x, long y, long width, long height)
{ return Combine(x, y, width, height, wxRGN_AND); }
bool Intersect(const wxRect& rect)
{ return Combine(rect, wxRGN_AND); }
bool Intersect(const wxRegion& region)
{ return Combine(region, wxRGN_AND); }
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(long x, long y, long width, long height)
{ return Combine(x, y, width, height, wxRGN_DIFF); }
bool Subtract(const wxRect& rect)
{ return Combine(rect, wxRGN_DIFF); }
bool Subtract(const wxRegion& region)
{ return Combine(region, wxRGN_DIFF); }
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(long x, long y, long width, long height)
{ return Combine(x, y, width, height, wxRGN_XOR); }
bool Xor(const wxRect& rect)
{ return Combine(rect, wxRGN_XOR); }
bool Xor(const wxRegion& region)
{ return Combine(region, wxRGN_XOR); }
//# Information on region
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const ;
// Is region empty?
bool Empty() const;
inline bool IsEmpty() const { return Empty(); }
//# Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(long x, long y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(long x, long y, long w, long h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// Internal // Internal
bool Combine(long x, long y, long width, long height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op);
const WXHRGN GetWXHRGN() const ; const WXHRGN GetWXHRGN() const ;
protected:
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoCombine(const wxRegion& region, wxRegionOp op);
private:
DECLARE_DYNAMIC_CLASS(wxRegion)
friend class WXDLLEXPORT wxRegionIterator;
}; };
class WXDLLEXPORT wxRegionIterator : public wxObject class WXDLLEXPORT wxRegionIterator : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
public: public:
wxRegionIterator(); wxRegionIterator();
wxRegionIterator(const wxRegion& region); wxRegionIterator(const wxRegion& region);
@@ -157,6 +82,7 @@ public:
long GetH() const; long GetH() const;
long GetHeight() const { return GetH(); } long GetHeight() const { return GetH(); }
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
private: private:
void SetRects(long numRects, wxRect *rects); void SetRects(long numRects, wxRect *rects);
@@ -164,7 +90,8 @@ private:
long m_numRects; long m_numRects;
wxRegion m_region; wxRegion m_region;
wxRect* m_rects; wxRect* m_rects;
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
}; };
#endif #endif // _WX_MAC_CARBON_REGION_H_
// _WX_REGION_H_

View File

@@ -8,23 +8,17 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_MGL_REGION_H_
#define _WX_REGION_H_ #define _WX_MGL_REGION_H_
#include "wx/list.h" #include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxPoint;
class MGLRegion; class MGLRegion;
class WXDLLEXPORT wxRegion : public wxGDIObject class WXDLLEXPORT wxRegion : public wxRegionBase
{ {
DECLARE_DYNAMIC_CLASS(wxRegion);
friend class WXDLLEXPORT wxRegionIterator;
public: public:
wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h); wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect); wxRegion(const wxRect& rect);
@@ -39,68 +33,11 @@ public:
Union(bmp, transColour, tolerance); Union(bmp, transColour, tolerance);
} }
wxRegion();
virtual ~wxRegion(); virtual ~wxRegion();
//# Modify region // wxRegionBase methods
// Clear current region virtual void Clear();
void Clear(void); virtual bool IsEmpty() const;
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
bool Union(const wxRect& rect) { return Union(rect.x, rect.y, rect.width, rect.height); }
bool Union(const wxRegion& region);
// Intersect rectangle or region with this.
bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
bool Intersect(const wxRect& rect) { return Intersect(rect.x, rect.y, rect.width, rect.height); }
bool Intersect(const wxRegion& region);
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
bool Subtract(const wxRect& rect) { return Subtract(rect.x, rect.y, rect.width, rect.height); }
bool Subtract(const wxRegion& region);
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
bool Xor(const wxRect& rect) { return Xor(rect.x, rect.y, rect.width, rect.height); }
bool Xor(const wxRegion& region);
//# Information on region
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox(void) const ;
// Is region empty?
bool Empty(void) const;
inline bool IsEmpty(void) const { return Empty(); }
//# Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(wxCoord x, wxCoord y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// implementation from now on: // implementation from now on:
const MGLRegion& GetMGLRegion() const; const MGLRegion& GetMGLRegion() const;
@@ -109,6 +46,23 @@ protected:
// ref counting code // ref counting code
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
private:
DECLARE_DYNAMIC_CLASS(wxRegion);
friend class WXDLLEXPORT wxRegionIterator;
}; };
@@ -116,7 +70,6 @@ WX_DECLARE_EXPORTED_LIST(wxRect, wxRegionRectList);
class WXDLLEXPORT wxRegionIterator : public wxObject class WXDLLEXPORT wxRegionIterator : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxRegionIterator);
public: public:
wxRegionIterator(void); wxRegionIterator(void);
wxRegionIterator(const wxRegion& region); wxRegionIterator(const wxRegion& region);
@@ -125,9 +78,7 @@ public:
void Reset(void) { m_currentNode = NULL; } void Reset(void) { m_currentNode = NULL; }
void Reset(const wxRegion& region); void Reset(const wxRegion& region);
#ifndef __SALFORDC__
operator bool (void) const { return (m_currentNode != NULL); } operator bool (void) const { return (m_currentNode != NULL); }
#endif
bool HaveRects(void) const { return (m_currentNode != NULL); } bool HaveRects(void) const { return (m_currentNode != NULL); }
@@ -145,7 +96,8 @@ public:
private: private:
wxRegionRectList m_rects; wxRegionRectList m_rects;
wxRegionRectList::Node *m_currentNode; wxRegionRectList::Node *m_currentNode;
DECLARE_DYNAMIC_CLASS(wxRegionIterator);
}; };
#endif #endif // _WX_MGL_REGION_H_
// _WX_REGION_H_

View File

@@ -9,26 +9,10 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_MSW_REGION_H_
#define _WX_REGION_H_ #define _WX_MSW_REGION_H_
#include "wx/gdiobj.h" class WXDLLEXPORT wxRegion : public wxRegionWithCombine
#include "wx/gdicmn.h"
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxPoint;
// So far, for internal use only
enum wxRegionOp
{
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
class WXDLLEXPORT wxRegion : public wxGDIObject
{ {
public: public:
wxRegion(); wxRegion();
@@ -49,74 +33,9 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
// Modify region // wxRegionBase methods
// ------------- virtual void Clear();
virtual bool IsEmpty() const;
// Clear current region
void Clear();
// Move the region
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
// Intersect rectangle or region with this.
bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
// Information on region
// ---------------------
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const ;
// Is region empty?
bool Empty() const;
inline bool IsEmpty() const { return Empty(); }
// Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(wxCoord x, wxCoord y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// Internal
bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op);
// Get internal region handle // Get internal region handle
WXHRGN GetHRGN() const; WXHRGN GetHRGN() const;
@@ -125,6 +44,14 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoCombine(const wxRegion& region, wxRegionOp op);
friend class WXDLLEXPORT wxRegionIterator; friend class WXDLLEXPORT wxRegionIterator;
DECLARE_DYNAMIC_CLASS(wxRegion) DECLARE_DYNAMIC_CLASS(wxRegion)
@@ -146,9 +73,7 @@ public:
bool HaveRects() const { return (m_current < m_numRects); } bool HaveRects() const { return (m_current < m_numRects); }
#ifndef __SALFORDC__
operator bool () const { return HaveRects(); } operator bool () const { return HaveRects(); }
#endif
wxRegionIterator& operator++(); wxRegionIterator& operator++();
wxRegionIterator operator++(int); wxRegionIterator operator++(int);
@@ -174,5 +99,4 @@ private:
DECLARE_DYNAMIC_CLASS(wxRegionIterator) DECLARE_DYNAMIC_CLASS(wxRegionIterator)
}; };
#endif #endif // _WX_MSW_REGION_H_
// _WX_REGION_H_

View File

@@ -9,27 +9,13 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_OS2_REGION_H_
#define _WX_REGION_H_ #define _WX_OS2_REGION_H_
#include "wx/list.h" #include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
#include "wx/bitmap.h"
#include "wx/os2/private.h" #include "wx/os2/private.h"
class WXDLLEXPORT wxRect; class WXDLLEXPORT wxRegion : public wxRegionWithCombine
class WXDLLEXPORT wxPoint;
// So far, for internal use only
enum wxRegionOp { wxRGN_AND // Creates the intersection of the two combined regions.
,wxRGN_COPY // Creates a copy of the region identified by hrgnSrc1.
,wxRGN_DIFF // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
,wxRGN_OR // Creates the union of two combined regions.
,wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
class WXDLLEXPORT wxRegion : public wxGDIObject
{ {
public: public:
wxRegion( wxCoord x wxRegion( wxCoord x
@@ -62,176 +48,32 @@ public:
// //
// Clear current region // Clear current region
// //
void Clear(void); virtual void Clear();
bool Offset( wxCoord x
,wxCoord y
);
//
// Union rectangle or region with this.
//
inline bool Union( wxCoord x
,wxCoord y
,wxCoord vWidth
,wxCoord vHeight
)
{
return Combine( x
,y
,vWidth
,vHeight
,wxRGN_OR
);
}
inline bool Union( const wxRect& rRect) { return Combine(rRect, wxRGN_OR); }
inline bool Union(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_OR); }
//
// Intersect rectangle or region with this.
//
inline bool Intersect( wxCoord x
,wxCoord y
,wxCoord vWidth
,wxCoord vHeight
)
{
return Combine( x
,y
,vWidth
,vHeight
,wxRGN_AND
);
}
inline bool Intersect(const wxRect& rRect) { return Combine(rRect, wxRGN_AND); }
inline bool Intersect(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_AND); }
//
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
//
inline bool Subtract( wxCoord x
,wxCoord y
,wxCoord vWidth
,wxCoord vHeight
)
{
return Combine( x
,y
,vWidth
,vHeight
,wxRGN_DIFF
);
}
inline bool Subtract(const wxRect& rRect) { return Combine(rRect, wxRGN_DIFF); }
inline bool Subtract(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_DIFF); }
//
// XOR: the union of two combined regions except for any overlapping areas.
//
inline bool Xor( wxCoord x
,wxCoord y
,wxCoord vWidth
,wxCoord vHeight
)
{
return Combine( x
,y
,vWidth
,vHeight
,wxRGN_XOR
);
}
inline bool Xor(const wxRect& rRect) { return Combine(rRect, wxRGN_XOR); }
inline bool Xor(const wxRegion& rRegion) { return Combine(rRegion, wxRGN_XOR); }
//
// Information on region
// Outer bounds of region
//
void GetBox( wxCoord& rX
,wxCoord& rY
,wxCoord& rWidth
,wxCoord& rHeight
) const;
wxRect GetBox(void) const;
// //
// Is region empty? // Is region empty?
// //
bool Empty(void) const; virtual bool IsEmpty() const;
inline bool IsEmpty() const { return Empty(); }
//
// Tests
// Does the region contain the point (x,y)?
//
inline wxRegionContain Contains( wxCoord lX, wxCoord lY ) const{
return Contains( wxPoint( lX, lY ) );
}
//
// Convert the region to a B&W bitmap with the black pixels being inside
// the region.
//
wxBitmap ConvertToBitmap(void) const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
//
// Does the region contain the point pt?
//
wxRegionContain Contains(const wxPoint& rPoint) const;
//
// Does the region contain the rectangle (x, y, w, h)?
//
wxRegionContain Contains( wxCoord x
,wxCoord y
,wxCoord lWidth
,wxCoord lHeight
) const;
//
// Does the region contain the rectangle rect?
//
inline wxRegionContain Contains(const wxRect& rRect) const{
return Contains( rRect.x, rRect.y,
rRect.GetWidth(), rRect.GetHeight());
}
//
// Internal
//
bool Combine( wxCoord x
,wxCoord y
,wxCoord vWidth
,wxCoord vHeight
,wxRegionOp eOp
);
bool Combine( const wxRegion& rRegion
,wxRegionOp eOp
);
bool Combine( const wxRect& rRect
,wxRegionOp eOp
);
// //
// Get internal region handle // Get internal region handle
// //
WXHRGN GetHRGN(void) const; WXHRGN GetHRGN() const;
void SetPS(HPS hPS); void SetPS(HPS hPS);
protected: protected:
virtual wxObjectRefData* CreateData(void) const; virtual wxObjectRefData* CreateData(void) const;
virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const; virtual wxObjectRefData* CloneData(const wxObjectRefData* pData) const;
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoCombine(const wxRegion& region, wxRegionOp op);
friend class WXDLLEXPORT wxRegionIterator; friend class WXDLLEXPORT wxRegionIterator;
DECLARE_DYNAMIC_CLASS(wxRegion); DECLARE_DYNAMIC_CLASS(wxRegion);
@@ -269,5 +111,4 @@ private:
wxRect* m_pRects; wxRect* m_pRects;
}; // end of wxRegionIterator }; // end of wxRegionIterator
#endif #endif // _WX_OS2_REGION_H_
// _WX_REGION_H_

View File

@@ -9,26 +9,10 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_PALMOS_REGION_H_
#define _WX_REGION_H_ #define _WX_PALMOS_REGION_H_
#include "wx/gdiobj.h" class WXDLLEXPORT wxRegion : public wxRegionWithCombine
#include "wx/gdicmn.h"
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxPoint;
// So far, for internal use only
enum wxRegionOp
{
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
class WXDLLEXPORT wxRegion : public wxGDIObject
{ {
public: public:
wxRegion(); wxRegion();
@@ -49,74 +33,9 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
// Modify region // wxRegionBase methods
// ------------- virtual void Clear();
virtual bool IsEmpty() const;
// Clear current region
void Clear();
// Move the region
bool Offset(wxCoord x, wxCoord y);
// Union rectangle or region with this.
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
// Intersect rectangle or region with this.
bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
// Information on region
// ---------------------
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const ;
// Is region empty?
bool Empty() const;
inline bool IsEmpty() const { return Empty(); }
// Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(wxCoord x, wxCoord y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
// Internal
bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op);
// Get internal region handle // Get internal region handle
WXHRGN GetHRGN() const; WXHRGN GetHRGN() const;
@@ -125,6 +44,14 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoCombine(const wxRegion& region, wxRegionOp op);
friend class WXDLLEXPORT wxRegionIterator; friend class WXDLLEXPORT wxRegionIterator;
DECLARE_DYNAMIC_CLASS(wxRegion) DECLARE_DYNAMIC_CLASS(wxRegion)
@@ -146,9 +73,7 @@ public:
bool HaveRects() const { return (m_current < m_numRects); } bool HaveRects() const { return (m_current < m_numRects); }
#ifndef __SALFORDC__
operator bool () const { return HaveRects(); } operator bool () const { return HaveRects(); }
#endif
wxRegionIterator& operator++(); wxRegionIterator& operator++();
wxRegionIterator operator++(int); wxRegionIterator operator++(int);
@@ -174,5 +99,4 @@ private:
DECLARE_DYNAMIC_CLASS(wxRegionIterator) DECLARE_DYNAMIC_CLASS(wxRegionIterator)
}; };
#endif #endif // _WX_PALMOS_REGION_H_
// _WX_REGION_H_

View File

@@ -12,8 +12,18 @@
#ifndef _WX_REGION_H_BASE_ #ifndef _WX_REGION_H_BASE_
#define _WX_REGION_H_BASE_ #define _WX_REGION_H_BASE_
#include "wx/colour.h" #include "wx/bitmap.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
class WXDLLEXPORT wxColour;
class WXDLLEXPORT wxRegion;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// result of wxRegion::Contains() call
enum wxRegionContain enum wxRegionContain
{ {
wxOutRegion = 0, wxOutRegion = 0,
@@ -21,6 +31,199 @@ enum wxRegionContain
wxInRegion = 2 wxInRegion = 2
}; };
// these constants are used with wxRegion::Combine() in the ports which have
// this method
enum wxRegionOp
{
// Creates the intersection of the two combined regions.
wxRGN_AND,
// Creates a copy of the region
wxRGN_COPY,
// Combines the parts of first region that are not in the second one
wxRGN_DIFF,
// Creates the union of two combined regions.
wxRGN_OR,
// Creates the union of two regions except for any overlapping areas.
wxRGN_XOR
};
// ----------------------------------------------------------------------------
// wxRegionBase defines wxRegion API
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxRegionBase : public wxGDIObject
{
public:
// ctors
// -----
// none are defined here but the following should be available:
#if 0
wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
wxRegion(size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE);
wxRegion(const wxBitmap& bmp);
wxRegion(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0);
#endif // 0
// operators
// ---------
bool operator==(const wxRegion& region) const { return IsEqual(region); }
bool operator!=(const wxRegion& region) const { return !(*this == region); }
// accessors
// ---------
bool Ok() const { return m_refData != NULL; }
// Is region empty?
virtual bool IsEmpty() const = 0;
bool Empty() const { return IsEmpty(); }
// Is region equal (i.e. covers the same area as another one)?
bool IsEqual(const wxRegion& region) const;
// Get the bounding box
bool GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
{ return DoGetBox(x, y, w, h); }
wxRect GetBox() const
{
wxCoord x, y, w, h;
return DoGetBox(x, y, w, h) ? wxRect(x, y, w, h) : wxRect();
}
// Test if the given point or rectangle is inside this region
wxRegionContain Contains(wxCoord x, wxCoord y) const
{ return DoContainsPoint(x, y); }
wxRegionContain Contains(const wxPoint& pt) const
{ return DoContainsPoint(pt.x, pt.y); }
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const
{ return DoContainsRect(wxRect(x, y, w, h)); }
wxRegionContain Contains(const wxRect& rect) const
{ return DoContainsRect(rect); }
// operations
// ----------
virtual void Clear() = 0;
// Move the region
bool Offset(wxCoord x, wxCoord y)
{ return DoOffset(x, y); }
bool Offset(const wxPoint& pt)
{ return DoOffset(pt.x, pt.y); }
// Union rectangle or region with this region.
bool Union(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{ return DoUnionWithRect(wxRect(x, y, w, h)); }
bool Union(const wxRect& rect)
{ return DoUnionWithRect(rect); }
bool Union(const wxRegion& region)
{ return DoUnionWithRegion(region); }
#if wxUSE_IMAGE
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp, const wxColour& transp, int tolerance = 0);
#endif // wxUSE_IMAGE
// Intersect rectangle or region with this one.
bool Intersect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{ return Intersect(wxRect(x, y, w, h)); }
bool Intersect(const wxRect& rect);
bool Intersect(const wxRegion& region)
{ return DoIntersect(region); }
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
bool Subtract(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{ return Subtract(wxRect(x, y, w, h)); }
bool Subtract(const wxRect& rect);
bool Subtract(const wxRegion& region)
{ return DoSubtract(region); }
// XOR: the union of two combined regions except for any overlapping areas.
bool Xor(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{ return Xor(wxRect(x, y, w, h)); }
bool Xor(const wxRect& rect);
bool Xor(const wxRegion& region)
{ return DoXor(region); }
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
protected:
virtual bool DoIsEqual(const wxRegion& region) const = 0;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const = 0;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const = 0;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const = 0;
virtual bool DoOffset(wxCoord x, wxCoord y) = 0;
virtual bool DoUnionWithRect(const wxRect& rect) = 0;
virtual bool DoUnionWithRegion(const wxRegion& region) = 0;
virtual bool DoIntersect(const wxRegion& region) = 0;
virtual bool DoSubtract(const wxRegion& region) = 0;
virtual bool DoXor(const wxRegion& region) = 0;
};
// some ports implement a generic Combine() function while others only
// implement individual wxRegion operations, factor out the common code for the
// ports with Combine() in this class
#if defined(__WXPALMOS__) || \
defined(__WXMSW__) || \
defined(__WXMAC__) || \
defined(__WXPM__)
#define wxHAS_REGION_COMBINE
class wxRegionWithCombine : public wxRegionBase
{
public:
// these methods are not part of public API as they're not implemented on
// all ports
bool Combine(wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op)
{ return DoCombine(region, op); }
protected:
// the real Combine() method, to be defined in the derived class
virtual bool DoCombine(const wxRegion& region, wxRegionOp op) = 0;
// implement some wxRegionBase pure virtuals in terms of Combine()
virtual bool DoUnionWithRect(const wxRect& rect)
{ return Combine(rect, wxRGN_OR); }
virtual bool DoUnionWithRegion(const wxRegion& region)
{ return Combine(region, wxRGN_OR); }
virtual bool DoIntersect(const wxRegion& region)
{ return Combine(region, wxRGN_AND); }
virtual bool DoSubtract(const wxRegion& region)
{ return Combine(region, wxRGN_DIFF); }
virtual bool DoXor(const wxRegion& region)
{ return Combine(region, wxRGN_XOR); }
};
#endif // ports with wxRegion::Combine()
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
#include "wx/palmos/region.h" #include "wx/palmos/region.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
@@ -43,5 +246,45 @@ enum wxRegionContain
#include "wx/os2/region.h" #include "wx/os2/region.h"
#endif #endif
#endif // ----------------------------------------------------------------------------
// _WX_REGION_H_BASE_ // inline functions implementation
// ----------------------------------------------------------------------------
// NB: these functions couldn't be defined in the class declaration as they use
// wxRegion and so can be only defined after including the header declaring
// the real class
inline bool wxRegionBase::Intersect(const wxRect& rect)
{
return DoIntersect(wxRegion(rect));
}
inline bool wxRegionBase::Subtract(const wxRect& rect)
{
return DoSubtract(wxRegion(rect));
}
inline bool wxRegionBase::Xor(const wxRect& rect)
{
return DoXor(wxRegion(rect));
}
#ifdef wxHAS_REGION_COMBINE
inline bool wxRegionWithCombine::Combine(wxCoord x,
wxCoord y,
wxCoord w,
wxCoord h,
wxRegionOp op)
{
return DoCombine(wxRegion(x, y, w, h), op);
}
inline bool wxRegionWithCombine::Combine(const wxRect& rect, wxRegionOp op)
{
return DoCombine(wxRegion(rect), op);
}
#endif // wxHAS_REGION_COMBINE
#endif // _WX_REGION_H_BASE_

View File

@@ -1,46 +1,24 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: region.h // Name: wx/x11/region.h
// Purpose: wxRegion class // Purpose: wxRegion class
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 17/09/98 // Created: 17/09/98
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart, Robert Roebling // Copyright: (c) Julian Smart, Robert Roebling
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_ #ifndef _WX_REGION_H_
#define _WX_REGION_H_ #define _WX_REGION_H_
#include "wx/list.h" #include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRegion;
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
// So far, for internal use only
enum wxRegionOp
{
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion // wxRegion
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{ {
public: public:
wxRegion() { } wxRegion() { }
@@ -75,55 +53,9 @@ public:
virtual ~wxRegion(); virtual ~wxRegion();
bool Ok() const { return m_refData != NULL; } // wxRegionBase methods
virtual void Clear();
bool operator == ( const wxRegion& region ) const; virtual bool IsEmpty() const;
bool operator != ( const wxRegion& region ) const { return !(*this == region); }
void Clear();
bool Offset( wxCoord x, wxCoord y );
bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Union( const wxRect& rect );
bool Union( const wxRegion& region );
bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Intersect( const wxRect& rect );
bool Intersect( const wxRegion& region );
bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Subtract( const wxRect& rect );
bool Subtract( const wxRegion& region );
bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
bool Xor( const wxRect& rect );
bool Xor( const wxRegion& region );
void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const;
wxRect GetBox() const ;
bool Empty() const;
bool IsEmpty() const { return Empty(); }
wxRegionContain Contains( wxCoord x, wxCoord y ) const;
wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const;
wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const;
// Convert the region to a B&W bitmap with the white pixels being inside
// the region.
wxBitmap ConvertToBitmap() const;
// Use the non-transparent pixels of a wxBitmap for the region to combine
// with this region. First version takes transparency from bitmap's mask,
// second lets the user specify the colour to be treated as transparent
// along with an optional tolerance value.
// NOTE: implemented in common/rgncmn.cpp
bool Union(const wxBitmap& bmp);
bool Union(const wxBitmap& bmp,
const wxColour& transColour, int tolerance = 0);
public: public:
WXRegion *GetX11Region() const; WXRegion *GetX11Region() const;
@@ -133,6 +65,19 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxRegionBase pure virtuals
virtual bool DoIsEqual(const wxRegion& region) const;
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
virtual wxRegionContain DoContainsPoint(wxCoord x, wxCoord y) const;
virtual wxRegionContain DoContainsRect(const wxRect& rect) const;
virtual bool DoOffset(wxCoord x, wxCoord y);
virtual bool DoUnionWithRect(const wxRect& rect);
virtual bool DoUnionWithRegion(const wxRegion& region);
virtual bool DoIntersect(const wxRegion& region);
virtual bool DoSubtract(const wxRegion& region);
virtual bool DoXor(const wxRegion& region);
// common part of ctors for a rectangle region // common part of ctors for a rectangle region
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);

View File

@@ -9,6 +9,10 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
@@ -24,8 +28,36 @@
#include "wx/image.h" #include "wx/image.h"
#endif //WX_PRECOMP #endif //WX_PRECOMP
// ============================================================================
// wxRegionBase implementation
// ============================================================================
wxBitmap wxRegion::ConvertToBitmap() const // ----------------------------------------------------------------------------
// region comparision
// ----------------------------------------------------------------------------
bool wxRegionBase::IsEqual(const wxRegion& region) const
{
if ( m_refData == region.m_refData )
{
// regions are identical, hence equal
return true;
}
if ( !m_refData || !region.m_refData )
{
// one, but not both, of the regions is invalid
return false;
}
return DoIsEqual(region);
}
// ----------------------------------------------------------------------------
// region to/from bitmap conversions
// ----------------------------------------------------------------------------
wxBitmap wxRegionBase::ConvertToBitmap() const
{ {
wxRect box = GetBox(); wxRect box = GetBox();
wxBitmap bmp(box.GetRight(), box.GetBottom()); wxBitmap bmp(box.GetRight(), box.GetBottom());
@@ -33,17 +65,16 @@ wxBitmap wxRegion::ConvertToBitmap() const
dc.SelectObject(bmp); dc.SelectObject(bmp);
dc.SetBackground(*wxBLACK_BRUSH); dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear(); dc.Clear();
dc.SetClippingRegion(*this); dc.SetClippingRegion(*wx_static_cast(const wxRegion *, this));
dc.SetBackground(*wxWHITE_BRUSH); dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear(); dc.Clear();
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
return bmp; return bmp;
} }
//---------------------------------------------------------------------------
#if wxUSE_IMAGE #if wxUSE_IMAGE
static bool DoRegionUnion(wxRegion& region,
static bool DoRegionUnion(wxRegionBase& region,
const wxImage& image, const wxImage& image,
unsigned char loR, unsigned char loR,
unsigned char loG, unsigned char loG,
@@ -95,9 +126,8 @@ static bool DoRegionUnion(wxRegion& region,
} }
bool wxRegion::Union(const wxBitmap& bmp) bool wxRegionBase::Union(const wxBitmap& bmp)
{ {
#if (!defined(__WXMSW__) || wxUSE_WXDIB)
if (bmp.GetMask()) if (bmp.GetMask())
{ {
wxImage image = bmp.ConvertToImage(); wxImage image = bmp.ConvertToImage();
@@ -109,42 +139,21 @@ bool wxRegion::Union(const wxBitmap& bmp)
0); 0);
} }
else else
#endif
{ {
return Union(0, 0, bmp.GetWidth(), bmp.GetHeight()); return Union(0, 0, bmp.GetWidth(), bmp.GetHeight());
} }
} }
bool wxRegion::Union(const wxBitmap& bmp, bool wxRegionBase::Union(const wxBitmap& bmp,
const wxColour& transColour, const wxColour& transColour,
int tolerance) int tolerance)
{ {
#if (!defined(__WXMSW__) || wxUSE_WXDIB)
wxImage image = bmp.ConvertToImage(); wxImage image = bmp.ConvertToImage();
return DoRegionUnion(*this, image, return DoRegionUnion(*this, image,
transColour.Red(), transColour.Red(),
transColour.Green(), transColour.Green(),
transColour.Blue(), transColour.Blue(),
tolerance); tolerance);
#else
return false;
#endif
} }
#else #endif // wxUSE_IMAGE
bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp))
{
// No wxImage support
return false;
}
bool wxRegion::Union(const wxBitmap& WXUNUSED(bmp),
const wxColour& WXUNUSED(transColour),
int WXUNUSED(tolerance))
{
// No wxImage support
return false;
}
#endif

View File

@@ -80,42 +80,30 @@ wxRegion::~wxRegion()
// m_refData unrefed in ~wxObject // m_refData unrefed in ~wxObject
} }
bool wxRegion::operator==(const wxRegion& region) const
{
if ( m_refData == region.m_refData )
return true;
if ( !Ok() )
{
// only equal if both are invalid, otherwise different
return !region.Ok();
}
return M_REGION->m_rect == M_REGION_OF(region)->m_rect;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Information about the region // Information about the region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const bool wxRegion::DoIsEqual(const wxRegion& region) const
{ {
wxRect r = GetBox(); return M_REGION->m_rect == M_REGION_OF(region)->m_rect;
}
bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
if ( !m_refData )
return false;
const wxRect& r = M_REGION->m_rect;
x = r.GetX(); x = r.GetX();
y = r.GetY(); y = r.GetY();
w = r.GetWidth(); w = r.GetWidth();
h = r.GetHeight(); h = r.GetHeight();
return true;
} }
wxRect wxRegion::GetBox() const bool wxRegion::IsEmpty() const
{
if (m_refData)
return M_REGION->m_rect;
else
return wxRect();
}
bool wxRegion::Empty() const
{ {
if (!m_refData) if (!m_refData)
return true; return true;
@@ -132,14 +120,14 @@ void wxRegion::Clear()
UnRef(); UnRef();
} }
bool wxRegion::Offset(wxCoord x, wxCoord y) bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{ {
AllocExclusive(); AllocExclusive();
M_REGION->m_rect.Offset(x, y); M_REGION->m_rect.Offset(x, y);
return true; return true;
} }
bool wxRegion::Union(const wxRect& rect) bool wxRegion::DoUnionWithRect(const wxRect& rect)
{ {
AllocExclusive(); AllocExclusive();
@@ -159,29 +147,28 @@ bool wxRegion::Union(const wxRect& rect)
} }
} }
bool wxRegion::Union(const wxRegion& region) bool wxRegion::DoUnionWithRegion(const wxRegion& region)
{ {
wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Union(M_REGION_OF(region)->m_rect); return DoUnionWithRect(M_REGION_OF(region)->m_rect);
} }
bool wxRegion::Intersect(const wxRect& rect) bool wxRegion::DoIntersect(const wxRegion& region)
{ {
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
AllocExclusive(); AllocExclusive();
M_REGION->m_rect.Intersect(rect); M_REGION->m_rect.Intersect(M_REGION_OF(region)->m_rect);
return true; return true;
} }
bool wxRegion::Intersect(const wxRegion& region) bool wxRegion::DoSubtract(const wxRegion& region)
{ {
wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Intersect(M_REGION_OF(region)->m_rect);
}
bool wxRegion::Subtract(const wxRect& rect)
{
wxCHECK_MSG( Ok(), false, _T("invalid region") ); wxCHECK_MSG( Ok(), false, _T("invalid region") );
const wxRect& rect = M_REGION_OF(region)->m_rect;
if ( rect.Contains(M_REGION->m_rect) ) if ( rect.Contains(M_REGION->m_rect) )
{ {
// subtracted rectangle contains this one, so the result is empty // subtracted rectangle contains this one, so the result is empty
@@ -201,30 +188,19 @@ bool wxRegion::Subtract(const wxRect& rect)
} }
} }
bool wxRegion::Subtract(const wxRegion& region) bool wxRegion::DoXor(const wxRegion& region)
{ {
wxCHECK_MSG( region.Ok(), false, _T("invalid region") ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Subtract(M_REGION_OF(region)->m_rect);
}
bool wxRegion::Xor(const wxRect& rect)
{
wxFAIL_MSG( _T("Xor not implemented") ); wxFAIL_MSG( _T("Xor not implemented") );
return false; return false;
} }
bool wxRegion::Xor(const wxRegion& region)
{
wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Xor(M_REGION_OF(region)->m_rect);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Tests // Tests
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{ {
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") ); wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );
@@ -234,7 +210,7 @@ wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains(const wxRect& rect) const wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{ {
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") ); wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );

View File

@@ -286,100 +286,72 @@ wxObjectRefData *wxRegionGeneric::CloneRefData(const wxObjectRefData *data) cons
return new wxRegionRefData(*(wxRegionRefData *)data); 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)); 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); if ( !m_refData )
wxRect rect; return false;
REGION::XClipBox(M_REGIONDATA,&rect);
return rect;
}
void wxRegionGeneric::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
wxASSERT(m_refData);
wxRect rect; wxRect rect;
REGION::XClipBox(M_REGIONDATA,&rect); REGION::XClipBox(M_REGIONDATA,&rect);
x = rect.x; x = rect.x;
y = rect.y; y = rect.y;
w = rect.width; w = rect.width;
h = rect.height; h = rect.height;
return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegionGeneric operations // wxRegionGeneric operations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegionGeneric::Union(const wxRect& rect) bool wxRegionGeneric::DoUnionWithRect(const wxRect& rect)
/* XUnionRectWithRegion */
{ {
if (!rect.width || !rect.height) if ( rect.IsEmpty() )
return false; {
// nothing to do
return true;
}
AllocExclusive(); AllocExclusive();
REGION region(rect); REGION region(rect);
return REGION::XUnionRegion(&region,M_REGIONDATA,M_REGIONDATA); return REGION::XUnionRegion(&region,M_REGIONDATA,M_REGIONDATA);
} }
bool wxRegionGeneric::Union(const wxRegionGeneric& region) bool wxRegionGeneric::DoUnionWithRegion(const wxRegionGeneric& region)
{ {
AllocExclusive(); AllocExclusive();
return REGION::XUnionRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); return REGION::XUnionRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
} }
bool wxRegionGeneric::Intersect(const wxRect& rect) bool wxRegionGeneric::DoIntersect(const wxRegionGeneric& region)
{
if (!rect.width || !rect.height)
return false;
AllocExclusive();
REGION region(rect);
return REGION::XIntersectRegion(&region,M_REGIONDATA,M_REGIONDATA);
}
bool wxRegionGeneric::Intersect(const wxRegionGeneric& region)
{ {
AllocExclusive(); AllocExclusive();
return REGION::XIntersectRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); return REGION::XIntersectRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
} }
bool wxRegionGeneric::Subtract(const wxRect& rect) bool wxRegionGeneric::DoSubtract(const wxRegionGeneric& region)
{ {
if (!rect.width || !rect.height) if ( region.IsEmpty() )
return false; {
AllocExclusive(); // nothing to do
REGION region(rect); return true;
}
return REGION::XSubtractRegion(&region,M_REGIONDATA,M_REGIONDATA);
}
bool wxRegionGeneric::Subtract(const wxRegionGeneric& region)
{
return REGION::XSubtractRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); return REGION::XSubtractRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
} }
bool wxRegionGeneric::Xor(const wxRect& rect) bool wxRegionGeneric::DoXor(const wxRegionGeneric& region)
{
if (!rect.width || !rect.height)
return false;
AllocExclusive();
REGION region(rect);
return REGION::XXorRegion(&region,M_REGIONDATA,M_REGIONDATA);
}
bool wxRegionGeneric::Xor(const wxRegionGeneric& region)
{ {
AllocExclusive(); AllocExclusive();
return REGION::XXorRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA); 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(); AllocExclusive();
return REGION::XOffsetRegion(M_REGIONDATA, x, y); return REGION::XOffsetRegion(M_REGIONDATA, x, y);
@@ -389,35 +361,21 @@ bool wxRegionGeneric::Offset(wxCoord x, wxCoord y)
// wxRegionGeneric comparison // wxRegionGeneric comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegionGeneric::Empty() const bool wxRegionGeneric::IsEmpty() const
{ {
wxASSERT(m_refData); wxASSERT(m_refData);
return REGION::XEmptyRegion(M_REGIONDATA); return REGION::XEmptyRegion(M_REGIONDATA);
} }
// Does the region contain the point (x,y)? // Does the region contain the point (x,y)?
wxRegionContain wxRegionGeneric::Contains(long x, long y) const wxRegionContain wxRegionGeneric::DoContainsPoint(long x, long y) const
{ {
wxASSERT(m_refData); wxASSERT(m_refData);
return REGION::XPointInRegion(M_REGIONDATA,x,y)?wxInRegion:wxOutRegion; 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
{
wxASSERT(m_refData);
return REGION::XRectInRegion(M_REGIONDATA,x,y,w,h);
} }
// Does the region contain the rectangle rect? // Does the region contain the rectangle rect?
wxRegionContain wxRegionGeneric::Contains(const wxRect& rect) const wxRegionContain wxRegionGeneric::DoContainsRect(const wxRect& rect) const
{ {
wxASSERT(m_refData); wxASSERT(m_refData);
return REGION::XRectInRegion(M_REGIONDATA,rect.x,rect.y,rect.width,rect.height); return REGION::XRectInRegion(M_REGIONDATA,rect.x,rect.y,rect.width,rect.height);

View File

@@ -133,13 +133,8 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
// wxRegion comparison // wxRegion comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegion::operator==( const wxRegion& region ) const bool wxRegion::DoIsEqual(const wxRegion& region) const
{ {
if (m_refData == region.m_refData) return true;
if (!m_refData || !region.m_refData) return false;
// compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
} }
@@ -153,27 +148,27 @@ void wxRegion::Clear()
UnRef(); UnRef();
} }
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoUnionWithRect(const wxRect& r)
{ {
// workaround for a strange GTK/X11 bug: taking union with an empty // workaround for a strange GTK/X11 bug: taking union with an empty
// rectangle results in an empty region which is definitely not what we // rectangle results in an empty region which is definitely not what we
// want // want
if ( !width || !height ) if ( r.IsEmpty() )
return true; return true;
if ( !m_refData ) if ( !m_refData )
{ {
InitRect(x, y, width, height); InitRect(r.x, r.y, r.width, r.height);
} }
else else
{ {
AllocExclusive(); AllocExclusive();
GdkRectangle rect; GdkRectangle rect;
rect.x = x; rect.x = r.x;
rect.y = y; rect.y = r.y;
rect.width = width; rect.width = r.width;
rect.height = height; rect.height = r.height;
gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
} }
@@ -181,15 +176,9 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
return true; return true;
} }
bool wxRegion::Union( const wxRect& rect ) bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{ {
return Union( rect.x, rect.y, rect.width, rect.height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
}
bool wxRegion::Union( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -206,24 +195,9 @@ bool wxRegion::Union( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoIntersect( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRect& rect )
{
wxRegion reg( rect );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -238,22 +212,9 @@ bool wxRegion::Intersect( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoSubtract( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRect& rect )
{
wxRegion reg( rect );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -268,22 +229,9 @@ bool wxRegion::Subtract( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoXor( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Xor( reg );
}
bool wxRegion::Xor( const wxRect& rect )
{
wxRegion reg( rect );
return Xor( reg );
}
bool wxRegion::Xor( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -297,7 +245,7 @@ bool wxRegion::Xor( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Offset( wxCoord x, wxCoord y ) bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{ {
if (!m_refData) if (!m_refData)
return false; return false;
@@ -313,7 +261,7 @@ bool wxRegion::Offset( wxCoord x, wxCoord y )
// wxRegion tests // wxRegion tests
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
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 ) if ( m_refData )
{ {
@@ -323,6 +271,8 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = rect.y; y = rect.y;
w = rect.width; w = rect.width;
h = rect.height; h = rect.height;
return true;
} }
else else
{ {
@@ -330,17 +280,12 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = 0; y = 0;
w = -1; w = -1;
h = -1; h = -1;
return false;
} }
} }
wxRect wxRegion::GetBox() const bool wxRegion::IsEmpty() const
{
wxCoord x, y, w, h;
GetBox( x, y, w, h );
return wxRect( x, y, w, h );
}
bool wxRegion::Empty() const
{ {
if (!m_refData) if (!m_refData)
return true; return true;
@@ -348,7 +293,7 @@ bool wxRegion::Empty() const
return gdk_region_empty( M_REGIONDATA->m_region ); return gdk_region_empty( M_REGIONDATA->m_region );
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
@@ -359,16 +304,16 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
GdkRectangle rect; GdkRectangle rect;
rect.x = x; rect.x = r.x;
rect.y = y; rect.y = r.y;
rect.width = w; rect.width = r.width;
rect.height = h; rect.height = r.height;
GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect ); GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
switch (res) switch (res)
{ {
@@ -379,16 +324,6 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains(const wxPoint& pt) const
{
return Contains( pt.x, pt.y );
}
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
return Contains( rect.x, rect.y, rect.width, rect.height );
}
GdkRegion *wxRegion::GetRegion() const GdkRegion *wxRegion::GetRegion() const
{ {
if (!m_refData) if (!m_refData)

View File

@@ -150,13 +150,8 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
// wxRegion comparison // wxRegion comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegion::operator==( const wxRegion& region ) const bool wxRegion::DoIsEqual(const wxRegion& region) const
{ {
if (m_refData == region.m_refData) return TRUE;
if (!m_refData || !region.m_refData) return FALSE;
// compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
} }
@@ -170,42 +165,35 @@ void wxRegion::Clear()
UnRef(); UnRef();
} }
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoUnionWithRect(const wxRect& r)
{ {
// workaround for a strange GTK/X11 bug: taking union with an empty // workaround for a strange GTK/X11 bug: taking union with an empty
// rectangle results in an empty region which is definitely not what we // rectangle results in an empty region which is definitely not what we
// want // want
if ( !width || !height ) if ( r.IsEmpty() )
return TRUE; return TRUE;
if ( !m_refData ) if ( !m_refData )
{ {
InitRect(x, y, width, height); InitRect(r.x, r.y, r.width, r.height);
} }
else else
{ {
AllocExclusive(); AllocExclusive();
GdkRectangle rect; GdkRectangle rect;
rect.x = x; rect.x = r.x;
rect.y = y; rect.y = r.y;
rect.width = width; rect.width = r.width;
rect.height = height; rect.height = r.height;
GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
} }
return TRUE; return TRUE;
} }
bool wxRegion::Union( const wxRect& rect ) bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
return Union( rect.x, rect.y, rect.width, rect.height );
}
bool wxRegion::Union( const wxRegion& region )
{ {
if (region.IsNull()) if (region.IsNull())
return FALSE; return FALSE;
@@ -227,24 +215,9 @@ bool wxRegion::Union( const wxRegion& region )
return TRUE; return TRUE;
} }
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoIntersect( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRect& rect )
{
wxRegion reg( rect );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRegion& region )
{
if (region.IsNull())
return FALSE;
if (!m_refData) if (!m_refData)
{ {
@@ -261,22 +234,9 @@ bool wxRegion::Intersect( const wxRegion& region )
return TRUE; return TRUE;
} }
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoSubtract( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRect& rect )
{
wxRegion reg( rect );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRegion& region )
{
if (region.IsNull())
return FALSE;
if (!m_refData) if (!m_refData)
{ {
@@ -293,22 +253,9 @@ bool wxRegion::Subtract( const wxRegion& region )
return TRUE; return TRUE;
} }
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoXor( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Xor( reg );
}
bool wxRegion::Xor( const wxRect& rect )
{
wxRegion reg( rect );
return Xor( reg );
}
bool wxRegion::Xor( const wxRegion& region )
{
if (region.IsNull())
return FALSE;
if (!m_refData) if (!m_refData)
{ {
@@ -324,7 +271,7 @@ bool wxRegion::Xor( const wxRegion& region )
return TRUE; return TRUE;
} }
bool wxRegion::Offset( wxCoord x, wxCoord y ) bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{ {
if (!m_refData) if (!m_refData)
return FALSE; return FALSE;
@@ -340,7 +287,7 @@ bool wxRegion::Offset( wxCoord x, wxCoord y )
// wxRegion tests // wxRegion tests
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
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 ) if ( m_refData )
{ {
@@ -350,6 +297,8 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = rect.y; y = rect.y;
w = rect.width; w = rect.width;
h = rect.height; h = rect.height;
return true;
} }
else else
{ {
@@ -357,17 +306,12 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = 0; y = 0;
w = -1; w = -1;
h = -1; h = -1;
return false;
} }
} }
wxRect wxRegion::GetBox() const bool wxRegion::IsEmpty() const
{
wxCoord x, y, w, h;
GetBox( x, y, w, h );
return wxRect( x, y, w, h );
}
bool wxRegion::Empty() const
{ {
if (!m_refData) if (!m_refData)
return TRUE; return TRUE;
@@ -375,7 +319,7 @@ bool wxRegion::Empty() const
return gdk_region_empty( M_REGIONDATA->m_region ); return gdk_region_empty( M_REGIONDATA->m_region );
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
@@ -386,16 +330,16 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
GdkRectangle rect; GdkRectangle rect;
rect.x = x; rect.x = r.x;
rect.y = y; rect.y = r.y;
rect.width = w; rect.width = r.width;
rect.height = h; rect.height = r.height;
GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect ); GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
switch (res) switch (res)
{ {
@@ -406,16 +350,6 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains(const wxPoint& pt) const
{
return Contains( pt.x, pt.y );
}
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
return Contains( rect.x, rect.y, rect.width, rect.height );
}
GdkRegion *wxRegion::GetRegion() const GdkRegion *wxRegion::GetRegion() const
{ {
if (!m_refData) if (!m_refData)

View File

@@ -142,7 +142,7 @@ void wxRegion::Clear()
} }
// Move the region // Move the region
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") );
@@ -156,58 +156,10 @@ bool wxRegion::Offset(wxCoord x, wxCoord y)
} }
//! Combine rectangle (x, y, w, h) with this.
bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op)
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxRegionRefData();
}
else if (m_refData->GetRefCount() > 1)
{
wxRegionRefData* ref = (wxRegionRefData*)m_refData;
UnRef();
m_refData = new wxRegionRefData( *ref );
}
RgnHandle rgn = NewRgn() ;
SetRectRgn( rgn , x , y, x + width, y + height ) ;
switch (op)
{
case wxRGN_AND:
SectRgn( M_REGION , rgn , M_REGION ) ;
break ;
case wxRGN_OR:
UnionRgn( M_REGION , rgn , M_REGION ) ;
break ;
case wxRGN_XOR:
XorRgn( M_REGION , rgn , M_REGION ) ;
break ;
case wxRGN_DIFF:
DiffRgn( M_REGION , rgn , M_REGION ) ;
break ;
case wxRGN_COPY:
default:
CopyRgn( rgn , M_REGION ) ;
break ;
}
DisposeRgn( rgn ) ;
return true;
}
//! Union /e region with this. //! Union /e region with this.
bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op)
{ {
if (region.Empty()) wxCHECK_MSG( region.Ok(), false, _T("invalid wxRegion") );
return false;
// Don't change shared data // Don't change shared data
if (!m_refData) if (!m_refData)
@@ -248,17 +200,19 @@ bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
return true; return true;
} }
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
{
return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//# Information on region //# Information on region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
wxFAIL_MSG( _T("not implemented") );
return false;
}
// Outer bounds of region // 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) if (m_refData)
{ {
@@ -268,23 +222,19 @@ void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
y = box.top ; y = box.top ;
w = box.right - box.left ; w = box.right - box.left ;
h = box.bottom - box.top ; h = box.bottom - box.top ;
return true;
} }
else else
{ {
x = y = w = h = 0; x = y = w = h = 0;
return false;
} }
} }
wxRect wxRegion::GetBox() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return wxRect(x, y, w, h);
}
// Is region empty? // Is region empty?
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
if ( m_refData ) if ( m_refData )
return EmptyRgn( M_REGION ) ; return EmptyRgn( M_REGION ) ;
@@ -301,26 +251,13 @@ const WXHRGN wxRegion::GetWXHRGN() const
//# Tests //# Tests
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
wxRegionContain wxRegion::Contains(long x, long y) const
{
if (!m_refData)
return wxOutRegion;
// TODO. Return wxInRegion if within region.
// if (0)
// return wxInRegion;
return wxOutRegion;
}
// Does the region contain the point? // Does the region contain the point?
wxRegionContain wxRegion::Contains(const wxPoint& pt) const wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
Point p = { pt.y , pt.x } ; Point p = { y , x } ;
if (PtInRgn( p , M_REGION ) ) if (PtInRgn( p , M_REGION ) )
return wxInRegion; return wxInRegion;
@@ -328,34 +265,18 @@ wxRegionContain wxRegion::Contains(const wxPoint& pt) const
} }
// Does the region contain the rectangle (x, y, w, h)? // Does the region contain the rectangle (x, y, w, h)?
wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
Rect rect = { y , x , y + h , x + w } ; Rect rect = { r.y , r.x , r.y + r.h , r.x + r.w } ;
if (RectInRgn( &rect , M_REGION ) ) if (RectInRgn( &rect , M_REGION ) )
return wxInRegion; return wxInRegion;
else else
return wxOutRegion; return wxOutRegion;
} }
// Does the region contain the rectangle rect
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
if (!m_refData)
return wxOutRegion;
long x, y, w, h;
x = rect.x;
y = rect.y;
w = rect.GetWidth();
h = rect.GetHeight();
return Contains(x, y, w, h);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// // // //
// wxRegionIterator // // wxRegionIterator //
@@ -479,7 +400,7 @@ void wxRegionIterator::Reset(const wxRegion& region)
m_rects = NULL; m_rects = NULL;
} }
if (m_region.Empty()) if (m_region.IsEmpty())
{ {
m_numRects = 0; m_numRects = 0;
} }

View File

@@ -127,8 +127,15 @@ void wxRegion::Clear()
// Information on region // Information on region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
wxFAIL_MSG( _T("not implemented") );
return false;
}
// Outer bounds of region // 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) if (m_refData)
{ {
@@ -138,22 +145,18 @@ void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
y = rect.top; y = rect.top;
w = rect.right - rect.left; w = rect.right - rect.left;
h = rect.bottom - rect.top; h = rect.bottom - rect.top;
return true;
} }
else else
{ {
x = y = w = h = 0; x = y = w = h = 0;
return false;
} }
} }
wxRect wxRegion::GetBox() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return wxRect(x, y, w, h);
}
// Is region empty? // Is region empty?
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
if (!m_refData) if (!m_refData)
return true; return true;
@@ -165,7 +168,7 @@ bool wxRegion::Empty() const
// Modifications // Modifications
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool wxRegion::Offset(wxCoord x, wxCoord y) bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{ {
AllocExclusive(); AllocExclusive();
M_REGION.offset(x, y); M_REGION.offset(x, y);
@@ -173,63 +176,35 @@ bool wxRegion::Offset(wxCoord x, wxCoord y)
} }
// Union rectangle or region with this. // Union rectangle or region with this.
bool wxRegion::Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) bool wxRegion::DoUnionWithRect(const wxRect& r)
{ {
AllocExclusive(); AllocExclusive();
M_REGION += MGLRect(x, y, x + width, y + height); M_REGION += MGLRect(r.x, r.y, r.GetRight() + 1, r.GetHeight() + 1);
return true; return true;
} }
bool wxRegion::Union(const wxRegion& region) bool wxRegion::DoUnionWithRegion(const wxRegion& region)
{ {
AllocExclusive(); AllocExclusive();
M_REGION += M_REGION_OF(region); M_REGION += M_REGION_OF(region);
return true; return true;
} }
// Intersect rectangle or region with this. bool wxRegion::DoIntersect(const wxRegion& region)
bool wxRegion::Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
AllocExclusive();
M_REGION &= MGLRect(x, y, x + width, y + height);
return true;
}
bool wxRegion::Intersect(const wxRegion& region)
{ {
AllocExclusive(); AllocExclusive();
M_REGION &= M_REGION_OF(region); M_REGION &= M_REGION_OF(region);
return true; return true;
} }
// Subtract rectangle or region from this: bool wxRegion::DoSubtract(const wxRegion& region)
// Combines the parts of 'this' that are not part of the second region.
bool wxRegion::Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
AllocExclusive();
M_REGION -= MGLRect(x, y, x + width, y + height);
return true;
}
bool wxRegion::Subtract(const wxRegion& region)
{ {
AllocExclusive(); AllocExclusive();
M_REGION -= M_REGION_OF(region); M_REGION -= M_REGION_OF(region);
return true; return true;
} }
// XOR: the union of two combined regions except for any overlapping areas. bool wxRegion::DoXor(const wxRegion& region)
bool wxRegion::Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
AllocExclusive();
MGLRect rect(x, y, x + width, y + height);
MGLRegion rg1 = M_REGION + rect,
rg2 = M_REGION & rect;
M_REGION = rg1 - rg2;
return true;
}
bool wxRegion::Xor(const wxRegion& region)
{ {
AllocExclusive(); AllocExclusive();
MGLRegion rg1 = M_REGION + M_REGION_OF(region), MGLRegion rg1 = M_REGION + M_REGION_OF(region),
@@ -244,7 +219,7 @@ bool wxRegion::Xor(const wxRegion& region)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Does the region contain the point (x,y)? // 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) if (!m_refData)
return wxOutRegion; return wxOutRegion;
@@ -255,40 +230,29 @@ wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
return wxOutRegion; return 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)? // 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& r) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
MGLRect rect(x, y, x + w, y + h); MGLRect rect(r.x, r.y, r.GetRight() + 1, r.GetBottom() + 1);
MGLRegion rg; MGLRegion rg;
// 1) is the rectangle entirely covered by the region? // 1) is the rectangle entirely covered by the region?
rg = MGLRegion(rect) - M_REGION; rg = MGLRegion(rect) - M_REGION;
if (rg.isEmpty()) return wxInRegion; if (rg.isEmpty())
return wxInRegion;
// 2) is the rectangle completely outside the region? // 2) is the rectangle completely outside the region?
rg = M_REGION & rect; // intersection rg = M_REGION & rect; // intersection
if (rg.isEmpty()) return wxOutRegion; if (rg.isEmpty())
return wxOutRegion;
// 3) neither case happened => it is partially covered: // 3) neither case happened => it is partially covered:
return wxPartRegion; return wxPartRegion;
} }
// Does the region contain the rectangle rect
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
return Contains(rect.x, rect.y, rect.width, rect.height);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// wxRegionIterator // // wxRegionIterator //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@@ -163,7 +163,7 @@ void wxRegion::Clear()
UnRef(); 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") );
@@ -186,7 +186,7 @@ bool wxRegion::Offset(wxCoord x, wxCoord y)
} }
// combine another region with this one // 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 // we can't use the API functions if we don't have a valid region handle
if ( !m_refData ) if ( !m_refData )
@@ -254,26 +254,12 @@ bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op)
return true; 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);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion bounding box // wxRegion bounding box
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Outer bounds of region // 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) if (m_refData)
{ {
@@ -283,22 +269,19 @@ void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
y = rect.top; y = rect.top;
w = rect.right - rect.left; w = rect.right - rect.left;
h = rect.bottom - rect.top; h = rect.bottom - rect.top;
return true;
} }
else else
{ {
x = y = w = h = 0; x = y = w = h = 0;
return false;
} }
} }
wxRect wxRegion::GetBox() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return wxRect(x, y, w, h);
}
// Is region empty? // Is region empty?
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
wxCoord x, y, w, h; wxCoord x, y, w, h;
GetBox(x, y, w, h); GetBox(x, y, w, h);
@@ -306,12 +289,17 @@ bool wxRegion::Empty() const
return (w == 0) && (h == 0); return (w == 0) && (h == 0);
} }
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
return ::EqualRgn(M_REGION, M_REGION_OF(region)) != 0;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion hit testing // wxRegion hit testing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Does the region contain the point (x,y)? // 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) if (!m_refData)
return wxOutRegion; return wxOutRegion;
@@ -319,32 +307,16 @@ wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
return ::PtInRegion(M_REGION, (int) x, (int) y) ? wxInRegion : 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)? // Does the region contain the rectangle (x, y, w, h)?
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
wxCoord w, wxCoord h) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
RECT rect; RECT rc;
rect.left = x; wxCopyRectToRECT(rect, rc);
rect.top = y;
rect.right = x + w;
rect.bottom = y + h;
return ::RectInRegion(M_REGION, &rect) ? wxInRegion : wxOutRegion; return ::RectInRegion(M_REGION, &rc) ? 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);
} }
// Get internal region handle // Get internal region handle

View File

@@ -246,7 +246,7 @@ wxObjectRefData *wxRegion::CloneData(const wxObjectRefData *data) const
//# Modify region //# Modify region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool wxRegion::Offset( wxCoord x, wxCoord y ) bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{ {
if ( !x && !y ) if ( !x && !y )
{ {
@@ -275,24 +275,10 @@ void wxRegion::Clear()
UnRef(); UnRef();
} // end of wxRegion::Clear } // end of wxRegion::Clear
//
// Combine rectangle (x, y, w, h) with this.
//
bool wxRegion::Combine(
wxCoord x
, wxCoord y
, wxCoord vWidth
, wxCoord vHeight
, wxRegionOp eOp
)
{
return Combine(wxRegion(x, y, vWidth, vHeight), eOp);
} // end of wxRegion::Combine
// //
// Union region with this. // Union region with this.
// //
bool wxRegion::Combine( const wxRegion& rRegion, wxRegionOp eOp ) bool wxRegion::DoCombine( const wxRegion& rRegion, wxRegionOp eOp )
{ {
// //
// We can't use the API functions if we don't have a valid region handle // We can't use the API functions if we don't have a valid region handle
@@ -357,27 +343,19 @@ bool wxRegion::Combine( const wxRegion& rRegion, wxRegionOp eOp )
return true; return true;
} // end of wxRegion::Combine } // end of wxRegion::Combine
bool wxRegion::Combine(
const wxRect& rRect
, wxRegionOp eOp
)
{
return Combine( rRect.GetLeft()
,rRect.GetTop()
,rRect.GetWidth()
,rRect.GetHeight()
,eOp
);
} // end of wxRegion::Combine
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//# Information on region //# Information on region
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
return false;
}
// //
// Outer bounds of region // Outer bounds of region
// //
void wxRegion::GetBox( bool wxRegion::DoGetBox(
wxCoord& x wxCoord& x
, wxCoord& y , wxCoord& y
, wxCoord& vWidth , wxCoord& vWidth
@@ -397,24 +375,19 @@ void wxRegion::GetBox(
y = vRect.yBottom; y = vRect.yBottom;
vWidth = vRect.xRight - vRect.xLeft; vWidth = vRect.xRight - vRect.xLeft;
vHeight = vRect.yTop - vRect.yBottom; vHeight = vRect.yTop - vRect.yBottom;
return true;
} }
else else
{ {
x = y = vWidth = vHeight = 0L; x = y = vWidth = vHeight = 0L;
return false;
} }
} // end of wxRegion::GetBox } // end of wxRegion::GetBox
wxRect wxRegion::GetBox() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return wxRect(x, y, w, h);
}
// //
// Is region empty? // Is region empty?
// //
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
wxCoord x; wxCoord x;
wxCoord y; wxCoord y;
@@ -430,7 +403,7 @@ bool wxRegion::Empty() const
,vHeight ,vHeight
); );
return ((vWidth == 0) && (vHeight == 0)); return ((vWidth == 0) && (vHeight == 0));
} // end of wxRegion::Empty } // end of wxRegion::IsEmpty
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Tests // Tests
@@ -438,7 +411,7 @@ bool wxRegion::Empty() const
// //
// Does the region contain the point pt? // Does the region contain the point pt?
// //
wxRegionContain wxRegion::Contains( const wxPoint& rPoint ) const wxRegionContain wxRegion::DoContainsPoint( const wxPoint& rPoint ) const
{ {
POINTL vPoint = { rPoint.x, rPoint.y }; POINTL vPoint = { rPoint.x, rPoint.y };
@@ -448,7 +421,7 @@ wxRegionContain wxRegion::Contains( const wxPoint& rPoint ) const
LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS, LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
M_REGION, M_REGION,
&vPoint &vPoint
); );
if (lInside == PRGN_INSIDE) if (lInside == PRGN_INSIDE)
return wxInRegion; return wxInRegion;
else else
@@ -458,23 +431,20 @@ wxRegionContain wxRegion::Contains( const wxPoint& rPoint ) const
// //
// Does the region contain the rectangle (x, y, w, h)? // Does the region contain the rectangle (x, y, w, h)?
// //
wxRegionContain wxRegion::Contains( wxCoord x, wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
wxCoord y,
wxCoord vWidth,
wxCoord vHeight ) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
RECTL vRect; RECTL vRect;
vRect.xLeft = x; vRect.xLeft = r.x;
vRect.xRight = x + vWidth; vRect.xRight = r.x + r.width;
vRect.yTop = y + vHeight; vRect.yTop = r.y + r.height;
vRect.yBottom = y; vRect.yBottom = r.y;
LONG lInside = ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS, LONG lInside = ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
M_REGION, M_REGION,
&vRect &vRect
); );
switch (lInside) switch (lInside)
{ {

View File

@@ -92,26 +92,13 @@ void wxRegion::Clear()
{ {
} }
bool wxRegion::Offset(wxCoord x, wxCoord y) bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{ {
return false; return false;
} }
// combine another region with this one // combine another region with this one
bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op) bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op)
{
return false;
}
// Combine rectangle (x, y, w, h) with this.
bool wxRegion::Combine(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
wxRegionOp op)
{
return false;
}
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
{ {
return false; return false;
} }
@@ -121,46 +108,34 @@ bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Outer bounds of region // 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
{ {
} return false;
wxRect wxRegion::GetBox() const
{
return wxRect(0, 0, 0, 0);
} }
// Is region empty? // Is region empty?
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
return true; return true;
} }
bool wxRegion::DoIsEqual(const wxRegion& region) const
{
return false;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion hit testing // wxRegion hit testing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Does the region contain the point (x,y)? // Does the region contain the point (x,y)?
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
return wxOutRegion;
}
// Does the region contain the point pt?
wxRegionContain wxRegion::Contains(const wxPoint& pt) const
{
return wxOutRegion;
}
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y,
wxCoord w, wxCoord h) const
{ {
return wxOutRegion; return wxOutRegion;
} }
// Does the region contain the rectangle rect // Does the region contain the rectangle rect
wxRegionContain wxRegion::Contains(const wxRect& rect) const wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{ {
return wxOutRegion; return wxOutRegion;
} }

View File

@@ -129,13 +129,8 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
// wxRegion comparison // wxRegion comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegion::operator==( const wxRegion& region ) const bool wxRegion::DoIsEqual(const wxRegion& region) const
{ {
if (m_refData == region.m_refData) return true;
if (!m_refData || !region.m_refData) return false;
// compare the regions themselves, not the pointers to ref data!
return XEqualRegion( M_REGIONDATA->m_region, return XEqualRegion( M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region ) == True; M_REGIONDATA_OF(region)->m_region ) == True;
} }
@@ -149,45 +144,38 @@ void wxRegion::Clear()
UnRef(); UnRef();
} }
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoUnionWithRect(const wxRect& r)
{ {
// work around for XUnionRectWithRegion() bug: taking a union with an empty // work around for XUnionRectWithRegion() bug: taking a union with an empty
// rect results in an empty region (at least XFree 3.3.6 and 4.0 have this // rect results in an empty region (at least XFree 3.3.6 and 4.0 have this
// problem) // problem)
if ( !width || !height ) if ( r.IsEmpty() )
return true; return true;
XRectangle rect; XRectangle rect;
rect.x = (short)x; rect.x = (short)r.x;
rect.y = (short)y; rect.y = (short)r.y;
rect.width = (unsigned short)width; rect.width = (unsigned short)r.width;
rect.height = (unsigned short)height; rect.height = (unsigned short)r.height;
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = XCreateRegion(); M_REGIONDATA->m_region = XCreateRegion();
XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
} }
else else
{ {
AllocExclusive(); AllocExclusive();
XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
} }
XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
return true; return true;
} }
bool wxRegion::Union( const wxRect& rect ) bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{ {
return Union( rect.x, rect.y, rect.width, rect.height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
}
bool wxRegion::Union( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -206,24 +194,9 @@ bool wxRegion::Union( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoIntersect( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRect& rect )
{
wxRegion reg( rect );
return Intersect( reg );
}
bool wxRegion::Intersect( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -245,22 +218,9 @@ bool wxRegion::Intersect( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoSubtract( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRect& rect )
{
wxRegion reg( rect );
return Subtract( reg );
}
bool wxRegion::Subtract( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -279,22 +239,9 @@ bool wxRegion::Subtract( const wxRegion& region )
return true; return true;
} }
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) bool wxRegion::DoXor( const wxRegion& region )
{ {
wxRegion reg( x, y, width, height ); wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
return Xor( reg );
}
bool wxRegion::Xor( const wxRect& rect )
{
wxRegion reg( rect );
return Xor( reg );
}
bool wxRegion::Xor( const wxRegion& region )
{
if (region.IsNull())
return false;
if (!m_refData) if (!m_refData)
{ {
@@ -317,7 +264,7 @@ bool wxRegion::Xor( const wxRegion& region )
// wxRegion tests // wxRegion tests
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
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) if (m_refData)
{ {
@@ -327,6 +274,8 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = rect.y; y = rect.y;
w = rect.width; w = rect.width;
h = rect.height; h = rect.height;
return true;
} }
else else
{ {
@@ -334,17 +283,12 @@ void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
y = 0; y = 0;
w = -1; w = -1;
h = -1; h = -1;
return false;
} }
} }
wxRect wxRegion::GetBox() const bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{
wxCoord x, y, w, h;
GetBox( x, y, w, h );
return wxRect( x, y, w, h );
}
bool wxRegion::Offset( wxCoord x, wxCoord y )
{ {
if (!m_refData) if (!m_refData)
return false; return false;
@@ -356,7 +300,7 @@ bool wxRegion::Offset( wxCoord x, wxCoord y )
return true; return true;
} }
bool wxRegion::Empty() const bool wxRegion::IsEmpty() const
{ {
if (!m_refData) if (!m_refData)
return true; return true;
@@ -364,7 +308,7 @@ bool wxRegion::Empty() const
return XEmptyRegion( M_REGIONDATA->m_region ) == True; return XEmptyRegion( M_REGIONDATA->m_region ) == True;
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const wxRegionContain wxRegion::DoContainsPoint( wxCoord x, wxCoord y ) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
@@ -375,12 +319,12 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{ {
if (!m_refData) if (!m_refData)
return wxOutRegion; return wxOutRegion;
int res = XRectInRegion( M_REGIONDATA->m_region, x, y, w, h ); int res = XRectInRegion(M_REGIONDATA->m_region, r.x, r.y, r.width, r.height);
switch (res) switch (res)
{ {
case RectangleIn: return wxInRegion; case RectangleIn: return wxInRegion;
@@ -390,16 +334,6 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h )
return wxOutRegion; return wxOutRegion;
} }
wxRegionContain wxRegion::Contains(const wxPoint& pt) const
{
return Contains( pt.x, pt.y );
}
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
return Contains( rect.x, rect.y, rect.width, rect.height );
}
WXRegion *wxRegion::GetX11Region() const WXRegion *wxRegion::GetX11Region() const
{ {
if (!m_refData) if (!m_refData)