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 class QPoint;
00049 #endif
00050 #if PLATFORM(SYMBIAN)
00051 class TPoint;
00052 #endif
00053
00054 namespace WebCore {
00055
00056 class IntPoint {
00057 public:
00058 IntPoint() : m_x(0), m_y(0) { }
00059 IntPoint(int x, int y) : m_x(x), m_y(y) { }
00060
00061 int x() const { return m_x; }
00062 int y() const { return m_y; }
00063
00064 void setX(int x) { m_x = x; }
00065 void setY(int y) { m_y = y; }
00066
00067 void move(int dx, int dy) { m_x += dx; m_y += dy; }
00068
00069 #if PLATFORM(CG)
00070 explicit IntPoint(const CGPoint&);
00071 operator CGPoint() const;
00072 #endif
00073
00074 #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
00075 explicit IntPoint(const NSPoint&);
00076 operator NSPoint() const;
00077 #endif
00078
00079 #if PLATFORM(WIN)
00080 IntPoint(const POINT&);
00081 operator POINT() const;
00082 IntPoint(const POINTS&);
00083 operator POINTS() const;
00084 #elif PLATFORM(QT)
00085 IntPoint(const QPoint&);
00086 operator QPoint() const;
00087 #endif
00088 #if PLATFORM(SYMBIAN)
00089 IntPoint(const TPoint&);
00090 operator TPoint() const;
00091 #endif
00092
00093 private:
00094 int m_x, m_y;
00095 };
00096
00097 inline IntPoint& operator+=(IntPoint& a, const IntSize& b)
00098 {
00099 a.move(b.width(), b.height());
00100 return a;
00101 }
00102
00103 inline IntPoint& operator-=(IntPoint& a, const IntSize& b)
00104 {
00105 a.move(-b.width(), -b.height());
00106 return a;
00107 }
00108 #ifdef __OWB__
00109 inline IntPoint operator+(const IntPoint& a, const IntPoint& b)
00110 {
00111 return IntPoint(a.x() + b.x(), a.y() + b.y());
00112 }
00113 #endif
00114 inline IntPoint operator+(const IntPoint& a, const IntSize& b)
00115 {
00116 return IntPoint(a.x() + b.width(), a.y() + b.height());
00117 }
00118
00119 inline IntSize operator-(const IntPoint& a, const IntPoint& b)
00120 {
00121 return IntSize(a.x() - b.x(), a.y() - b.y());
00122 }
00123
00124 inline IntPoint operator-(const IntPoint& a, const IntSize& b)
00125 {
00126 return IntPoint(a.x() - b.width(), a.y() - b.height());
00127 }
00128
00129 inline bool operator==(const IntPoint& a, const IntPoint& b)
00130 {
00131 return a.x() == b.x() && a.y() == b.y();
00132 }
00133
00134 inline bool operator!=(const IntPoint& a, const IntPoint& b)
00135 {
00136 return a.x() != b.x() || a.y() != b.y();
00137 }
00138
00139 }
00140
00141 #endif // IntPoint_h