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. It uses
14 reference counting, so copying and assignment operations are fast.
16 \wxheading{Derived from
}
18 \helpref{wxGDIObject
}{wxgdiobject
}\\
19 \helpref{wxObject
}{wxobject
}
21 \wxheading{Include files
}
27 \helpref{wxRegionIterator
}{wxregioniterator
}
29 \latexignore{\rtfignore{\wxheading{Members
}}}
32 \membersection{wxRegion::wxRegion
}\label{wxregionctor
}
34 \func{}{wxRegion
}{\void}
38 \func{}{wxRegion
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
40 Constructs a rectangular region with the given position and size.
42 \func{}{wxRegion
}{\param{const wxPoint\&
}{ topLeft
},
\param{const wxPoint\&
}{ bottomRight
}}
44 Constructs a rectangular region from the top left point and the bottom right point.
46 \func{}{wxRegion
}{\param{const wxRect\&
}{ rect
}}
48 Constructs a rectangular region a wxRect object.
50 \func{}{wxRegion
}{\param{const wxRegion\&
}{ region
}}
52 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
54 \func{}{wxRegion
}{\param{size
\_t}{ n
},
\param{const wxPoint
}{*points
},
\param{int
}{fillStyle = wxWINDING
\_RULE}}
56 Constructs a region corresponding to the polygon made of
{\it n
} points in the
57 provided array.
{\it fillStyle
} parameter may have values
58 {\tt wxWINDING
\_RULE} or
{\tt wxODDEVEN
\_RULE}.
60 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
}}
62 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
},
63 \param{const wxColour\&
}{ transColour
},
64 \param{int
}{ tolerance =
0}}
66 Constructs a region using the non-transparent pixels of a bitmap. See
67 \helpref{Union
}{wxregionunion
} for more details.
71 \membersection{wxRegion::
\destruct{wxRegion
}}\label{wxregiondtor
}
73 \func{}{\destruct{wxRegion
}}{\void}
76 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
79 \membersection{wxRegion::Clear
}\label{wxregionclear
}
81 \func{void
}{Clear
}{\void}
83 Clears the current region.
86 \membersection{wxRegion::Contains
}\label{wxregioncontains
}
88 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
}}
90 Returns a value indicating whether the given point is contained within the region.
92 \constfunc{wxRegionContain
}{Contains
}{\param{const wxPoint\&
}{ pt
}}
94 Returns a value indicating whether the given point is contained within the region.
96 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
},
\param{long\&
}{width
},
\param{long\&
}{height
}}
98 Returns a value indicating whether the given rectangle is contained within the region.
100 \constfunc{wxRegionContain
}{Contains
}{\param{const wxRect\&
}{rect
}}
102 Returns a value indicating whether the given rectangle is contained within the region.
104 \wxheading{Return value
}
106 The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
108 On Windows, only wxOutRegion and wxInRegion are returned; a value wxInRegion then indicates that
109 all or some part of the region is contained in this region.
112 \membersection{wxRegion::ConvertToBitmap
}\label{wxregionconverttobitmap
}
114 \constfunc{wxBitmap
}{ConvertToBitmap
}{}
116 Convert the region to a black and white bitmap with the white pixels
117 being inside the region.
120 \membersection{wxRegion::GetBox
}\label{wxregiongetbox
}
122 \constfunc{void
}{GetBox
}{\param{wxCoord\&
}{x
},
\param{wxCoord\&
}{y
},
\param{wxCoord\&
}{width
},
\param{wxCoord\&
}{height
}}
124 Returns the outer bounds of the region.
126 \constfunc{wxRect
}{GetBox
}{\void}
128 Returns the outer bounds of the region.
131 \membersection{wxRegion::Intersect
}\label{wxregionintersect
}
133 \func{bool
}{Intersect
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
135 Finds the intersection of this region and another, rectangular region, specified using position and size.
137 \func{bool
}{Intersect
}{\param{const wxRect\&
}{ rect
}}
139 Finds the intersection of this region and another, rectangular region.
141 \func{bool
}{Intersect
}{\param{const wxRegion\&
}{ region
}}
143 Finds the intersection of this region and another region.
145 \wxheading{Return value
}
147 {\tt true
} if successful,
{\tt false
} otherwise.
151 Creates the intersection of the two regions, that is, the parts which are in both regions. The result
152 is stored in this region.
155 \membersection{wxRegion::IsEmpty
}\label{wxregionisempty
}
157 \constfunc{bool
}{IsEmpty
}{\void}
159 Returns
{\tt true
} if the region is empty,
{\tt false
} otherwise.
162 \membersection{wxRegion::IsEqual
}\label{wxregionisequal
}
164 \constfunc{bool
}{IsEqual
}{\param{const wxRegion\&
}{region
}}
166 Returns
{\tt true
} if the region is equal to, i.e. covers the same area as,
167 another one. Note that if both this region and
\arg{region
} are invalid, they
168 are considered to be equal.
171 \membersection{wxRegion::Subtract
}\label{wxregionsubtract
}
173 \func{bool
}{Subtract
}{\param{const wxRect\&
}{ rect
}}
175 Subtracts a rectangular region from this region.
177 \func{bool
}{Subtract
}{\param{const wxRegion\&
}{ region
}}
179 Subtracts a region from this region.
181 \wxheading{Return value
}
183 {\tt true
} if successful,
{\tt false
} otherwise.
187 This operation combines the parts of 'this' region that are not part of the second region.
188 The result is stored in this region.
191 \membersection{wxRegion::Offset
}\label{wxregionoffset
}
193 \func{bool
}{Offset
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
}}
195 \func{bool
}{Offset
}{\param{const wxPoint\&
}{ pt
}}
197 Moves the region by the specified offsets in horizontal and vertical
200 \wxheading{Return value
}
202 {\tt true
} if successful,
{\tt false
} otherwise (the region is unchanged then).
205 \membersection{wxRegion::Union
}\label{wxregionunion
}
207 \func{bool
}{Union
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
209 Finds the union of this region and another, rectangular region, specified using position and size.
211 \func{bool
}{Union
}{\param{const wxRect\&
}{ rect
}}
213 Finds the union of this region and another, rectangular region.
215 \func{bool
}{Union
}{\param{const wxRegion\&
}{ region
}}
217 Finds the union of this region and another region.
219 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
}}
221 Finds the union of this region and the non-transparent pixels of a
222 bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't
223 have a mask, solid rectangle of bitmap's dimensions is used.
225 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
},
226 \param{const wxColour\&
}{ transColour
},
227 \param{int
}{ tolerance =
0}}
229 Finds the union of this region and the non-transparent pixels of a
230 bitmap. Colour to be treated as transparent is specified in the
231 \arg{transColour
} argument, along with an
232 optional colour tolerance value.
234 \wxheading{Return value
}
236 {\tt true
} if successful,
{\tt false
} otherwise.
240 This operation creates a region that combines all of this region and the second region.
241 The result is stored in this region.
244 \membersection{wxRegion::Xor
}\label{wxregionxor
}
246 \func{bool
}{Xor
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
248 Finds the Xor of this region and another, rectangular region, specified using position and size.
250 \func{bool
}{Xor
}{\param{const wxRect\&
}{ rect
}}
252 Finds the Xor of this region and another, rectangular region.
254 \func{bool
}{Xor
}{\param{const wxRegion\&
}{ region
}}
256 Finds the Xor of this region and another region.
258 \wxheading{Return value
}
260 {\tt true
} if successful,
{\tt false
} otherwise.
264 This operation creates a region that combines all of this region and the second region, except
265 for any overlapping areas. The result is stored in this region.
268 \membersection{wxRegion::operator $=$
}\label{wxregionassign
}
270 \func{void
}{operator $=$
}{\param{const wxRegion\&
}{ region
}}
272 Assignment operator, using
\helpref{reference counting
}{trefcount
}.
276 \section{\class{wxRegionIterator
}}\label{wxregioniterator
}
278 This class is used to iterate through the rectangles in a region,
279 typically when examining the damaged regions of a window within an OnPaint call.
281 To use it, construct an iterator object on the stack and loop through the
282 regions, testing the object and incrementing the iterator at the end of the loop.
284 See
\helpref{wxPaintEvent
}{wxpaintevent
} for an example of use.
286 \wxheading{Derived from
}
288 \helpref{wxObject
}{wxobject
}
290 \wxheading{Include files
}
296 \helpref{wxPaintEvent
}{wxpaintevent
}
298 \latexignore{\rtfignore{\wxheading{Members
}}}
301 \membersection{wxRegionIterator::wxRegionIterator
}\label{wxregioniteratorctor
}
303 \func{}{wxRegionIterator
}{\void}
307 \func{}{wxRegionIterator
}{\param{const wxRegion\&
}{ region
}}
309 Creates an iterator object given a region.
312 \membersection{wxRegionIterator::GetX
}\label{wxregioniteratorgetx
}
314 \constfunc{wxCoord
}{GetX
}{\void}
316 Returns the x value for the current region.
319 \membersection{wxRegionIterator::GetY
}\label{wxregioniteratorgety
}
321 \constfunc{wxCoord
}{GetY
}{\void}
323 Returns the y value for the current region.
326 \membersection{wxRegionIterator::GetW
}\label{wxregioniteratorgetw
}
328 \constfunc{wxCoord
}{GetW
}{\void}
330 An alias for GetWidth.
333 \membersection{wxRegionIterator::GetHeight
}\label{wxregioniteratorgetheight
}
335 \constfunc{wxCoord
}{GetHeight
}{\void}
337 Returns the height value for the current region.
340 \membersection{wxRegionIterator::GetH
}\label{wxregioniteratorgeth
}
342 \constfunc{wxCoord
}{GetH
}{\void}
344 An alias for GetHeight.
347 \membersection{wxRegionIterator::GetRect
}\label{wxregioniteratorgetrect
}
349 \constfunc{wxRect
}{GetRect
}{\void}
351 Returns the current rectangle.
354 \membersection{wxRegionIterator::GetWidth
}\label{wxregioniteratorgetwidth
}
356 \constfunc{wxCoord
}{GetWidth
}{\void}
358 Returns the width value for the current region.
361 \membersection{wxRegionIterator::HaveRects
}\label{wxregioniteratorhaverects
}
363 \constfunc{bool
}{HaveRects
}{\void}
365 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
368 \membersection{wxRegionIterator::Reset
}\label{wxregioniteratorreset
}
370 \func{void
}{Reset
}{\void}
372 Resets the iterator to the beginning of the rectangles.
374 \func{void
}{Reset
}{\param{const wxRegion\&
}{ region
}}
376 Resets the iterator to the given region.
379 \membersection{wxRegionIterator::operator $++$
}\label{wxregioniteratorinc
}
381 \func{void
}{operator $++$
}{\void}
383 Increment operator. Increments the iterator to the next region.
385 \pythonnote{A wxPython alias for this operator is called
{\tt Next
}.
}
388 \membersection{wxRegionIterator::operator bool
}\label{wxregioniteratorbool
}
390 \constfunc{}{operator bool
}{\void}
392 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
394 You can use this to test the iterator object as if it were of type bool.