• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

IntPoint.h

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

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal