1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxRegion documentation
7 %% Copyright: (c) wxTeam
8 %% License: wxWindows license
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{\class{wxRegion
}}\label{wxregion
}
13 A wxRegion represents a simple or complex region on a device context or window.
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.
22 \wxheading{Derived from
}
24 \helpref{wxGDIObject
}{wxgdiobject
}\\
25 \helpref{wxObject
}{wxobject
}
27 \wxheading{Include files
}
33 \helpref{wxRegionIterator
}{wxregioniterator
}
35 \latexignore{\rtfignore{\wxheading{Members
}}}
38 \membersection{wxRegion::wxRegion
}\label{wxregionctor
}
40 \func{}{wxRegion
}{\void}
44 \func{}{wxRegion
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
46 Constructs a rectangular region with the given position and size.
48 \func{}{wxRegion
}{\param{const wxPoint\&
}{ topLeft
},
\param{const wxPoint\&
}{ bottomRight
}}
50 Constructs a rectangular region from the top left point and the bottom right point.
52 \func{}{wxRegion
}{\param{const wxRect\&
}{ rect
}}
54 Constructs a rectangular region a wxRect object.
56 \func{}{wxRegion
}{\param{const wxRegion\&
}{ region
}}
58 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
60 \func{}{wxRegion
}{\param{size
\_t}{ n
},
\param{const wxPoint
}{*points
},
\param{int
}{fillStyle = wxWINDING
\_RULE}}
62 Constructs a region corresponding to the polygon made of
{\it n
} points in the
63 provided array.
{\it fillStyle
} parameter may have values
64 {\tt wxWINDING
\_RULE} or
{\tt wxODDEVEN
\_RULE}.
66 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
}}
68 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
},
69 \param{const wxColour\&
}{ transColour
},
70 \param{int
}{ tolerance =
0}}
72 Constructs a region using the non-transparent pixels of a bitmap. See
73 \helpref{Union
}{wxregionunion
} for more details.
77 \membersection{wxRegion::
\destruct{wxRegion
}}\label{wxregiondtor
}
79 \func{}{\destruct{wxRegion
}}{\void}
82 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
85 \membersection{wxRegion::Clear
}\label{wxregionclear
}
87 \func{void
}{Clear
}{\void}
89 Clears the current region.
92 \membersection{wxRegion::Contains
}\label{wxregioncontains
}
94 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
}}
96 Returns a value indicating whether the given point is contained within the region.
98 \constfunc{wxRegionContain
}{Contains
}{\param{const wxPoint\&
}{ pt
}}
100 Returns a value indicating whether the given point is contained within the region.
102 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
},
\param{long\&
}{width
},
\param{long\&
}{height
}}
104 Returns a value indicating whether the given rectangle is contained within the region.
106 \constfunc{wxRegionContain
}{Contains
}{\param{const wxRect\&
}{rect
}}
108 Returns a value indicating whether the given rectangle is contained within the region.
110 \wxheading{Return value
}
112 The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
114 On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that
115 all or some part of the region is contained in this region.
118 \membersection{wxRegion::ConvertToBitmap
}\label{wxregionconverttobitmap
}
120 \constfunc{wxBitmap
}{ConvertToBitmap
}{}
122 Convert the region to a black and white bitmap with the white pixels
123 being inside the region.
126 \membersection{wxRegion::GetBox
}\label{wxregiongetbox
}
128 \constfunc{void
}{GetBox
}{\param{wxCoord\&
}{x
},
\param{wxCoord\&
}{y
},
\param{wxCoord\&
}{width
},
\param{wxCoord\&
}{height
}}
130 Returns the outer bounds of the region.
132 \constfunc{wxRect
}{GetBox
}{\void}
134 Returns the outer bounds of the region.
137 \membersection{wxRegion::Intersect
}\label{wxregionintersect
}
139 \func{bool
}{Intersect
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
141 Finds the intersection of this region and another, rectangular region, specified using position and size.
143 \func{bool
}{Intersect
}{\param{const wxRect\&
}{ rect
}}
145 Finds the intersection of this region and another, rectangular region.
147 \func{bool
}{Intersect
}{\param{const wxRegion\&
}{ region
}}
149 Finds the intersection of this region and another region.
151 \wxheading{Return value
}
153 {\tt true
} if successful,
{\tt false
} otherwise.
157 Creates the intersection of the two regions, that is, the parts which are in both regions. The result
158 is stored in this region.
161 \membersection{wxRegion::IsEmpty
}\label{wxregionisempty
}
163 \constfunc{bool
}{IsEmpty
}{\void}
165 Returns
{\tt true
} if the region is empty,
{\tt false
} otherwise.
168 \membersection{wxRegion::IsEqual
}\label{wxregionisequal
}
170 \constfunc{bool
}{IsEqual
}{\param{const wxRegion\&
}{region
}}
172 Returns
{\tt true
} if the region is equal to, i.e. covers the same area as,
173 another one. Note that if both this region and
\arg{region
} are invalid, they
174 are considered to be equal.
177 \membersection{wxRegion::Subtract
}\label{wxregionsubtract
}
179 \func{bool
}{Subtract
}{\param{const wxRect\&
}{ rect
}}
181 Subtracts a rectangular region from this region.
183 \func{bool
}{Subtract
}{\param{const wxRegion\&
}{ region
}}
185 Subtracts a region from this region.
187 \wxheading{Return value
}
189 {\tt true
} if successful,
{\tt false
} otherwise.
193 This operation combines the parts of 'this' region that are not part of the second region.
194 The result is stored in this region.
197 \membersection{wxRegion::Offset
}\label{wxregionoffset
}
199 \func{bool
}{Offset
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
}}
201 \func{bool
}{Offset
}{\param{const wxPoint\&
}{ pt
}}
203 Moves the region by the specified offsets in horizontal and vertical
206 \wxheading{Return value
}
208 {\tt true
} if successful,
{\tt false
} otherwise (the region is unchanged then).
211 \membersection{wxRegion::Union
}\label{wxregionunion
}
213 \func{bool
}{Union
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
215 Finds the union of this region and another, rectangular region, specified using position and size.
217 \func{bool
}{Union
}{\param{const wxRect\&
}{ rect
}}
219 Finds the union of this region and another, rectangular region.
221 \func{bool
}{Union
}{\param{const wxRegion\&
}{ region
}}
223 Finds the union of this region and another region.
225 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
}}
227 Finds the union of this region and the non-transparent pixels of a
228 bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't
229 have a mask, solid rectangle of bitmap's dimensions is used.
231 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
},
232 \param{const wxColour\&
}{ transColour
},
233 \param{int
}{ tolerance =
0}}
235 Finds the union of this region and the non-transparent pixels of a
236 bitmap. Colour to be treated as transparent is specified in the
237 \arg{transColour
} argument, along with an
238 optional colour tolerance value.
240 \wxheading{Return value
}
242 {\tt true
} if successful,
{\tt false
} otherwise.
246 This operation creates a region that combines all of this region and the second region.
247 The result is stored in this region.
250 \membersection{wxRegion::Xor
}\label{wxregionxor
}
252 \func{bool
}{Xor
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
254 Finds the Xor of this region and another, rectangular region, specified using position and size.
256 \func{bool
}{Xor
}{\param{const wxRect\&
}{ rect
}}
258 Finds the Xor of this region and another, rectangular region.
260 \func{bool
}{Xor
}{\param{const wxRegion\&
}{ region
}}
262 Finds the Xor of this region and another region.
264 \wxheading{Return value
}
266 {\tt true
} if successful,
{\tt false
} otherwise.
270 This operation creates a region that combines all of this region and the second region, except
271 for any overlapping areas. The result is stored in this region.
274 \membersection{wxRegion::operator $=$
}\label{wxregionassign
}
276 \func{void
}{operator $=$
}{\param{const wxRegion\&
}{ region
}}
278 Assignment operator, using
\helpref{reference counting
}{trefcount
}.
282 \section{\class{wxRegionIterator
}}\label{wxregioniterator
}
284 This class is used to iterate through the rectangles in a region,
285 typically when examining the damaged regions of a window within an OnPaint call.
287 To use it, construct an iterator object on the stack and loop through the
288 regions, testing the object and incrementing the iterator at the end of the loop.
290 See
\helpref{wxPaintEvent
}{wxpaintevent
} for an example of use.
292 \wxheading{Derived from
}
294 \helpref{wxObject
}{wxobject
}
296 \wxheading{Include files
}
302 \helpref{wxPaintEvent
}{wxpaintevent
}
304 \latexignore{\rtfignore{\wxheading{Members
}}}
307 \membersection{wxRegionIterator::wxRegionIterator
}\label{wxregioniteratorctor
}
309 \func{}{wxRegionIterator
}{\void}
313 \func{}{wxRegionIterator
}{\param{const wxRegion\&
}{ region
}}
315 Creates an iterator object given a region.
318 \membersection{wxRegionIterator::GetX
}\label{wxregioniteratorgetx
}
320 \constfunc{wxCoord
}{GetX
}{\void}
322 Returns the x value for the current region.
325 \membersection{wxRegionIterator::GetY
}\label{wxregioniteratorgety
}
327 \constfunc{wxCoord
}{GetY
}{\void}
329 Returns the y value for the current region.
332 \membersection{wxRegionIterator::GetW
}\label{wxregioniteratorgetw
}
334 \constfunc{wxCoord
}{GetW
}{\void}
336 An alias for GetWidth.
339 \membersection{wxRegionIterator::GetHeight
}\label{wxregioniteratorgetheight
}
341 \constfunc{wxCoord
}{GetHeight
}{\void}
343 Returns the height value for the current region.
346 \membersection{wxRegionIterator::GetH
}\label{wxregioniteratorgeth
}
348 \constfunc{wxCoord
}{GetH
}{\void}
350 An alias for GetHeight.
353 \membersection{wxRegionIterator::GetRect
}\label{wxregioniteratorgetrect
}
355 \constfunc{wxRect
}{GetRect
}{\void}
357 Returns the current rectangle.
360 \membersection{wxRegionIterator::GetWidth
}\label{wxregioniteratorgetwidth
}
362 \constfunc{wxCoord
}{GetWidth
}{\void}
364 Returns the width value for the current region.
367 \membersection{wxRegionIterator::HaveRects
}\label{wxregioniteratorhaverects
}
369 \constfunc{bool
}{HaveRects
}{\void}
371 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
374 \membersection{wxRegionIterator::Reset
}\label{wxregioniteratorreset
}
376 \func{void
}{Reset
}{\void}
378 Resets the iterator to the beginning of the rectangles.
380 \func{void
}{Reset
}{\param{const wxRegion\&
}{ region
}}
382 Resets the iterator to the given region.
385 \membersection{wxRegionIterator::operator $++$
}\label{wxregioniteratorinc
}
387 \func{void
}{operator $++$
}{\void}
389 Increment operator. Increments the iterator to the next region.
391 \pythonnote{A wxPython alias for this operator is called
{\tt Next
}.
}
394 \membersection{wxRegionIterator::operator bool
}\label{wxregioniteratorbool
}
396 \constfunc{}{operator bool
}{\void}
398 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
400 You can use this to test the iterator object as if it were of type bool.