1 /****************************************************************************
3 ** This file is based on sources of the Qt GUI Toolkit, used under the terms
4 ** of the GNU General Public License version 2 (see the original copyright
6 ** All further contributions to this file are (and are required to be)
7 ** licensed under the terms of the GNU General Public License as published by
8 ** the Free Software Foundation; either version 2 of the License, or
9 ** (at your option) any later version.
11 ** The original Qt license header follows:
14 ** Definition of QPoint class
18 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
20 ** This file is part of the kernel module of the Qt GUI Toolkit.
22 ** This file may be distributed under the terms of the Q Public License
23 ** as defined by Trolltech AS of Norway and appearing in the file
24 ** LICENSE.QPL included in the packaging of this file.
26 ** This file may be distributed and/or modified under the terms of the
27 ** GNU General Public License version 2 as published by the Free Software
28 ** Foundation and appearing in the file LICENSE.GPL included in the
29 ** packaging of this file.
31 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
32 ** licenses may use this file in accordance with the Qt Commercial License
33 ** Agreement provided with the Software.
35 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
36 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
38 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
39 ** information about Qt Commercial License Agreements.
40 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
41 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
43 ** Contact info@trolltech.com if any conditions of this licensing are
46 **********************************************************************/
52 #include "qwindowdefs.h"
60 QPoint( int xpos
, int ypos
);
69 int manhattanLength() const;
74 QPoint
&operator+=( const QPoint
&p
);
75 QPoint
&operator-=( const QPoint
&p
);
76 QPoint
&operator*=( int c
);
77 QPoint
&operator*=( double c
);
78 QPoint
&operator/=( int c
);
79 QPoint
&operator/=( double c
);
81 friend inline bool operator==( const QPoint
&, const QPoint
& );
82 friend inline bool operator!=( const QPoint
&, const QPoint
& );
83 friend inline const QPoint
operator+( const QPoint
&, const QPoint
& );
84 friend inline const QPoint
operator-( const QPoint
&, const QPoint
& );
85 friend inline const QPoint
operator*( const QPoint
&, int );
86 friend inline const QPoint
operator*( int, const QPoint
& );
87 friend inline const QPoint
operator*( const QPoint
&, double );
88 friend inline const QPoint
operator*( double, const QPoint
& );
89 friend inline const QPoint
operator-( const QPoint
& );
90 friend inline const QPoint
operator/( const QPoint
&, int );
91 friend inline const QPoint
operator/( const QPoint
&, double );
94 static void warningDivByZero();
106 /*****************************************************************************
107 QPoint stream functions
108 *****************************************************************************/
109 #ifndef QT_NO_DATASTREAM
110 Q_EXPORT QDataStream
&operator<<( QDataStream
&, const QPoint
& );
111 Q_EXPORT QDataStream
&operator>>( QDataStream
&, QPoint
& );
114 /*****************************************************************************
115 QPoint inline functions
116 *****************************************************************************/
118 inline QPoint::QPoint()
121 inline QPoint::QPoint( int xpos
, int ypos
)
122 { xp
=(QCOORD
)xpos
; yp
=(QCOORD
)ypos
; }
124 inline bool QPoint::isNull() const
125 { return xp
== 0 && yp
== 0; }
127 inline int QPoint::x() const
130 inline int QPoint::y() const
133 inline void QPoint::setX( int x
)
136 inline void QPoint::setY( int y
)
139 inline QCOORD
&QPoint::rx()
142 inline QCOORD
&QPoint::ry()
145 inline QPoint
&QPoint::operator+=( const QPoint
&p
)
146 { xp
+=p
.xp
; yp
+=p
.yp
; return *this; }
148 inline QPoint
&QPoint::operator-=( const QPoint
&p
)
149 { xp
-=p
.xp
; yp
-=p
.yp
; return *this; }
151 inline QPoint
&QPoint::operator*=( int c
)
152 { xp
*=(QCOORD
)c
; yp
*=(QCOORD
)c
; return *this; }
154 inline QPoint
&QPoint::operator*=( double c
)
155 { xp
=(QCOORD
)(xp
*c
); yp
=(QCOORD
)(yp
*c
); return *this; }
157 inline bool operator==( const QPoint
&p1
, const QPoint
&p2
)
158 { return p1
.xp
== p2
.xp
&& p1
.yp
== p2
.yp
; }
160 inline bool operator!=( const QPoint
&p1
, const QPoint
&p2
)
161 { return p1
.xp
!= p2
.xp
|| p1
.yp
!= p2
.yp
; }
163 inline const QPoint
operator+( const QPoint
&p1
, const QPoint
&p2
)
164 { return QPoint(p1
.xp
+p2
.xp
, p1
.yp
+p2
.yp
); }
166 inline const QPoint
operator-( const QPoint
&p1
, const QPoint
&p2
)
167 { return QPoint(p1
.xp
-p2
.xp
, p1
.yp
-p2
.yp
); }
169 inline const QPoint
operator*( const QPoint
&p
, int c
)
170 { return QPoint(p
.xp
*c
, p
.yp
*c
); }
172 inline const QPoint
operator*( int c
, const QPoint
&p
)
173 { return QPoint(p
.xp
*c
, p
.yp
*c
); }
175 inline const QPoint
operator*( const QPoint
&p
, double c
)
176 { return QPoint((QCOORD
)(p
.xp
*c
), (QCOORD
)(p
.yp
*c
)); }
178 inline const QPoint
operator*( double c
, const QPoint
&p
)
179 { return QPoint((QCOORD
)(p
.xp
*c
), (QCOORD
)(p
.yp
*c
)); }
181 inline const QPoint
operator-( const QPoint
&p
)
182 { return QPoint(-p
.xp
, -p
.yp
); }
184 inline QPoint
&QPoint::operator/=( int c
)
186 #if defined(QT_CHECK_MATH)
195 inline QPoint
&QPoint::operator/=( double c
)
197 #if defined(QT_CHECK_MATH)
206 inline const QPoint
operator/( const QPoint
&p
, int c
)
208 #if defined(QT_CHECK_MATH)
210 QPoint::warningDivByZero();
212 return QPoint(p
.xp
/c
, p
.yp
/c
);
215 inline const QPoint
operator/( const QPoint
&p
, double c
)
217 #if defined(QT_CHECK_MATH)
219 QPoint::warningDivByZero();
221 return QPoint((QCOORD
)(p
.xp
/c
), (QCOORD
)(p
.yp
/c
));
224 #define Q_DEFINED_QPOINT
225 #include "qwinexport.h"