1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qrect.h:1 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>qrect.h Include File</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qrect.h</h1>
|
---|
33 |
|
---|
34 | <p>This is the verbatim text of the qrect.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
35 | <hr>
|
---|
36 | <pre>
|
---|
37 | /****************************************************************************
|
---|
38 | ** $Id: qrect-h.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
39 | **
|
---|
40 | ** Definition of QRect class
|
---|
41 | **
|
---|
42 | ** Created : 931028
|
---|
43 | **
|
---|
44 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
45 | **
|
---|
46 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
47 | **
|
---|
48 | ** This file may be distributed under the terms of the Q Public License
|
---|
49 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
50 | ** LICENSE.QPL included in the packaging of this file.
|
---|
51 | **
|
---|
52 | ** This file may be distributed and/or modified under the terms of the
|
---|
53 | ** GNU General Public License version 2 as published by the Free Software
|
---|
54 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
55 | ** packaging of this file.
|
---|
56 | **
|
---|
57 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
58 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
59 | ** Agreement provided with the Software.
|
---|
60 | **
|
---|
61 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
62 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
63 | **
|
---|
64 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
65 | ** information about Qt Commercial License Agreements.
|
---|
66 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
67 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
68 | **
|
---|
69 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
70 | ** not clear to you.
|
---|
71 | **
|
---|
72 | **********************************************************************/
|
---|
73 |
|
---|
74 | #ifndef QRECT_H
|
---|
75 | #define QRECT_H
|
---|
76 |
|
---|
77 | #ifndef QT_H
|
---|
78 | #include "qsize.h"
|
---|
79 | #endif // QT_H
|
---|
80 |
|
---|
81 | #if defined(topLeft)
|
---|
82 | #error "Macro definition of topLeft conflicts with QRect"
|
---|
83 | // don't just silently undo people's defines: #undef topLeft
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | class Q_EXPORT QRect // rectangle class
|
---|
87 | {
|
---|
88 | public:
|
---|
89 | QRect() { x1 = y1 = 0; x2 = y2 = -1; }
|
---|
90 | QRect( const QPoint &topleft, const QPoint &bottomright );
|
---|
91 | QRect( const QPoint &topleft, const QSize &size );
|
---|
92 | QRect( int left, int top, int width, int height );
|
---|
93 |
|
---|
94 | bool isNull() const;
|
---|
95 | bool isEmpty() const;
|
---|
96 | bool isValid() const;
|
---|
97 | QRect normalize() const;
|
---|
98 |
|
---|
99 | int left() const;
|
---|
100 | int top() const;
|
---|
101 | int right() const;
|
---|
102 | int bottom() const;
|
---|
103 |
|
---|
104 | QCOORD &rLeft();
|
---|
105 | QCOORD &rTop();
|
---|
106 | QCOORD &rRight();
|
---|
107 | QCOORD &rBottom();
|
---|
108 |
|
---|
109 | int x() const;
|
---|
110 | int y() const;
|
---|
111 | void setLeft( int pos );
|
---|
112 | void setTop( int pos );
|
---|
113 | void setRight( int pos );
|
---|
114 | void setBottom( int pos );
|
---|
115 | void setX( int x );
|
---|
116 | void setY( int y );
|
---|
117 |
|
---|
118 | void setTopLeft( const QPoint &p );
|
---|
119 | void setBottomRight( const QPoint &p );
|
---|
120 | void setTopRight( const QPoint &p );
|
---|
121 | void setBottomLeft( const QPoint &p );
|
---|
122 |
|
---|
123 | QPoint topLeft() const;
|
---|
124 | QPoint bottomRight() const;
|
---|
125 | QPoint topRight() const;
|
---|
126 | QPoint bottomLeft() const;
|
---|
127 | QPoint center() const;
|
---|
128 |
|
---|
129 | void rect( int *x, int *y, int *w, int *h ) const;
|
---|
130 | void coords( int *x1, int *y1, int *x2, int *y2 ) const;
|
---|
131 |
|
---|
132 | void moveLeft( int pos );
|
---|
133 | void moveTop( int pos );
|
---|
134 | void moveRight( int pos );
|
---|
135 | void moveBottom( int pos );
|
---|
136 | void moveTopLeft( const QPoint &p );
|
---|
137 | void moveBottomRight( const QPoint &p );
|
---|
138 | void moveTopRight( const QPoint &p );
|
---|
139 | void moveBottomLeft( const QPoint &p );
|
---|
140 | void moveCenter( const QPoint &p );
|
---|
141 | void moveBy( int dx, int dy );
|
---|
142 |
|
---|
143 | void setRect( int x, int y, int w, int h );
|
---|
144 | void setCoords( int x1, int y1, int x2, int y2 );
|
---|
145 | void addCoords( int x1, int y1, int x2, int y2 );
|
---|
146 |
|
---|
147 | QSize size() const;
|
---|
148 | int width() const;
|
---|
149 | int height() const;
|
---|
150 | void setWidth( int w );
|
---|
151 | void setHeight( int h );
|
---|
152 | void setSize( const QSize &s );
|
---|
153 |
|
---|
154 | QRect operator|(const QRect &r) const;
|
---|
155 | QRect operator&(const QRect &r) const;
|
---|
156 | QRect& operator|=(const QRect &r);
|
---|
157 | QRect& operator&=(const QRect &r);
|
---|
158 |
|
---|
159 | bool contains( const QPoint &p, bool proper=FALSE ) const;
|
---|
160 | bool contains( int x, int y ) const; // inline methods, _don't_ merge these
|
---|
161 | bool contains( int x, int y, bool proper ) const;
|
---|
162 | bool contains( const QRect &r, bool proper=FALSE ) const;
|
---|
163 | QRect unite( const QRect &r ) const;
|
---|
164 | QRect intersect( const QRect &r ) const;
|
---|
165 | bool intersects( const QRect &r ) const;
|
---|
166 |
|
---|
167 | friend Q_EXPORT bool operator==( const QRect &, const QRect & );
|
---|
168 | friend Q_EXPORT bool operator!=( const QRect &, const QRect & );
|
---|
169 |
|
---|
170 | private:
|
---|
171 | #if defined(Q_WS_X11) || defined(Q_OS_TEMP)
|
---|
172 | friend void qt_setCoords( QRect *r, int xp1, int yp1, int xp2, int yp2 );
|
---|
173 | #endif
|
---|
174 | #if defined(Q_OS_MAC)
|
---|
175 | QCOORD y1;
|
---|
176 | QCOORD x1;
|
---|
177 | QCOORD y2;
|
---|
178 | QCOORD x2;
|
---|
179 | #else
|
---|
180 | QCOORD x1;
|
---|
181 | QCOORD y1;
|
---|
182 | QCOORD x2;
|
---|
183 | QCOORD y2;
|
---|
184 | #endif
|
---|
185 | };
|
---|
186 |
|
---|
187 | Q_EXPORT bool operator==( const QRect &, const QRect & );
|
---|
188 | Q_EXPORT bool operator!=( const QRect &, const QRect & );
|
---|
189 |
|
---|
190 |
|
---|
191 | /*****************************************************************************
|
---|
192 | QRect stream functions
|
---|
193 | *****************************************************************************/
|
---|
194 | #ifndef QT_NO_DATASTREAM
|
---|
195 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QRect & );
|
---|
196 | Q_EXPORT QDataStream &operator>>( QDataStream &, QRect & );
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | /*****************************************************************************
|
---|
200 | QRect inline member functions
|
---|
201 | *****************************************************************************/
|
---|
202 |
|
---|
203 | inline QRect::QRect( int left, int top, int width, int height )
|
---|
204 | {
|
---|
205 | x1 = (QCOORD)left;
|
---|
206 | y1 = (QCOORD)top;
|
---|
207 | x2 = (QCOORD)(left+width-1);
|
---|
208 | y2 = (QCOORD)(top+height-1);
|
---|
209 | }
|
---|
210 |
|
---|
211 | inline bool QRect::isNull() const
|
---|
212 | { return x2 == x1-1 && y2 == y1-1; }
|
---|
213 |
|
---|
214 | inline bool QRect::isEmpty() const
|
---|
215 | { return x1 > x2 || y1 > y2; }
|
---|
216 |
|
---|
217 | inline bool QRect::isValid() const
|
---|
218 | { return x1 <= x2 && y1 <= y2; }
|
---|
219 |
|
---|
220 | inline int QRect::left() const
|
---|
221 | { return x1; }
|
---|
222 |
|
---|
223 | inline int QRect::top() const
|
---|
224 | { return y1; }
|
---|
225 |
|
---|
226 | inline int QRect::right() const
|
---|
227 | { return x2; }
|
---|
228 |
|
---|
229 | inline int QRect::bottom() const
|
---|
230 | { return y2; }
|
---|
231 |
|
---|
232 | inline QCOORD &QRect::rLeft()
|
---|
233 | { return x1; }
|
---|
234 |
|
---|
235 | inline QCOORD & QRect::rTop()
|
---|
236 | { return y1; }
|
---|
237 |
|
---|
238 | inline QCOORD & QRect::rRight()
|
---|
239 | { return x2; }
|
---|
240 |
|
---|
241 | inline QCOORD & QRect::rBottom()
|
---|
242 | { return y2; }
|
---|
243 |
|
---|
244 | inline int QRect::x() const
|
---|
245 | { return x1; }
|
---|
246 |
|
---|
247 | inline int QRect::y() const
|
---|
248 | { return y1; }
|
---|
249 |
|
---|
250 | inline void QRect::setLeft( int pos )
|
---|
251 | { x1 = (QCOORD)pos; }
|
---|
252 |
|
---|
253 | inline void QRect::setTop( int pos )
|
---|
254 | { y1 = (QCOORD)pos; }
|
---|
255 |
|
---|
256 | inline void QRect::setRight( int pos )
|
---|
257 | { x2 = (QCOORD)pos; }
|
---|
258 |
|
---|
259 | inline void QRect::setBottom( int pos )
|
---|
260 | { y2 = (QCOORD)pos; }
|
---|
261 |
|
---|
262 | inline void QRect::setX( int x )
|
---|
263 | { x1 = (QCOORD)x; }
|
---|
264 |
|
---|
265 | inline void QRect::setY( int y )
|
---|
266 | { y1 = (QCOORD)y; }
|
---|
267 |
|
---|
268 | inline QPoint QRect::topLeft() const
|
---|
269 | { return QPoint(x1, y1); }
|
---|
270 |
|
---|
271 | inline QPoint QRect::bottomRight() const
|
---|
272 | { return QPoint(x2, y2); }
|
---|
273 |
|
---|
274 | inline QPoint QRect::topRight() const
|
---|
275 | { return QPoint(x2, y1); }
|
---|
276 |
|
---|
277 | inline QPoint QRect::bottomLeft() const
|
---|
278 | { return QPoint(x1, y2); }
|
---|
279 |
|
---|
280 | inline QPoint QRect::center() const
|
---|
281 | { return QPoint((x1+x2)/2, (y1+y2)/2); }
|
---|
282 |
|
---|
283 | inline int QRect::width() const
|
---|
284 | { return x2 - x1 + 1; }
|
---|
285 |
|
---|
286 | inline int QRect::height() const
|
---|
287 | { return y2 - y1 + 1; }
|
---|
288 |
|
---|
289 | inline QSize QRect::size() const
|
---|
290 | { return QSize(x2-x1+1, y2-y1+1); }
|
---|
291 |
|
---|
292 | inline bool QRect::contains( int x, int y, bool proper ) const
|
---|
293 | {
|
---|
294 | if ( proper )
|
---|
295 | return x > x1 && x < x2 &&
|
---|
296 | y > y1 && y < y2;
|
---|
297 | else
|
---|
298 | return x >= x1 && x <= x2 &&
|
---|
299 | y >= y1 && y <= y2;
|
---|
300 | }
|
---|
301 |
|
---|
302 | inline bool QRect::contains( int x, int y ) const
|
---|
303 | {
|
---|
304 | return x >= x1 && x <= x2 &&
|
---|
305 | y >= y1 && y <= y2;
|
---|
306 | }
|
---|
307 | #define Q_DEFINED_QRECT
|
---|
308 | #include "qwinexport.h"
|
---|
309 | #endif // QRECT_H
|
---|
310 | </pre>
|
---|
311 | <!-- eof -->
|
---|
312 | <p><address><hr><div align=center>
|
---|
313 | <table width=100% cellspacing=0 border=0><tr>
|
---|
314 | <td>Copyright © 2007
|
---|
315 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
316 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
317 | </table></div></address></body>
|
---|
318 | </html>
|
---|