1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRegionIterator
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 Types of results returned from a call to wxRegion::Contains().
14 /** The specified value is not contained within this region. */
18 The specified value is partially contained within this region.
20 On Windows, this result is not supported. ::wxInRegion will be returned
26 The specified value is fully contained within this region.
28 On Windows, this result will be returned even if only part of the specified
29 value is contained in this region.
35 @class wxRegionIterator
37 This class is used to iterate through the rectangles in a region,
38 typically when examining the damaged regions of a window within an OnPaint call.
40 To use it, construct an iterator object on the stack and loop through the
41 regions, testing the object and incrementing the iterator at the end of the
44 See wxPaintEvent for an example of use.
54 class wxRegionIterator
: public wxObject
62 Creates an iterator object given a region.
64 wxRegionIterator(const wxRegion
& region
);
67 An alias for GetHeight().
72 Returns the height value for the current region.
74 wxCoord
GetHeight() const;
77 Returns the current rectangle.
79 wxRect
GetRect() const;
82 An alias for GetWidth().
87 Returns the width value for the current region.
89 wxCoord
GetWidth() const;
92 Returns the x value for the current region.
97 Returns the y value for the current region.
102 Returns @true if there are still some rectangles; otherwise returns @false.
104 bool HaveRects() const;
107 Resets the iterator to the beginning of the rectangles.
112 Resets the iterator to the given region.
114 void Reset(const wxRegion
& region
);
117 Increment operator. Increments the iterator to the next region.
120 A wxPython alias for this operator is called Next.
123 wxRegionIterator
& operator ++();
126 Returns @true if there are still some rectangles; otherwise returns @false.
128 You can use this to test the iterator object as if it were of type @c bool.
130 operator bool() const;
138 A wxRegion represents a simple or complex region on a device context or window.
140 This class uses @ref overview_refcount "reference counting and copy-on-write"
141 internally so that assignments between two instances of this class are very
142 cheap. You can therefore use actual objects instead of pointers without
143 efficiency problems. If an instance of this class is changed it will create
144 its own data internally so that other instances, which previously shared the
145 data using the reference counting, are not affected.
153 @see wxRegionIterator
155 class wxRegion
: public wxGDIObject
161 This constructor creates an invalid, or null, object, i.e. calling
162 IsOk() on it returns @false and IsNull() returns @true.
166 Constructs a rectangular region with the given position and size.
168 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
170 Constructs a rectangular region from the top left point and the bottom right
173 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
175 Constructs a rectangular region a wxRect object.
177 wxRegion(const wxRect
& rect
);
179 Copy constructor, uses @ref overview_refcount.
181 wxRegion(const wxRegion
& region
);
183 Constructs a region corresponding to the polygon made of @a n points
184 in the provided array.
185 @a fillStyle parameter may have values @c wxWINDING_RULE or @c wxODDEVEN_RULE.
187 wxRegion(size_t n
, const wxPoint
* points
, wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
189 Constructs a region using a bitmap. See Union() for more details.
191 wxRegion(const wxBitmap
& bmp
);
193 Constructs a region using the non-transparent pixels of a bitmap. See
194 Union() for more details.
196 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
201 See @ref overview_refcount_destruct "reference-counted object destruction" for
207 Clears the current region.
209 The object becomes invalid, or null, after being cleared.
211 virtual void Clear();
214 Returns a value indicating whether the given point is contained within the region.
216 This method always returns @c wxOutRegion for an invalid region but
217 may, nevertheless, be safely called in this case.
219 @return The return value is one of @c wxOutRegion and @c wxInRegion.
221 wxRegionContain
Contains(wxCoord x
, wxCoord y
) const;
223 Returns a value indicating whether the given point is contained within the region.
225 This method always returns @c wxOutRegion for an invalid region but
226 may, nevertheless, be safely called in this case.
228 @return The return value is one of @c wxOutRegion and @c wxInRegion.
230 wxRegionContain
Contains(const wxPoint
& pt
) const;
232 Returns a value indicating whether the given rectangle is contained within the
235 This method always returns @c wxOutRegion for an invalid region but
236 may, nevertheless, be safely called in this case.
238 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
240 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
241 ::wxInRegion then indicates that all or some part of the region is
242 contained in this region.
244 wxRegionContain
Contains(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) const;
246 Returns a value indicating whether the given rectangle is contained within the
249 This method always returns @c wxOutRegion for an invalid region but
250 may, nevertheless, be safely called in this case.
252 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
254 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
255 ::wxInRegion then indicates that all or some part of the region is
256 contained in this region.
258 wxRegionContain
Contains(const wxRect
& rect
) const;
261 Convert the region to a black and white bitmap with the white pixels
262 being inside the region.
264 This method can't be used for invalid region.
266 wxBitmap
ConvertToBitmap() const;
270 Returns the outer bounds of the region.
272 This method returns 0-sized bounding box for invalid regions.
274 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
275 wxCoord
& height
) const;
276 wxRect
GetBox() const;
280 Finds the intersection of this region and another, rectangular region,
281 specified using position and size.
283 This method always fails, i.e. returns @false, if this region is
284 invalid but may nevertheless be safely used even in this case.
286 @return @true if successful, @false otherwise.
288 @remarks Creates the intersection of the two regions, that is, the parts
289 which are in both regions. The result is stored in this
292 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
295 Finds the intersection of this region and another, rectangular region.
297 This method always fails, i.e. returns @false, if this region is
298 invalid but may nevertheless be safely used even in this case.
300 @return @true if successful, @false otherwise.
302 @remarks Creates the intersection of the two regions, that is, the parts
303 which are in both regions. The result is stored in this
306 bool Intersect(const wxRect
& rect
);
308 Finds the intersection of this region and another region.
310 This method always fails, i.e. returns @false, if this region is
311 invalid but may nevertheless be safely used even in this case.
313 @return @true if successful, @false otherwise.
315 @remarks Creates the intersection of the two regions, that is, the parts
316 which are in both regions. The result is stored in this
319 bool Intersect(const wxRegion
& region
);
322 Returns @true if the region is empty, @false otherwise.
324 Always returns @true if the region is invalid.
326 virtual bool IsEmpty() const;
329 Returns @true if the region is equal to, i.e. covers the same area as,
332 If both this region and @a region are both invalid, they are considered
335 bool IsEqual(const wxRegion
& region
) const;
339 Moves the region by the specified offsets in horizontal and vertical
342 This method can't be called if the region is invalid as it doesn't make
343 sense to offset it then. Attempts to do it will result in assert
346 @return @true if successful, @false otherwise (the region is unchanged
349 bool Offset(wxCoord x
, wxCoord y
);
350 bool Offset(const wxPoint
& pt
);
354 Subtracts a rectangular region from this region.
356 This method always fails, i.e. returns @false, if this region is
357 invalid but may nevertheless be safely used even in this case.
359 @return @true if successful, @false otherwise.
361 @remarks This operation combines the parts of 'this' region that are not
362 part of the second region. The result is stored in this
365 bool Subtract(const wxRect
& rect
);
367 Subtracts a region from this region.
369 This method always fails, i.e. returns @false, if this region is
370 invalid but may nevertheless be safely used even in this case.
372 @return @true if successful, @false otherwise.
374 @remarks This operation combines the parts of 'this' region that are not
375 part of the second region. The result is stored in this
378 bool Subtract(const wxRegion
& region
);
381 Finds the union of this region and another, rectangular region, specified using
384 This method can be used even if this region is invalid and has the
385 natural behaviour in this case, i.e. makes this region equal to the
388 @return @true if successful, @false otherwise.
390 @remarks This operation creates a region that combines all of this region
391 and the second region. The result is stored in this
394 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
396 Finds the union of this region and another, rectangular region.
398 This method can be used even if this region is invalid and has the
399 natural behaviour in this case, i.e. makes this region equal to the
402 @return @true if successful, @false otherwise.
404 @remarks This operation creates a region that combines all of this region
405 and the second region. The result is stored in this
408 bool Union(const wxRect
& rect
);
410 Finds the union of this region and another region.
412 This method can be used even if this region is invalid and has the
413 natural behaviour in this case, i.e. makes this region equal to the
416 @return @true if successful, @false otherwise.
418 @remarks This operation creates a region that combines all of this region
419 and the second region. The result is stored in this
422 bool Union(const wxRegion
& region
);
424 Finds the union of this region and the non-transparent pixels of a
425 bitmap. The bitmap's mask is used to determine transparency. If the
426 bitmap doesn't have a mask, the bitmap's full dimensions are used.
428 @return @true if successful, @false otherwise.
430 @remarks This operation creates a region that combines all of this region
431 and the second region. The result is stored in this
434 bool Union(const wxBitmap
& bmp
);
436 Finds the union of this region and the non-transparent pixels of a
437 bitmap. Colour to be treated as transparent is specified in the
438 @a transColour argument, along with an optional colour tolerance value.
440 @return @true if successful, @false otherwise.
442 @remarks This operation creates a region that combines all of this region
443 and the second region. The result is stored in this
446 bool Union(const wxBitmap
& bmp
, const wxColour
& transColour
,
450 Finds the Xor of this region and another, rectangular region, specified using
453 This method can be used even if this region is invalid and has the
454 natural behaviour in this case, i.e. makes this region equal to the
457 @return @true if successful, @false otherwise.
459 @remarks This operation creates a region that combines all of this region
460 and the second region, except for any overlapping
461 areas. The result is stored in this region.
463 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
465 Finds the Xor of this region and another, rectangular region.
467 This method can be used even if this region is invalid and has the
468 natural behaviour in this case, i.e. makes this region equal to the
471 @return @true if successful, @false otherwise.
473 @remarks This operation creates a region that combines all of this region
474 and the second region, except for any overlapping
475 areas. The result is stored in this region.
477 bool Xor(const wxRect
& rect
);
479 Finds the Xor of this region and another region.
481 This method can be used even if this region is invalid and has the
482 natural behaviour in this case, i.e. makes this region equal to the
485 @return @true if successful, @false otherwise.
487 @remarks This operation creates a region that combines all of this region
488 and the second region, except for any overlapping
489 areas. The result is stored in this region.
491 bool Xor(const wxRegion
& region
);
494 Assignment operator, using @ref overview_refcount.
496 wxRegion
& operator=(const wxRegion
& region
);
502 wxRegion wxNullRegion
;