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{wxCore
}{librarieslist
}
37 \helpref{wxRegionIterator
}{wxregioniterator
}
39 \latexignore{\rtfignore{\wxheading{Members
}}}
42 \membersection{wxRegion::wxRegion
}\label{wxregionctor
}
44 \func{}{wxRegion
}{\void}
48 \func{}{wxRegion
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
50 Constructs a rectangular region with the given position and size.
52 \func{}{wxRegion
}{\param{const wxPoint\&
}{ topLeft
},
\param{const wxPoint\&
}{ bottomRight
}}
54 Constructs a rectangular region from the top left point and the bottom right point.
56 \func{}{wxRegion
}{\param{const wxRect\&
}{ rect
}}
58 Constructs a rectangular region a wxRect object.
60 \func{}{wxRegion
}{\param{const wxRegion\&
}{ region
}}
62 Copy constructor, uses
\helpref{reference counting
}{trefcount
}.
64 \func{}{wxRegion
}{\param{size
\_t}{ n
},
\param{const wxPoint
}{*points
},
\param{int
}{fillStyle = wxWINDING
\_RULE}}
66 Constructs a region corresponding to the polygon made of
{\it n
} points in the
67 provided array.
{\it fillStyle
} parameter may have values
68 {\tt wxWINDING
\_RULE} or
{\tt wxODDEVEN
\_RULE}.
70 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
}}
72 \func{}{wxRegion
}{\param{const wxBitmap\&
}{ bmp
},
73 \param{const wxColour\&
}{ transColour
},
74 \param{int
}{ tolerance =
0}}
76 Constructs a region using the non-transparent pixels of a bitmap. See
77 \helpref{Union
}{wxregionunion
} for more details.
81 \membersection{wxRegion::
\destruct{wxRegion
}}\label{wxregiondtor
}
83 \func{}{\destruct{wxRegion
}}{\void}
86 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
89 \membersection{wxRegion::Clear
}\label{wxregionclear
}
91 \func{void
}{Clear
}{\void}
93 Clears the current region.
96 \membersection{wxRegion::Contains
}\label{wxregioncontains
}
98 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
}}
100 Returns a value indicating whether the given point is contained within the region.
102 \constfunc{wxRegionContain
}{Contains
}{\param{const wxPoint\&
}{ pt
}}
104 Returns a value indicating whether the given point is contained within the region.
106 \constfunc{wxRegionContain
}{Contains
}{\param{long\&
}{x
},
\param{long\&
}{y
},
\param{long\&
}{width
},
\param{long\&
}{height
}}
108 Returns a value indicating whether the given rectangle is contained within the region.
110 \constfunc{wxRegionContain
}{Contains
}{\param{const wxRect\&
}{rect
}}
112 Returns a value indicating whether the given rectangle is contained within the region.
114 \wxheading{Return value
}
116 The return value is one of wxOutRegion, wxPartRegion and wxInRegion.
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.
122 \membersection{wxRegion::ConvertToBitmap
}\label{wxregionconverttobitmap
}
124 \constfunc{wxBitmap
}{ConvertToBitmap
}{}
126 Convert the region to a black and white bitmap with the white pixels
127 being inside the region.
130 \membersection{wxRegion::GetBox
}\label{wxregiongetbox
}
132 \constfunc{void
}{GetBox
}{\param{wxCoord\&
}{x
},
\param{wxCoord\&
}{y
},
\param{wxCoord\&
}{width
},
\param{wxCoord\&
}{height
}}
134 Returns the outer bounds of the region.
136 \constfunc{wxRect
}{GetBox
}{\void}
138 Returns the outer bounds of the region.
141 \membersection{wxRegion::Intersect
}\label{wxregionintersect
}
143 \func{bool
}{Intersect
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
145 Finds the intersection of this region and another, rectangular region, specified using position and size.
147 \func{bool
}{Intersect
}{\param{const wxRect\&
}{ rect
}}
149 Finds the intersection of this region and another, rectangular region.
151 \func{bool
}{Intersect
}{\param{const wxRegion\&
}{ region
}}
153 Finds the intersection of this region and another region.
155 \wxheading{Return value
}
157 {\tt true
} if successful,
{\tt false
} otherwise.
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.
165 \membersection{wxRegion::IsEmpty
}\label{wxregionisempty
}
167 \constfunc{bool
}{IsEmpty
}{\void}
169 Returns
{\tt true
} if the region is empty,
{\tt false
} otherwise.
172 \membersection{wxRegion::IsEqual
}\label{wxregionisequal
}
174 \constfunc{bool
}{IsEqual
}{\param{const wxRegion\&
}{region
}}
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.
181 \membersection{wxRegion::Subtract
}\label{wxregionsubtract
}
183 \func{bool
}{Subtract
}{\param{const wxRect\&
}{ rect
}}
185 Subtracts a rectangular region from this region.
187 \func{bool
}{Subtract
}{\param{const wxRegion\&
}{ region
}}
189 Subtracts a region from this region.
191 \wxheading{Return value
}
193 {\tt true
} if successful,
{\tt false
} otherwise.
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.
201 \membersection{wxRegion::Offset
}\label{wxregionoffset
}
203 \func{bool
}{Offset
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
}}
205 \func{bool
}{Offset
}{\param{const wxPoint\&
}{ pt
}}
207 Moves the region by the specified offsets in horizontal and vertical
210 \wxheading{Return value
}
212 {\tt true
} if successful,
{\tt false
} otherwise (the region is unchanged then).
215 \membersection{wxRegion::Union
}\label{wxregionunion
}
217 \func{bool
}{Union
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
219 Finds the union of this region and another, rectangular region, specified using position and size.
221 \func{bool
}{Union
}{\param{const wxRect\&
}{ rect
}}
223 Finds the union of this region and another, rectangular region.
225 \func{bool
}{Union
}{\param{const wxRegion\&
}{ region
}}
227 Finds the union of this region and another region.
229 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
}}
231 Finds the union of this region and the non-transparent pixels of a
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.
235 \func{bool
}{Union
}{\param{const wxBitmap\&
}{ bmp
},
236 \param{const wxColour\&
}{ transColour
},
237 \param{int
}{ tolerance =
0}}
239 Finds the union of this region and the non-transparent pixels of a
240 bitmap. Colour to be treated as transparent is specified in the
241 \arg{transColour
} argument, along with an
242 optional colour tolerance value.
244 \wxheading{Return value
}
246 {\tt true
} if successful,
{\tt false
} otherwise.
250 This operation creates a region that combines all of this region and the second region.
251 The result is stored in this region.
254 \membersection{wxRegion::Xor
}\label{wxregionxor
}
256 \func{bool
}{Xor
}{\param{wxCoord
}{ x
},
\param{wxCoord
}{ y
},
\param{wxCoord
}{ width
},
\param{wxCoord
}{ height
}}
258 Finds the Xor of this region and another, rectangular region, specified using position and size.
260 \func{bool
}{Xor
}{\param{const wxRect\&
}{ rect
}}
262 Finds the Xor of this region and another, rectangular region.
264 \func{bool
}{Xor
}{\param{const wxRegion\&
}{ region
}}
266 Finds the Xor of this region and another region.
268 \wxheading{Return value
}
270 {\tt true
} if successful,
{\tt false
} otherwise.
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.
278 \membersection{wxRegion::operator $=$
}\label{wxregionassign
}
280 \func{void
}{operator $=$
}{\param{const wxRegion\&
}{ region
}}
282 Assignment operator, using
\helpref{reference counting
}{trefcount
}.
286 \section{\class{wxRegionIterator
}}\label{wxregioniterator
}
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.
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.
294 See
\helpref{wxPaintEvent
}{wxpaintevent
} for an example of use.
296 \wxheading{Derived from
}
298 \helpref{wxObject
}{wxobject
}
300 \wxheading{Include files
}
306 \helpref{wxCore
}{librarieslist
}
310 \helpref{wxPaintEvent
}{wxpaintevent
}
312 \latexignore{\rtfignore{\wxheading{Members
}}}
315 \membersection{wxRegionIterator::wxRegionIterator
}\label{wxregioniteratorctor
}
317 \func{}{wxRegionIterator
}{\void}
321 \func{}{wxRegionIterator
}{\param{const wxRegion\&
}{ region
}}
323 Creates an iterator object given a region.
326 \membersection{wxRegionIterator::GetX
}\label{wxregioniteratorgetx
}
328 \constfunc{wxCoord
}{GetX
}{\void}
330 Returns the x value for the current region.
333 \membersection{wxRegionIterator::GetY
}\label{wxregioniteratorgety
}
335 \constfunc{wxCoord
}{GetY
}{\void}
337 Returns the y value for the current region.
340 \membersection{wxRegionIterator::GetW
}\label{wxregioniteratorgetw
}
342 \constfunc{wxCoord
}{GetW
}{\void}
344 An alias for GetWidth.
347 \membersection{wxRegionIterator::GetHeight
}\label{wxregioniteratorgetheight
}
349 \constfunc{wxCoord
}{GetHeight
}{\void}
351 Returns the height value for the current region.
354 \membersection{wxRegionIterator::GetH
}\label{wxregioniteratorgeth
}
356 \constfunc{wxCoord
}{GetH
}{\void}
358 An alias for GetHeight.
361 \membersection{wxRegionIterator::GetRect
}\label{wxregioniteratorgetrect
}
363 \constfunc{wxRect
}{GetRect
}{\void}
365 Returns the current rectangle.
368 \membersection{wxRegionIterator::GetWidth
}\label{wxregioniteratorgetwidth
}
370 \constfunc{wxCoord
}{GetWidth
}{\void}
372 Returns the width value for the current region.
375 \membersection{wxRegionIterator::HaveRects
}\label{wxregioniteratorhaverects
}
377 \constfunc{bool
}{HaveRects
}{\void}
379 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
382 \membersection{wxRegionIterator::Reset
}\label{wxregioniteratorreset
}
384 \func{void
}{Reset
}{\void}
386 Resets the iterator to the beginning of the rectangles.
388 \func{void
}{Reset
}{\param{const wxRegion\&
}{ region
}}
390 Resets the iterator to the given region.
393 \membersection{wxRegionIterator::operator $++$
}\label{wxregioniteratorinc
}
395 \func{void
}{operator $++$
}{\void}
397 Increment operator. Increments the iterator to the next region.
399 \pythonnote{A wxPython alias for this operator is called
{\tt Next
}.
}
402 \membersection{wxRegionIterator::operator bool
}\label{wxregioniteratorbool
}
404 \constfunc{}{operator bool
}{\void}
406 Returns
{\tt true
} if there are still some rectangles; otherwise returns
{\tt false
}.
408 You can use this to test the iterator object as if it were of type bool.