<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/reggie/tmp/qt-3.1-reggie-23625/qt-x11-free-3.1.1/src/kernel/qregion.cpp:44 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QRegion Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QRegion Class Reference</h1> <p>The QRegion class specifies a clip region for a painter. <a href="#details">More...</a> <p><tt>#include <<a href="qregion-h.html">qregion.h</a>></tt> <p><a href="qregion-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn>enum <a href="#RegionType-enum"><b>RegionType</b></a> { Rectangle, Ellipse }</div></li> <li><div class=fn><a href="#QRegion"><b>QRegion</b></a> ()</div></li> <li><div class=fn><a href="#QRegion-2"><b>QRegion</b></a> ( int x, int y, int w, int h, RegionType t = Rectangle )</div></li> <li><div class=fn><a href="#QRegion-3"><b>QRegion</b></a> ( const QRect & r, RegionType t = Rectangle )</div></li> <li><div class=fn><a href="#QRegion-4"><b>QRegion</b></a> ( const QPointArray & a, bool winding = FALSE )</div></li> <li><div class=fn><a href="#QRegion-5"><b>QRegion</b></a> ( const QRegion & r )</div></li> <li><div class=fn><a href="#QRegion-6"><b>QRegion</b></a> ( const QBitmap & bm )</div></li> <li><div class=fn><a href="#~QRegion"><b>~QRegion</b></a> ()</div></li> <li><div class=fn>QRegion & <a href="#operator-eq"><b>operator=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li> <li><div class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</div></li> <li><div class=fn>bool <a href="#contains"><b>contains</b></a> ( const QPoint & p ) const</div></li> <li><div class=fn>bool <a href="#contains-2"><b>contains</b></a> ( const QRect & r ) const</div></li> <li><div class=fn>void <a href="#translate"><b>translate</b></a> ( int dx, int dy )</div></li> <li><div class=fn>QRegion <a href="#unite"><b>unite</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>QRegion <a href="#intersect"><b>intersect</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>QRegion <a href="#subtract"><b>subtract</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>QRegion <a href="#eor"><b>eor</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</div></li> <li><div class=fn>QMemArray<QRect> <a href="#rects"><b>rects</b></a> () const</div></li> <li><div class=fn>const QRegion <a href="#operator|"><b>operator|</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>const QRegion <a href="#operator+"><b>operator+</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>const QRegion <a href="#operator-and"><b>operator&</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>const QRegion <a href="#operator-"><b>operator-</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>const QRegion <a href="#operator^"><b>operator^</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>QRegion & <a href="#operator|-eq"><b>operator|=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>QRegion & <a href="#operator+-eq"><b>operator+=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>QRegion & <a href="#operator-and-eq"><b>operator&=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>QRegion & <a href="#operator--eq"><b>operator-=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>QRegion & <a href="#operator^-eq"><b>operator^=</b></a> ( const QRegion & r )</div></li> <li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QRegion & r ) const</div></li> <li><div class=fn>HRGN <a href="#handle"><b>handle</b></a> () const</div></li> </ul> <h2>Related Functions</h2> <ul> <li><div class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QRegion & r )</div></li> <li><div class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QRegion & r )</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QRegion class specifies a clip region for a painter. <p> <p> QRegion is used with <a href="qpainter.html#setClipRegion">QPainter::setClipRegion</a>() to limit the paint area to what needs to be painted. There is also a <a href="qwidget.html#repaint">QWidget::repaint</a>() that takes a QRegion parameter. QRegion is the best tool for reducing flicker. <p> A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple regions using <a href="#unite">unite</a>(), <a href="#intersect">intersect</a>(), <a href="#subtract">subtract</a>() or <a href="#eor">eor</a>() (exclusive or). You can move a region using <a href="#translate">translate</a>(). <p> You can test whether a region <a href="#isNull">isNull</a>(), <a href="#isEmpty">isEmpty</a>() or if it <a href="#contains">contains</a>() a <a href="qpoint.html">QPoint</a> or <a href="qrect.html">QRect</a>. The bounding rectangle is given by <a href="#boundingRect">boundingRect</a>(). <p> The function <a href="#rects">rects</a>() gives a decomposition of the region into rectangles. <p> Example of using complex regions: <pre> void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * ) { <a href="qpainter.html">QPainter</a> p; // our painter QRegion r1( QRect(100,100,200,80), // r1 = elliptic region QRegion::<a href="#RegionType-enum">Ellipse</a> ); QRegion r2( QRect(100,120,90,30) ); // r2 = rectangular region QRegion r3 = r1.<a href="#intersect">intersect</a>( r2 ); // r3 = intersection p.<a href="qpainter.html#begin">begin</a>( this ); // start painting widget p.<a href="qpainter.html#setClipRegion">setClipRegion</a>( r3 ); // set clip region ... // paint clipped graphics p.<a href="qpainter.html#end">end</a>(); // painting done } </pre> <p> QRegion is an <a href="shclass.html">implicitly shared</a> class. <p> <b>Warning:</b> Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Windows 95/98/ME. <p> <p>See also <a href="qpainter.html#setClipRegion">QPainter::setClipRegion</a>(), <a href="qpainter.html#setClipRect">QPainter::setClipRect</a>(), <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="RegionType-enum"></a>QRegion::RegionType</h3> <p> Specifies the shape of the region to be created. <ul> <li><tt>QRegion::Rectangle</tt> - the region covers the entire rectangle. <li><tt>QRegion::Ellipse</tt> - the region is an ellipse inside the rectangle. </ul> <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QRegion"></a>QRegion::QRegion () </h3> Constructs a null region. <p> <p>See also <a href="#isNull">isNull</a>(). <h3 class=fn><a name="QRegion-2"></a>QRegion::QRegion ( int x, int y, int w, int h, <a href="qregion.html#RegionType-enum">RegionType</a> t = Rectangle ) </h3> Constructs a rectangular or elliptic region. <p> If <em>t</em> is <a href="#RegionType-enum">Rectangle</a>, the region is the filled rectangle (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>). If <em>t</em> is <a href="#RegionType-enum">Ellipse</a>, the region is the filled ellipse with center at (<em>x</em> + <em>w</em> / 2, <em>y</em> + <em>h</em> / 2) and size (<em>w</em> ,<em>h</em> ). <h3 class=fn><a name="QRegion-3"></a>QRegion::QRegion ( const <a href="qrect.html">QRect</a> & r, <a href="qregion.html#RegionType-enum">RegionType</a> t = Rectangle ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Create a region based on the rectange <em>r</em> with region type <em>t</em>. <p> If the rectangle is invalid a null region will be created. <p> <p>See also <a href="#RegionType-enum">QRegion::RegionType</a>. <h3 class=fn><a name="QRegion-4"></a>QRegion::QRegion ( const <a href="qpointarray.html">QPointArray</a> & a, bool winding = FALSE ) </h3> Constructs a polygon region from the point array <em>a</em>. <p> If <em>winding</em> is TRUE, the polygon region is filled using the winding algorithm, otherwise the default even-odd fill algorithm is used. <p> This constructor may create complex regions that will slow down painting when used. <h3 class=fn><a name="QRegion-5"></a>QRegion::QRegion ( const <a href="qregion.html">QRegion</a> & r ) </h3> Constructs a new region which is equal to region <em>r</em>. <h3 class=fn><a name="QRegion-6"></a>QRegion::QRegion ( const <a href="qbitmap.html">QBitmap</a> & bm ) </h3> Constructs a region from the bitmap <em>bm</em>. <p> The resulting region consists of the pixels in bitmap <em>bm</em> that are <tt>color1</tt>, as if each pixel was a 1 by 1 rectangle. <p> This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using <a href="qpixmap.html#setMask">QPixmap::setMask</a>(). <h3 class=fn><a name="~QRegion"></a>QRegion::~QRegion () </h3> Destroys the region. <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QRegion::boundingRect () const </h3> Returns the bounding rectangle of this region. An empty region gives a rectangle that is <a href="qrect.html#isNull">QRect::isNull</a>(). <h3 class=fn>bool <a name="contains"></a>QRegion::contains ( const <a href="qpoint.html">QPoint</a> & p ) const </h3> Returns TRUE if the region contains the point <em>p</em>; otherwise returns FALSE. <h3 class=fn>bool <a name="contains-2"></a>QRegion::contains ( const <a href="qrect.html">QRect</a> & r ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if the region overlaps the rectangle <em>r</em>; otherwise returns FALSE. <h3 class=fn><a href="qregion.html">QRegion</a> <a name="eor"></a>QRegion::eor ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Returns a region which is the exclusive or (XOR) of this region and <em>r</em>. <p> <center><img src="rxor.png" alt="Region XORed"></center> <p> The figure shows the exclusive or of two elliptical regions. <h3 class=fn>HRGN <a name="handle"></a>QRegion::handle () const </h3> <p> Returns the region's handle. <h3 class=fn><a href="qregion.html">QRegion</a> <a name="intersect"></a>QRegion::intersect ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Returns a region which is the intersection of this region and <em>r</em>. <p> <center><img src="rintersect.png" alt="Region Intersection"></center> <p> The figure shows the intersection of two elliptical regions. <h3 class=fn>bool <a name="isEmpty"></a>QRegion::isEmpty () const </h3> Returns TRUE if the region is empty; otherwise returns FALSE. An empty region is a region that contains no points. <p> Example: <pre> QRegion r1( 10, 10, 20, 20 ); QRegion r2( 40, 40, 20, 20 ); QRegion r3; r1.<a href="#isNull">isNull</a>(); // FALSE r1.<a href="#isEmpty">isEmpty</a>(); // FALSE r3.<a href="#isNull">isNull</a>(); // TRUE r3.<a href="#isEmpty">isEmpty</a>(); // TRUE r3 = r1.<a href="#intersect">intersect</a>( r2 ); // r3 = intersection of r1 and r2 r3.<a href="#isNull">isNull</a>(); // FALSE r3.<a href="#isEmpty">isEmpty</a>(); // TRUE r3 = r1.<a href="#unite">unite</a>( r2 ); // r3 = union of r1 and r2 r3.<a href="#isNull">isNull</a>(); // FALSE r3.<a href="#isEmpty">isEmpty</a>(); // FALSE </pre> <p> <p>See also <a href="#isNull">isNull</a>(). <h3 class=fn>bool <a name="isNull"></a>QRegion::isNull () const </h3> Returns TRUE if the region is a null region; otherwise returns FALSE. <p> A null region is a region that has not been initialized. A null region is always empty. <p> <p>See also <a href="#isEmpty">isEmpty</a>(). <h3 class=fn>bool <a name="operator!-eq"></a>QRegion::operator!= ( const <a href="qregion.html">QRegion</a> & r ) const </h3> <p> Returns TRUE if the region is different from <em>r</em>; otherwise returns FALSE. <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="operator-and"></a>QRegion::operator& ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Applies the <a href="#intersect">intersect</a>() function to this region and <em>r</em>. <tt>r1&r2</tt> is equivalent to <tt>r1.intersect(r2)</tt> <p> <p>See also <a href="#intersect">intersect</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator-and-eq"></a>QRegion::operator&= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Applies the <a href="#intersect">intersect</a>() function to this region and <em>r</em> and assigns the result to this region. <tt>r1&=r2</tt> is equivalent to <tt>r1=r1.intersect(r2)</tt> <p> <p>See also <a href="#intersect">intersect</a>(). <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="operator+"></a>QRegion::operator+ ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Applies the <a href="#unite">unite</a>() function to this region and <em>r</em>. <tt>r1+r2</tt> is equivalent to <tt>r1.unite(r2)</tt> <p> <p>See also <a href="#unite">unite</a>() and <a href="#operator|">operator|</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator+-eq"></a>QRegion::operator+= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Applies the <a href="#unite">unite</a>() function to this region and <em>r</em> and assigns the result to this region. <tt>r1+=r2</tt> is equivalent to <tt>r1=r1.unite(r2)</tt> <p> <p>See also <a href="#intersect">intersect</a>(). <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="operator-"></a>QRegion::operator- ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Applies the <a href="#subtract">subtract</a>() function to this region and <em>r</em>. <tt>r1-r2</tt> is equivalent to <tt>r1.subtract(r2)</tt> <p> <p>See also <a href="#subtract">subtract</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator--eq"></a>QRegion::operator-= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Applies the <a href="#subtract">subtract</a>() function to this region and <em>r</em> and assigns the result to this region. <tt>r1-=r2</tt> is equivalent to <tt>r1=r1.subtract(r2)</tt> <p> <p>See also <a href="#subtract">subtract</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator-eq"></a>QRegion::operator= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Assigns <em>r</em> to this region and returns a reference to the region. <h3 class=fn>bool <a name="operator-eq-eq"></a>QRegion::operator== ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Returns TRUE if the region is equal to <em>r</em>; otherwise returns FALSE. <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="operator^"></a>QRegion::operator^ ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Applies the <a href="#eor">eor</a>() function to this region and <em>r</em>. <tt>r1^r2</tt> is equivalent to <tt>r1.eor(r2)</tt> <p> <p>See also <a href="#eor">eor</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator^-eq"></a>QRegion::operator^= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Applies the <a href="#eor">eor</a>() function to this region and <em>r</em> and assigns the result to this region. <tt>r1^=r2</tt> is equivalent to <tt>r1=r1.eor(r2)</tt> <p> <p>See also <a href="#eor">eor</a>(). <h3 class=fn>const <a href="qregion.html">QRegion</a> <a name="operator|"></a>QRegion::operator| ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Applies the <a href="#unite">unite</a>() function to this region and <em>r</em>. <tt>r1|r2</tt> is equivalent to <tt>r1.unite(r2)</tt> <p> <p>See also <a href="#unite">unite</a>() and <a href="#operator+">operator+</a>(). <h3 class=fn><a href="qregion.html">QRegion</a> & <a name="operator|-eq"></a>QRegion::operator|= ( const <a href="qregion.html">QRegion</a> & r ) </h3> Applies the <a href="#unite">unite</a>() function to this region and <em>r</em> and assigns the result to this region. <tt>r1|=r2</tt> is equivalent to <tt>r1=r1.unite(r2)</tt> <p> <p>See also <a href="#unite">unite</a>(). <h3 class=fn><a href="qmemarray.html">QMemArray</a><QRect> <a name="rects"></a>QRegion::rects () const </h3> Returns an array of non-overlapping rectangles that make up the region. <p> The union of all the rectangles is equal to the original region. <h3 class=fn><a href="qregion.html">QRegion</a> <a name="subtract"></a>QRegion::subtract ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Returns a region which is <em>r</em> subtracted from this region. <p> <center><img src="rsubtract.png" alt="Region Subtraction"></center> <p> The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left. (<tt>left-right</tt> ) <h3 class=fn>void <a name="translate"></a>QRegion::translate ( int dx, int dy ) </h3> Translates (moves) the region <em>dx</em> along the X axis and <em>dy</em> along the Y axis. <h3 class=fn><a href="qregion.html">QRegion</a> <a name="unite"></a>QRegion::unite ( const <a href="qregion.html">QRegion</a> & r ) const </h3> Returns a region which is the union of this region and <em>r</em>. <p> <center><img src="runion.png" alt="Region Union"></center> <p> The figure shows the union of two elliptical regions. <hr><h2>Related Functions</h2> <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qregion.html">QRegion</a> & r ) </h3> <p> Writes the region <em>r</em> to the stream <em>s</em> and returns a reference to the stream. <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>. <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qregion.html">QRegion</a> & r ) </h3> <p> Reads a region from the stream <em>s</em> into <em>r</em> and returns a reference to the stream. <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>. <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2002 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.1.1</div> </table></div></address></body> </html>