1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the painting module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
32
#include "QtCore/qatomic.h"
33
#include "QtCore/qrect.h"
34
#include "QtGui/qwindowdefs.h"
36
template <class T> class QVector;
39
#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC)
40
struct QRegionPrivate;
45
class Q_GUI_EXPORT QRegion
48
enum RegionType { Rectangle, Ellipse };
51
QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
52
QRegion(const QRect &r, RegionType t = Rectangle);
53
QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill);
55
QT3_SUPPORT_CONSTRUCTOR QRegion(const QPolygon &pa, bool winding);
57
QRegion(const QRegion ®ion);
58
QRegion(const QBitmap &bitmap);
60
QRegion &operator=(const QRegion &);
63
inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
67
bool contains(const QPoint &p) const;
68
bool contains(const QRect &r) const;
70
void translate(int dx, int dy);
71
inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
73
QRegion unite(const QRegion &r) const;
74
QRegion intersect(const QRegion &r) const;
75
QRegion subtract(const QRegion &r) const;
76
QRegion eor(const QRegion &r) const;
78
QRect boundingRect() const;
79
QVector<QRect> rects() const;
80
void setRects(const QRect *rect, int num);
82
const QRegion operator|(const QRegion &r) const;
83
const QRegion operator+(const QRegion &r) const;
84
const QRegion operator&(const QRegion &r) const;
85
const QRegion operator-(const QRegion &r) const;
86
const QRegion operator^(const QRegion &r) const;
87
QRegion& operator|=(const QRegion &r);
88
QRegion& operator+=(const QRegion &r);
89
QRegion& operator&=(const QRegion &r);
90
QRegion& operator-=(const QRegion &r);
91
QRegion& operator^=(const QRegion &r);
93
bool operator==(const QRegion &r) const;
94
inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
95
operator QVariant() const;
98
Handle handle() const;
99
#elif defined(Q_WS_WIN)
100
inline HRGN handle() const { return d->rgn; }
101
#elif defined(Q_WS_X11)
102
inline Region handle() const { if(!d->rgn) updateX11Region(); return d->rgn; }
103
#elif defined(Q_WS_MAC)
104
inline RgnHandle handle() const { return handle(false); }
105
RgnHandle handle(bool require_rgn) const;
106
#elif defined(Q_WS_QWS)
107
// QGfx_QWS needs this for region drawing
108
inline void *handle() const { return d->qt_rgn; }
111
#ifndef QT_NO_DATASTREAM
112
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
113
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
116
QRegion copy() const; // helper of detach.
118
#if defined(Q_WS_WIN)
119
QRegion winCombine(const QRegion &r, int num) const;
120
#elif defined(Q_WS_X11)
121
void updateX11Region() const;
122
void *clipRectangles(int &num) const;
123
friend void *qt_getClipRects(const QRegion &r, int &num);
124
#elif defined(Q_WS_MAC)
125
friend QRegion qt_mac_convert_mac_region(RgnHandle rgn);
127
void exec(const QByteArray &ba, int ver = 0);
130
#if defined(Q_WS_WIN)
132
#elif defined(Q_WS_X11)
135
#elif defined(Q_WS_MAC)
136
mutable RgnHandle rgn;
138
#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC)
139
QRegionPrivate *qt_rgn;
142
#if defined(Q_WS_WIN)
143
friend class QETWidget;
145
struct QRegionData *d;
146
static struct QRegionData shared_empty;
147
static void cleanUp(QRegionData *x);
150
/*****************************************************************************
151
QRegion stream functions
152
*****************************************************************************/
154
#ifndef QT_NO_DATASTREAM
155
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
156
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
159
#ifndef QT_NO_DEBUG_STREAM
160
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);