source: trunk/doc/html/qrect-h.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 9.7 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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
86class Q_EXPORT QRect // rectangle class
87{
88public:
89 QRect() { x1 = y1 = 0; x2 = y2 = -1; }
90 QRect( const QPoint &amp;topleft, const QPoint &amp;bottomright );
91 QRect( const QPoint &amp;topleft, const QSize &amp;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 &amp;rLeft();
105 QCOORD &amp;rTop();
106 QCOORD &amp;rRight();
107 QCOORD &amp;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 &amp;p );
119 void setBottomRight( const QPoint &amp;p );
120 void setTopRight( const QPoint &amp;p );
121 void setBottomLeft( const QPoint &amp;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 &amp;p );
137 void moveBottomRight( const QPoint &amp;p );
138 void moveTopRight( const QPoint &amp;p );
139 void moveBottomLeft( const QPoint &amp;p );
140 void moveCenter( const QPoint &amp;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 &amp;s );
153
154 QRect operator|(const QRect &amp;r) const;
155 QRect operator&amp;(const QRect &amp;r) const;
156 QRect&amp; operator|=(const QRect &amp;r);
157 QRect&amp; operator&amp;=(const QRect &amp;r);
158
159 bool contains( const QPoint &amp;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 &amp;r, bool proper=FALSE ) const;
163 QRect unite( const QRect &amp;r ) const;
164 QRect intersect( const QRect &amp;r ) const;
165 bool intersects( const QRect &amp;r ) const;
166
167 friend Q_EXPORT bool operator==( const QRect &amp;, const QRect &amp; );
168 friend Q_EXPORT bool operator!=( const QRect &amp;, const QRect &amp; );
169
170private:
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
187Q_EXPORT bool operator==( const QRect &amp;, const QRect &amp; );
188Q_EXPORT bool operator!=( const QRect &amp;, const QRect &amp; );
189
190
191/*****************************************************************************
192 QRect stream functions
193 *****************************************************************************/
194#ifndef QT_NO_DATASTREAM
195Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QRect &amp; );
196Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QRect &amp; );
197#endif
198
199/*****************************************************************************
200 QRect inline member functions
201 *****************************************************************************/
202
203inline 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
211inline bool QRect::isNull() const
212{ return x2 == x1-1 &amp;&amp; y2 == y1-1; }
213
214inline bool QRect::isEmpty() const
215{ return x1 &gt; x2 || y1 &gt; y2; }
216
217inline bool QRect::isValid() const
218{ return x1 &lt;= x2 &amp;&amp; y1 &lt;= y2; }
219
220inline int QRect::left() const
221{ return x1; }
222
223inline int QRect::top() const
224{ return y1; }
225
226inline int QRect::right() const
227{ return x2; }
228
229inline int QRect::bottom() const
230{ return y2; }
231
232inline QCOORD &amp;QRect::rLeft()
233{ return x1; }
234
235inline QCOORD &amp; QRect::rTop()
236{ return y1; }
237
238inline QCOORD &amp; QRect::rRight()
239{ return x2; }
240
241inline QCOORD &amp; QRect::rBottom()
242{ return y2; }
243
244inline int QRect::x() const
245{ return x1; }
246
247inline int QRect::y() const
248{ return y1; }
249
250inline void QRect::setLeft( int pos )
251{ x1 = (QCOORD)pos; }
252
253inline void QRect::setTop( int pos )
254{ y1 = (QCOORD)pos; }
255
256inline void QRect::setRight( int pos )
257{ x2 = (QCOORD)pos; }
258
259inline void QRect::setBottom( int pos )
260{ y2 = (QCOORD)pos; }
261
262inline void QRect::setX( int x )
263{ x1 = (QCOORD)x; }
264
265inline void QRect::setY( int y )
266{ y1 = (QCOORD)y; }
267
268inline QPoint QRect::topLeft() const
269{ return QPoint(x1, y1); }
270
271inline QPoint QRect::bottomRight() const
272{ return QPoint(x2, y2); }
273
274inline QPoint QRect::topRight() const
275{ return QPoint(x2, y1); }
276
277inline QPoint QRect::bottomLeft() const
278{ return QPoint(x1, y2); }
279
280inline QPoint QRect::center() const
281{ return QPoint((x1+x2)/2, (y1+y2)/2); }
282
283inline int QRect::width() const
284{ return x2 - x1 + 1; }
285
286inline int QRect::height() const
287{ return y2 - y1 + 1; }
288
289inline QSize QRect::size() const
290{ return QSize(x2-x1+1, y2-y1+1); }
291
292inline bool QRect::contains( int x, int y, bool proper ) const
293{
294 if ( proper )
295 return x &gt; x1 &amp;&amp; x &lt; x2 &amp;&amp;
296 y &gt; y1 &amp;&amp; y &lt; y2;
297 else
298 return x &gt;= x1 &amp;&amp; x &lt;= x2 &amp;&amp;
299 y &gt;= y1 &amp;&amp; y &lt;= y2;
300}
301
302inline bool QRect::contains( int x, int y ) const
303{
304 return x &gt;= x1 &amp;&amp; x &lt;= x2 &amp;&amp;
305 y &gt;= y1 &amp;&amp; y &lt;= 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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.