\latexignore{\rtfignore{\wxheading{Members}}}
+
\membersection{wxRegion::wxRegion}\label{wxregionctor}
\func{}{wxRegion}{\void}
\func{}{wxRegion}{\param{const wxBitmap\&}{ bmp},
\param{const wxColour\&}{ transColour},
- \param{int}{ tolerance = 0}}
+ \param{int}{ tolerance = 0}}
Constructs a region using the non-transparent pixels of a bitmap. See
\helpref{Union}{wxregionunion} for more details.
+
\membersection{wxRegion::\destruct{wxRegion}}\label{wxregiondtor}
\func{}{\destruct{wxRegion}}{\void}
Destructor.
+
\membersection{wxRegion::Clear}\label{wxregionclear}
\func{void}{Clear}{\void}
Clears the current region.
+
\membersection{wxRegion::Contains}\label{wxregioncontains}
\constfunc{wxRegionContain}{Contains}{\param{long\& }{x}, \param{long\& }{y}}
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.
+
\membersection{wxRegion::ConvertToBitmap}\label{wxregionconverttobitmap}
\constfunc{wxBitmap}{ConvertToBitmap}{}
Convert the region to a black and white bitmap with the white pixels
being inside the region.
+
\membersection{wxRegion::GetBox}\label{wxregiongetbox}
\constfunc{void}{GetBox}{\param{wxCoord\& }{x}, \param{wxCoord\& }{y}, \param{wxCoord\& }{width}, \param{wxCoord\& }{height}}
Returns the outer bounds of the region.
+
\membersection{wxRegion::Intersect}\label{wxregionintersect}
\func{bool}{Intersect}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
Creates the intersection of the two regions, that is, the parts which are in both regions. The result
is stored in this region.
+
\membersection{wxRegion::IsEmpty}\label{wxregionisempty}
\constfunc{bool}{IsEmpty}{\void}
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}
\func{bool}{Subtract}{\param{const wxRect\&}{ rect}}
This operation combines the parts of 'this' region that are not part of the second region.
The result is stored in this region.
+
\membersection{wxRegion::Offset}\label{wxregionoffset}
\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
directions.
{\tt true} if successful, {\tt false} otherwise (the region is unchanged then).
+
\membersection{wxRegion::Union}\label{wxregionunion}
\func{bool}{Union}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
\func{bool}{Union}{\param{const wxBitmap\&}{ bmp},
\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
bitmap. Colour to be treated as transparent is specified in the
This operation creates a region that combines all of this region and the second region.
The result is stored in this region.
+
\membersection{wxRegion::Xor}\label{wxregionxor}
\func{bool}{Xor}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
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.
+
\membersection{wxRegion::operator $=$}\label{wxregionassign}
\func{void}{operator $=$}{\param{const wxRegion\&}{ region}}
\latexignore{\rtfignore{\wxheading{Members}}}
+
\membersection{wxRegionIterator::wxRegionIterator}\label{wxregioniteratorctor}
\func{}{wxRegionIterator}{\void}
Creates an iterator object given a region.
+
\membersection{wxRegionIterator::GetX}\label{wxregioniteratorgetx}
\constfunc{wxCoord}{GetX}{\void}
Returns the x value for the current region.
+
\membersection{wxRegionIterator::GetY}\label{wxregioniteratorgety}
\constfunc{wxCoord}{GetY}{\void}
Returns the y value for the current region.
+
\membersection{wxRegionIterator::GetW}\label{wxregioniteratorgetw}
\constfunc{wxCoord}{GetW}{\void}
An alias for GetWidth.
+
\membersection{wxRegionIterator::GetHeight}\label{wxregioniteratorgetheight}
\constfunc{wxCoord}{GetHeight}{\void}
Returns the height value for the current region.
+
\membersection{wxRegionIterator::GetH}\label{wxregioniteratorgeth}
\constfunc{wxCoord}{GetH}{\void}
An alias for GetHeight.
+
\membersection{wxRegionIterator::GetRect}\label{wxregioniteratorgetrect}
\constfunc{wxRect}{GetRect}{\void}
Returns the current rectangle.
+
\membersection{wxRegionIterator::GetWidth}\label{wxregioniteratorgetwidth}
\constfunc{wxCoord}{GetWidth}{\void}
Returns the width value for the current region.
+
\membersection{wxRegionIterator::HaveRects}\label{wxregioniteratorhaverects}
\constfunc{bool}{HaveRects}{\void}
Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}.
+
\membersection{wxRegionIterator::Reset}\label{wxregioniteratorreset}
\func{void}{Reset}{\void}
Resets the iterator to the given region.
+
\membersection{wxRegionIterator::operator $++$}\label{wxregioniteratorinc}
\func{void}{operator $++$}{\void}
\pythonnote{A wxPython alias for this operator is called {\tt Next}.}
+
\membersection{wxRegionIterator::operator bool}\label{wxregioniteratorbool}
\constfunc{}{operator bool}{\void}
class WXDLLEXPORT wxRegion : public wxRegionGeneric
{
- DECLARE_DYNAMIC_CLASS(wxRegion);
public:
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
: wxRegionGeneric(x,y,w,h)
wxRegion(const NSRect& rect);
wxRegion(const NSRect *rects, int count);
- // 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);
- /* 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;
-
+private:
+ DECLARE_DYNAMIC_CLASS(wxRegion);
};
class WXDLLEXPORT wxRegionIterator : public wxRegionIteratorGeneric
#ifndef _WX_DFB_REGION_H_
#define _WX_DFB_REGION_H_
-#include "wx/gdiobj.h"
-#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
+class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{
-
public:
+ wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
Union(bmp, transColour, tolerance);
}
- wxRegion();
- ~wxRegion();
-
- #warning "FIXME: move this to common code? at least Ok()"
- bool Ok() const { return m_refData != NULL; }
-
- 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);
+ virtual ~wxRegion();
+
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
// NB: implementation detail of DirectFB, should be removed if full
// (i.e. not rect-only version is implemented) so that all code that
virtual wxObjectRefData *CreateRefData() 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;
DECLARE_DYNAMIC_CLASS(wxRegion);
#ifndef _WX_GENERIC_REGION_H__
#define _WX_GENERIC_REGION_H__
-#include "wx/gdiobj.h"
-#include "wx/gdicmn.h"
-
-class WXDLLEXPORT wxRect;
-class WXDLLEXPORT wxPoint;
-
-class WXDLLEXPORT wxRegionGeneric : public wxGDIObject
+class WXDLLEXPORT wxRegionGeneric : public wxRegionBase
{
-// DECLARE_DYNAMIC_CLASS(wxRegionGeneric);
- friend class WXDLLEXPORT wxRegionIteratorGeneric;
public:
wxRegionGeneric(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegionGeneric(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegionGeneric();
virtual ~wxRegionGeneric();
- bool Ok() const { return m_refData != NULL; }
-
- bool operator == ( const wxRegionGeneric& region ) 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;
+ // wxRegionBase pure virtuals
+ virtual void Clear();
+ virtual bool IsEmpty() const;
protected:
virtual wxObjectRefData *CreateRefData() 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
{
-// DECLARE_DYNAMIC_CLASS(wxRegionIteratorGeneric);
public:
wxRegionIteratorGeneric();
wxRegionIteratorGeneric(const wxRegionGeneric& region);
wxRegionGeneric m_region;
};
-#endif //ndef _WX_GENERIC_REGION_H__
+#endif // _WX_GENERIC_REGION_H__
#ifndef _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
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
+class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{
public:
wxRegion() { }
virtual ~wxRegion();
- bool Ok() const { return m_refData != NULL; }
-
- bool operator == ( const wxRegion& region ) 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);
-
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
public:
// Init with GdkRegion, set ref count to 2 so that
virtual wxObjectRefData *CreateRefData() 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
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
#define _WX_GTK_REGION_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
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
+class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{
public:
wxRegion() { }
virtual ~wxRegion();
- bool Ok() const { return m_refData != NULL; }
-
- bool operator == ( const wxRegion& region ) 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);
-
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
public:
// Init with GdkRegion, set ref count to 2 so that
virtual wxObjectRefData *CreateRefData() 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
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
+#ifndef _WX_MAC_CARBON_REGION_H_
+#define _WX_MAC_CARBON_REGION_H_
#include "wx/list.h"
-#include "wx/gdiobj.h"
-#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 {
-DECLARE_DYNAMIC_CLASS(wxRegion)
- friend class WXDLLEXPORT wxRegionIterator;
+class WXDLLEXPORT wxRegion : public wxRegionWithCombine
+{
public:
wxRegion(long x, long y, long w, long h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
virtual ~wxRegion();
- //# 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 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);
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
// 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 ;
+
+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
{
- DECLARE_DYNAMIC_CLASS(wxRegionIterator)
-
public:
wxRegionIterator();
wxRegionIterator(const wxRegion& region);
long GetH() const;
long GetHeight() const { return GetH(); }
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
+
private:
void SetRects(long numRects, wxRect *rects);
long m_numRects;
wxRegion m_region;
wxRect* m_rects;
+
+ DECLARE_DYNAMIC_CLASS(wxRegionIterator)
};
-#endif
- // _WX_REGION_H_
+#endif // _WX_MAC_CARBON_REGION_H_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
+#ifndef _WX_MGL_REGION_H_
+#define _WX_MGL_REGION_H_
#include "wx/list.h"
-#include "wx/gdiobj.h"
-#include "wx/gdicmn.h"
-class WXDLLEXPORT wxRect;
-class WXDLLEXPORT wxPoint;
class MGLRegion;
-class WXDLLEXPORT wxRegion : public wxGDIObject
+class WXDLLEXPORT wxRegion : public wxRegionBase
{
- DECLARE_DYNAMIC_CLASS(wxRegion);
- friend class WXDLLEXPORT wxRegionIterator;
-
public:
+ wxRegion();
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
Union(bmp, transColour, tolerance);
}
- wxRegion();
virtual ~wxRegion();
- //# Modify region
- // Clear current region
- void Clear(void);
-
- 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);
-
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
// implementation from now on:
const MGLRegion& GetMGLRegion() const;
// ref counting code
virtual wxObjectRefData *CreateRefData() 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;
};
class WXDLLEXPORT wxRegionIterator : public wxObject
{
- DECLARE_DYNAMIC_CLASS(wxRegionIterator);
public:
wxRegionIterator(void);
wxRegionIterator(const wxRegion& region);
void Reset(void) { m_currentNode = NULL; }
void Reset(const wxRegion& region);
-#ifndef __SALFORDC__
operator bool (void) const { return (m_currentNode != NULL); }
-#endif
bool HaveRects(void) const { return (m_currentNode != NULL); }
private:
wxRegionRectList m_rects;
wxRegionRectList::Node *m_currentNode;
+
+ DECLARE_DYNAMIC_CLASS(wxRegionIterator);
};
-#endif
- // _WX_REGION_H_
+#endif // _WX_MGL_REGION_H_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
+#ifndef _WX_MSW_REGION_H_
+#define _WX_MSW_REGION_H_
-#include "wx/gdiobj.h"
-#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
+class WXDLLEXPORT wxRegion : public wxRegionWithCombine
{
public:
wxRegion();
virtual ~wxRegion();
- // Modify region
- // -------------
-
- // 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);
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
// Get internal region handle
WXHRGN GetHRGN() const;
virtual wxObjectRefData *CreateRefData() 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;
DECLARE_DYNAMIC_CLASS(wxRegion)
bool HaveRects() const { return (m_current < m_numRects); }
-#ifndef __SALFORDC__
operator bool () const { return HaveRects(); }
-#endif
wxRegionIterator& operator++();
wxRegionIterator operator++(int);
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
};
-#endif
- // _WX_REGION_H_
+#endif // _WX_MSW_REGION_H_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
+#ifndef _WX_OS2_REGION_H_
+#define _WX_OS2_REGION_H_
#include "wx/list.h"
-#include "wx/gdiobj.h"
-#include "wx/gdicmn.h"
-#include "wx/bitmap.h"
#include "wx/os2/private.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
+class WXDLLEXPORT wxRegion : public wxRegionWithCombine
{
public:
wxRegion( wxCoord x
//
// Clear current region
//
- void Clear(void);
-
- 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;
+ virtual void Clear();
//
// Is region empty?
//
- bool Empty(void) 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
- );
+ virtual bool IsEmpty() const;
//
// Get internal region handle
//
- WXHRGN GetHRGN(void) const;
+ WXHRGN GetHRGN() const;
+
void SetPS(HPS hPS);
protected:
virtual wxObjectRefData* CreateData(void) 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;
DECLARE_DYNAMIC_CLASS(wxRegion);
wxRect* m_pRects;
}; // end of wxRegionIterator
-#endif
- // _WX_REGION_H_
+#endif // _WX_OS2_REGION_H_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_REGION_H_
-#define _WX_REGION_H_
+#ifndef _WX_PALMOS_REGION_H_
+#define _WX_PALMOS_REGION_H_
-#include "wx/gdiobj.h"
-#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
+class WXDLLEXPORT wxRegion : public wxRegionWithCombine
{
public:
wxRegion();
virtual ~wxRegion();
- // Modify region
- // -------------
-
- // 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);
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
// Get internal region handle
WXHRGN GetHRGN() const;
virtual wxObjectRefData *CreateRefData() 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;
DECLARE_DYNAMIC_CLASS(wxRegion)
bool HaveRects() const { return (m_current < m_numRects); }
-#ifndef __SALFORDC__
operator bool () const { return HaveRects(); }
-#endif
wxRegionIterator& operator++();
wxRegionIterator operator++(int);
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
};
-#endif
- // _WX_REGION_H_
+#endif // _WX_PALMOS_REGION_H_
#ifndef _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
{
wxOutRegion = 0,
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__)
#include "wx/palmos/region.h"
#elif defined(__WXMSW__)
#include "wx/os2/region.h"
#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_
/////////////////////////////////////////////////////////////////////////////
-// Name: region.h
+// Name: wx/x11/region.h
// Purpose: wxRegion class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Robert Roebling
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_
#define _WX_REGION_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
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxRegion : public wxGDIObject
+class WXDLLIMPEXP_CORE wxRegion : public wxRegionBase
{
public:
wxRegion() { }
virtual ~wxRegion();
- bool Ok() const { return m_refData != NULL; }
-
- bool operator == ( const wxRegion& region ) 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);
-
+ // wxRegionBase methods
+ virtual void Clear();
+ virtual bool IsEmpty() const;
public:
WXRegion *GetX11Region() const;
virtual wxObjectRefData *CreateRefData() 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
void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/image.h"
#endif //WX_PRECOMP
+// ============================================================================
+// wxRegionBase implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// 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 wxRegion::ConvertToBitmap() const
+wxBitmap wxRegionBase::ConvertToBitmap() const
{
wxRect box = GetBox();
wxBitmap bmp(box.GetRight(), box.GetBottom());
dc.SelectObject(bmp);
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
- dc.SetClippingRegion(*this);
+ dc.SetClippingRegion(*wx_static_cast(const wxRegion *, this));
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
dc.SelectObject(wxNullBitmap);
return bmp;
}
-//---------------------------------------------------------------------------
-
#if wxUSE_IMAGE
-static bool DoRegionUnion(wxRegion& region,
+
+static bool DoRegionUnion(wxRegionBase& region,
const wxImage& image,
unsigned char loR,
unsigned char loG,
}
-bool wxRegion::Union(const wxBitmap& bmp)
+bool wxRegionBase::Union(const wxBitmap& bmp)
{
-#if (!defined(__WXMSW__) || wxUSE_WXDIB)
if (bmp.GetMask())
{
wxImage image = bmp.ConvertToImage();
0);
}
else
-#endif
{
return Union(0, 0, bmp.GetWidth(), bmp.GetHeight());
}
}
-bool wxRegion::Union(const wxBitmap& bmp,
- const wxColour& transColour,
- int tolerance)
+bool wxRegionBase::Union(const wxBitmap& bmp,
+ const wxColour& transColour,
+ int tolerance)
{
-#if (!defined(__WXMSW__) || wxUSE_WXDIB)
wxImage image = bmp.ConvertToImage();
return DoRegionUnion(*this, image,
transColour.Red(),
transColour.Green(),
transColour.Blue(),
tolerance);
-#else
- return false;
-#endif
-}
-
-#else
-
-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
+#endif // wxUSE_IMAGE
// 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
//-----------------------------------------------------------------------------
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ return M_REGION->m_rect == M_REGION_OF(region)->m_rect;
+}
+
+bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
- wxRect r = GetBox();
+ if ( !m_refData )
+ return false;
+
+ const wxRect& r = M_REGION->m_rect;
x = r.GetX();
y = r.GetY();
w = r.GetWidth();
h = r.GetHeight();
-}
-wxRect wxRegion::GetBox() const
-{
- if (m_refData)
- return M_REGION->m_rect;
- else
- return wxRect();
+ return true;
}
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if (!m_refData)
return true;
UnRef();
}
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
AllocExclusive();
M_REGION->m_rect.Offset(x, y);
return true;
}
-bool wxRegion::Union(const wxRect& rect)
+bool wxRegion::DoUnionWithRect(const wxRect& rect)
{
AllocExclusive();
}
}
-bool wxRegion::Union(const wxRegion& region)
+bool wxRegion::DoUnionWithRegion(const wxRegion& 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();
- M_REGION->m_rect.Intersect(rect);
+ M_REGION->m_rect.Intersect(M_REGION_OF(region)->m_rect);
return true;
}
-bool wxRegion::Intersect(const wxRegion& region)
+bool wxRegion::DoSubtract(const wxRegion& 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") );
+ const wxRect& rect = M_REGION_OF(region)->m_rect;
+
if ( rect.Contains(M_REGION->m_rect) )
{
// subtracted rectangle contains this one, so the result is empty
}
}
-bool wxRegion::Subtract(const wxRegion& region)
+bool wxRegion::DoXor(const wxRegion& 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") );
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
//-----------------------------------------------------------------------------
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );
return wxOutRegion;
}
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{
wxCHECK_MSG( Ok(), wxOutRegion, _T("invalid region") );
return new wxRegionRefData(*(wxRegionRefData *)data);
}
-bool wxRegionGeneric::operator== (const wxRegionGeneric& region) const
+bool wxRegionGeneric::DoIsEqual(const wxRegion& region) const
{
- wxASSERT(m_refData && region.m_refData);
return REGION::XEqualRegion(M_REGIONDATA,M_REGIONDATA_OF(region));
}
-wxRect wxRegionGeneric::GetBox() const
+bool wxRegionGeneric::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
- wxASSERT(m_refData);
- wxRect rect;
- REGION::XClipBox(M_REGIONDATA,&rect);
- return rect;
-}
+ if ( !m_refData )
+ return false;
-void wxRegionGeneric::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
-{
- wxASSERT(m_refData);
wxRect rect;
REGION::XClipBox(M_REGIONDATA,&rect);
x = rect.x;
y = rect.y;
w = rect.width;
h = rect.height;
+ return true;
}
// ----------------------------------------------------------------------------
// wxRegionGeneric operations
// ----------------------------------------------------------------------------
-bool wxRegionGeneric::Union(const wxRect& rect)
-/* XUnionRectWithRegion */
+bool wxRegionGeneric::DoUnionWithRect(const wxRect& rect)
{
- if (!rect.width || !rect.height)
- return false;
+ if ( rect.IsEmpty() )
+ {
+ // nothing to do
+ return true;
+ }
AllocExclusive();
REGION region(rect);
return REGION::XUnionRegion(®ion,M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Union(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoUnionWithRegion(const wxRegionGeneric& region)
{
AllocExclusive();
return REGION::XUnionRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Intersect(const wxRect& rect)
-{
- if (!rect.width || !rect.height)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XIntersectRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
-
-bool wxRegionGeneric::Intersect(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoIntersect(const wxRegionGeneric& region)
{
AllocExclusive();
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)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XSubtractRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
+ if ( region.IsEmpty() )
+ {
+ // nothing to do
+ return true;
+ }
-bool wxRegionGeneric::Subtract(const wxRegionGeneric& region)
-{
return REGION::XSubtractRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Xor(const wxRect& rect)
-{
- if (!rect.width || !rect.height)
- return false;
- AllocExclusive();
- REGION region(rect);
-
- return REGION::XXorRegion(®ion,M_REGIONDATA,M_REGIONDATA);
-}
-
-bool wxRegionGeneric::Xor(const wxRegionGeneric& region)
+bool wxRegionGeneric::DoXor(const wxRegionGeneric& region)
{
AllocExclusive();
return REGION::XXorRegion(M_REGIONDATA_OF(region),M_REGIONDATA,M_REGIONDATA);
}
-bool wxRegionGeneric::Offset(wxCoord x, wxCoord y)
+bool wxRegionGeneric::DoOffset(wxCoord x, wxCoord y)
{
AllocExclusive();
return REGION::XOffsetRegion(M_REGIONDATA, x, y);
// wxRegionGeneric comparison
// ----------------------------------------------------------------------------
-bool wxRegionGeneric::Empty() const
+bool wxRegionGeneric::IsEmpty() const
{
wxASSERT(m_refData);
return REGION::XEmptyRegion(M_REGIONDATA);
}
// Does the region contain the point (x,y)?
-wxRegionContain wxRegionGeneric::Contains(long x, long y) const
-{
- wxASSERT(m_refData);
- return REGION::XPointInRegion(M_REGIONDATA,x,y)?wxInRegion:wxOutRegion;
-}
-
-// Does the region contain the point pt?
-wxRegionContain wxRegionGeneric::Contains(const wxPoint& pt) const
-{
- wxASSERT(m_refData);
- return REGION::XPointInRegion(M_REGIONDATA,pt.x,pt.y)?wxInRegion:wxOutRegion;
-}
-
-// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegionGeneric::Contains(long x, long y, long w, long h) const
+wxRegionContain wxRegionGeneric::DoContainsPoint(long x, long y) const
{
wxASSERT(m_refData);
- return REGION::XRectInRegion(M_REGIONDATA,x,y,w,h);
+ return REGION::XPointInRegion(M_REGIONDATA,x,y) ? wxInRegion : wxOutRegion;
}
// Does the region contain the rectangle rect?
-wxRegionContain wxRegionGeneric::Contains(const wxRect& rect) const
+wxRegionContain wxRegionGeneric::DoContainsRect(const wxRect& rect) const
{
wxASSERT(m_refData);
return REGION::XRectInRegion(M_REGIONDATA,rect.x,rect.y,rect.width,rect.height);
// 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,
M_REGIONDATA_OF(region)->m_region);
}
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
// rectangle results in an empty region which is definitely not what we
// want
- if ( !width || !height )
+ if ( r.IsEmpty() )
return true;
if ( !m_refData )
{
- InitRect(x, y, width, height);
+ InitRect(r.x, r.y, r.width, r.height);
}
else
{
AllocExclusive();
GdkRectangle rect;
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.width = r.width;
+ rect.height = r.height;
gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
}
return true;
}
-bool wxRegion::Union( const wxRect& rect )
-{
- return Union( rect.x, rect.y, rect.width, rect.height );
-}
-
-bool wxRegion::Union( const wxRegion& region )
+bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
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 );
-
- 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;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
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 );
- 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;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return true;
}
-bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
- return Xor( reg );
-}
-
-bool wxRegion::Xor( const wxRect& rect )
-{
- wxRegion reg( rect );
- return Xor( reg );
-}
-
-bool wxRegion::Xor( const wxRegion& region )
+bool wxRegion::DoXor( const wxRegion& region )
{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return true;
}
-bool wxRegion::Offset( wxCoord x, wxCoord y )
+bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{
if (!m_refData)
return false;
// 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 )
{
y = rect.y;
w = rect.width;
h = rect.height;
+
+ return true;
}
else
{
y = 0;
w = -1;
h = -1;
- }
-}
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox( x, y, w, h );
- return wxRect( x, y, w, h );
+ return false;
+ }
}
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if (!m_refData)
return true;
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)
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)
return wxOutRegion;
GdkRectangle rect;
- rect.x = x;
- rect.y = y;
- rect.width = w;
- rect.height = h;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.width = r.width;
+ rect.height = r.height;
GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
switch (res)
{
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
{
if (!m_refData)
// 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,
M_REGIONDATA_OF(region)->m_region);
}
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
// rectangle results in an empty region which is definitely not what we
// want
- if ( !width || !height )
+ if ( r.IsEmpty() )
return TRUE;
if ( !m_refData )
{
- InitRect(x, y, width, height);
+ InitRect(r.x, r.y, r.width, r.height);
}
else
{
AllocExclusive();
GdkRectangle rect;
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
-
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.width = r.width;
+ rect.height = r.height;
+
+ gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
}
return TRUE;
}
-bool wxRegion::Union( const wxRect& rect )
-{
- return Union( rect.x, rect.y, rect.width, rect.height );
-}
-
-bool wxRegion::Union( const wxRegion& region )
+bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
if (region.IsNull())
return FALSE;
return TRUE;
}
-bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
-
- return Intersect( reg );
-}
-
-bool wxRegion::Intersect( const wxRect& rect )
-{
- wxRegion reg( rect );
-
- return Intersect( reg );
-}
-
-bool wxRegion::Intersect( const wxRegion& region )
+bool wxRegion::DoIntersect( const wxRegion& region )
{
- if (region.IsNull())
- return FALSE;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return TRUE;
}
-bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
- return Subtract( reg );
-}
-
-bool wxRegion::Subtract( const wxRect& rect )
-{
- wxRegion reg( rect );
- return Subtract( reg );
-}
-
-bool wxRegion::Subtract( const wxRegion& region )
+bool wxRegion::DoSubtract( const wxRegion& region )
{
- if (region.IsNull())
- return FALSE;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
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 );
- 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;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return TRUE;
}
-bool wxRegion::Offset( wxCoord x, wxCoord y )
+bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{
if (!m_refData)
return FALSE;
// 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 )
{
y = rect.y;
w = rect.width;
h = rect.height;
+
+ return true;
}
else
{
y = 0;
w = -1;
h = -1;
- }
-}
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox( x, y, w, h );
- return wxRect( x, y, w, h );
+ return false;
+ }
}
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if (!m_refData)
return TRUE;
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)
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)
return wxOutRegion;
GdkRectangle rect;
- rect.x = x;
- rect.y = y;
- rect.width = w;
- rect.height = h;
+ rect.x = r.x;
+ rect.y = r.y;
+ rect.width = r.width;
+ rect.height = r.height;
GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect );
switch (res)
{
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
{
if (!m_refData)
}
// 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") );
}
-//! 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.
-bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
+bool wxRegion::DoCombine(const wxRegion& region, wxRegionOp op)
{
- if (region.Empty())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid wxRegion") );
// Don't change shared data
if (!m_refData)
return true;
}
-bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
-{
- return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
-}
-
//-----------------------------------------------------------------------------
//# Information on region
//-----------------------------------------------------------------------------
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
// Outer bounds of region
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
+bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const
{
if (m_refData)
{
y = box.top ;
w = box.right - box.left ;
h = box.bottom - box.top ;
+
+ return true;
}
else
{
x = y = w = h = 0;
- }
-}
-
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox(x, y, w, h);
- return wxRect(x, y, w, h);
+ return false;
+ }
}
// Is region empty?
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if ( m_refData )
return EmptyRgn( M_REGION ) ;
//# 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?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
if (!m_refData)
return wxOutRegion;
- Point p = { pt.y , pt.x } ;
+ Point p = { y , x } ;
if (PtInRgn( p , M_REGION ) )
return wxInRegion;
}
// 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)
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 ) )
return wxInRegion;
else
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 //
m_rects = NULL;
}
- if (m_region.Empty())
+ if (m_region.IsEmpty())
{
m_numRects = 0;
}
// Information on region
//-----------------------------------------------------------------------------
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ wxFAIL_MSG( _T("not implemented") );
+
+ return false;
+}
+
// Outer bounds of region
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
+bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
if (m_refData)
{
y = rect.top;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
+
+ return true;
}
else
{
x = y = w = h = 0;
+ 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?
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if (!m_refData)
return true;
// Modifications
//-----------------------------------------------------------------------------
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
AllocExclusive();
M_REGION.offset(x, y);
}
// Union rectangle or region with this.
-bool wxRegion::Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
+bool wxRegion::DoUnionWithRect(const wxRect& r)
{
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;
}
-bool wxRegion::Union(const wxRegion& region)
+bool wxRegion::DoUnionWithRegion(const wxRegion& region)
{
AllocExclusive();
M_REGION += M_REGION_OF(region);
return true;
}
-// Intersect rectangle or region with this.
-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)
+bool wxRegion::DoIntersect(const wxRegion& region)
{
AllocExclusive();
M_REGION &= M_REGION_OF(region);
return true;
}
-// Subtract rectangle or region from this:
-// 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)
+bool wxRegion::DoSubtract(const wxRegion& region)
{
AllocExclusive();
M_REGION -= M_REGION_OF(region);
return true;
}
-// XOR: the union of two combined regions except for any overlapping areas.
-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)
+bool wxRegion::DoXor(const wxRegion& region)
{
AllocExclusive();
MGLRegion rg1 = M_REGION + M_REGION_OF(region),
//-----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
if (!m_refData)
return wxOutRegion;
return wxOutRegion;
}
-// Does the region contain the point pt?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
-{
- return Contains(pt.x, pt.y);
-}
-
// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& r) const
{
if (!m_refData)
return wxOutRegion;
- MGLRect rect(x, y, x + w, y + h);
+ MGLRect rect(r.x, r.y, r.GetRight() + 1, r.GetBottom() + 1);
MGLRegion rg;
// 1) is the rectangle entirely covered by the region?
rg = MGLRegion(rect) - M_REGION;
- if (rg.isEmpty()) return wxInRegion;
+ if (rg.isEmpty())
+ return wxInRegion;
// 2) is the rectangle completely outside the region?
rg = M_REGION & rect; // intersection
- if (rg.isEmpty()) return wxOutRegion;
+ if (rg.isEmpty())
+ return wxOutRegion;
// 3) neither case happened => it is partially covered:
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 //
///////////////////////////////////////////////////////////////////////////////
UnRef();
}
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
wxCHECK_MSG( M_REGION, false, _T("invalid wxRegion") );
}
// combine another region with this one
-bool wxRegion::Combine(const wxRegion& rgn, wxRegionOp op)
+bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op)
{
// we can't use the API functions if we don't have a valid region handle
if ( !m_refData )
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
// ----------------------------------------------------------------------------
// Outer bounds of region
-void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
+bool wxRegion::DoGetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
if (m_refData)
{
y = rect.top;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
+
+ return true;
}
else
{
x = y = w = h = 0;
- }
-}
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox(x, y, w, h);
- return wxRect(x, y, w, h);
+ return false;
+ }
}
// Is region empty?
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return (w == 0) && (h == 0);
}
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ return ::EqualRgn(M_REGION, M_REGION_OF(region)) != 0;
+}
+
// ----------------------------------------------------------------------------
// wxRegion hit testing
// ----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y) const
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
if (!m_refData)
return wxOutRegion;
return ::PtInRegion(M_REGION, (int) x, (int) y) ? wxInRegion : wxOutRegion;
}
-// Does the region contain the point pt?
-wxRegionContain wxRegion::Contains(const wxPoint& pt) const
-{
- return Contains(pt.x, pt.y);
-}
-
// Does the region contain the rectangle (x, y, w, h)?
-wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y,
- wxCoord w, wxCoord h) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{
if (!m_refData)
return wxOutRegion;
- RECT rect;
- rect.left = x;
- rect.top = y;
- rect.right = x + w;
- rect.bottom = y + h;
+ RECT rc;
+ wxCopyRectToRECT(rect, rc);
- return ::RectInRegion(M_REGION, &rect) ? wxInRegion : wxOutRegion;
-}
-
-// Does the region contain the rectangle rect
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
-{
- return Contains(rect.x, rect.y, rect.width, rect.height);
+ return ::RectInRegion(M_REGION, &rc) ? wxInRegion : wxOutRegion;
}
// Get internal region handle
//# Modify region
//-----------------------------------------------------------------------------
-bool wxRegion::Offset( wxCoord x, wxCoord y )
+bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{
if ( !x && !y )
{
UnRef();
} // 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.
//
-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
return true;
} // 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
//-----------------------------------------------------------------------------
+bool wxRegion::DoIsEqual(const wxRegion& region) const
+{
+ return false;
+}
+
//
// Outer bounds of region
//
-void wxRegion::GetBox(
+bool wxRegion::DoGetBox(
wxCoord& x
, wxCoord& y
, wxCoord& vWidth
y = vRect.yBottom;
vWidth = vRect.xRight - vRect.xLeft;
vHeight = vRect.yTop - vRect.yBottom;
+ return true;
}
else
{
x = y = vWidth = vHeight = 0L;
+ return false;
}
} // 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?
//
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
wxCoord x;
wxCoord y;
,vHeight
);
return ((vWidth == 0) && (vHeight == 0));
-} // end of wxRegion::Empty
+} // end of wxRegion::IsEmpty
//-----------------------------------------------------------------------------
// Tests
//
// 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 };
LONG lInside = ::GpiPtInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
M_REGION,
&vPoint
- );
+ );
if (lInside == PRGN_INSIDE)
return wxInRegion;
else
//
// Does the region contain the rectangle (x, y, w, h)?
//
-wxRegionContain wxRegion::Contains( wxCoord x,
- wxCoord y,
- wxCoord vWidth,
- wxCoord vHeight ) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{
if (!m_refData)
return wxOutRegion;
RECTL vRect;
- vRect.xLeft = x;
- vRect.xRight = x + vWidth;
- vRect.yTop = y + vHeight;
- vRect.yBottom = y;
+ vRect.xLeft = r.x;
+ vRect.xRight = r.x + r.width;
+ vRect.yTop = r.y + r.height;
+ vRect.yBottom = r.y;
LONG lInside = ::GpiRectInRegion( ((wxRegionRefData*)m_refData)->m_hPS,
M_REGION,
- &vRect
+ &vRect
);
switch (lInside)
{
{
}
-bool wxRegion::Offset(wxCoord x, wxCoord y)
+bool wxRegion::DoOffset(wxCoord x, wxCoord y)
{
return false;
}
// combine another region with this one
-bool wxRegion::Combine(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)
+bool wxRegion::DoCombine(const wxRegion& rgn, wxRegionOp op)
{
return false;
}
// ----------------------------------------------------------------------------
// 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
+// Is region empty?
+bool wxRegion::IsEmpty() const
{
- return wxRect(0, 0, 0, 0);
+ return true;
}
-// Is region empty?
-bool wxRegion::Empty() const
+bool wxRegion::DoIsEqual(const wxRegion& region) const
{
- return true;
+ return false;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
-wxRegionContain wxRegion::Contains(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
+wxRegionContain wxRegion::DoContainsPoint(wxCoord x, wxCoord y) const
{
return wxOutRegion;
}
// Does the region contain the rectangle rect
-wxRegionContain wxRegion::Contains(const wxRect& rect) const
+wxRegionContain wxRegion::DoContainsRect(const wxRect& rect) const
{
return wxOutRegion;
}
// 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,
M_REGIONDATA_OF(region)->m_region ) == True;
}
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
// rect results in an empty region (at least XFree 3.3.6 and 4.0 have this
// problem)
- if ( !width || !height )
+ if ( r.IsEmpty() )
return true;
XRectangle rect;
- rect.x = (short)x;
- rect.y = (short)y;
- rect.width = (unsigned short)width;
- rect.height = (unsigned short)height;
+ rect.x = (short)r.x;
+ rect.y = (short)r.y;
+ rect.width = (unsigned short)r.width;
+ rect.height = (unsigned short)r.height;
if (!m_refData)
{
m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = XCreateRegion();
- XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
}
else
{
AllocExclusive();
-
- XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
}
- return true;
-}
+ XUnionRectWithRegion( &rect, M_REGIONDATA->m_region, M_REGIONDATA->m_region );
-bool wxRegion::Union( const wxRect& rect )
-{
- return Union( rect.x, rect.y, rect.width, rect.height );
+ return true;
}
-bool wxRegion::Union( const wxRegion& region )
+bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return true;
}
-bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
-
- return Intersect( reg );
-}
-
-bool wxRegion::Intersect( const wxRect& rect )
-{
- wxRegion reg( rect );
-
- return Intersect( reg );
-}
-
-bool wxRegion::Intersect( const wxRegion& region )
+bool wxRegion::DoIntersect( const wxRegion& region )
{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return true;
}
-bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
- return Subtract( reg );
-}
-
-bool wxRegion::Subtract( const wxRect& rect )
+bool wxRegion::DoSubtract( const wxRegion& region )
{
- wxRegion reg( rect );
- return Subtract( reg );
-}
-
-bool wxRegion::Subtract( const wxRegion& region )
-{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
return true;
}
-bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
-{
- wxRegion reg( x, y, width, height );
- return Xor( reg );
-}
-
-bool wxRegion::Xor( const wxRect& rect )
+bool wxRegion::DoXor( const wxRegion& region )
{
- wxRegion reg( rect );
- return Xor( reg );
-}
-
-bool wxRegion::Xor( const wxRegion& region )
-{
- if (region.IsNull())
- return false;
+ wxCHECK_MSG( region.Ok(), false, _T("invalid region") );
if (!m_refData)
{
// 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)
{
y = rect.y;
w = rect.width;
h = rect.height;
+
+ return true;
}
else
{
y = 0;
w = -1;
h = -1;
- }
-}
-wxRect wxRegion::GetBox() const
-{
- wxCoord x, y, w, h;
- GetBox( x, y, w, h );
- return wxRect( x, y, w, h );
+ return false;
+ }
}
-bool wxRegion::Offset( wxCoord x, wxCoord y )
+bool wxRegion::DoOffset( wxCoord x, wxCoord y )
{
if (!m_refData)
return false;
return true;
}
-bool wxRegion::Empty() const
+bool wxRegion::IsEmpty() const
{
if (!m_refData)
return 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)
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)
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)
{
case RectangleIn: return wxInRegion;
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
{
if (!m_refData)