1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxRegionIterator
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 Types of results returned from a call to wxRegion::Contains().
13 /** The specified value is not contained within this region. */
17 The specified value is partially contained within this region.
19 On Windows, this result is not supported. ::wxInRegion will be returned
25 The specified value is fully contained within this region.
27 On Windows, this result will be returned even if only part of the specified
28 value is contained in this region.
34 @class wxRegionIterator
36 This class is used to iterate through the rectangles in a region,
37 typically when examining the damaged regions of a window within an OnPaint call.
39 To use it, construct an iterator object on the stack and loop through the
40 regions, testing the object and incrementing the iterator at the end of the
43 See wxPaintEvent for an example of use.
53 class wxRegionIterator
: public wxObject
61 Creates an iterator object given a region.
63 wxRegionIterator(const wxRegion
& region
);
66 An alias for GetHeight().
71 Returns the height value for the current region.
73 wxCoord
GetHeight() const;
76 Returns the current rectangle.
78 wxRect
GetRect() const;
81 An alias for GetWidth().
86 Returns the width value for the current region.
88 wxCoord
GetWidth() const;
91 Returns the x value for the current region.
96 Returns the y value for the current region.
101 Returns @true if there are still some rectangles; otherwise returns @false.
103 bool HaveRects() const;
106 Resets the iterator to the beginning of the rectangles.
111 Resets the iterator to the given region.
113 void Reset(const wxRegion
& region
);
116 Increment operator. Increments the iterator to the next region.
118 wxRegionIterator
& operator ++();
121 Returns @true if there are still some rectangles; otherwise returns @false.
123 You can use this to test the iterator object as if it were of type @c bool.
125 operator bool() const;
133 A wxRegion represents a simple or complex region on a device context or window.
135 This class uses @ref overview_refcount "reference counting and copy-on-write"
136 internally so that assignments between two instances of this class are very
137 cheap. You can therefore use actual objects instead of pointers without
138 efficiency problems. If an instance of this class is changed it will create
139 its own data internally so that other instances, which previously shared the
140 data using the reference counting, are not affected.
148 @see wxRegionIterator
150 class wxRegion
: public wxGDIObject
156 This constructor creates an invalid, or null, object, i.e. calling
157 IsOk() on it returns @false and IsEmpty() returns @true.
161 Constructs a rectangular region with the given position and size.
163 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
165 Constructs a rectangular region from the top left point and the bottom right
168 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
170 Constructs a rectangular region a wxRect object.
172 wxRegion(const wxRect
& rect
);
174 Copy constructor, uses @ref overview_refcount.
176 wxRegion(const wxRegion
& region
);
178 Constructs a region corresponding to the polygon made of @a n points
179 in the provided array.
180 @a fillStyle parameter may have values @c wxWINDING_RULE or @c wxODDEVEN_RULE.
182 wxRegion(size_t n
, const wxPoint
* points
, wxPolygonFillMode fillStyle
= wxODDEVEN_RULE
);
184 Constructs a region using a bitmap. See Union() for more details.
186 wxRegion(const wxBitmap
& bmp
);
188 Constructs a region using the non-transparent pixels of a bitmap. See
189 Union() for more details.
191 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
196 See @ref overview_refcount_destruct "reference-counted object destruction" for
202 Clears the current region.
204 The object becomes invalid, or null, after being cleared.
206 virtual void Clear();
209 Returns a value indicating whether the given point is contained within the region.
211 This method always returns @c wxOutRegion for an invalid region but
212 may, nevertheless, be safely called in this case.
214 @return The return value is one of @c wxOutRegion and @c wxInRegion.
216 wxRegionContain
Contains(wxCoord x
, wxCoord y
) const;
218 Returns a value indicating whether the given point is contained within the region.
220 This method always returns @c wxOutRegion for an invalid region but
221 may, nevertheless, be safely called in this case.
223 @return The return value is one of @c wxOutRegion and @c wxInRegion.
225 wxRegionContain
Contains(const wxPoint
& pt
) const;
227 Returns a value indicating whether the given rectangle is contained within the
230 This method always returns @c wxOutRegion for an invalid region but
231 may, nevertheless, be safely called in this case.
233 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
235 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
236 ::wxInRegion then indicates that all or some part of the region is
237 contained in this region.
239 wxRegionContain
Contains(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
) const;
241 Returns a value indicating whether the given rectangle is contained within the
244 This method always returns @c wxOutRegion for an invalid region but
245 may, nevertheless, be safely called in this case.
247 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
249 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
250 ::wxInRegion then indicates that all or some part of the region is
251 contained in this region.
253 wxRegionContain
Contains(const wxRect
& rect
) const;
256 Convert the region to a black and white bitmap with the white pixels
257 being inside the region.
259 This method can't be used for invalid region.
261 wxBitmap
ConvertToBitmap() const;
265 Returns the outer bounds of the region.
267 This method returns 0-sized bounding box for invalid regions.
269 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
270 wxCoord
& height
) const;
271 wxRect
GetBox() const;
275 Finds the intersection of this region and another, rectangular region,
276 specified using position and size.
278 This method always fails, i.e. returns @false, if this region is
279 invalid but may nevertheless be safely used even in this case.
281 @return @true if successful, @false otherwise.
283 @remarks Creates the intersection of the two regions, that is, the parts
284 which are in both regions. The result is stored in this
287 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
290 Finds the intersection of this region and another, rectangular region.
292 This method always fails, i.e. returns @false, if this region is
293 invalid but may nevertheless be safely used even in this case.
295 @return @true if successful, @false otherwise.
297 @remarks Creates the intersection of the two regions, that is, the parts
298 which are in both regions. The result is stored in this
301 bool Intersect(const wxRect
& rect
);
303 Finds the intersection of this region and another region.
305 This method always fails, i.e. returns @false, if this region is
306 invalid but may nevertheless be safely used even in this case.
308 @return @true if successful, @false otherwise.
310 @remarks Creates the intersection of the two regions, that is, the parts
311 which are in both regions. The result is stored in this
314 bool Intersect(const wxRegion
& region
);
317 Returns @true if the region is empty, @false otherwise.
319 Always returns @true if the region is invalid.
321 virtual bool IsEmpty() const;
324 Returns @true if the region is equal to, i.e.\ covers the same area as,
327 If both this region and @a region are both invalid, they are considered
330 bool IsEqual(const wxRegion
& region
) const;
334 Moves the region by the specified offsets in horizontal and vertical
337 This method can't be called if the region is invalid as it doesn't make
338 sense to offset it then. Attempts to do it will result in assert
341 @return @true if successful, @false otherwise (the region is unchanged
344 bool Offset(wxCoord x
, wxCoord y
);
345 bool Offset(const wxPoint
& pt
);
349 Subtracts a rectangular region from this region.
351 This method always fails, i.e. returns @false, if this region is
352 invalid but may nevertheless be safely used even in this case.
354 @return @true if successful, @false otherwise.
356 @remarks This operation combines the parts of 'this' region that are not
357 part of the second region. The result is stored in this
360 bool Subtract(const wxRect
& rect
);
362 Subtracts a region from this region.
364 This method always fails, i.e. returns @false, if this region is
365 invalid but may nevertheless be safely used even in this case.
367 @return @true if successful, @false otherwise.
369 @remarks This operation combines the parts of 'this' region that are not
370 part of the second region. The result is stored in this
373 bool Subtract(const wxRegion
& region
);
376 Finds the union of this region and another, rectangular region, specified using
379 This method can be used even if this region is invalid and has the
380 natural behaviour in this case, i.e. makes this region equal to the
383 @return @true if successful, @false otherwise.
385 @remarks This operation creates a region that combines all of this region
386 and the second region. The result is stored in this
389 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
391 Finds the union of this region and another, rectangular region.
393 This method can be used even if this region is invalid and has the
394 natural behaviour in this case, i.e. makes this region equal to the
397 @return @true if successful, @false otherwise.
399 @remarks This operation creates a region that combines all of this region
400 and the second region. The result is stored in this
403 bool Union(const wxRect
& rect
);
405 Finds the union of this region and another region.
407 This method can be used even if this region is invalid and has the
408 natural behaviour in this case, i.e. makes this region equal to the
411 @return @true if successful, @false otherwise.
413 @remarks This operation creates a region that combines all of this region
414 and the second region. The result is stored in this
417 bool Union(const wxRegion
& region
);
419 Finds the union of this region and the non-transparent pixels of a
420 bitmap. The bitmap's mask is used to determine transparency. If the
421 bitmap doesn't have a mask, the bitmap's full dimensions are used.
423 @return @true if successful, @false otherwise.
425 @remarks This operation creates a region that combines all of this region
426 and the second region. The result is stored in this
429 bool Union(const wxBitmap
& bmp
);
431 Finds the union of this region and the non-transparent pixels of a
432 bitmap. Colour to be treated as transparent is specified in the
433 @a transColour argument, along with an optional colour tolerance value.
435 @return @true if successful, @false otherwise.
437 @remarks This operation creates a region that combines all of this region
438 and the second region. The result is stored in this
441 bool Union(const wxBitmap
& bmp
, const wxColour
& transColour
,
445 Finds the Xor of this region and another, rectangular region, specified using
448 This method can be used even if this region is invalid and has the
449 natural behaviour in this case, i.e. makes this region equal to the
452 @return @true if successful, @false otherwise.
454 @remarks This operation creates a region that combines all of this region
455 and the second region, except for any overlapping
456 areas. The result is stored in this region.
458 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
460 Finds the Xor of this region and another, rectangular region.
462 This method can be used even if this region is invalid and has the
463 natural behaviour in this case, i.e. makes this region equal to the
466 @return @true if successful, @false otherwise.
468 @remarks This operation creates a region that combines all of this region
469 and the second region, except for any overlapping
470 areas. The result is stored in this region.
472 bool Xor(const wxRect
& rect
);
474 Finds the Xor of this region and another region.
476 This method can be used even if this region is invalid and has the
477 natural behaviour in this case, i.e. makes this region equal to the
480 @return @true if successful, @false otherwise.
482 @remarks This operation creates a region that combines all of this region
483 and the second region, except for any overlapping
484 areas. The result is stored in this region.
486 bool Xor(const wxRegion
& region
);
489 Assignment operator, using @ref overview_refcount.
491 wxRegion
& operator=(const wxRegion
& region
);
497 wxRegion wxNullRegion
;