]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/region.tex
fixed anchor link naming, indentation in some places, added the <hr> divisor, fixed...
[wxWidgets.git] / docs / latex / wx / region.tex
CommitLineData
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
13A wxRegion represents a simple or complex region on a device context or window.
14
15This class uses \helpref{reference counting and copy-on-write}{trefcount}
16internally so that assignments between two instances of this class are very
17cheap. You can therefore use actual objects instead of pointers without
18efficiency problems. If an instance of this class is changed it will create
19its own data internally so that other instances, which previously shared the
20data 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
46Default constructor.
47
0fb067bb 48\func{}{wxRegion}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxCoord}{ width}, \param{wxCoord}{ height}}
a660d684
KB
49
50Constructs a rectangular region with the given position and size.
51
52\func{}{wxRegion}{\param{const wxPoint\&}{ topLeft}, \param{const wxPoint\&}{ bottomRight}}
53
54Constructs a rectangular region from the top left point and the bottom right point.
55
56\func{}{wxRegion}{\param{const wxRect\&}{ rect}}
57
58Constructs a rectangular region a wxRect object.
59
60\func{}{wxRegion}{\param{const wxRegion\&}{ region}}
61
a91225b2 62Copy 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
66Constructs a region corresponding to the polygon made of {\it n} points in the
1542ea39 67provided 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
76Constructs 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
85Destructor.
55ccdb93 86See \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
93Clears 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
100Returns a value indicating whether the given point is contained within the region.
101
102\constfunc{wxRegionContain}{Contains}{\param{const wxPoint\&}{ pt}}
103
104Returns 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
108Returns a value indicating whether the given rectangle is contained within the region.
109
110\constfunc{wxRegionContain}{Contains}{\param{const wxRect\& }{rect}}
111
112Returns a value indicating whether the given rectangle is contained within the region.
113
114\wxheading{Return value}
115
116The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
117
118On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that
119all 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 126Convert the region to a black and white bitmap with the white pixels
1542ea39
RD
127being 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
134Returns the outer bounds of the region.
135
136\constfunc{wxRect}{GetBox}{\void}
137
138Returns 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
145Finds the intersection of this region and another, rectangular region, specified using position and size.
146
147\func{bool}{Intersect}{\param{const wxRect\&}{ rect}}
148
149Finds the intersection of this region and another, rectangular region.
150
151\func{bool}{Intersect}{\param{const wxRegion\&}{ region}}
152
153Finds 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
161Creates the intersection of the two regions, that is, the parts which are in both regions. The result
162is stored in this region.
163
8a16d737 164
a660d684
KB
165\membersection{wxRegion::IsEmpty}\label{wxregionisempty}
166
167\constfunc{bool}{IsEmpty}{\void}
168
cc81d32f 169Returns {\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
176Returns {\tt true} if the region is equal to, i.e. covers the same area as,
177another one. Note that if both this region and \arg{region} are invalid, they
178are 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
185Subtracts a rectangular region from this region.
186
187\func{bool}{Subtract}{\param{const wxRegion\&}{ region}}
188
189Subtracts 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
197This operation combines the parts of 'this' region that are not part of the second region.
198The 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
207Moves the region by the specified offsets in horizontal and vertical
208directions.
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
219Finds the union of this region and another, rectangular region, specified using position and size.
220
221\func{bool}{Union}{\param{const wxRect\&}{ rect}}
222
223Finds the union of this region and another, rectangular region.
224
225\func{bool}{Union}{\param{const wxRegion\&}{ region}}
226
227Finds the union of this region and another region.
228
85f6b408
VS
229\func{bool}{Union}{\param{const wxBitmap\&}{ bmp}}
230
43e8916f 231Finds the union of this region and the non-transparent pixels of a
85f6b408
VS
232bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't
233have 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 239Finds the union of this region and the non-transparent pixels of a
85f6b408
VS
240bitmap. Colour to be treated as transparent is specified in the
241\arg{transColour} argument, along with an
1542ea39
RD
242optional 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
250This operation creates a region that combines all of this region and the second region.
251The 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
258Finds the Xor of this region and another, rectangular region, specified using position and size.
259
260\func{bool}{Xor}{\param{const wxRect\&}{ rect}}
261
262Finds the Xor of this region and another, rectangular region.
263
264\func{bool}{Xor}{\param{const wxRegion\&}{ region}}
265
266Finds 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
274This operation creates a region that combines all of this region and the second region, except
275for 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
282Assignment operator, using \helpref{reference counting}{trefcount}.
283
284
a660d684 285
76c5df24
JS
286\section{\class{wxRegionIterator}}\label{wxregioniterator}
287
288This class is used to iterate through the rectangles in a region,
289typically when examining the damaged regions of a window within an OnPaint call.
290
291To use it, construct an iterator object on the stack and loop through the
292regions, testing the object and incrementing the iterator at the end of the loop.
293
f4fcc291 294See \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
319Default constructor.
320
321\func{}{wxRegionIterator}{\param{const wxRegion\&}{ region}}
322
323Creates 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
330Returns 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
337Returns 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
344An alias for GetWidth.
345
8a16d737 346
f6e9a818 347\membersection{wxRegionIterator::GetHeight}\label{wxregioniteratorgetheight}
76c5df24 348
f6e9a818 349\constfunc{wxCoord}{GetHeight}{\void}
76c5df24 350
f6e9a818 351Returns 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
358An alias for GetHeight.
359
8a16d737 360
39275175 361\membersection{wxRegionIterator::GetRect}\label{wxregioniteratorgetrect}
76c5df24
JS
362
363\constfunc{wxRect}{GetRect}{\void}
364
365Returns the current rectangle.
366
8a16d737 367
f6e9a818
RN
368\membersection{wxRegionIterator::GetWidth}\label{wxregioniteratorgetwidth}
369
370\constfunc{wxCoord}{GetWidth}{\void}
371
372Returns 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 379Returns {\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
386Resets the iterator to the beginning of the rectangles.
387
388\func{void}{Reset}{\param{const wxRegion\&}{ region}}
389
390Resets 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
397Increment 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 406Returns {\tt true} if there are still some rectangles; otherwise returns {\tt false}.
76c5df24
JS
407
408You can use this to test the iterator object as if it were of type bool.
59b48b46 409