]>
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.
27 class wxRegionIterator
: public wxObject
32 Creates an iterator object given a region.
35 wxRegionIterator(const wxRegion
& region
);
39 An alias for GetHeight.
44 Returns the height value for the current region.
46 wxCoord
GetHeight() const;
49 Returns the current rectangle.
51 wxRect
GetRect() const;
54 An alias for GetWidth.
59 Returns the width value for the current region.
61 wxCoord
GetWidth() const;
64 Returns the x value for the current region.
69 Returns the y value for the current region.
74 Returns @true if there are still some rectangles; otherwise returns @false.
76 bool HaveRects() const;
80 Resets the iterator to the given region.
83 void Reset(const wxRegion
& region
);
87 Increment operator. Increments the iterator to the next region.
92 Returns @true if there are still some rectangles; otherwise returns @false.
93 You can use this to test the iterator object as if it were of type bool.
95 operator bool() const;
104 A wxRegion represents a simple or complex region on a device context or window.
106 This class uses @ref overview_trefcount "reference counting and copy-on-write"
107 internally so that assignments between two instances of this class are very
108 cheap. You can therefore use actual objects instead of pointers without
109 efficiency problems. If an instance of this class is changed it will create
110 its own data internally so that other instances, which previously shared the
111 data using the reference counting, are not affected.
116 @see wxRegionIterator
118 class wxRegion
: public wxGDIObject
123 Constructs a region using the non-transparent pixels of a bitmap. See
124 Union() for more details.
127 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
128 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
129 wxRegion(const wxRect
& rect
);
130 wxRegion(const wxRegion
& region
);
131 wxRegion(size_t n
, const wxPoint points
,
132 int fillStyle
= wxWINDING_RULE
);
133 wxRegion(const wxBitmap
& bmp
);
134 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
140 See @ref overview_refcountdestruct "reference-counted object destruction" for
146 Clears the current region.
152 Returns a value indicating whether the given rectangle is contained within the
155 @returns The return value is one of wxOutRegion, wxPartRegion and
158 wxRegionContain
Contains(long& x
, long& y
) const;
159 const wxRegionContain
Contains(const wxPoint
& pt
) const;
160 const wxRegionContain
Contains(long& x
, long& y
,
163 const wxRegionContain
Contains(const wxRect
& rect
) const;
167 Convert the region to a black and white bitmap with the white pixels
168 being inside the region.
170 wxBitmap
ConvertToBitmap() const;
174 Returns the outer bounds of the region.
176 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
177 wxCoord
& height
) const;
178 const wxRect
GetBox() const;
183 Finds the intersection of this region and another region.
185 @returns @true if successful, @false otherwise.
187 @remarks Creates the intersection of the two regions, that is, the parts
188 which are in both regions. The result is stored in this
191 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
193 bool Intersect(const wxRect
& rect
);
194 bool Intersect(const wxRegion
& region
);
198 Returns @true if the region is empty, @false otherwise.
200 bool IsEmpty() const;
203 Returns @true if the region is equal to, i.e. covers the same area as,
204 another one. Note that if both this region and @a region are invalid, they
205 are considered to be equal.
207 bool IsEqual(const wxRegion
& region
) const;
211 Moves the region by the specified offsets in horizontal and vertical
214 @returns @true if successful, @false otherwise (the region is unchanged
217 bool Offset(wxCoord x
, wxCoord y
);
218 bool Offset(const wxPoint
& pt
);
223 Subtracts a region from this region.
225 @returns @true if successful, @false otherwise.
227 @remarks This operation combines the parts of 'this' region that are not
228 part of the second region. The result is stored in this
231 bool Subtract(const wxRect
& rect
);
232 bool Subtract(const wxRegion
& region
);
237 Finds the union of this region and the non-transparent pixels of a
238 bitmap. Colour to be treated as transparent is specified in the
239 @a transColour argument, along with an
240 optional colour tolerance value.
242 @returns @true if successful, @false otherwise.
244 @remarks This operation creates a region that combines all of this region
245 and the second region. The result is stored in this
248 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
249 bool Union(const wxRect
& rect
);
250 bool Union(const wxRegion
& region
);
251 bool Union(const wxBitmap
& bmp
);
252 bool Union(const wxBitmap
& bmp
, const wxColour
& transColour
,
258 Finds the Xor of this region and another region.
260 @returns @true if successful, @false otherwise.
262 @remarks This operation creates a region that combines all of this region
263 and the second region, except for any overlapping
264 areas. The result is stored in this region.
266 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
267 bool Xor(const wxRect
& rect
);
268 bool Xor(const wxRegion
& region
);
272 Assignment operator, using @ref overview_trefcount "reference counting".
274 void operator =(const wxRegion
& region
);