Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** $Id: qt/qpoint.h 3.3.8 edited Jan 11 14:38 $ 00003 ** 00004 ** Definition of QPoint class 00005 ** 00006 ** Created : 931028 00007 ** 00008 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the kernel module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00022 ** licenses may use this file in accordance with the Qt Commercial License 00023 ** Agreement provided with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QPOINT_H 00039 #define QPOINT_H 00040 00041 #ifndef QT_H 00042 #include "qwindowdefs.h" 00043 #endif // QT_H 00044 00045 00046 class Q_EXPORT QPoint 00047 { 00048 public: 00049 QPoint(); 00050 QPoint( int xpos, int ypos ); 00051 00052 bool isNull() const; 00053 00054 int x() const; 00055 int y() const; 00056 void setX( int x ); 00057 void setY( int y ); 00058 00059 int manhattanLength() const; 00060 00061 QCOORD &rx(); 00062 QCOORD &ry(); 00063 00064 QPoint &operator+=( const QPoint &p ); 00065 QPoint &operator-=( const QPoint &p ); 00066 QPoint &operator*=( int c ); 00067 QPoint &operator*=( double c ); 00068 QPoint &operator/=( int c ); 00069 QPoint &operator/=( double c ); 00070 00071 friend inline bool operator==( const QPoint &, const QPoint & ); 00072 friend inline bool operator!=( const QPoint &, const QPoint & ); 00073 friend inline const QPoint operator+( const QPoint &, const QPoint & ); 00074 friend inline const QPoint operator-( const QPoint &, const QPoint & ); 00075 friend inline const QPoint operator*( const QPoint &, int ); 00076 friend inline const QPoint operator*( int, const QPoint & ); 00077 friend inline const QPoint operator*( const QPoint &, double ); 00078 friend inline const QPoint operator*( double, const QPoint & ); 00079 friend inline const QPoint operator-( const QPoint & ); 00080 friend inline const QPoint operator/( const QPoint &, int ); 00081 friend inline const QPoint operator/( const QPoint &, double ); 00082 00083 private: 00084 static void warningDivByZero(); 00085 00086 #if defined(Q_OS_MAC) 00087 QCOORD yp; 00088 QCOORD xp; 00089 #else 00090 QCOORD xp; 00091 QCOORD yp; 00092 #endif 00093 }; 00094 00095 00096 /***************************************************************************** 00097 QPoint stream functions 00098 *****************************************************************************/ 00099 #ifndef QT_NO_DATASTREAM 00100 Q_EXPORT QDataStream &operator<<( QDataStream &, const QPoint & ); 00101 Q_EXPORT QDataStream &operator>>( QDataStream &, QPoint & ); 00102 #endif 00103 00104 /***************************************************************************** 00105 QPoint inline functions 00106 *****************************************************************************/ 00107 00108 inline QPoint::QPoint() 00109 { xp=0; yp=0; } 00110 00111 inline QPoint::QPoint( int xpos, int ypos ) 00112 { xp=(QCOORD)xpos; yp=(QCOORD)ypos; } 00113 00114 inline bool QPoint::isNull() const 00115 { return xp == 0 && yp == 0; } 00116 00117 inline int QPoint::x() const 00118 { return xp; } 00119 00120 inline int QPoint::y() const 00121 { return yp; } 00122 00123 inline void QPoint::setX( int x ) 00124 { xp = (QCOORD)x; } 00125 00126 inline void QPoint::setY( int y ) 00127 { yp = (QCOORD)y; } 00128 00129 inline QCOORD &QPoint::rx() 00130 { return xp; } 00131 00132 inline QCOORD &QPoint::ry() 00133 { return yp; } 00134 00135 inline QPoint &QPoint::operator+=( const QPoint &p ) 00136 { xp+=p.xp; yp+=p.yp; return *this; } 00137 00138 inline QPoint &QPoint::operator-=( const QPoint &p ) 00139 { xp-=p.xp; yp-=p.yp; return *this; } 00140 00141 inline QPoint &QPoint::operator*=( int c ) 00142 { xp*=(QCOORD)c; yp*=(QCOORD)c; return *this; } 00143 00144 inline QPoint &QPoint::operator*=( double c ) 00145 { xp=(QCOORD)(xp*c); yp=(QCOORD)(yp*c); return *this; } 00146 00147 inline bool operator==( const QPoint &p1, const QPoint &p2 ) 00148 { return p1.xp == p2.xp && p1.yp == p2.yp; } 00149 00150 inline bool operator!=( const QPoint &p1, const QPoint &p2 ) 00151 { return p1.xp != p2.xp || p1.yp != p2.yp; } 00152 00153 inline const QPoint operator+( const QPoint &p1, const QPoint &p2 ) 00154 { return QPoint(p1.xp+p2.xp, p1.yp+p2.yp); } 00155 00156 inline const QPoint operator-( const QPoint &p1, const QPoint &p2 ) 00157 { return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); } 00158 00159 inline const QPoint operator*( const QPoint &p, int c ) 00160 { return QPoint(p.xp*c, p.yp*c); } 00161 00162 inline const QPoint operator*( int c, const QPoint &p ) 00163 { return QPoint(p.xp*c, p.yp*c); } 00164 00165 inline const QPoint operator*( const QPoint &p, double c ) 00166 { return QPoint((QCOORD)(p.xp*c), (QCOORD)(p.yp*c)); } 00167 00168 inline const QPoint operator*( double c, const QPoint &p ) 00169 { return QPoint((QCOORD)(p.xp*c), (QCOORD)(p.yp*c)); } 00170 00171 inline const QPoint operator-( const QPoint &p ) 00172 { return QPoint(-p.xp, -p.yp); } 00173 00174 inline QPoint &QPoint::operator/=( int c ) 00175 { 00176 #if defined(QT_CHECK_MATH) 00177 if ( c == 0 ) 00178 warningDivByZero(); 00179 #endif 00180 xp/=(QCOORD)c; 00181 yp/=(QCOORD)c; 00182 return *this; 00183 } 00184 00185 inline QPoint &QPoint::operator/=( double c ) 00186 { 00187 #if defined(QT_CHECK_MATH) 00188 if ( c == 0.0 ) 00189 warningDivByZero(); 00190 #endif 00191 xp=(QCOORD)(xp/c); 00192 yp=(QCOORD)(yp/c); 00193 return *this; 00194 } 00195 00196 inline const QPoint operator/( const QPoint &p, int c ) 00197 { 00198 #if defined(QT_CHECK_MATH) 00199 if ( c == 0 ) 00200 QPoint::warningDivByZero(); 00201 #endif 00202 return QPoint(p.xp/c, p.yp/c); 00203 } 00204 00205 inline const QPoint operator/( const QPoint &p, double c ) 00206 { 00207 #if defined(QT_CHECK_MATH) 00208 if ( c == 0.0 ) 00209 QPoint::warningDivByZero(); 00210 #endif 00211 return QPoint((QCOORD)(p.xp/c), (QCOORD)(p.yp/c)); 00212 } 00213 00214 #define Q_DEFINED_QPOINT 00215 #include "qwinexport.h" 00216 #endif // QPOINT_H