Contents Up Previous Next

wxRegion

A wxRegion represents a simple or complex region on a device context or window. It uses reference counting, so copying and assignment operations are fast.

Derived from

wxGDIObject
wxObject

Include files

<wx/region.h>

See also

wxRegionIterator

Members

wxRegion::wxRegion
wxRegion::~wxRegion
wxRegion::Clear
wxRegion::Contains
wxRegion::ConvertToBitmap
wxRegion::GetBox
wxRegion::Intersect
wxRegion::IsEmpty
wxRegion::Subtract
wxRegion::Offset
wxRegion::Union
wxRegion::Xor
wxRegion::operator =


wxRegion::wxRegion

wxRegion()

Default constructor.

wxRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

Constructs a rectangular region with the given position and size.

wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)

Constructs a rectangular region from the top left point and the bottom right point.

wxRegion(const wxRect& rect)

Constructs a rectangular region a wxRect object.

wxRegion(const wxRegion& region)

Constructs a region by copying another region.

wxRegion(size_t n, const wxPoint *points, int fillStyle = wxWINDING_RULE)

Constructs a region corresponding to the polygon made of n points in the provided array. fillStyle parameter may have values wxWINDING_RULE or wxODDEVEN_RULE.

NB: This constructor is only implemented for Win32 and GTK+ wxWidgets ports.

wxRegion(const wxBitmap& bmp)

wxRegion(const wxBitmap& bmp, const wxColour& transColour, int tolerance = 0)

Constructs a region using the non-transparent pixels of a bitmap. See Union for more details.


wxRegion::~wxRegion

~wxRegion()

Destructor.


wxRegion::Clear

void Clear()

Clears the current region.


wxRegion::Contains

wxRegionContain Contains(long& x, long& y) const

Returns a value indicating whether the given point is contained within the region.

wxRegionContain Contains(const wxPoint& pt) const

Returns a value indicating whether the given point is contained within the region.

wxRegionContain Contains(long& x, long& y, long& width, long& height) const

Returns a value indicating whether the given rectangle is contained within the region.

wxRegionContain Contains(const wxRect& rect) const

Returns a value indicating whether the given rectangle is contained within the region.

Return value

The return value is one of wxOutRegion, wxPartRegion and wxInRegion.

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.


wxRegion::ConvertToBitmap

wxBitmap ConvertToBitmap() const

Convert the region to a black and white bitmap with the white pixels being inside the region.


wxRegion::GetBox

void GetBox(long& x, long& y, long& width, long& height) const

Returns the outer bounds of the region.

wxRect GetBox() const

Returns the outer bounds of the region.


wxRegion::Intersect

bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

Finds the intersection of this region and another, rectangular region, specified using position and size.

bool Intersect(const wxRect& rect)

Finds the intersection of this region and another, rectangular region.

bool Intersect(const wxRegion& region)

Finds the intersection of this region and another region.

Return value

true if successful, false otherwise.

Remarks

Creates the intersection of the two regions, that is, the parts which are in both regions. The result is stored in this region.


wxRegion::IsEmpty

bool IsEmpty() const

Returns true if the region is empty, false otherwise.


wxRegion::Subtract

bool Subtract(const wxRect& rect)

Subtracts a rectangular region from this region.

bool Subtract(const wxRegion& region)

Subtracts a region from this region.

Return value

true if successful, false otherwise.

Remarks

This operation combines the parts of 'this' region that are not part of the second region. The result is stored in this region.


wxRegion::Offset

bool Offset(wxCoord x, wxCoord y)

Moves the region by the specified offsets in horizontal and vertical directions.

Return value

true if successful, false otherwise (the region is unchanged then).


wxRegion::Union

bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

Finds the union of this region and another, rectangular region, specified using position and size.

bool Union(const wxRect& rect)

Finds the union of this region and another, rectangular region.

bool Union(const wxRegion& region)

Finds the union of this region and another region.

bool Union(const wxBitmap& bmp)

Finds the union of this region and the the non-transparent pixels of a bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't have a mask, solid rectangle of bitmap's dimensions is used.

bool Union(const wxBitmap& bmp, const wxColour& transColour, int tolerance = 0)

Finds the union of this region and the the non-transparent pixels of a bitmap. Colour to be treated as transparent is specified in the transColour argument, along with an optional colour tolerance value.

Return value

true if successful, false otherwise.

Remarks

This operation creates a region that combines all of this region and the second region. The result is stored in this region.


wxRegion::Xor

bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)

Finds the Xor of this region and another, rectangular region, specified using position and size.

bool Xor(const wxRect& rect)

Finds the Xor of this region and another, rectangular region.

bool Xor(const wxRegion& region)

Finds the Xor of this region and another region.

Return value

true if successful, false otherwise.

Remarks

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.


wxRegion::operator =

void operator =(const wxRegion& region)

Copies region by reference counting.