#include <qregion.h>
Collaboration diagram for QRegion:

QRegion is used with QPainter::setClipRegion() to limit the paint area to what needs to be painted. There is also a QWidget::repaint() function 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 united(), intersected(), subtracted(), or xored() (exclusive or). You can move a region using translate().
You can test whether a region isEmpty() or if it contains() a QPoint or QRect. The bounding rectangle can be found with boundingRect().
The function rects() gives a decomposition of the region into rectangles.
Example of using complex regions:
void MyWidget::paintEvent(QPaintEvent *) { 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.intersected(r2); // r3: intersection QPainter painter(this); painter.setClipRegion(r3); ... // paint clipped graphics }
QRegion is an {implicitly shared class}.
For Qt/X11 and Qtopia Core, parts of this class rely on code obtained under the following license: \legalese Copyright (c) 1987 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. \endlegalese \raw HTML <hr /> \endraw \legalese 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. \endlegalese \sa QPainter::setClipRegion(), QPainter::setClipRect(), QPainterPath Definition at line 44 of file qregion.h.
Public Types | |
| enum | RegionType |
Public Member Functions | |
| QRegion () | |
| QRegion (int x, int y, int w, int h, RegionType t=Rectangle) | |
| QRegion (const QRect &r, RegionType t=Rectangle) | |
| QRegion (const QPolygon &pa, Qt::FillRule fillRule=Qt::OddEvenFill) | |
| QRegion (const QRegion ®ion) | |
| QRegion (const QBitmap &bitmap) | |
| ~QRegion () | |
| QRegion & | operator= (const QRegion &) |
| bool | isEmpty () const |
| bool | contains (const QPoint &p) const |
| bool | contains (const QRect &r) const |
| void | translate (int dx, int dy) |
| void | translate (const QPoint &p) |
| QRegion | translated (int dx, int dy) const |
| QRegion | translated (const QPoint &p) const |
| QRegion | unite (const QRegion &r) const |
| QRegion | intersect (const QRegion &r) const |
| QRegion | subtract (const QRegion &r) const |
| QRegion | eor (const QRegion &r) const |
| QRegion | united (const QRegion &r) const |
| QRegion | intersected (const QRegion &r) const |
| QRegion | subtracted (const QRegion &r) const |
| QRegion | xored (const QRegion &r) const |
| bool | intersects (const QRegion &r) const |
| bool | intersects (const QRect &r) const |
| QRect | boundingRect () const |
| QVector< QRect > | rects () const |
| void | setRects (const QRect *rect, int num) |
| const QRegion | operator| (const QRegion &r) const |
| const QRegion | operator+ (const QRegion &r) const |
| const QRegion | operator & (const QRegion &r) const |
| const QRegion | operator- (const QRegion &r) const |
| const QRegion | operator^ (const QRegion &r) const |
| QRegion & | operator|= (const QRegion &r) |
| QRegion & | operator+= (const QRegion &r) |
| QRegion & | operator &= (const QRegion &r) |
| QRegion & | operator-= (const QRegion &r) |
| QRegion & | operator^= (const QRegion &r) |
| bool | operator== (const QRegion &r) const |
| bool | operator!= (const QRegion &r) const |
| operator QVariant () const | |
Private Member Functions | |
| QRegion | copy () const |
| void | detach () |
| void | exec (const QByteArray &ba, int ver=0) |
Static Private Member Functions | |
| static void | cleanUp (QRegionData *x) |
Private Attributes | |
| QRegionData * | d |
Static Private Attributes | |
| static struct QRegionData | shared_empty |
Friends | |
| Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &, const QRegion &) |
| Q_GUI_EXPORT QDataStream & | operator>> (QDataStream &, QRegion &) |
Classes | |
| struct | QRegionData |
| enum QRegion::RegionType |
| QRegion::QRegion | ( | ) |
Constructs an empty region.
Definition at line 2397 of file qregion_unix.cpp.
Referenced by exec().
02401 : d(&shared_empty)
| QRegion::QRegion | ( | int | x, | |
| int | y, | |||
| int | w, | |||
| int | h, | |||
| RegionType | t = Rectangle | |||
| ) |
Constructs a rectangular or elliptic region.
If t is Rectangle, the region is the filled rectangle (x, y, w, h). If t is Ellipse, the region is the filled ellipse with center at (x + w / 2, y + h / 2) and size (w ,h).
Definition at line 180 of file qregion.cpp.
References d, QRegion::QRegionData::ref, and QBasicAtomic::ref().
Here is the call graph for this function:

| QRegion::QRegion | ( | const QRect & | r, | |
| RegionType | t = Rectangle | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a region based on the rectange r with region type t.
If the rectangle is invalid a null region will be created.
Definition at line 2413 of file qregion_unix.cpp.
02417 { 02418 if (r.isEmpty()) { 02419 d = &shared_empty; 02420 d->ref.ref(); 02421 } else { 02422 d = new QRegionData; 02423 d->ref.init(1); 02424 #if defined(Q_WS_X11) 02425 d->rgn = 0; 02426 d->xrectangles = 0; 02427 #elif defined(Q_WS_MAC) 02428 d->rgn = 0; 02429 #endif 02430 if (t == Rectangle) { 02431 d->qt_rgn = new QRegionPrivate(r); 02432 } else if (t == Ellipse) { 02433 QPainterPath path; 02434 path.addEllipse(r.x(), r.y(), r.width(), r.height()); 02435 QPolygon a = path.toSubpathPolygons().at(0).toPolygon(); 02436 d->qt_rgn = PolygonRegion(a.constData(), a.size(), EvenOddRule);
| QRegion::QRegion | ( | const QPolygon & | a, | |
| Qt::FillRule | fillRule = Qt::OddEvenFill | |||
| ) |
Constructs a polygon region from the point array a with the fill rule specified by fillRule.
If fillRule is {Qt::WindingFill}, the polygon region is defined using the winding algorithm; if it is {Qt::OddEvenFill}, the odd-even fill algorithm is used.
Definition at line 2450 of file qregion_unix.cpp.
02454 { 02455 if (a.count() > 2) { 02456 d = new QRegionData; 02457 d->ref.init(1); 02458 #if defined(Q_WS_X11) 02459 d->rgn = 0; 02460 d->xrectangles = 0; 02461 #elif defined(Q_WS_MAC) 02462 d->rgn = 0; 02463 #endif 02464 d->qt_rgn = PolygonRegion(a.constData(), a.size(), 02465 fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); 02466 } else { 02467 d = &shared_empty;
| QRegion::QRegion | ( | const QRegion & | r | ) |
Constructs a new region which is equal to region r.
Definition at line 2474 of file qregion_unix.cpp.
| QRegion::QRegion | ( | const QBitmap & | bm | ) |
Constructs a region from the bitmap bm.
The resulting region consists of the pixels in bitmap bm that are Qt::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().
Definition at line 2491 of file qregion_unix.cpp.
02495 { 02496 if (bm.isNull()) { 02497 d = &shared_empty; 02498 d->ref.ref(); 02499 } else { 02500 d = new QRegionData; 02501 d->ref.init(1); 02502 #if defined(Q_WS_X11) 02503 d->rgn = 0; 02504 d->xrectangles = 0; 02505 #elif defined(Q_WS_MAC) 02506 d->rgn = 0; 02507 #endif
| QRegion::~QRegion | ( | ) |
Assigns r to this region and returns a reference to the region.
Definition at line 2539 of file qregion_unix.cpp.
02543 { 02544 QRegionData *x = r.d; 02545 x->ref.ref(); 02546 x = qAtomicSetPtr(&d, x); 02547 if (!x->ref.deref())
| bool QRegion::isEmpty | ( | ) | const |
Returns true if the region is empty; otherwise returns false. An empty region is a region that contains no points.
Example:
QRegion r1(10, 10, 20, 20); r1.isNull(); // false r1.isEmpty(); // false QRegion r2(40, 40, 20, 20); QRegion r3; r3.isNull(); // true r3.isEmpty(); // true r3 = r1.intersected(r2); // r3: intersection of r1 and r2 r3.isNull(); // false r3.isEmpty(); // true r3 = r1.united(r2); // r3: union of r1 and r2 r3.isNull(); // false r3.isEmpty(); // false
Definition at line 2600 of file qregion_unix.cpp.
Referenced by QRasterPaintEngine::begin(), Q3ScrollView::changeFrameRect(), qdesigner_internal::childAt_SkipDropLine(), QWidget::childrenRegion(), QWidgetBackingStore::cleanRegion(), QWidgetBackingStore::copyToScreen(), QWidgetPrivate::create_sys(), QWidgetBackingStore::dirtyRegion(), QWidgetPrivate::dirtyWidget_sys(), QWindowsXPStylePrivate::drawBackgroundDirectly(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), Q3IconView::drawContents(), Q3CanvasView::drawContents(), QWindowsStyle::drawControl(), QWidgetPrivate::drawWidget(), QRasterPaintEngine::flush(), Q3TableHeader::paintEvent(), QWidgetBackingStore::paintSiblingsRecursive(), Q3ListBox::refreshSlot(), QWidget::repaint(), QWidgetPrivate::scrollRect(), QMenuPrivate::setCurrentAction(), PieView::setSelection(), QWidgetPrivate::subtractOpaqueChildren(), QETWidget::translatePaintEvent(), QWidget::update(), QX11PaintEngine::updateBrush(), QRasterPaintEngine::updateClipRegion(), QPicturePaintEngine::updateClipRegion(), QX11PaintEngine::updateClipRegion_dev(), QWorkspaceChild::updateMask(), QX11PaintEngine::updatePen(), QGraphicsView::updateScene(), Q3ListBox::viewportPaintEvent(), and QApplication::widgetAt().
| bool QRegion::contains | ( | const QPoint & | p | ) | const |
Returns true if the region contains the point p; otherwise returns false.
Definition at line 2611 of file qregion_unix.cpp.
Referenced by qdesigner_internal::childAt_SkipDropLine(), qdesigner_internal::TabOrderEditor::mouseMoveEvent(), qdesigner_internal::TabOrderEditor::mousePressEvent(), QDockAreaLayoutInfo::paintSeparators(), and QDockWidgetLayout::paintSeparators().
| bool QRegion::contains | ( | const QRect & | r | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns true if the region overlaps the rectangle r; otherwise returns false.
Definition at line 2623 of file qregion_unix.cpp.
| void QRegion::translate | ( | int | dx, | |
| int | dy | |||
| ) |
Translates (moves) the region dx along the X axis and dy along the Y axis.
Definition at line 2635 of file qregion_unix.cpp.
Referenced by QWidgetBackingStore::cleanRegion(), QWidgetBackingStore::copyToScreen(), QWidgetBackingStore::dirtyRegion(), QWidgetPrivate::drawWidget(), exec(), QWidgetPrivate::moveRect(), QWidget::repaint(), and translated().
02639 { 02640 detach(); 02641 OffsetRegion(*d->qt_rgn, dx, dy); 02642 #if defined(Q_WS_X11) 02643 if (d->xrectangles) { 02644 free(d->xrectangles); 02645 d->xrectangles = 0; 02646 } 02647 #elif defined(Q_WS_MAC) 02648 if(d->rgn) { 02649 qt_mac_dispose_rgn(d->rgn); 02650 d->rgn = 0;
| void QRegion::translate | ( | const QPoint & | point | ) | [inline] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Translates the region {point}{.x()} along the x axis and {point}{.y()} along the y axis, relative to the current position. Positive values move the region to the right and down.
Translates to the given point.
Definition at line 70 of file qregion.h.
References p.
| QRegion QRegion::translated | ( | int | dx, | |
| int | dy | |||
| ) | const |
Definition at line 521 of file qregion.cpp.
References translate().
Referenced by QWidget::childrenRegion(), QWindowsXPStylePrivate::drawBackgroundDirectly(), QWidgetPrivate::moveRect(), QWidgetBackingStore::paintSiblingsRecursive(), QWidgetPrivate::setGeometry_sys(), QWidget::setMask(), and QWidgetPrivate::subtractOpaqueChildren().
00522 { 00523 QRegion ret(*this); 00524 ret.translate(dx, dy); 00525 return ret; 00526 }
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 72 of file qregion.h.
References p.
00072 { return translated(p.x(), p.y()); }
Use united(r) instead.
Definition at line 2672 of file qregion_unix.cpp.
Referenced by CannonField::moveShot(), and qdesigner_internal::Connection::region().
Use intersected(r) instead.
Definition at line 2716 of file qregion_unix.cpp.
Referenced by PieView::setSelection().
02720 { 02721 QRegion result; 02722 if (::isEmpty(d->qt_rgn) || ::isEmpty(r.d->qt_rgn) 02723 || !EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents)) 02724 return result; 02725 02726 #ifdef QT_EXPERIMENTAL_REGIONS 02727 /* this is fully contained in r */ 02728 if (r.d->qt_rgn->contains(*d->qt_rgn)) 02729 return *this; 02730 02731 /* r is fully contained in this */ 02732 if (d->qt_rgn->contains(*r.d->qt_rgn)) 02733 return r; 02734 #endif 02735 02736 result.detach(); 02737 miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0); 02738 02739 /* 02740 * Can't alter dest's extents before we call miRegionOp because 02741 * it might be one of the source regions and miRegionOp depends 02742 * on the extents of those regions being the same. Besides, this 02743 * way there's no checking against rectangles that will be nuked 02744 * due to coalescing, so we have to examine fewer rectangles. 02745 */
Use subtracted(r) instead.
Definition at line 2768 of file qregion_unix.cpp.
Referenced by Spacer::updateMask().
runion.png Region Union
The figure shows the union of two elliptical regions.
Definition at line 80 of file qregion.h.
Referenced by Q3ScrollView::changeFrameRect(), exec(), operator+(), operator|(), and Q3ListBox::refreshSlot().
00080 { return unite(r); }
rintersect.png Region Intersection
The figure shows the intersection of two elliptical regions.
Definition at line 81 of file qregion.h.
Referenced by Q3IconView::drawContents(), QWindowsStyle::drawControl(), exec(), operator &(), QX11PaintEngine::updateClipRegion_dev(), and Q3ListBox::viewportPaintEvent().
00081 { return intersect(r); }
rsubtract.png Region Subtraction
The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left ({left - right}).
Definition at line 82 of file qregion.h.
Referenced by Q3ScrollView::changeFrameRect(), Q3IconView::doAutoScroll(), Q3IconView::drawContents(), exec(), Q3IconView::insertInGrid(), operator-(), Q3GridView::paintEmptyArea(), Q3Table::paintEmptyArea(), Q3Table::repaintSelections(), and Q3ListBox::viewportPaintEvent().
00082 { return subtract(r); }
rxor.png Region XORed
The figure shows the exclusive or of two elliptical regions.
Definition at line 83 of file qregion.h.
Referenced by exec(), and operator^().
00083 { return eor(r); }
| bool QRegion::intersects | ( | const QRegion & | region | ) | const |
Definition at line 541 of file qregion.cpp.
References QVector< T >::begin(), QVector< T >::end(), rect_intersects(), and rects().
00542 { 00543 const QVector<QRect> myRects = rects(); 00544 const QVector<QRect> otherRects = region.rects(); 00545 00546 for (QVector<QRect>::const_iterator i1 = myRects.begin(); i1 < myRects.end(); ++i1) 00547 for (QVector<QRect>::const_iterator i2 = otherRects.begin(); i2 < otherRects.end(); ++i2) 00548 if (rect_intersects(*i1, *i2)) 00549 return true; 00550 return false; 00551 }
Here is the call graph for this function:

| bool QRegion::intersects | ( | const QRect & | rect | ) | const |
Definition at line 559 of file qregion.cpp.
References QVector< T >::begin(), QVector< T >::end(), QRect::normalized(), rect_intersects(), and rects().
00560 { 00561 QRect r = rect.normalized(); 00562 const QVector<QRect> myRects = rects(); 00563 for (QVector<QRect>::const_iterator it = myRects.begin(); it < myRects.end(); ++it) 00564 if (rect_intersects(r, *it)) 00565 return true; 00566 return false; 00567 }
Here is the call graph for this function:

| QRect QRegion::boundingRect | ( | ) | const |
Returns the bounding rectangle of this region. An empty region gives a rectangle that is QRect::isNull().
Definition at line 2810 of file qregion_unix.cpp.
Referenced by QWidgetBackingStore::copyToScreen(), Q3SimpleRichText::draw(), QWindowsXPStylePrivate::drawBackgroundDirectly(), Q3IconView::drawContents(), QTreeView::drawTree(), QWidgetPrivate::drawWidget(), Skin::endPress(), QX11WindowSurface::flush(), QRasterWindowSurface::flush(), operator<<(), Skin::paintEvent(), QWidgetBackingStore::paintSiblingsRecursive(), qdesigner_internal::Connection::region(), QPainter::setClipRegion(), Skin::startPress(), QPicturePaintEngine::updateClipRegion(), and QPicturePaintEngine::writeCmdLength().
02814 { 02815 if (isEmpty())
Returns an array of non-overlapping rectangles that make up the region.
The union of all the rectangles is equal to the original region.
Definition at line 2865 of file qregion_unix.cpp.
Referenced by QPainterPath::addRegion(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), Q3CanvasView::drawContents(), QTreeView::drawTree(), QRasterPaintEngine::flush(), Q3IconView::insertInGrid(), intersects(), operator<<(), Q3GridView::paintEmptyArea(), Q3Table::paintEmptyArea(), QGraphicsView::paintEvent(), Q3Table::repaintSelections(), QPainter::setClipRegion(), QPdfBaseEngine::updateState(), and Q3ListBox::viewportPaintEvent().
02869 { 02870 if (d->qt_rgn) { 02871 d->qt_rgn->rects.resize(d->qt_rgn->numRects); 02872 return d->qt_rgn->rects; 02873 } else {
| void QRegion::setRects | ( | const QRect * | rects, | |
| int | number | |||
| ) |
Sets the region using the array of rectangles specified by rects and number. The rectangles must be optimally Y-X sorted and follow these restrictions:
The rectangles must not intersect. All rectangles with a given top coordinate must have the same height. No two rectangles may abut horizontally (they should be combined into a single wider rectangle in that case). The rectangles must be sorted in ascending order, with Y as the major sort key and X as the minor sort key. Only some platforms have that restriction (QWS and X11 and Mac OS X).
Definition at line 2894 of file qregion_unix.cpp.
02898 { 02899 *this = QRegion(); 02900 detach(); 02901 if (!rects || (num == 1 && rects->isEmpty())) 02902 num = 0; 02903 02904 d->qt_rgn->rects.resize(num); 02905 d->qt_rgn->numRects = num; 02906 if (num == 0) { 02907 d->qt_rgn->extents = QRect(); 02908 } else { 02909 int left = INT_MAX, 02910 right = INT_MIN, 02911 top = INT_MAX, 02912 bottom = INT_MIN; 02913 for (int i = 0; i < num; ++i) { 02914 const QRect &rect = rects[i]; 02915 d->qt_rgn->rects[i] = rect; 02916 left = qMin(rect.left(), left); 02917 right = qMax(rect.right(), right); 02918 top = qMin(rect.top(), top); 02919 bottom = qMax(rect.bottom(), bottom); 02920 #ifdef QT_EXPERIMENTAL_REGIONS 02921 d->qt_rgn->updateInnerRect(rect); 02922 #endif 02923 }
Applies the united() function to this region and r. r1|r2 is equivalent to r1.united(r2).
Definition at line 383 of file qregion.cpp.
References united().
00384 { return united(r); }
Here is the call graph for this function:

Applies the united() function to this region and r. r1+r2 is equivalent to r1.united(r2).
Definition at line 392 of file qregion.cpp.
References united().
00393 { return united(r); }
Here is the call graph for this function:

Applies the intersected() function to this region and r. r1&r2 is equivalent to r1.intersected(r2).
Definition at line 401 of file qregion.cpp.
References intersected().
00402 { return intersected(r); }
Here is the call graph for this function:

Applies the subtracted() function to this region and r. r1-r2 is equivalent to r1.subtracted(r2).
Definition at line 410 of file qregion.cpp.
References subtracted().
00411 { return subtracted(r); }
Here is the call graph for this function:

Applies the united() function to this region and r and assigns the result to this region. r1|=r2 is equivalent to {r1 = r1.united(r2)}.
Definition at line 429 of file qregion.cpp.
Applies the united() function to this region and r and assigns the result to this region. r1+=r2 is equivalent to {r1 = r1.united(r2)}.
Definition at line 440 of file qregion.cpp.
Applies the intersected() function to this region and r and assigns the result to this region. r1&=r2 is equivalent to r1 = r1.intersected(r2).
Definition at line 451 of file qregion.cpp.
Applies the subtracted() function to this region and r and assigns the result to this region. r1-=r2 is equivalent to {r1 = r1.subtracted(r2)}.
Definition at line 461 of file qregion.cpp.
Applies the xored() function to this region and r and assigns the result to this region. r1^=r2 is equivalent to {r1 = r1.xored(r2)}.
Definition at line 471 of file qregion.cpp.
| bool QRegion::operator== | ( | const QRegion & | r | ) | const |
| bool QRegion::operator!= | ( | const QRegion & | other | ) | const [inline] |
Returns true if this region is different from the other region; otherwise returns false.
Definition at line 104 of file qregion.h.
References operator==().
00104 { return !(operator==(r)); }
Here is the call graph for this function:

| QRegion::operator QVariant | ( | ) | const |
Returns the region as a QVariant
Definition at line 484 of file qregion.cpp.
References QVariant::Region.
00485 { 00486 return QVariant(QVariant::Region, this); 00487 }
| QRegion QRegion::copy | ( | ) | const [private] |
Definition at line 2554 of file qregion_unix.cpp.
Referenced by detach(), and exec().
02558 { 02559 QRegion r; 02560 QRegionData *x = new QRegionData; 02561 x->ref.init(1); 02562 #if defined(Q_WS_X11) 02563 x->rgn = 0; 02564 x->xrectangles = 0; 02565 #elif defined(Q_WS_MAC) 02566 x->rgn = 0; 02567 #endif 02568 if (d->qt_rgn) 02569 x->qt_rgn = new QRegionPrivate(*d->qt_rgn); 02570 else 02571 x->qt_rgn = new QRegionPrivate; 02572 x = qAtomicSetPtr(&r.d, x); 02573 if (!x->ref.deref())
| void QRegion::detach | ( | ) | [private] |
Definition at line 202 of file qregion.cpp.
References copy(), d, and QRegion::QRegionData::ref.
Here is the call graph for this function:

| void QRegion::exec | ( | const QByteArray & | ba, | |
| int | ver = 0 | |||
| ) | [private] |
Definition at line 232 of file qregion.cpp.
References a, buffer, copy(), Ellipse, exec(), i, int, intersected(), n, Qt::OddEvenFill, p, QRegion(), QRGN_AND, QRGN_OR, QRGN_RECTS, QRGN_SETELLIPSE, QRGN_SETPTARRAY_ALT, QRGN_SETPTARRAY_WIND, QRGN_SETRECT, QRGN_SUB, QRGN_TRANSLATE, QRGN_XOR, qWarning(), QIODevice::ReadOnly, Rectangle, s, subtracted(), translate(), united(), Qt::WindingFill, and xored().
Referenced by exec().
00233 { 00234 QByteArray copy = buffer; 00235 QDataStream s(©, QIODevice::ReadOnly); 00236 if (ver) 00237 s.setVersion(ver); 00238 QRegion rgn; 00239 #ifndef QT_NO_DEBUG 00240 int test_cnt = 0; 00241 #endif 00242 while (!s.atEnd()) { 00243 qint32 id; 00244 if (s.version() == 1) { 00245 int id_int; 00246 s >> id_int; 00247 id = id_int; 00248 } else { 00249 s >> id; 00250 } 00251 #ifndef QT_NO_DEBUG 00252 if (test_cnt > 0 && id != QRGN_TRANSLATE) 00253 qWarning("QRegion::exec: Internal error"); 00254 test_cnt++; 00255 #endif 00256 if (id == QRGN_SETRECT || id == QRGN_SETELLIPSE) { 00257 QRect r; 00258 s >> r; 00259 rgn = QRegion(r, id == QRGN_SETRECT ? Rectangle : Ellipse); 00260 } else if (id == QRGN_SETPTARRAY_ALT || id == QRGN_SETPTARRAY_WIND) { 00261 QPolygon a; 00262 s >> a; 00263 rgn = QRegion(a, id == QRGN_SETPTARRAY_WIND ? Qt::WindingFill : Qt::OddEvenFill); 00264 } else if (id == QRGN_TRANSLATE) { 00265 QPoint p; 00266 s >> p; 00267 rgn.translate(p.x(), p.y()); 00268 } else if (id >= QRGN_OR && id <= QRGN_XOR) { 00269 QByteArray bop1, bop2; 00270 QRegion r1, r2; 00271 s >> bop1; 00272 r1.exec(bop1); 00273 s >> bop2; 00274 r2.exec(bop2); 00275 00276 switch (id) { 00277 case QRGN_OR: 00278 rgn = r1.united(r2); 00279 break; 00280 case QRGN_AND: 00281 rgn = r1.intersected(r2); 00282 break; 00283 case QRGN_SUB: 00284 rgn = r1.subtracted(r2); 00285 break; 00286 case QRGN_XOR: 00287 rgn = r1.xored(r2); 00288 break; 00289 } 00290 } else if (id == QRGN_RECTS) { 00291 // (This is the only form used in Qt 2.0) 00292 quint32 n; 00293 s >> n; 00294 QRect r; 00295 for (int i=0; i<(int)n; i++) { 00296 s >> r; 00297 rgn = rgn.united(QRegion(r)); 00298 } 00299 } 00300 } 00301 *this = rgn; 00302 }
Here is the call graph for this function:

| void QRegion::cleanUp | ( | QRegionData * | x | ) | [static, private] |
| QDataStream & operator<< | ( | QDataStream & | s, | |
| const QRegion & | r | |||
| ) | [friend] |
Writes the region r to the stream s and returns a reference to the stream.
Definition at line 318 of file qregion.cpp.
00319 { 00320 QVector<QRect> a = r.rects(); 00321 if (a.isEmpty()) { 00322 s << (quint32)0; 00323 } else { 00324 if (s.version() == 1) { 00325 int i; 00326 for (i = a.size() - 1; i > 0; --i) { 00327 s << (quint32)(12 + i * 24); 00328 s << (int)QRGN_OR; 00329 } 00330 for (i = 0; i < a.size(); ++i) { 00331 s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i]; 00332 } 00333 } else { 00334 s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect 00335 s << (qint32)QRGN_RECTS; 00336 s << a; 00337 } 00338 } 00339 return s; 00340 }
| QDataStream & operator>> | ( | QDataStream & | s, | |
| QRegion & | r | |||
| ) | [friend] |
Reads a region from the stream s into r and returns a reference to the stream.
Definition at line 351 of file qregion.cpp.
struct QRegionData* QRegion::d [private] |
QRegion::QRegionData QRegion::shared_empty [static, private] |
1.5.1