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