]>
git.saurik.com Git - wxWidgets.git/blob - interface/region.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRegionIterator
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRegionIterator
13 This class is used to iterate through the rectangles in a region,
14 typically when examining the damaged regions of a window within an OnPaint call.
16 To use it, construct an iterator object on the stack and loop through the
17 regions, testing the object and incrementing the iterator at the end of the
20 See wxPaintEvent for an example of use.
30 class wxRegionIterator
: public wxObject
35 Creates an iterator object given a region.
38 wxRegionIterator(const wxRegion
& region
);
42 An alias for GetHeight.
47 Returns the height value for the current region.
49 wxCoord
GetHeight() const;
52 Returns the current rectangle.
54 wxRect
GetRect() const;
57 An alias for GetWidth.
62 Returns the width value for the current region.
64 wxCoord
GetWidth() const;
67 Returns the x value for the current region.
72 Returns the y value for the current region.
77 Returns @true if there are still some rectangles; otherwise returns @false.
79 bool HaveRects() const;
83 Resets the iterator to the given region.
86 void Reset(const wxRegion
& region
);
90 Increment operator. Increments the iterator to the next region.
95 Returns @true if there are still some rectangles; otherwise returns @false.
96 You can use this to test the iterator object as if it were of type bool.
98 operator bool() const;
107 A wxRegion represents a simple or complex region on a device context or window.
109 This class uses @ref overview_trefcount "reference counting and copy-on-write"
110 internally so that assignments between two instances of this class are very
111 cheap. You can therefore use actual objects instead of pointers without
112 efficiency problems. If an instance of this class is changed it will create
113 its own data internally so that other instances, which previously shared the
114 data using the reference counting, are not affected.
119 @see wxRegionIterator
121 class wxRegion
: public wxGDIObject
126 Constructs a region using the non-transparent pixels of a bitmap. See
127 Union() for more details.
130 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
131 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
132 wxRegion(const wxRect
& rect
);
133 wxRegion(const wxRegion
& region
);
134 wxRegion(size_t n
, const wxPoint points
,
135 int fillStyle
= wxWINDING_RULE
);
136 wxRegion(const wxBitmap
& bmp
);
137 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
143 See @ref overview_refcountdestruct "reference-counted object destruction" for
149 Clears the current region.
155 Returns a value indicating whether the given rectangle is contained within the
158 @returns The return value is one of wxOutRegion, wxPartRegion and
161 wxRegionContain
Contains(long& x
, long& y
) const;
162 const wxRegionContain
Contains(const wxPoint
& pt
) const;
163 const wxRegionContain
Contains(long& x
, long& y
,
166 const wxRegionContain
Contains(const wxRect
& rect
) const;
170 Convert the region to a black and white bitmap with the white pixels
171 being inside the region.
173 wxBitmap
ConvertToBitmap() const;
177 Returns the outer bounds of the region.
179 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
180 wxCoord
& height
) const;
181 const wxRect
GetBox() const;
186 Finds the intersection of this region and another region.
188 @returns @true if successful, @false otherwise.
190 @remarks Creates the intersection of the two regions, that is, the parts
191 which are in both regions. The result is stored in this
194 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
196 bool Intersect(const wxRect
& rect
);
197 bool Intersect(const wxRegion
& region
);
201 Returns @true if the region is empty, @false otherwise.
203 bool IsEmpty() const;
206 Returns @true if the region is equal to, i.e. covers the same area as,
207 another one. Note that if both this region and @a region are invalid, they
208 are considered to be equal.
210 bool IsEqual(const wxRegion
& region
) const;
214 Moves the region by the specified offsets in horizontal and vertical
217 @returns @true if successful, @false otherwise (the region is unchanged
220 bool Offset(wxCoord x
, wxCoord y
);
221 bool Offset(const wxPoint
& pt
);
226 Subtracts a region from this region.
228 @returns @true if successful, @false otherwise.
230 @remarks This operation combines the parts of 'this' region that are not
231 part of the second region. The result is stored in this
234 bool Subtract(const wxRect
& rect
);
235 bool Subtract(const wxRegion
& region
);
240 Finds the union of this region and the non-transparent pixels of a
241 bitmap. Colour to be treated as transparent is specified in the
242 @a transColour argument, along with an
243 optional colour tolerance value.
245 @returns @true if successful, @false otherwise.
247 @remarks This operation creates a region that combines all of this region
248 and the second region. The result is stored in this
251 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
252 bool Union(const wxRect
& rect
);
253 bool Union(const wxRegion
& region
);
254 bool Union(const wxBitmap
& bmp
);
255 bool Union(const wxBitmap
& bmp
, const wxColour
& transColour
,
261 Finds the Xor of this region and another region.
263 @returns @true if successful, @false otherwise.
265 @remarks This operation creates a region that combines all of this region
266 and the second region, except for any overlapping
267 areas. The result is stored in this region.
269 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
270 bool Xor(const wxRect
& rect
);
271 bool Xor(const wxRegion
& region
);
275 Assignment operator, using @ref overview_trefcount "reference counting".
277 void operator =(const wxRegion
& region
);