Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference |
|
The QRegion class specifies a clip region for a painter. More...
#include <qregion.h>
QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a QWidget::repaint() that takes a QRegion parameter. QRegion is the best tool for reducing flicker.
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 unite(), intersect(), subtract() or eor() (exclusive or). Use translate() to move a region.
You can test if a region isNull(), isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle is given by boundingRect().
The function rects() gives a decomposition of the region into rectangles.
Example of using complex regions:
void MyWidget::paintEvent( QPaintEvent * )
{
QPainter p; // our painter
QRegion r1( QRect(100,100,200,80), // r1 = elliptic region
QRegion::Ellipse );
QRegion r2( QRect(100,120,90,30) ); // r2 = rectangular region
QRegion r3 = r1.intersect( r2 ); // r3 = intersection
p.begin( this ); // start painting widget
p.setClipRegion( r3 ); // set clip region
... // paint clipped graphics
p.end(); // painting done
}
QRegion is an implicitely shared class.
Due to window system limitations, the width and height of a region is limited to 65535 on Unix/X11.
\mustquote
Some functions in QRegion are copyright (c) 1987 X Consortium. Please see src/3rdparty/kernel/qregion_qws.cpp for more information.
Some functions in QRegion for Qt/Embedded are copyright Digital Equipment Corporation:
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
See also QPainter::setClipRegion() and QPainter::setClipRect().
See also isNull().
If t is Rectangle, the region is the filled rectangle (x, y, w, h). If t is Ellipse, the region is the filled ellipse ellipse with center at (x + w / 2, y + h / 2) and size (w ,h ).
If the rectangle is invalid, the rectangle will be normalized() before the region is created. This semantics will change in Qt-3 and an invalid rectangle will construct an empty region.
See also QRect::isValid() and QRect::normalize().
If winding is TRUE, the polygon region is filled using the winding algorithm, otherwise the default even-odd fill algorithm is used.
This constructor may create complex regions that will slow down painting when used.
The resulting region consists of the pixels in bm that are color1, as if each pixel was a 1 by 1 rectangle.
This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using QPixmap::setMask().
The figure shows the exclusive or of two elliptical regions.
The figure shows the intersection of two elliptical regions.
Example:
QRegion r1( 10, 10, 20, 20 );
QRegion r2( 40, 40, 20, 20 );
QRegion r3;
r1.isNull(); // FALSE
r1.isEmpty(); // FALSE
r3.isNull(); // TRUE
r3.isEmpty(); // TRUE
r3 = r1.intersect( r2 ); // r3 = intersection of r1 and r2
r3.isNull(); // FALSE
r3.isEmpty(); // TRUE
r3 = r1.unite( r2 ); // r3 = union of r1 and r2
r3.isNull(); // FALSE
r3.isEmpty(); // FALSE
See also isNull().
A null region is a region that has not been initialized. A null region is always empty.
See also isEmpty().
See also intersect().
See also intersect().
See also unite() and operator|().
See also intersect().
See also subtract().
See also subtract().
See also eor().
See also eor().
See also unite() and operator+().
See also unite().
The union of all the rectangles is equal to the original region.
The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left. (left-right )
The figure shows the union of two elliptical regions.
See also Format of the QDataStream operators.
See also Format of the QDataStream operators.
This file is part of the Qtopia platform, copyright © 1995-2005 Trolltech, all rights reserved.
| Copyright © 2005 Trolltech | Trademarks | Qtopia version 2.2.0
|