~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/painting/qregion.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the painting module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QREGION_H
 
30
#define QREGION_H
 
31
 
 
32
#include "QtCore/qatomic.h"
 
33
#include "QtCore/qrect.h"
 
34
#include "QtGui/qwindowdefs.h"
 
35
 
 
36
template <class T> class QVector;
 
37
class QVariant;
 
38
 
 
39
#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC)
 
40
struct QRegionPrivate;
 
41
#endif
 
42
 
 
43
class QBitmap;
 
44
 
 
45
class Q_GUI_EXPORT QRegion
 
46
{
 
47
public:
 
48
    enum RegionType { Rectangle, Ellipse };
 
49
 
 
50
    QRegion();
 
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);
 
54
#ifdef QT3_SUPPORT
 
55
    QT3_SUPPORT_CONSTRUCTOR QRegion(const QPolygon &pa, bool winding);
 
56
#endif
 
57
    QRegion(const QRegion &region);
 
58
    QRegion(const QBitmap &bitmap);
 
59
    ~QRegion();
 
60
    QRegion &operator=(const QRegion &);
 
61
 
 
62
#ifdef QT3_SUPPORT
 
63
    inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
 
64
#endif
 
65
    bool isEmpty() const;
 
66
 
 
67
    bool contains(const QPoint &p) const;
 
68
    bool contains(const QRect &r) const;
 
69
 
 
70
    void translate(int dx, int dy);
 
71
    inline void translate(const QPoint &p) { translate(p.x(), p.y()); }
 
72
 
 
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;
 
77
 
 
78
    QRect boundingRect() const;
 
79
    QVector<QRect> rects() const;
 
80
    void setRects(const QRect *rect, int num);
 
81
 
 
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);
 
92
 
 
93
    bool operator==(const QRegion &r) const;
 
94
    inline bool operator!=(const QRegion &r) const { return !(operator==(r)); }
 
95
    operator QVariant() const;
 
96
 
 
97
#if defined(qdoc)
 
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; }
 
109
#endif
 
110
 
 
111
#ifndef QT_NO_DATASTREAM
 
112
    friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
 
113
    friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
 
114
#endif
 
115
private:
 
116
    QRegion copy() const;   // helper of detach.
 
117
    void 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);
 
126
#endif
 
127
    void exec(const QByteArray &ba, int ver = 0);
 
128
    struct QRegionData {
 
129
        QBasicAtomic ref;
 
130
#if defined(Q_WS_WIN)
 
131
        HRGN   rgn;
 
132
#elif defined(Q_WS_X11)
 
133
        Region rgn;
 
134
        void *xrectangles;
 
135
#elif defined(Q_WS_MAC)
 
136
        mutable RgnHandle rgn;
 
137
#endif
 
138
#if defined(Q_WS_QWS) || defined(Q_WS_X11) || defined(Q_WS_MAC)
 
139
        QRegionPrivate *qt_rgn;
 
140
#endif
 
141
    };
 
142
#if defined(Q_WS_WIN)
 
143
    friend class QETWidget;
 
144
#endif
 
145
    struct QRegionData *d;
 
146
    static struct QRegionData shared_empty;
 
147
    static void cleanUp(QRegionData *x);
 
148
};
 
149
 
 
150
/*****************************************************************************
 
151
  QRegion stream functions
 
152
 *****************************************************************************/
 
153
 
 
154
#ifndef QT_NO_DATASTREAM
 
155
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QRegion &);
 
156
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QRegion &);
 
157
#endif
 
158
 
 
159
#ifndef QT_NO_DEBUG_STREAM
 
160
Q_GUI_EXPORT QDebug operator<<(QDebug, const QRegion &);
 
161
#endif
 
162
 
 
163
 
 
164
#endif // QREGION_H