source: trunk/include/qregion.h@ 7

Last change on this file since 7 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 5.4 KB
Line 
1/****************************************************************************
2** $Id: qregion.h 2 2005-11-16 15:49:26Z 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
47struct QRegionPrivate;
48#endif
49
50class Q_EXPORT QRegion
51{
52public:
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)
97 HRGN handle() const { 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
111private:
112 QRegion( bool );
113 QRegion copy() const;
114 void detach();
115#if defined(Q_WS_WIN)
116 QRegion winCombine( const QRegion &, int ) const;
117#endif
118#if defined(Q_WS_X11)
119 void updateX11Region() const;
120 void *clipRectangles( int &num ) const;
121 friend void *qt_getClipRects( const QRegion &, int & );
122#endif
123 void exec( const QByteArray &, int ver = 0 );
124 struct QRegionData : public QShared {
125#if defined(Q_WS_WIN)
126 HRGN rgn;
127#elif defined(Q_WS_X11)
128 Region rgn;
129 void *xrectangles;
130 QRegionPrivate *region;
131#elif defined(Q_WS_MAC)
132 uint is_rect:1;
133 QRect rect;
134 RgnHandle rgn;
135#elif defined(Q_WS_QWS)
136 void * rgn;
137#endif
138 bool is_null;
139 } *data;
140#if defined(Q_WS_MAC)
141 friend struct qt_mac_rgn_data_cache;
142 friend QRegionData *qt_mac_get_rgn_data();
143 friend void qt_mac_free_rgn_data(QRegionData *);
144 void rectifyRegion();
145#elif defined(Q_WS_WIN)
146 friend class QETWidget;
147#endif
148
149};
150
151
152#define QRGN_SETRECT 1 // region stream commands
153#define QRGN_SETELLIPSE 2 // (these are internal)
154#define QRGN_SETPTARRAY_ALT 3
155#define QRGN_SETPTARRAY_WIND 4
156#define QRGN_TRANSLATE 5
157#define QRGN_OR 6
158#define QRGN_AND 7
159#define QRGN_SUB 8
160#define QRGN_XOR 9
161#define QRGN_RECTS 10
162
163
164/*****************************************************************************
165 QRegion stream functions
166 *****************************************************************************/
167
168#ifndef QT_NO_DATASTREAM
169Q_EXPORT QDataStream &operator<<( QDataStream &, const QRegion & );
170Q_EXPORT QDataStream &operator>>( QDataStream &, QRegion & );
171#endif
172
173
174#endif // QREGION_H
Note: See TracBrowser for help on using the repository browser.