]>
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 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
38 This class is used to iterate through the rectangles in a region,
39 typically when examining the damaged regions of a window within an OnPaint call.
41 To use it, construct an iterator object on the stack and loop through the
42 regions, testing the object and incrementing the iterator at the end of the
45 See wxPaintEvent for an example of use.
55 class wxRegionIterator
: public wxObject
63 Creates an iterator object given a region.
65 wxRegionIterator(const wxRegion
& region
);
68 An alias for GetHeight().
73 Returns the height value for the current region.
75 wxCoord
GetHeight() const;
78 Returns the current rectangle.
80 wxRect
GetRect() const;
83 An alias for GetWidth().
88 Returns the width value for the current region.
90 wxCoord
GetWidth() const;
93 Returns the x value for the current region.
98 Returns the y value for the current region.
100 wxCoord
GetY() const;
103 Returns @true if there are still some rectangles; otherwise returns @false.
105 bool HaveRects() const;
108 Resets the iterator to the beginning of the rectangles.
113 Resets the iterator to the given region.
115 void Reset(const wxRegion
& region
);
118 Increment operator. Increments the iterator to the next region.
121 A wxPython alias for this operator is called Next.
127 Returns @true if there are still some rectangles; otherwise returns @false.
129 You can use this to test the iterator object as if it were of type @c bool.
131 operator bool() const;
140 A wxRegion represents a simple or complex region on a device context or window.
142 This class uses @ref overview_refcount "reference counting and copy-on-write"
143 internally so that assignments between two instances of this class are very
144 cheap. You can therefore use actual objects instead of pointers without
145 efficiency problems. If an instance of this class is changed it will create
146 its own data internally so that other instances, which previously shared the
147 data using the reference counting, are not affected.
155 @see wxRegionIterator
157 class wxRegion
: public wxGDIObject
165 Constructs a rectangular region with the given position and size.
167 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
169 Constructs a rectangular region from the top left point and the bottom right
172 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
174 Constructs a rectangular region a wxRect object.
176 wxRegion(const wxRect
& rect
);
178 Copy constructor, uses @ref overview_refcount.
180 wxRegion(const wxRegion
& region
);
182 Constructs a region corresponding to the polygon made of @a n points
183 in the provided array.
184 @a fillStyle parameter may have values @c wxWINDING_RULE or @c wxODDEVEN_RULE.
186 wxRegion(size_t n
, const wxPoint
* points
, int fillStyle
= wxWINDING_RULE
);
188 Constructs a region using a bitmap. See Union() for more details.
190 wxRegion(const wxBitmap
& bmp
);
192 Constructs a region using the non-transparent pixels of a bitmap. See
193 Union() for more details.
195 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
200 See @ref overview_refcount_destruct "reference-counted object destruction" for
206 Clears the current region.
211 Returns a value indicating whether the given point is contained within the region.
213 @return The return value is one of @c wxOutRegion and @c wxInRegion.
215 wxRegionContain
Contains(long& x
, long& y
) const;
217 Returns a value indicating whether the given point is contained within the region.
219 @return The return value is one of @c wxOutRegion and @c wxInRegion.
221 wxRegionContain
Contains(const wxPoint
& pt
) const;
223 Returns a value indicating whether the given rectangle is contained within the
226 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
228 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
229 ::wxInRegion then indicates that all or some part of the region is
230 contained in this region.
232 wxRegionContain
Contains(long& x
, long& y
, long& width
, long& height
) const;
234 Returns a value indicating whether the given rectangle is contained within the
237 @return One of ::wxOutRegion, ::wxPartRegion or ::wxInRegion.
239 @note On Windows, only ::wxOutRegion and ::wxInRegion are returned; a value
240 ::wxInRegion then indicates that all or some part of the region is
241 contained in this region.
243 wxRegionContain
Contains(const wxRect
& rect
) const;
246 Convert the region to a black and white bitmap with the white pixels
247 being inside the region.
249 wxBitmap
ConvertToBitmap() const;
253 Returns the outer bounds of the region.
255 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
256 wxCoord
& height
) const;
257 const wxRect
GetBox() const;
261 Finds the intersection of this region and another, rectangular region,
262 specified using position and size.
264 @return @true if successful, @false otherwise.
266 @remarks Creates the intersection of the two regions, that is, the parts
267 which are in both regions. The result is stored in this
270 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
273 Finds the intersection of this region and another, rectangular region.
275 @return @true if successful, @false otherwise.
277 @remarks Creates the intersection of the two regions, that is, the parts
278 which are in both regions. The result is stored in this
281 bool Intersect(const wxRect
& rect
);
283 Finds the intersection of this region and another region.
285 @return @true if successful, @false otherwise.
287 @remarks Creates the intersection of the two regions, that is, the parts
288 which are in both regions. The result is stored in this
291 bool Intersect(const wxRegion
& region
);
294 Returns @true if the region is empty, @false otherwise.
296 bool IsEmpty() const;
299 Returns @true if the region is equal to, i.e. covers the same area as,
302 @note If both this region and @a region are invalid, they are
303 considered to be equal.
305 bool IsEqual(const wxRegion
& region
) const;
309 Moves the region by the specified offsets in horizontal and vertical
312 @return @true if successful, @false otherwise (the region is unchanged
315 bool Offset(wxCoord x
, wxCoord y
);
316 bool Offset(const wxPoint
& pt
);
320 Subtracts a rectangular region from this region.
322 @return @true if successful, @false otherwise.
324 @remarks This operation combines the parts of 'this' region that are not
325 part of the second region. The result is stored in this
328 bool Subtract(const wxRect
& rect
);
330 Subtracts a region from this region.
332 @return @true if successful, @false otherwise.
334 @remarks This operation combines the parts of 'this' region that are not
335 part of the second region. The result is stored in this
338 bool Subtract(const wxRegion
& region
);
341 Finds the union of this region and another, rectangular region, specified using
344 @return @true if successful, @false otherwise.
346 @remarks This operation creates a region that combines all of this region
347 and the second region. The result is stored in this
350 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
352 Finds the union of this region and another, rectangular region.
354 @return @true if successful, @false otherwise.
356 @remarks This operation creates a region that combines all of this region
357 and the second region. The result is stored in this
360 bool Union(const wxRect
& rect
);
362 Finds the union of this region and another region.
364 @return @true if successful, @false otherwise.
366 @remarks This operation creates a region that combines all of this region
367 and the second region. The result is stored in this
370 bool Union(const wxRegion
& region
);
372 Finds the union of this region and the non-transparent pixels of a
373 bitmap. The bitmap's mask is used to determine transparency. If the
374 bitmap doesn't have a mask, the bitmap's full dimensions are used.
376 @return @true if successful, @false otherwise.
378 @remarks This operation creates a region that combines all of this region
379 and the second region. The result is stored in this
382 bool Union(const wxBitmap
& bmp
);
384 Finds the union of this region and the non-transparent pixels of a
385 bitmap. Colour to be treated as transparent is specified in the
386 @a transColour argument, along with an optional colour tolerance value.
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(const wxBitmap
& bmp
, const wxColour
& transColour
,
398 Finds the Xor of this region and another, rectangular region, specified using
401 @return @true if successful, @false otherwise.
403 @remarks This operation creates a region that combines all of this region
404 and the second region, except for any overlapping
405 areas. The result is stored in this region.
407 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
409 Finds the Xor of this region and another, rectangular region.
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, except for any overlapping
415 areas. The result is stored in this region.
417 bool Xor(const wxRect
& rect
);
419 Finds the Xor of this region and another region.
421 @return @true if successful, @false otherwise.
423 @remarks This operation creates a region that combines all of this region
424 and the second region, except for any overlapping
425 areas. The result is stored in this region.
427 bool Xor(const wxRegion
& region
);
430 Assignment operator, using @ref overview_refcount.
432 void operator =(const wxRegion
& region
);
438 wxRegion wxNullRegion
;