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
00027
00028 #ifndef FloatPoint_h
00029 #define FloatPoint_h
00030
00031 #include "FloatSize.h"
00032 #include <wtf/Platform.h>
00033
00034 #ifdef __OWB__
00035 #include "AffineTransform.h"
00036 #endif
00037
00038 #if PLATFORM(CG)
00039 typedef struct CGPoint CGPoint;
00040 #endif
00041
00042 #if PLATFORM(MAC)
00043 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
00044 typedef struct CGPoint NSPoint;
00045 #else
00046 typedef struct _NSPoint NSPoint;
00047 #endif
00048 #endif
00049
00050 #if PLATFORM(QT)
00051 class QPointF;
00052 #endif
00053
00054 #if PLATFORM(SYMBIAN)
00055 class TPoint;
00056 #endif
00057
00058 namespace WebCore {
00059
00060 class AffineTransform;
00061 class IntPoint;
00062
00063 class FloatPoint {
00064 public:
00065 FloatPoint() : m_x(0), m_y(0) { }
00066 FloatPoint(float x, float y) : m_x(x), m_y(y) { }
00067 FloatPoint(const IntPoint&);
00068
00069 static FloatPoint narrowPrecision(double x, double y);
00070
00071 float x() const { return m_x; }
00072 float y() const { return m_y; }
00073
00074 void setX(float x) { m_x = x; }
00075 void setY(float y) { m_y = y; }
00076 void move(float dx, float dy) { m_x += dx; m_y += dy; }
00077
00078 #if PLATFORM(CG)
00079 FloatPoint(const CGPoint&);
00080 operator CGPoint() const;
00081 #endif
00082
00083 #if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
00084 FloatPoint(const NSPoint&);
00085 operator NSPoint() const;
00086 #endif
00087
00088 #if PLATFORM(QT)
00089 FloatPoint(const QPointF&);
00090 operator QPointF() const;
00091 #endif
00092
00093 #if PLATFORM(SYMBIAN)
00094 operator TPoint() const;
00095 FloatPoint(const TPoint& );
00096 #endif
00097
00098 FloatPoint matrixTransform(const AffineTransform&) const;
00099
00100 private:
00101 float m_x, m_y;
00102 };
00103
00104
00105 inline FloatPoint& operator+=(FloatPoint& a, const FloatSize& b)
00106 {
00107 a.move(b.width(), b.height());
00108 return a;
00109 }
00110
00111 inline FloatPoint& operator-=(FloatPoint& a, const FloatSize& b)
00112 {
00113 a.move(-b.width(), -b.height());
00114 return a;
00115 }
00116
00117 inline FloatPoint operator+(const FloatPoint& a, const FloatSize& b)
00118 {
00119 return FloatPoint(a.x() + b.width(), a.y() + b.height());
00120 }
00121
00122 inline FloatSize operator-(const FloatPoint& a, const FloatPoint& b)
00123 {
00124 return FloatSize(a.x() - b.x(), a.y() - b.y());
00125 }
00126
00127 inline FloatPoint operator-(const FloatPoint& a, const FloatSize& b)
00128 {
00129 return FloatPoint(a.x() - b.width(), a.y() - b.height());
00130 }
00131
00132 inline bool operator==(const FloatPoint& a, const FloatPoint& b)
00133 {
00134 return a.x() == b.x() && a.y() == b.y();
00135 }
00136
00137 inline bool operator!=(const FloatPoint& a, const FloatPoint& b)
00138 {
00139 return a.x() != b.x() || a.y() != b.y();
00140 }
00141
00142 }
00143
00144 #endif