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