]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxRegion}}\label{wxregion} |
2 | ||
3 | A wxRegion represents a simple or complex region on a device context or window. It uses | |
4 | reference counting, so copying and assignment operations are fast. | |
5 | ||
6 | \wxheading{Derived from} | |
7 | ||
8 | \helpref{wxGDIObject}{wxgdiobject}\\ | |
9 | \helpref{wxObject}{wxobject} | |
10 | ||
954b8ae6 JS |
11 | \wxheading{Include files} |
12 | ||
13 | <wx/region.h> | |
14 | ||
76c5df24 JS |
15 | \wxheading{See also} |
16 | ||
17 | \helpref{wxRegionIterator}{wxregioniterator} | |
18 | ||
a660d684 KB |
19 | \latexignore{\rtfignore{\wxheading{Members}}} |
20 | ||
8a16d737 | 21 | |
39275175 | 22 | \membersection{wxRegion::wxRegion}\label{wxregionctor} |
a660d684 KB |
23 | |
24 | \func{}{wxRegion}{\void} | |
25 | ||
26 | Default constructor. | |
27 | ||
0fb067bb | 28 | \func{}{wxRegion}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} |
a660d684 KB |
29 | |
30 | Constructs a rectangular region with the given position and size. | |
31 | ||
32 | \func{}{wxRegion}{\param{const wxPoint\&}{ topLeft}, \param{const wxPoint\&}{ bottomRight}} | |
33 | ||
34 | Constructs a rectangular region from the top left point and the bottom right point. | |
35 | ||
36 | \func{}{wxRegion}{\param{const wxRect\&}{ rect}} | |
37 | ||
38 | Constructs a rectangular region a wxRect object. | |
39 | ||
40 | \func{}{wxRegion}{\param{const wxRegion\&}{ region}} | |
41 | ||
a91225b2 | 42 | Copy constructor, uses \helpref{reference counting}{trefcount}. |
a660d684 | 43 | |
5549e9f7 VZ |
44 | \func{}{wxRegion}{\param{size\_t}{ n}, \param{const wxPoint }{*points}, \param{int }{fillStyle = wxWINDING\_RULE}} |
45 | ||
46 | Constructs a region corresponding to the polygon made of {\it n} points in the | |
1542ea39 | 47 | provided array. {\it fillStyle} parameter may have values |
5549e9f7 VZ |
48 | {\tt wxWINDING\_RULE} or {\tt wxODDEVEN\_RULE}. |
49 | ||
fc2171bd | 50 | {\bf NB:} This constructor is only implemented for Win32 and GTK+ wxWidgets ports. |
5549e9f7 | 51 | |
85f6b408 VS |
52 | \func{}{wxRegion}{\param{const wxBitmap\&}{ bmp}} |
53 | ||
bf43ff9a | 54 | \func{}{wxRegion}{\param{const wxBitmap\&}{ bmp}, |
85f6b408 | 55 | \param{const wxColour\&}{ transColour}, |
8a16d737 | 56 | \param{int}{ tolerance = 0}} |
1542ea39 RD |
57 | |
58 | Constructs a region using the non-transparent pixels of a bitmap. See | |
59 | \helpref{Union}{wxregionunion} for more details. | |
60 | ||
61 | ||
8a16d737 | 62 | |
39275175 | 63 | \membersection{wxRegion::\destruct{wxRegion}}\label{wxregiondtor} |
a660d684 KB |
64 | |
65 | \func{}{\destruct{wxRegion}}{\void} | |
66 | ||
67 | Destructor. | |
68 | ||
8a16d737 | 69 | |
a660d684 KB |
70 | \membersection{wxRegion::Clear}\label{wxregionclear} |
71 | ||
72 | \func{void}{Clear}{\void} | |
73 | ||
74 | Clears the current region. | |
75 | ||
8a16d737 | 76 | |
a660d684 KB |
77 | \membersection{wxRegion::Contains}\label{wxregioncontains} |
78 | ||
79 | \constfunc{wxRegionContain}{Contains}{\param{long\& }{x}, \param{long\& }{y}} | |
80 | ||
81 | Returns a value indicating whether the given point is contained within the region. | |
82 | ||
83 | \constfunc{wxRegionContain}{Contains}{\param{const wxPoint\&}{ pt}} | |
84 | ||
85 | Returns a value indicating whether the given point is contained within the region. | |
86 | ||
87 | \constfunc{wxRegionContain}{Contains}{\param{long\& }{x}, \param{long\& }{y}, \param{long\& }{width}, \param{long\& }{height}} | |
88 | ||
89 | Returns a value indicating whether the given rectangle is contained within the region. | |
90 | ||
91 | \constfunc{wxRegionContain}{Contains}{\param{const wxRect\& }{rect}} | |
92 | ||
93 | Returns a value indicating whether the given rectangle is contained within the region. | |
94 | ||
95 | \wxheading{Return value} | |
96 | ||
97 | The return value is one of wxOutRegion, wxPartRegion and wxInRegion. | |
98 | ||
99 | On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that | |
100 | all or some part of the region is contained in this region. | |
101 | ||
8a16d737 | 102 | |
1542ea39 RD |
103 | \membersection{wxRegion::ConvertToBitmap}\label{wxregionconverttobitmap} |
104 | ||
105 | \constfunc{wxBitmap}{ConvertToBitmap}{} | |
106 | ||
819451b6 | 107 | Convert the region to a black and white bitmap with the white pixels |
1542ea39 RD |
108 | being inside the region. |
109 | ||
8a16d737 | 110 | |
a660d684 KB |
111 | \membersection{wxRegion::GetBox}\label{wxregiongetbox} |
112 | ||
9a75ba66 | 113 | \constfunc{void}{GetBox}{\param{wxCoord\& }{x}, \param{wxCoord\& }{y}, \param{wxCoord\& }{width}, \param{wxCoord\& }{height}} |
a660d684 KB |
114 | |
115 | Returns the outer bounds of the region. | |
116 | ||
117 | \constfunc{wxRect}{GetBox}{\void} | |
118 | ||
119 | Returns the outer bounds of the region. | |
120 | ||
8a16d737 | 121 | |
a660d684 KB |
122 | \membersection{wxRegion::Intersect}\label{wxregionintersect} |
123 | ||
0fb067bb | 124 | \func{bool}{Intersect}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} |
a660d684 KB |
125 | |
126 | Finds the intersection of this region and another, rectangular region, specified using position and size. | |
127 | ||
128 | \func{bool}{Intersect}{\param{const wxRect\&}{ rect}} | |
129 | ||
130 | Finds the intersection of this region and another, rectangular region. | |
131 | ||
132 | \func{bool}{Intersect}{\param{const wxRegion\&}{ region}} | |
133 | ||
134 | Finds the intersection of this region and another region. | |
135 | ||
136 | \wxheading{Return value} | |
137 | ||
cc81d32f | 138 | {\tt true} if successful, {\tt false} otherwise. |
a660d684 KB |
139 | |
140 | \wxheading{Remarks} | |
141 | ||
142 | Creates the intersection of the two regions, that is, the parts which are in both regions. The result | |
143 | is stored in this region. | |
144 | ||
8a16d737 | 145 | |
a660d684 KB |
146 | \membersection{wxRegion::IsEmpty}\label{wxregionisempty} |
147 | ||
148 | \constfunc{bool}{IsEmpty}{\void} | |
149 | ||
cc81d32f | 150 | Returns {\tt true} if the region is empty, {\tt false} otherwise. |
a660d684 | 151 | |
8a16d737 VZ |
152 | |
153 | \membersection{wxRegion::IsEqual}\label{wxregionisequal} | |
154 | ||
155 | \constfunc{bool}{IsEqual}{\param{const wxRegion\& }{region}} | |
156 | ||
157 | Returns {\tt true} if the region is equal to, i.e. covers the same area as, | |
158 | another one. Note that if both this region and \arg{region} are invalid, they | |
159 | are considered to be equal. | |
160 | ||
161 | ||
dbd94b75 | 162 | \membersection{wxRegion::Subtract}\label{wxregionsubtract} |
f3339684 | 163 | |
a660d684 KB |
164 | \func{bool}{Subtract}{\param{const wxRect\&}{ rect}} |
165 | ||
166 | Subtracts a rectangular region from this region. | |
167 | ||
168 | \func{bool}{Subtract}{\param{const wxRegion\&}{ region}} | |
169 | ||
170 | Subtracts a region from this region. | |
171 | ||
172 | \wxheading{Return value} | |
173 | ||
cc81d32f | 174 | {\tt true} if successful, {\tt false} otherwise. |
a660d684 KB |
175 | |
176 | \wxheading{Remarks} | |
177 | ||
178 | This operation combines the parts of 'this' region that are not part of the second region. | |
179 | The result is stored in this region. | |
180 | ||
8a16d737 | 181 | |
0fb067bb VZ |
182 | \membersection{wxRegion::Offset}\label{wxregionoffset} |
183 | ||
184 | \func{bool}{Offset}{\param{wxCoord}{ x}, \param{wxCoord}{ y}} | |
185 | ||
8a16d737 VZ |
186 | \func{bool}{Offset}{\param{const wxPoint\& }{ pt}} |
187 | ||
0fb067bb VZ |
188 | Moves the region by the specified offsets in horizontal and vertical |
189 | directions. | |
190 | ||
191 | \wxheading{Return value} | |
192 | ||
cc81d32f | 193 | {\tt true} if successful, {\tt false} otherwise (the region is unchanged then). |
0fb067bb | 194 | |
8a16d737 | 195 | |
a660d684 KB |
196 | \membersection{wxRegion::Union}\label{wxregionunion} |
197 | ||
0fb067bb | 198 | \func{bool}{Union}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} |
a660d684 KB |
199 | |
200 | Finds the union of this region and another, rectangular region, specified using position and size. | |
201 | ||
202 | \func{bool}{Union}{\param{const wxRect\&}{ rect}} | |
203 | ||
204 | Finds the union of this region and another, rectangular region. | |
205 | ||
206 | \func{bool}{Union}{\param{const wxRegion\&}{ region}} | |
207 | ||
208 | Finds the union of this region and another region. | |
209 | ||
85f6b408 VS |
210 | \func{bool}{Union}{\param{const wxBitmap\&}{ bmp}} |
211 | ||
43e8916f | 212 | Finds the union of this region and the non-transparent pixels of a |
85f6b408 VS |
213 | bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't |
214 | have a mask, solid rectangle of bitmap's dimensions is used. | |
215 | ||
bf43ff9a | 216 | \func{bool}{Union}{\param{const wxBitmap\&}{ bmp}, |
85f6b408 | 217 | \param{const wxColour\&}{ transColour}, |
8a16d737 | 218 | \param{int}{ tolerance = 0}} |
1542ea39 | 219 | |
43e8916f | 220 | Finds the union of this region and the non-transparent pixels of a |
85f6b408 VS |
221 | bitmap. Colour to be treated as transparent is specified in the |
222 | \arg{transColour} argument, along with an | |
1542ea39 RD |
223 | optional colour tolerance value. |
224 | ||
a660d684 KB |
225 | \wxheading{Return value} |
226 | ||
cc81d32f | 227 | {\tt true} if successful, {\tt false} otherwise. |
a660d684 KB |
228 | |
229 | \wxheading{Remarks} | |
230 | ||
231 | This operation creates a region that combines all of this region and the second region. | |
232 | The result is stored in this region. | |
233 | ||
8a16d737 | 234 | |
a660d684 KB |
235 | \membersection{wxRegion::Xor}\label{wxregionxor} |
236 | ||
0fb067bb | 237 | \func{bool}{Xor}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}} |
a660d684 KB |
238 | |
239 | Finds the Xor of this region and another, rectangular region, specified using position and size. | |
240 | ||
241 | \func{bool}{Xor}{\param{const wxRect\&}{ rect}} | |
242 | ||
243 | Finds the Xor of this region and another, rectangular region. | |
244 | ||
245 | \func{bool}{Xor}{\param{const wxRegion\&}{ region}} | |
246 | ||
247 | Finds the Xor of this region and another region. | |
248 | ||
249 | \wxheading{Return value} | |
250 | ||
cc81d32f | 251 | {\tt true} if successful, {\tt false} otherwise. |
a660d684 KB |
252 | |
253 | \wxheading{Remarks} | |
254 | ||
255 | This operation creates a region that combines all of this region and the second region, except | |
256 | for any overlapping areas. The result is stored in this region. | |
257 | ||
8a16d737 | 258 | |
a660d684 KB |
259 | \membersection{wxRegion::operator $=$}\label{wxregionassign} |
260 | ||
261 | \func{void}{operator $=$}{\param{const wxRegion\&}{ region}} | |
262 | ||
a91225b2 RR |
263 | Assignment operator, using \helpref{reference counting}{trefcount}. |
264 | ||
265 | ||
a660d684 | 266 | |
76c5df24 JS |
267 | \section{\class{wxRegionIterator}}\label{wxregioniterator} |
268 | ||
269 | This class is used to iterate through the rectangles in a region, | |
270 | typically when examining the damaged regions of a window within an OnPaint call. | |
271 | ||
272 | To use it, construct an iterator object on the stack and loop through the | |
273 | regions, testing the object and incrementing the iterator at the end of the loop. | |
274 | ||
f4fcc291 | 275 | See \helpref{wxPaintEvent}{wxpaintevent} for an example of use. |
76c5df24 JS |
276 | |
277 | \wxheading{Derived from} | |
278 | ||
279 | \helpref{wxObject}{wxobject} | |
280 | ||
954b8ae6 JS |
281 | \wxheading{Include files} |
282 | ||
283 | <wx/region.h> | |
284 | ||
76c5df24 JS |
285 | \wxheading{See also} |
286 | ||
f4fcc291 | 287 | \helpref{wxPaintEvent}{wxpaintevent} |
76c5df24 JS |
288 | |
289 | \latexignore{\rtfignore{\wxheading{Members}}} | |
290 | ||
8a16d737 | 291 | |
39275175 | 292 | \membersection{wxRegionIterator::wxRegionIterator}\label{wxregioniteratorctor} |
76c5df24 JS |
293 | |
294 | \func{}{wxRegionIterator}{\void} | |
295 | ||
296 | Default constructor. | |
297 | ||
298 | \func{}{wxRegionIterator}{\param{const wxRegion\&}{ region}} | |
299 | ||
300 | Creates an iterator object given a region. | |
301 | ||
8a16d737 | 302 | |
39275175 | 303 | \membersection{wxRegionIterator::GetX}\label{wxregioniteratorgetx} |
76c5df24 | 304 | |
0fb067bb | 305 | \constfunc{wxCoord}{GetX}{\void} |
76c5df24 JS |
306 | |
307 | Returns the x value for the current region. | |
308 | ||
8a16d737 | 309 | |
39275175 | 310 | \membersection{wxRegionIterator::GetY}\label{wxregioniteratorgety} |
76c5df24 | 311 | |
0fb067bb | 312 | \constfunc{wxCoord}{GetY}{\void} |
76c5df24 JS |
313 | |
314 | Returns the y value for the current region. | |
315 | ||
8a16d737 | 316 | |
39275175 | 317 | \membersection{wxRegionIterator::GetW}\label{wxregioniteratorgetw} |
76c5df24 | 318 | |
0fb067bb | 319 | \constfunc{wxCoord}{GetW}{\void} |
76c5df24 JS |
320 | |
321 | An alias for GetWidth. | |
322 | ||
8a16d737 | 323 | |
f6e9a818 | 324 | \membersection{wxRegionIterator::GetHeight}\label{wxregioniteratorgetheight} |
76c5df24 | 325 | |
f6e9a818 | 326 | \constfunc{wxCoord}{GetHeight}{\void} |
76c5df24 | 327 | |
f6e9a818 | 328 | Returns the height value for the current region. |
76c5df24 | 329 | |
8a16d737 | 330 | |
39275175 | 331 | \membersection{wxRegionIterator::GetH}\label{wxregioniteratorgeth} |
76c5df24 | 332 | |
0fb067bb | 333 | \constfunc{wxCoord}{GetH}{\void} |
76c5df24 JS |
334 | |
335 | An alias for GetHeight. | |
336 | ||
8a16d737 | 337 | |
39275175 | 338 | \membersection{wxRegionIterator::GetRect}\label{wxregioniteratorgetrect} |
76c5df24 JS |
339 | |
340 | \constfunc{wxRect}{GetRect}{\void} | |
341 | ||
342 | Returns the current rectangle. | |
343 | ||
8a16d737 | 344 | |
f6e9a818 RN |
345 | \membersection{wxRegionIterator::GetWidth}\label{wxregioniteratorgetwidth} |
346 | ||
347 | \constfunc{wxCoord}{GetWidth}{\void} | |
348 | ||
349 | Returns the width value for the current region. | |
350 | ||
8a16d737 | 351 | |
39275175 | 352 | \membersection{wxRegionIterator::HaveRects}\label{wxregioniteratorhaverects} |
76c5df24 JS |
353 | |
354 | \constfunc{bool}{HaveRects}{\void} | |
355 | ||
cc81d32f | 356 | Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}. |
76c5df24 | 357 | |
8a16d737 | 358 | |
39275175 | 359 | \membersection{wxRegionIterator::Reset}\label{wxregioniteratorreset} |
76c5df24 JS |
360 | |
361 | \func{void}{Reset}{\void} | |
362 | ||
363 | Resets the iterator to the beginning of the rectangles. | |
364 | ||
365 | \func{void}{Reset}{\param{const wxRegion\&}{ region}} | |
366 | ||
367 | Resets the iterator to the given region. | |
368 | ||
8a16d737 | 369 | |
39275175 | 370 | \membersection{wxRegionIterator::operator $++$}\label{wxregioniteratorinc} |
76c5df24 JS |
371 | |
372 | \func{void}{operator $++$}{\void} | |
373 | ||
374 | Increment operator. Increments the iterator to the next region. | |
375 | ||
c9110876 | 376 | \pythonnote{A wxPython alias for this operator is called {\tt Next}.} |
06d20283 | 377 | |
8a16d737 | 378 | |
39275175 | 379 | \membersection{wxRegionIterator::operator bool}\label{wxregioniteratorbool} |
76c5df24 JS |
380 | |
381 | \constfunc{}{operator bool}{\void} | |
382 | ||
cc81d32f | 383 | Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}. |
76c5df24 JS |
384 | |
385 | You can use this to test the iterator object as if it were of type bool. | |
a660d684 | 386 |