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