pleyo.com

/src/trunk2/BAL/Interfaces/graphics/FloatPoint.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
00003  * Copyright (C) 2005 Nokia.  All rights reserved.
00004  * Copyright (C) 2007 Pleyo.  All rights reserved.
00005  * 
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
00016  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00018  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
00019  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00021  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00022  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00023  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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

Generated on Wed Nov 21 20:04:17 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com