]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: region.h | |
e54c96f1 | 3 | // Purpose: interface of wxRegionIterator |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxRegionIterator | |
11 | @wxheader{region.h} | |
7c913512 | 12 | |
23324ae1 FM |
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. | |
7c913512 | 15 | |
23324ae1 FM |
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 | |
18 | loop. | |
7c913512 | 19 | |
23324ae1 | 20 | See wxPaintEvent for an example of use. |
7c913512 | 21 | |
23324ae1 FM |
22 | @library{wxcore} |
23 | @category{FIXME} | |
7c913512 | 24 | |
e54c96f1 | 25 | @see wxPaintEvent |
23324ae1 FM |
26 | */ |
27 | class wxRegionIterator : public wxObject | |
28 | { | |
29 | public: | |
30 | //@{ | |
31 | /** | |
32 | Creates an iterator object given a region. | |
33 | */ | |
34 | wxRegionIterator(); | |
7c913512 | 35 | wxRegionIterator(const wxRegion& region); |
23324ae1 FM |
36 | //@} |
37 | ||
38 | /** | |
39 | An alias for GetHeight. | |
40 | */ | |
328f5751 | 41 | wxCoord GetH() const; |
23324ae1 FM |
42 | |
43 | /** | |
44 | Returns the height value for the current region. | |
45 | */ | |
328f5751 | 46 | wxCoord GetHeight() const; |
23324ae1 FM |
47 | |
48 | /** | |
49 | Returns the current rectangle. | |
50 | */ | |
328f5751 | 51 | wxRect GetRect() const; |
23324ae1 FM |
52 | |
53 | /** | |
54 | An alias for GetWidth. | |
55 | */ | |
328f5751 | 56 | wxCoord GetW() const; |
23324ae1 FM |
57 | |
58 | /** | |
59 | Returns the width value for the current region. | |
60 | */ | |
328f5751 | 61 | wxCoord GetWidth() const; |
23324ae1 FM |
62 | |
63 | /** | |
64 | Returns the x value for the current region. | |
65 | */ | |
328f5751 | 66 | wxCoord GetX() const; |
23324ae1 FM |
67 | |
68 | /** | |
69 | Returns the y value for the current region. | |
70 | */ | |
328f5751 | 71 | wxCoord GetY() const; |
23324ae1 FM |
72 | |
73 | /** | |
74 | Returns @true if there are still some rectangles; otherwise returns @false. | |
75 | */ | |
328f5751 | 76 | bool HaveRects() const; |
23324ae1 FM |
77 | |
78 | //@{ | |
79 | /** | |
80 | Resets the iterator to the given region. | |
81 | */ | |
82 | void Reset(); | |
7c913512 | 83 | void Reset(const wxRegion& region); |
23324ae1 FM |
84 | //@} |
85 | ||
86 | /** | |
87 | Increment operator. Increments the iterator to the next region. | |
88 | */ | |
89 | void operator ++(); | |
90 | ||
91 | /** | |
92 | Returns @true if there are still some rectangles; otherwise returns @false. | |
23324ae1 FM |
93 | You can use this to test the iterator object as if it were of type bool. |
94 | */ | |
328f5751 | 95 | operator bool() const; |
23324ae1 FM |
96 | }; |
97 | ||
98 | ||
e54c96f1 | 99 | |
23324ae1 FM |
100 | /** |
101 | @class wxRegion | |
102 | @wxheader{region.h} | |
7c913512 | 103 | |
23324ae1 | 104 | A wxRegion represents a simple or complex region on a device context or window. |
7c913512 | 105 | |
23324ae1 FM |
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. | |
7c913512 | 112 | |
23324ae1 | 113 | @library{wxcore} |
c0cc7004 | 114 | @category{data,gdi} |
7c913512 | 115 | |
e54c96f1 | 116 | @see wxRegionIterator |
23324ae1 FM |
117 | */ |
118 | class wxRegion : public wxGDIObject | |
119 | { | |
120 | public: | |
121 | //@{ | |
122 | /** | |
123 | Constructs a region using the non-transparent pixels of a bitmap. See | |
124 | Union() for more details. | |
125 | */ | |
126 | wxRegion(); | |
7c913512 FM |
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, | |
135 | int tolerance = 0); | |
23324ae1 FM |
136 | //@} |
137 | ||
138 | /** | |
139 | Destructor. | |
140 | See @ref overview_refcountdestruct "reference-counted object destruction" for | |
141 | more info. | |
142 | */ | |
143 | ~wxRegion(); | |
144 | ||
145 | /** | |
146 | Clears the current region. | |
147 | */ | |
148 | void Clear(); | |
149 | ||
150 | //@{ | |
151 | /** | |
152 | Returns a value indicating whether the given rectangle is contained within the | |
153 | region. | |
154 | ||
155 | @returns The return value is one of wxOutRegion, wxPartRegion and | |
4cc4bfaf | 156 | wxInRegion. |
23324ae1 | 157 | */ |
328f5751 FM |
158 | wxRegionContain Contains(long& x, long& y) const; |
159 | const wxRegionContain Contains(const wxPoint& pt) const; | |
160 | const wxRegionContain Contains(long& x, long& y, | |
161 | long& width, | |
162 | long& height) const; | |
163 | const wxRegionContain Contains(const wxRect& rect) const; | |
23324ae1 FM |
164 | //@} |
165 | ||
166 | /** | |
167 | Convert the region to a black and white bitmap with the white pixels | |
168 | being inside the region. | |
169 | */ | |
328f5751 | 170 | wxBitmap ConvertToBitmap() const; |
23324ae1 FM |
171 | |
172 | //@{ | |
173 | /** | |
174 | Returns the outer bounds of the region. | |
175 | */ | |
176 | void GetBox(wxCoord& x, wxCoord& y, wxCoord& width, | |
328f5751 FM |
177 | wxCoord& height) const; |
178 | const wxRect GetBox() const; | |
23324ae1 FM |
179 | //@} |
180 | ||
181 | //@{ | |
182 | /** | |
183 | Finds the intersection of this region and another region. | |
184 | ||
185 | @returns @true if successful, @false otherwise. | |
186 | ||
187 | @remarks Creates the intersection of the two regions, that is, the parts | |
4cc4bfaf FM |
188 | which are in both regions. The result is stored in this |
189 | region. | |
23324ae1 FM |
190 | */ |
191 | bool Intersect(wxCoord x, wxCoord y, wxCoord width, | |
192 | wxCoord height); | |
7c913512 FM |
193 | bool Intersect(const wxRect& rect); |
194 | bool Intersect(const wxRegion& region); | |
23324ae1 FM |
195 | //@} |
196 | ||
197 | /** | |
198 | Returns @true if the region is empty, @false otherwise. | |
199 | */ | |
328f5751 | 200 | bool IsEmpty() const; |
23324ae1 FM |
201 | |
202 | /** | |
203 | Returns @true if the region is equal to, i.e. covers the same area as, | |
4cc4bfaf | 204 | another one. Note that if both this region and @a region are invalid, they |
23324ae1 FM |
205 | are considered to be equal. |
206 | */ | |
328f5751 | 207 | bool IsEqual(const wxRegion& region) const; |
23324ae1 FM |
208 | |
209 | //@{ | |
210 | /** | |
211 | Moves the region by the specified offsets in horizontal and vertical | |
212 | directions. | |
213 | ||
214 | @returns @true if successful, @false otherwise (the region is unchanged | |
4cc4bfaf | 215 | then). |
23324ae1 FM |
216 | */ |
217 | bool Offset(wxCoord x, wxCoord y); | |
7c913512 | 218 | bool Offset(const wxPoint& pt); |
23324ae1 FM |
219 | //@} |
220 | ||
221 | //@{ | |
222 | /** | |
223 | Subtracts a region from this region. | |
224 | ||
225 | @returns @true if successful, @false otherwise. | |
226 | ||
227 | @remarks This operation combines the parts of 'this' region that are not | |
4cc4bfaf FM |
228 | part of the second region. The result is stored in this |
229 | region. | |
23324ae1 FM |
230 | */ |
231 | bool Subtract(const wxRect& rect); | |
7c913512 | 232 | bool Subtract(const wxRegion& region); |
23324ae1 FM |
233 | //@} |
234 | ||
235 | //@{ | |
236 | /** | |
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 | |
4cc4bfaf | 239 | @a transColour argument, along with an |
23324ae1 FM |
240 | optional colour tolerance value. |
241 | ||
242 | @returns @true if successful, @false otherwise. | |
243 | ||
244 | @remarks This operation creates a region that combines all of this region | |
4cc4bfaf FM |
245 | and the second region. The result is stored in this |
246 | region. | |
23324ae1 FM |
247 | */ |
248 | bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
7c913512 FM |
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, | |
253 | int tolerance = 0); | |
23324ae1 FM |
254 | //@} |
255 | ||
256 | //@{ | |
257 | /** | |
258 | Finds the Xor of this region and another region. | |
259 | ||
260 | @returns @true if successful, @false otherwise. | |
261 | ||
262 | @remarks This operation creates a region that combines all of this region | |
4cc4bfaf FM |
263 | and the second region, except for any overlapping |
264 | areas. The result is stored in this region. | |
23324ae1 FM |
265 | */ |
266 | bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height); | |
7c913512 FM |
267 | bool Xor(const wxRect& rect); |
268 | bool Xor(const wxRegion& region); | |
23324ae1 FM |
269 | //@} |
270 | ||
271 | /** | |
272 | Assignment operator, using @ref overview_trefcount "reference counting". | |
273 | */ | |
274 | void operator =(const wxRegion& region); | |
275 | }; | |
e54c96f1 | 276 |