]>
git.saurik.com Git - wxWidgets.git/blob - interface/region.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxRegionIterator class
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.
28 class wxRegionIterator
: public wxObject
33 Creates an iterator object given a region.
36 wxRegionIterator(const wxRegion
& region
);
40 An alias for GetHeight.
42 #define wxCoord GetH() /* implementation is private */
45 Returns the height value for the current region.
50 Returns the current rectangle.
55 An alias for GetWidth.
57 #define wxCoord GetW() /* implementation is private */
60 Returns the width value for the current region.
65 Returns the x value for the current region.
67 #define wxCoord GetX() /* implementation is private */
70 Returns the y value for the current region.
72 #define wxCoord GetY() /* implementation is private */
75 Returns @true if there are still some rectangles; otherwise returns @false.
81 Resets the iterator to the given region.
84 void Reset(const wxRegion
& region
);
88 Increment operator. Increments the iterator to the next region.
93 Returns @true if there are still some rectangles; otherwise returns @false.
95 You can use this to test the iterator object as if it were of type bool.
105 A wxRegion represents a simple or complex region on a device context or window.
107 This class uses @ref overview_trefcount "reference counting and copy-on-write"
108 internally so that assignments between two instances of this class are very
109 cheap. You can therefore use actual objects instead of pointers without
110 efficiency problems. If an instance of this class is changed it will create
111 its own data internally so that other instances, which previously shared the
112 data using the reference counting, are not affected.
120 class wxRegion
: public wxGDIObject
125 Constructs a region using the non-transparent pixels of a bitmap. See
126 Union() for more details.
129 wxRegion(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
130 wxRegion(const wxPoint
& topLeft
, const wxPoint
& bottomRight
);
131 wxRegion(const wxRect
& rect
);
132 wxRegion(const wxRegion
& region
);
133 wxRegion(size_t n
, const wxPoint points
,
134 int fillStyle
= wxWINDING_RULE
);
135 wxRegion(const wxBitmap
& bmp
);
136 wxRegion(const wxBitmap
& bmp
, const wxColour
& transColour
,
142 See @ref overview_refcountdestruct "reference-counted object destruction" for
148 Clears the current region.
154 Returns a value indicating whether the given rectangle is contained within the
157 @returns The return value is one of wxOutRegion, wxPartRegion and
160 wxRegionContain
Contains(long& x
, long& y
);
161 wxRegionContain
Contains(const wxPoint
& pt
);
162 wxRegionContain
Contains(long& x
, long& y
,
165 wxRegionContain
Contains(const wxRect
& rect
);
169 Convert the region to a black and white bitmap with the white pixels
170 being inside the region.
172 wxBitmap
ConvertToBitmap();
176 Returns the outer bounds of the region.
178 void GetBox(wxCoord
& x
, wxCoord
& y
, wxCoord
& width
,
185 Finds the intersection of this region and another region.
187 @returns @true if successful, @false otherwise.
189 @remarks Creates the intersection of the two regions, that is, the parts
190 which are in both regions. The result is stored in
193 bool Intersect(wxCoord x
, wxCoord y
, wxCoord width
,
195 bool Intersect(const wxRect
& rect
);
196 bool Intersect(const wxRegion
& region
);
200 Returns @true if the region is empty, @false otherwise.
205 Returns @true if the region is equal to, i.e. covers the same area as,
206 another one. Note that if both this region and @e region are invalid, they
207 are considered to be equal.
209 bool IsEqual(const wxRegion
& region
);
213 Moves the region by the specified offsets in horizontal and vertical
216 @returns @true if successful, @false otherwise (the region is unchanged
219 bool Offset(wxCoord x
, wxCoord y
);
220 bool Offset(const wxPoint
& pt
);
225 Subtracts a region from this region.
227 @returns @true if successful, @false otherwise.
229 @remarks This operation combines the parts of 'this' region that are not
230 part of the second region. The result is stored in
233 bool Subtract(const wxRect
& rect
);
234 bool Subtract(const wxRegion
& region
);
239 Finds the union of this region and the non-transparent pixels of a
240 bitmap. Colour to be treated as transparent is specified in the
241 @e transColour argument, along with an
242 optional colour tolerance value.
244 @returns @true if successful, @false otherwise.
246 @remarks This operation creates a region that combines all of this region
247 and the second region. The result is stored in this
250 bool Union(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
251 bool Union(const wxRect
& rect
);
252 bool Union(const wxRegion
& region
);
253 bool Union(const wxBitmap
& bmp
);
254 bool Union(const wxBitmap
& bmp
, const wxColour
& transColour
,
260 Finds the Xor of this region and another region.
262 @returns @true if successful, @false otherwise.
264 @remarks This operation creates a region that combines all of this region
265 and the second region, except for any overlapping
266 areas. The result is stored in this region.
268 bool Xor(wxCoord x
, wxCoord y
, wxCoord width
, wxCoord height
);
269 bool Xor(const wxRect
& rect
);
270 bool Xor(const wxRegion
& region
);
274 Assignment operator, using @ref overview_trefcount "reference counting".
276 void operator =(const wxRegion
& region
);