1 | /****************************************************************************
|
---|
2 | ** $Id: qregion.h 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QRegion class
|
---|
5 | **
|
---|
6 | ** Created : 940514
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QREGION_H
|
---|
39 | #define QREGION_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qshared.h"
|
---|
43 | #include "qrect.h"
|
---|
44 | #endif // QT_H
|
---|
45 |
|
---|
46 | #ifdef Q_WS_X11
|
---|
47 | struct QRegionPrivate;
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | class Q_EXPORT QRegion
|
---|
51 | {
|
---|
52 | public:
|
---|
53 | enum RegionType { Rectangle, Ellipse };
|
---|
54 |
|
---|
55 | QRegion();
|
---|
56 | QRegion( int x, int y, int w, int h, RegionType = Rectangle );
|
---|
57 | QRegion( const QRect &, RegionType = Rectangle );
|
---|
58 | QRegion( const QPointArray &, bool winding=FALSE );
|
---|
59 | QRegion( const QRegion & );
|
---|
60 | QRegion( const QBitmap & );
|
---|
61 | ~QRegion();
|
---|
62 | QRegion &operator=( const QRegion & );
|
---|
63 |
|
---|
64 | bool isNull() const;
|
---|
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 |
|
---|
72 | QRegion unite( const QRegion & ) const;
|
---|
73 | QRegion intersect( const QRegion &) const;
|
---|
74 | QRegion subtract( const QRegion & ) const;
|
---|
75 | QRegion eor( const QRegion & ) const;
|
---|
76 |
|
---|
77 | QRect boundingRect() const;
|
---|
78 | QMemArray<QRect> rects() const;
|
---|
79 | void setRects( const QRect *, int );
|
---|
80 |
|
---|
81 | const QRegion operator|( const QRegion & ) const;
|
---|
82 | const QRegion operator+( const QRegion & ) const;
|
---|
83 | const QRegion operator&( const QRegion & ) const;
|
---|
84 | const QRegion operator-( const QRegion & ) const;
|
---|
85 | const QRegion operator^( const QRegion & ) const;
|
---|
86 | QRegion& operator|=( const QRegion & );
|
---|
87 | QRegion& operator+=( const QRegion & );
|
---|
88 | QRegion& operator&=( const QRegion & );
|
---|
89 | QRegion& operator-=( const QRegion & );
|
---|
90 | QRegion& operator^=( const QRegion & );
|
---|
91 |
|
---|
92 | bool operator==( const QRegion & ) const;
|
---|
93 | bool operator!=( const QRegion &r ) const
|
---|
94 | { return !(operator==(r)); }
|
---|
95 |
|
---|
96 | #if defined(Q_WS_WIN) || defined(Q_WS_PM)
|
---|
97 | HRGN handle() const { if (! data->rgn ) update(); return data->rgn; }
|
---|
98 | #elif defined(Q_WS_X11)
|
---|
99 | Region handle() const { if(!data->rgn) updateX11Region(); return data->rgn; }
|
---|
100 | #elif defined(Q_WS_MAC)
|
---|
101 | RgnHandle handle(bool require_rgn=FALSE) const;
|
---|
102 | #elif defined(Q_WS_QWS)
|
---|
103 | // QGfx_QWS needs this for region drawing
|
---|
104 | void * handle() const { return data->rgn; }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | #ifndef QT_NO_DATASTREAM
|
---|
108 | friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QRegion & );
|
---|
109 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QRegion & );
|
---|
110 | #endif
|
---|
111 | private:
|
---|
112 | QRegion( bool );
|
---|
113 | QRegion copy() const;
|
---|
114 | void detach();
|
---|
115 | #if defined(Q_WS_WIN)
|
---|
116 | QRegion winCombine( const QRegion &, int ) const;
|
---|
117 | #elif defined(Q_WS_PM)
|
---|
118 | QRegion pmCombine( const QRegion &, int ) const;
|
---|
119 | void update() const;
|
---|
120 | #elif defined(Q_WS_X11)
|
---|
121 | void updateX11Region() const;
|
---|
122 | void *clipRectangles( int &num ) const;
|
---|
123 | friend void *qt_getClipRects( const QRegion &, int & );
|
---|
124 | #endif
|
---|
125 | void exec( const QByteArray &, int ver = 0 );
|
---|
126 | struct QRegionData : public QShared {
|
---|
127 | #if defined(Q_WS_WIN) || defined(Q_WS_PM)
|
---|
128 | HRGN rgn;
|
---|
129 | #elif defined(Q_WS_X11)
|
---|
130 | Region rgn;
|
---|
131 | void *xrectangles;
|
---|
132 | QRegionPrivate *region;
|
---|
133 | #elif defined(Q_WS_MAC)
|
---|
134 | uint is_rect:1;
|
---|
135 | QRect rect;
|
---|
136 | RgnHandle rgn;
|
---|
137 | #elif defined(Q_WS_QWS)
|
---|
138 | void * rgn;
|
---|
139 | #endif
|
---|
140 | bool is_null;
|
---|
141 | } *data;
|
---|
142 | #if defined(Q_WS_MAC)
|
---|
143 | friend struct qt_mac_rgn_data_cache;
|
---|
144 | friend QRegionData *qt_mac_get_rgn_data();
|
---|
145 | friend void qt_mac_free_rgn_data(QRegionData *);
|
---|
146 | void rectifyRegion();
|
---|
147 | #elif defined(Q_WS_WIN)
|
---|
148 | friend class QETWidget;
|
---|
149 | #elif defined(Q_WS_PM)
|
---|
150 | friend class QETWidget;
|
---|
151 | friend class QPainter;
|
---|
152 | friend void qt_set_paintevent_clipping( QPaintDevice*, const QRegion& );
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | };
|
---|
156 |
|
---|
157 |
|
---|
158 | #define QRGN_SETRECT 1 // region stream commands
|
---|
159 | #define QRGN_SETELLIPSE 2 // (these are internal)
|
---|
160 | #define QRGN_SETPTARRAY_ALT 3
|
---|
161 | #define QRGN_SETPTARRAY_WIND 4
|
---|
162 | #define QRGN_TRANSLATE 5
|
---|
163 | #define QRGN_OR 6
|
---|
164 | #define QRGN_AND 7
|
---|
165 | #define QRGN_SUB 8
|
---|
166 | #define QRGN_XOR 9
|
---|
167 | #define QRGN_RECTS 10
|
---|
168 |
|
---|
169 |
|
---|
170 | /*****************************************************************************
|
---|
171 | QRegion stream functions
|
---|
172 | *****************************************************************************/
|
---|
173 |
|
---|
174 | #ifndef QT_NO_DATASTREAM
|
---|
175 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QRegion & );
|
---|
176 | Q_EXPORT QDataStream &operator>>( QDataStream &, QRegion & );
|
---|
177 | #endif
|
---|
178 |
|
---|
179 |
|
---|
180 | #endif // QREGION_H
|
---|