1QRegion(3qt) QRegion(3qt)
2
3
4
6 QRegion - Clip region for a painter
7
9 #include <qregion.h>
10
11 Public Members
12 enum RegionType { Rectangle, Ellipse }
13 QRegion ()
14 QRegion ( int x, int y, int w, int h, RegionType t = Rectangle )
15 QRegion ( const QRect & r, RegionType t = Rectangle )
16 QRegion ( const QPointArray & a, bool winding = FALSE )
17 QRegion ( const QRegion & r )
18 QRegion ( const QBitmap & bm )
19 ~QRegion ()
20 QRegion & operator= ( const QRegion & r )
21 bool isNull () const
22 bool isEmpty () const
23 bool contains ( const QPoint & p ) const
24 bool contains ( const QRect & r ) const
25 void translate ( int dx, int dy )
26 QRegion unite ( const QRegion & r ) const
27 QRegion intersect ( const QRegion & r ) const
28 QRegion subtract ( const QRegion & r ) const
29 QRegion eor ( const QRegion & r ) const
30 QRect boundingRect () const
31 QMemArray<QRect> rects () const
32 const QRegion operator| ( const QRegion & r ) const
33 const QRegion operator+ ( const QRegion & r ) const
34 const QRegion operator& ( const QRegion & r ) const
35 const QRegion operator- ( const QRegion & r ) const
36 const QRegion operator^ ( const QRegion & r ) const
37 QRegion & operator|= ( const QRegion & r )
38 QRegion & operator+= ( const QRegion & r )
39 QRegion & operator&= ( const QRegion & r )
40 QRegion & operator-= ( const QRegion & r )
41 QRegion & operator^= ( const QRegion & r )
42 bool operator== ( const QRegion & r ) const
43 bool operator!= ( const QRegion & r ) const
44 HRGN handle () const
45
47 QDataStream & operator<< ( QDataStream & s, const QRegion & r )
48 QDataStream & operator>> ( QDataStream & s, QRegion & r )
49
51 The QRegion class specifies a clip region for a painter.
52
53 QRegion is used with QPainter::setClipRegion() to limit the paint area
54 to what needs to be painted. There is also a QWidget::repaint() that
55 takes a QRegion parameter. QRegion is the best tool for reducing
56 flicker.
57
58 A region can be created from a rectangle, an ellipse, a polygon or a
59 bitmap. Complex regions may be created by combining simple regions
60 using unite(), intersect(), subtract() or eor() (exclusive or). You can
61 move a region using translate().
62
63 You can test whether a region isNull(), isEmpty() or if it contains() a
64 QPoint or QRect. The bounding rectangle is given by boundingRect().
65
66 The function rects() gives a decomposition of the region into
67 rectangles.
68
69 Example of using complex regions:
70
71 void MyWidget::paintEvent( QPaintEvent * )
72 {
73 QPainter p; // our painter
74 QRegion r1( QRect(100,100,200,80), // r1 = elliptic region
75 QRegion::Ellipse );
76 QRegion r2( QRect(100,120,90,30) ); // r2 = rectangular region
77 QRegion r3 = r1.intersect( r2 ); // r3 = intersection
78 p.begin( this ); // start painting widget
79 p.setClipRegion( r3 ); // set clip region
80 ... // paint clipped graphics
81 p.end(); // painting done
82 }
83
84 QRegion is an implicitly shared class.
85
86 Warning: Due to window system limitations, the whole coordinate space
87 for a region is limited to the points between -32767 and 32767 on Mac
88 OS X and Windows 95/98/ME.
89
90 See also QPainter::setClipRegion(), QPainter::setClipRect(), Graphics
91 Classes, and Image Processing Classes.
92
93 Member Type Documentation
95 Specifies the shape of the region to be created.
96
97 QRegion::Rectangle - the region covers the entire rectangle.
98
99 QRegion::Ellipse - the region is an ellipse inside the rectangle.
100
103 Constructs a null region.
104
105 See also isNull().
106
108 Constructs a rectangular or elliptic region.
109
110 If t is Rectangle, the region is the filled rectangle (x, y, w, h). If
111 t is Ellipse, the region is the filled ellipse with center at (x + w /
112 2, y + h / 2) and size (w ,h ).
113
115 This is an overloaded member function, provided for convenience. It
116 behaves essentially like the above function.
117
118 Create a region based on the rectange r with region type t.
119
120 If the rectangle is invalid a null region will be created.
121
122 See also QRegion::RegionType.
123
125 Constructs a polygon region from the point array a.
126
127 If winding is TRUE, the polygon region is filled using the winding
128 algorithm, otherwise the default even-odd fill algorithm is used.
129
130 This constructor may create complex regions that will slow down
131 painting when used.
132
134 Constructs a new region which is equal to region r.
135
137 Constructs a region from the bitmap bm.
138
139 The resulting region consists of the pixels in bitmap bm that are
140 color1, as if each pixel was a 1 by 1 rectangle.
141
142 This constructor may create complex regions that will slow down
143 painting when used. Note that drawing masked pixmaps can be done much
144 faster using QPixmap::setMask().
145
147 Destroys the region.
148
150 Returns the bounding rectangle of this region. An empty region gives a
151 rectangle that is QRect::isNull().
152
154 Returns TRUE if the region contains the point p; otherwise returns
155 FALSE.
156
158 This is an overloaded member function, provided for convenience. It
159 behaves essentially like the above function.
160
161 Returns TRUE if the region overlaps the rectangle r; otherwise returns
162 FALSE.
163
165 Returns a region which is the exclusive or (XOR) of this region and r.
166
167 <center>
168 [Image Omitted]
169
170 </center>
171
172 The figure shows the exclusive or of two elliptical regions.
173
175 Returns the region's handle.
176
178 Returns a region which is the intersection of this region and r.
179
180 <center>
181 [Image Omitted]
182
183 </center>
184
185 The figure shows the intersection of two elliptical regions.
186
188 Returns TRUE if the region is empty; otherwise returns FALSE. An empty
189 region is a region that contains no points.
190
191 Example:
192
193 QRegion r1( 10, 10, 20, 20 );
194 QRegion r2( 40, 40, 20, 20 );
195 QRegion r3;
196 r1.isNull(); // FALSE
197 r1.isEmpty(); // FALSE
198 r3.isNull(); // TRUE
199 r3.isEmpty(); // TRUE
200 r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2
201 r3.isNull(); // FALSE
202 r3.isEmpty(); // TRUE
203 r3 = r1.unite( r2 ); // r3 = union of r1 and r2
204 r3.isNull(); // FALSE
205 r3.isEmpty(); // FALSE
206
207 See also isNull().
208
210 Returns TRUE if the region is a null region; otherwise returns FALSE.
211
212 A null region is a region that has not been initialized. A null region
213 is always empty.
214
215 See also isEmpty().
216
218 Returns TRUE if the region is different from r; otherwise returns
219 FALSE.
220
222 Applies the intersect() function to this region and r. r1&r2 is
223 equivalent to r1.intersect(r2)
224
225 See also intersect().
226
228 Applies the intersect() function to this region and r and assigns the
229 result to this region. r1&=r2 is equivalent to r1=r1.intersect(r2)
230
231 See also intersect().
232
234 Applies the unite() function to this region and r. r1+r2 is equivalent
235 to r1.unite(r2)
236
237 See also unite() and operator|().
238
240 Applies the unite() function to this region and r and assigns the
241 result to this region. r1+=r2 is equivalent to r1=r1.unite(r2)
242
243 See also intersect().
244
246 Applies the subtract() function to this region and r. r1-r2 is
247 equivalent to r1.subtract(r2)
248
249 See also subtract().
250
252 Applies the subtract() function to this region and r and assigns the
253 result to this region. r1-=r2 is equivalent to r1=r1.subtract(r2)
254
255 See also subtract().
256
258 Assigns r to this region and returns a reference to the region.
259
261 Returns TRUE if the region is equal to r; otherwise returns FALSE.
262
264 Applies the eor() function to this region and r. r1^r2 is equivalent to
265 r1.eor(r2)
266
267 See also eor().
268
270 Applies the eor() function to this region and r and assigns the result
271 to this region. r1^=r2 is equivalent to r1=r1.eor(r2)
272
273 See also eor().
274
276 Applies the unite() function to this region and r. r1|r2 is equivalent
277 to r1.unite(r2)
278
279 See also unite() and operator+().
280
282 Applies the unite() function to this region and r and assigns the
283 result to this region. r1|=r2 is equivalent to r1=r1.unite(r2)
284
285 See also unite().
286
288 Returns an array of non-overlapping rectangles that make up the region.
289
290 The union of all the rectangles is equal to the original region.
291
293 Returns a region which is r subtracted from this region.
294
295 <center>
296 [Image Omitted]
297
298 </center>
299
300 The figure shows the result when the ellipse on the right is subtracted
301 from the ellipse on the left. (left-right )
302
304 Translates (moves) the region dx along the X axis and dy along the Y
305 axis.
306
308 Returns a region which is the union of this region and r.
309
310 <center>
311 [Image Omitted]
312
313 </center>
314
315 The figure shows the union of two elliptical regions.
316
319 Writes the region r to the stream s and returns a reference to the
320 stream.
321
322 See also Format of the QDataStream operators.
323
325 Reads a region from the stream s into r and returns a reference to the
326 stream.
327
328 See also Format of the QDataStream operators.
329
330
332 http://doc.trolltech.com/qregion.html
333 http://www.trolltech.com/faq/tech.html
334
336 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
337 license file included in the distribution for a complete license
338 statement.
339
341 Generated automatically from the source code.
342
344 If you find a bug in Qt, please report it as described in
345 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
346 help you. Thank you.
347
348 The definitive Qt documentation is provided in HTML format; it is
349 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
350 web browser. This man page is provided as a convenience for those users
351 who prefer man pages, although this format is not officially supported
352 by Trolltech.
353
354 If you find errors in this manual page, please report them to qt-
355 bugs@trolltech.com. Please include the name of the manual page
356 (qregion.3qt) and the Qt version (3.3.8).
357
358
359
360Trolltech AS 2 February 2007 QRegion(3qt)