]> git.saurik.com Git - wxWidgets.git/blame - interface/region.h
Corrected typecasts (Sebastian Gottschalk)
[wxWidgets.git] / interface / region.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: region.h
e54c96f1 3// Purpose: interface of wxRegionIterator
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRegionIterator
11 @wxheader{region.h}
7c913512 12
23324ae1
FM
13 This class is used to iterate through the rectangles in a region,
14 typically when examining the damaged regions of a window within an OnPaint call.
7c913512 15
23324ae1
FM
16 To use it, construct an iterator object on the stack and loop through the
17 regions, testing the object and incrementing the iterator at the end of the
18 loop.
7c913512 19
23324ae1 20 See wxPaintEvent for an example of use.
7c913512 21
23324ae1
FM
22 @library{wxcore}
23 @category{FIXME}
7c913512 24
e54c96f1 25 @see wxPaintEvent
23324ae1
FM
26*/
27class wxRegionIterator : public wxObject
28{
29public:
30 //@{
31 /**
32 Creates an iterator object given a region.
33 */
34 wxRegionIterator();
7c913512 35 wxRegionIterator(const wxRegion& region);
23324ae1
FM
36 //@}
37
38 /**
39 An alias for GetHeight.
40 */
328f5751 41 wxCoord GetH() const;
23324ae1
FM
42
43 /**
44 Returns the height value for the current region.
45 */
328f5751 46 wxCoord GetHeight() const;
23324ae1
FM
47
48 /**
49 Returns the current rectangle.
50 */
328f5751 51 wxRect GetRect() const;
23324ae1
FM
52
53 /**
54 An alias for GetWidth.
55 */
328f5751 56 wxCoord GetW() const;
23324ae1
FM
57
58 /**
59 Returns the width value for the current region.
60 */
328f5751 61 wxCoord GetWidth() const;
23324ae1
FM
62
63 /**
64 Returns the x value for the current region.
65 */
328f5751 66 wxCoord GetX() const;
23324ae1
FM
67
68 /**
69 Returns the y value for the current region.
70 */
328f5751 71 wxCoord GetY() const;
23324ae1
FM
72
73 /**
74 Returns @true if there are still some rectangles; otherwise returns @false.
75 */
328f5751 76 bool HaveRects() const;
23324ae1
FM
77
78 //@{
79 /**
80 Resets the iterator to the given region.
81 */
82 void Reset();
7c913512 83 void Reset(const wxRegion& region);
23324ae1
FM
84 //@}
85
86 /**
87 Increment operator. Increments the iterator to the next region.
88 */
89 void operator ++();
90
91 /**
92 Returns @true if there are still some rectangles; otherwise returns @false.
23324ae1
FM
93 You can use this to test the iterator object as if it were of type bool.
94 */
328f5751 95 operator bool() const;
23324ae1
FM
96};
97
98
e54c96f1 99
23324ae1
FM
100/**
101 @class wxRegion
3db7c3b1 102 @ingroup group_class_gdi
23324ae1 103 @wxheader{region.h}
7c913512 104
23324ae1 105 A wxRegion represents a simple or complex region on a device context or window.
7c913512 106
23324ae1
FM
107 This class uses @ref overview_trefcount "reference counting and copy-on-write"
108 internally so that assignments between two instances of this class are very
109 cheap. You can therefore use actual objects instead of pointers without
110 efficiency problems. If an instance of this class is changed it will create
111 its own data internally so that other instances, which previously shared the
112 data using the reference counting, are not affected.
7c913512 113
23324ae1
FM
114 @library{wxcore}
115 @category{data}
7c913512 116
e54c96f1 117 @see wxRegionIterator
23324ae1
FM
118*/
119class wxRegion : public wxGDIObject
120{
121public:
122 //@{
123 /**
124 Constructs a region using the non-transparent pixels of a bitmap. See
125 Union() for more details.
126 */
127 wxRegion();
7c913512
FM
128 wxRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
129 wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
130 wxRegion(const wxRect& rect);
131 wxRegion(const wxRegion& region);
132 wxRegion(size_t n, const wxPoint points,
133 int fillStyle = wxWINDING_RULE);
134 wxRegion(const wxBitmap& bmp);
135 wxRegion(const wxBitmap& bmp, const wxColour& transColour,
136 int tolerance = 0);
23324ae1
FM
137 //@}
138
139 /**
140 Destructor.
141 See @ref overview_refcountdestruct "reference-counted object destruction" for
142 more info.
143 */
144 ~wxRegion();
145
146 /**
147 Clears the current region.
148 */
149 void Clear();
150
151 //@{
152 /**
153 Returns a value indicating whether the given rectangle is contained within the
154 region.
155
156 @returns The return value is one of wxOutRegion, wxPartRegion and
4cc4bfaf 157 wxInRegion.
23324ae1 158 */
328f5751
FM
159 wxRegionContain Contains(long& x, long& y) const;
160 const wxRegionContain Contains(const wxPoint& pt) const;
161 const wxRegionContain Contains(long& x, long& y,
162 long& width,
163 long& height) const;
164 const wxRegionContain Contains(const wxRect& rect) const;
23324ae1
FM
165 //@}
166
167 /**
168 Convert the region to a black and white bitmap with the white pixels
169 being inside the region.
170 */
328f5751 171 wxBitmap ConvertToBitmap() const;
23324ae1
FM
172
173 //@{
174 /**
175 Returns the outer bounds of the region.
176 */
177 void GetBox(wxCoord& x, wxCoord& y, wxCoord& width,
328f5751
FM
178 wxCoord& height) const;
179 const wxRect GetBox() const;
23324ae1
FM
180 //@}
181
182 //@{
183 /**
184 Finds the intersection of this region and another region.
185
186 @returns @true if successful, @false otherwise.
187
188 @remarks Creates the intersection of the two regions, that is, the parts
4cc4bfaf
FM
189 which are in both regions. The result is stored in this
190 region.
23324ae1
FM
191 */
192 bool Intersect(wxCoord x, wxCoord y, wxCoord width,
193 wxCoord height);
7c913512
FM
194 bool Intersect(const wxRect& rect);
195 bool Intersect(const wxRegion& region);
23324ae1
FM
196 //@}
197
198 /**
199 Returns @true if the region is empty, @false otherwise.
200 */
328f5751 201 bool IsEmpty() const;
23324ae1
FM
202
203 /**
204 Returns @true if the region is equal to, i.e. covers the same area as,
4cc4bfaf 205 another one. Note that if both this region and @a region are invalid, they
23324ae1
FM
206 are considered to be equal.
207 */
328f5751 208 bool IsEqual(const wxRegion& region) const;
23324ae1
FM
209
210 //@{
211 /**
212 Moves the region by the specified offsets in horizontal and vertical
213 directions.
214
215 @returns @true if successful, @false otherwise (the region is unchanged
4cc4bfaf 216 then).
23324ae1
FM
217 */
218 bool Offset(wxCoord x, wxCoord y);
7c913512 219 bool Offset(const wxPoint& pt);
23324ae1
FM
220 //@}
221
222 //@{
223 /**
224 Subtracts a region from this region.
225
226 @returns @true if successful, @false otherwise.
227
228 @remarks This operation combines the parts of 'this' region that are not
4cc4bfaf
FM
229 part of the second region. The result is stored in this
230 region.
23324ae1
FM
231 */
232 bool Subtract(const wxRect& rect);
7c913512 233 bool Subtract(const wxRegion& region);
23324ae1
FM
234 //@}
235
236 //@{
237 /**
238 Finds the union of this region and the non-transparent pixels of a
239 bitmap. Colour to be treated as transparent is specified in the
4cc4bfaf 240 @a transColour argument, along with an
23324ae1
FM
241 optional colour tolerance value.
242
243 @returns @true if successful, @false otherwise.
244
245 @remarks This operation creates a region that combines all of this region
4cc4bfaf
FM
246 and the second region. The result is stored in this
247 region.
23324ae1
FM
248 */
249 bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
7c913512
FM
250 bool Union(const wxRect& rect);
251 bool Union(const wxRegion& region);
252 bool Union(const wxBitmap& bmp);
253 bool Union(const wxBitmap& bmp, const wxColour& transColour,
254 int tolerance = 0);
23324ae1
FM
255 //@}
256
257 //@{
258 /**
259 Finds the Xor of this region and another region.
260
261 @returns @true if successful, @false otherwise.
262
263 @remarks This operation creates a region that combines all of this region
4cc4bfaf
FM
264 and the second region, except for any overlapping
265 areas. The result is stored in this region.
23324ae1
FM
266 */
267 bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
7c913512
FM
268 bool Xor(const wxRect& rect);
269 bool Xor(const wxRegion& region);
23324ae1
FM
270 //@}
271
272 /**
273 Assignment operator, using @ref overview_trefcount "reference counting".
274 */
275 void operator =(const wxRegion& region);
276};
e54c96f1 277