Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / ksplash / ksplashx / qpoint.h
blob47733445f5c9c24b239a6774eeeecb2f1bf7b2f9
1 /****************************************************************************
2 **
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
5 ** notice below).
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:
12 **
14 ** Definition of QPoint class
16 ** Created : 931028
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
44 ** not clear to you.
46 **********************************************************************/
48 #ifndef QPOINT_H
49 #define QPOINT_H
51 #ifndef QT_H
52 #include "qwindowdefs.h"
53 #endif // QT_H
56 class Q_EXPORT QPoint
58 public:
59 QPoint();
60 QPoint( int xpos, int ypos );
62 bool isNull() const;
64 int x() const;
65 int y() const;
66 void setX( int x );
67 void setY( int y );
69 int manhattanLength() const;
71 QCOORD &rx();
72 QCOORD &ry();
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 );
93 private:
94 static void warningDivByZero();
96 #if defined(Q_OS_MAC)
97 QCOORD yp;
98 QCOORD xp;
99 #else
100 QCOORD xp;
101 QCOORD yp;
102 #endif
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 & );
112 #endif
114 /*****************************************************************************
115 QPoint inline functions
116 *****************************************************************************/
118 inline QPoint::QPoint()
119 { xp=0; yp=0; }
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
128 { return xp; }
130 inline int QPoint::y() const
131 { return yp; }
133 inline void QPoint::setX( int x )
134 { xp = (QCOORD)x; }
136 inline void QPoint::setY( int y )
137 { yp = (QCOORD)y; }
139 inline QCOORD &QPoint::rx()
140 { return xp; }
142 inline QCOORD &QPoint::ry()
143 { return yp; }
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)
187 if ( c == 0 )
188 warningDivByZero();
189 #endif
190 xp/=(QCOORD)c;
191 yp/=(QCOORD)c;
192 return *this;
195 inline QPoint &QPoint::operator/=( double c )
197 #if defined(QT_CHECK_MATH)
198 if ( c == 0.0 )
199 warningDivByZero();
200 #endif
201 xp=(QCOORD)(xp/c);
202 yp=(QCOORD)(yp/c);
203 return *this;
206 inline const QPoint operator/( const QPoint &p, int c )
208 #if defined(QT_CHECK_MATH)
209 if ( c == 0 )
210 QPoint::warningDivByZero();
211 #endif
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)
218 if ( c == 0.0 )
219 QPoint::warningDivByZero();
220 #endif
221 return QPoint((QCOORD)(p.xp/c), (QCOORD)(p.yp/c));
224 #define Q_DEFINED_QPOINT
225 #include "qwinexport.h"
226 #endif // QPOINT_H