Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QREGION_H
00043 #define QREGION_H
00044
00045 #include <QtCore/qatomic.h>
00046 #include <QtCore/qrect.h>
00047 #include <QtGui/qwindowdefs.h>
00048
00049 #ifndef QT_NO_DATASTREAM
00050 #include <QtCore/qdatastream.h>
00051 #endif
00052
00053 QT_BEGIN_HEADER
00054
00055 QT_BEGIN_NAMESPACE
00056
00057 QT_MODULE(Gui)
00058
00059 template <class T> class QVector;
00060 class QVariant;
00061
00062 #if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
00063 struct QRegionPrivate;
00064 #endif
00065
00066 class QBitmap;
00067
00068 class Q_GUI_EXPORT QRegion
00069 {
00070 public:
00071 enum RegionType { Rectangle, Ellipse };
00072
00073 QRegion();
00074 QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
00075 QRegion(const QRect &r, RegionType t = Rectangle);
00076 QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill);
00077 #ifdef QT3_SUPPORT
00078 QT3_SUPPORT_CONSTRUCTOR QRegion(const QPolygon &pa, bool winding);
00079 #endif
00080 QRegion(const QRegion ®ion);
00081 QRegion(const QBitmap &bitmap);
00082 ~QRegion();
00083 QRegion &operator=(const QRegion &);
00084
00085 #ifdef QT3_SUPPORT
00086 inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
00087 #endif
00088 bool isEmpty() const;
00089
00090 bool contains(const QPoint &p) const;
00091 bool contains(const QRect &r) const;
00092
00093 void translate(int dx, int dy);
00094 inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
00095 QRegion translated(int dx, int dy) const;
00096 inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); }
00097
00098
00099 QRegion unite(const QRegion &r) const;
00100 QRegion unite(const QRect &r) const;
00101 QRegion intersect(const QRegion &r) const;
00102 QRegion intersect(const QRect &r) const;
00103 QRegion subtract(const QRegion &r) const;
00104 QRegion eor(const QRegion &r) const;
00105
00106 inline QRegion united(const QRegion &r) const { return unite(r); }
00107 inline QRegion united(const QRect &r) const { return unite(r); }
00108 inline QRegion intersected(const QRegion &r) const { return intersect(r); }
00109 inline QRegion intersected(const QRect &r) const { return intersect(r); }
00110 inline QRegion subtracted(const QRegion &r) const { return subtract(r); }
00111 inline QRegion xored(const QRegion &r) const { return eor(r); }
00112
00113 bool intersects(const QRegion &r) const;
00114 bool intersects(const QRect &r) const;
00115
00116 QRect boundingRect() const;
00117 QVector<QRect> rects() const;
00118 void setRects(const QRect *rect, int num);
00119 #ifdef QT_DEPRECATED
00120 QT_DEPRECATED int numRects() const;
00121 #endif
00122 int rectCount() const;
00123
00124 const QRegion operator|(const QRegion &r) const;
00125 const QRegion operator+(const QRegion &r) const;
00126 const QRegion operator+(const QRect &r) const;
00127 const QRegion operator&(const QRegion &r) const;
00128 const QRegion operator&(const QRect &r) const;
00129 const QRegion operator-(const QRegion &r) const;
00130 const QRegion operator^(const QRegion &r) const;
00131 QRegion& operator|=(const QRegion &r);
00132 QRegion& operator+=(const QRegion &r);
00133 QRegion& operator+=(const QRect &r);
00134 QRegion& operator&=(const QRegion &r);
00135 QRegion& operator&=(const QRect &r);
00136 QRegion& operator-=(const QRegion &r);
00137 QRegion& operator^=(const QRegion &r);
00138
00139 bool operator==(const QRegion &r) const;
00140 inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
00141 operator QVariant() const;
00142
00143 #ifdef qdoc
00144 Handle handle() const;
00145 #endif
00146 #ifndef qdoc
00147 #if defined(Q_WS_WIN)
00148 inline HRGN handle() const { ensureHandle(); return d->rgn; }
00149 #elif defined(Q_WS_X11)
00150 inline Region handle() const { if(!d->rgn) updateX11Region(); return d->rgn; }
00151 #elif defined(Q_WS_MAC)
00152 #if defined Q_WS_MAC32
00153 RgnHandle toQDRgn() const;
00154 RgnHandle toQDRgnForUpdate_sys() const;
00155 static QRegion fromQDRgn(RgnHandle shape);
00156 #endif
00157 #ifdef QT_MAC_USE_COCOA
00158 inline HIMutableShapeRef handle(bool unused = false) const
00159 { Q_UNUSED(unused); return toHIMutableShape(); }
00160 #else
00161 inline RgnHandle handle() const { return handle(false); }
00162 inline RgnHandle handle(bool) const { return toQDRgn(); }
00163 #endif
00164 HIMutableShapeRef toHIMutableShape() const;
00165 static QRegion fromHIShapeRef(HIShapeRef shape);
00166 #elif defined(Q_WS_QWS)
00167 inline void *handle() const { return d->qt_rgn; }
00168 #endif
00169 #endif
00170
00171 #ifndef QT_NO_DATASTREAM
00172 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
00173 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
00174 #endif
00175 private:
00176 QRegion copy() const;
00177 void detach();
00178 #if defined(Q_WS_WIN)
00179 void ensureHandle() const;
00180 QRegion winCombine(const QRegion &r, int num) const;
00181 #elif defined(Q_WS_X11)
00182 void updateX11Region() const;
00183 void *clipRectangles(int &num) const;
00184 friend void *qt_getClipRects(const QRegion &r, int &num);
00185 #elif defined(Q_WS_MAC)
00186 static OSStatus shape2QRegionHelper(int inMessage, HIShapeRef inShape,
00187 const CGRect *inRect, void *inRefcon);
00188 #endif
00189 friend bool qt_region_strictContains(const QRegion ®ion,
00190 const QRect &rect);
00191 friend struct QRegionPrivate;
00192
00193 #ifndef QT_NO_DATASTREAM
00194 void exec(const QByteArray &ba, int ver = 0, QDataStream::ByteOrder byteOrder = QDataStream::BigEndian);
00195 #endif
00196 struct QRegionData {
00197 QBasicAtomicInt ref;
00198 #if defined(Q_WS_WIN)
00199 HRGN rgn;
00200 #elif defined(Q_WS_X11)
00201 Region rgn;
00202 void *xrectangles;
00203 #elif defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
00204 mutable RgnHandle unused;
00205 #endif
00206 #if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_WIN) || defined(Q_OS_SYMBIAN)
00207 QRegionPrivate *qt_rgn;
00208 #endif
00209 };
00210 #if defined(Q_WS_WIN)
00211 friend class QETWidget;
00212 #endif
00213 struct QRegionData *d;
00214 static struct QRegionData shared_empty;
00215 static void cleanUp(QRegionData *x);
00216 };
00217
00218
00219
00220
00221
00222 #ifndef QT_NO_DATASTREAM
00223 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
00224 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
00225 #endif
00226
00227 #ifndef QT_NO_DEBUG_STREAM
00228 Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
00229 #endif
00230
00231 QT_END_NAMESPACE
00232
00233 QT_END_HEADER
00234
00235 #endif // QREGION_H