KHTML
IntPoint.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef IntPoint_h
00027 #define IntPoint_h
00028
00029 #include "IntSize.h"
00030 #include <wtf/Platform.h>
00031
00032 #if PLATFORM(CG)
00033 typedef struct CGPoint CGPoint;
00034 #endif
00035
00036 #if PLATFORM(MAC)
00037 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
00038 typedef struct CGPoint NSPoint;
00039 #else
00040 typedef struct _NSPoint NSPoint;
00041 #endif
00042 #endif
00043
00044 #if PLATFORM(WIN)
00045 typedef struct tagPOINT POINT;
00046 typedef struct tagPOINTS POINTS;
00047 #elif PLATFORM(QT)
00048 QT_BEGIN_NAMESPACE
00049 class QPoint;
00050 QT_END_NAMESPACE
00051 #elif PLATFORM(GTK)
00052 typedef struct _GdkPoint GdkPoint;
00053 #endif
00054 #if PLATFORM(SYMBIAN)
00055 class TPoint;
00056 #endif
00057
00058 #if PLATFORM(WX)
00059 class wxPoint;
00060 #endif
00061
00062 namespace WebCore {
00063
00064 class IntPoint {
00065 public:
00066 IntPoint() : m_x(0), m_y(0) { }
00067 IntPoint(int x, int y) : m_x(x), m_y(y) { }
00068
00069 int x() const { return m_x; }
00070 int y() const { return m_y; }
00071
00072 void setX(int x) { m_x = x; }
00073 void setY(int y) { m_y = y; }
00074
00075 void move(int dx, int dy) { m_x += dx; m_y += dy; }
00076
00077 #if PLATFORM(CG)
00078 explicit IntPoint(const CGPoint&);
00079 operator CGPoint() const;
00080 #endif
00081
00082 #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
00083 explicit IntPoint(const NSPoint&);
00084 operator NSPoint() const;
00085 #endif
00086
00087 #if PLATFORM(WIN)
00088 IntPoint(const POINT&);
00089 operator POINT() const;
00090 IntPoint(const POINTS&);
00091 operator POINTS() const;
00092 #elif PLATFORM(QT)
00093 IntPoint(const QPoint&);
00094 operator QPoint() const;
00095 #elif PLATFORM(GTK)
00096 IntPoint(const GdkPoint&);
00097 operator GdkPoint() const;
00098 #endif
00099 #if PLATFORM(SYMBIAN)
00100 IntPoint(const TPoint&);
00101 operator TPoint() const;
00102 #endif
00103
00104 #if PLATFORM(WX)
00105 IntPoint(const wxPoint&);
00106 operator wxPoint() const;
00107 #endif
00108
00109 private:
00110 int m_x, m_y;
00111 };
00112
00113 inline IntPoint& operator+=(IntPoint& a, const IntSize& b)
00114 {
00115 a.move(b.width(), b.height());
00116 return a;
00117 }
00118
00119 inline IntPoint& operator-=(IntPoint& a, const IntSize& b)
00120 {
00121 a.move(-b.width(), -b.height());
00122 return a;
00123 }
00124
00125 inline IntPoint operator+(const IntPoint& a, const IntSize& b)
00126 {
00127 return IntPoint(a.x() + b.width(), a.y() + b.height());
00128 }
00129
00130 inline IntSize operator-(const IntPoint& a, const IntPoint& b)
00131 {
00132 return IntSize(a.x() - b.x(), a.y() - b.y());
00133 }
00134
00135 inline IntPoint operator-(const IntPoint& a, const IntSize& b)
00136 {
00137 return IntPoint(a.x() - b.width(), a.y() - b.height());
00138 }
00139
00140 inline bool operator==(const IntPoint& a, const IntPoint& b)
00141 {
00142 return a.x() == b.x() && a.y() == b.y();
00143 }
00144
00145 inline bool operator!=(const IntPoint& a, const IntPoint& b)
00146 {
00147 return a.x() != b.x() || a.y() != b.y();
00148 }
00149
00150 }
00151
00152 #endif // IntPoint_h