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