• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • platform
  • graphics
IntPoint.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef IntPoint_h
27#define IntPoint_h
28
29#include "IntSize.h"
30#include <wtf/Platform.h>
31
32#if PLATFORM(CG)
33typedef struct CGPoint CGPoint;
34#endif
35
36#if PLATFORM(MAC)
37#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
38typedef struct CGPoint NSPoint;
39#else
40typedef struct _NSPoint NSPoint;
41#endif
42#endif
43
44#if PLATFORM(WIN)
45typedef struct tagPOINT POINT;
46typedef struct tagPOINTS POINTS;
47#elif PLATFORM(QT)
48QT_BEGIN_NAMESPACE
49class QPoint;
50QT_END_NAMESPACE
51#elif PLATFORM(GTK)
52typedef struct _GdkPoint GdkPoint;
53#endif
54#if PLATFORM(SYMBIAN)
55class TPoint;
56#endif
57
58#if PLATFORM(WX)
59class wxPoint;
60#endif
61
62namespace WebCore {
63
64class IntPoint {
65public:
66 IntPoint() : m_x(0), m_y(0) { }
67 IntPoint(int x, int y) : m_x(x), m_y(y) { }
68
69 int x() const { return m_x; }
70 int y() const { return m_y; }
71
72 void setX(int x) { m_x = x; }
73 void setY(int y) { m_y = y; }
74
75 void move(int dx, int dy) { m_x += dx; m_y += dy; }
76
77#if PLATFORM(CG)
78 explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
79 operator CGPoint() const;
80#endif
81
82#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
83 explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
84 operator NSPoint() const;
85#endif
86
87#if PLATFORM(WIN)
88 IntPoint(const POINT&);
89 operator POINT() const;
90 IntPoint(const POINTS&);
91 operator POINTS() const;
92#elif PLATFORM(QT)
93 IntPoint(const QPoint&);
94 operator QPoint() const;
95#elif PLATFORM(GTK)
96 IntPoint(const GdkPoint&);
97 operator GdkPoint() const;
98#endif
99#if PLATFORM(SYMBIAN)
100 IntPoint(const TPoint&);
101 operator TPoint() const;
102#endif
103
104#if PLATFORM(WX)
105 IntPoint(const wxPoint&);
106 operator wxPoint() const;
107#endif
108
109private:
110 int m_x, m_y;
111};
112
113inline IntPoint& operator+=(IntPoint& a, const IntSize& b)
114{
115 a.move(b.width(), b.height());
116 return a;
117}
118
119inline IntPoint& operator-=(IntPoint& a, const IntSize& b)
120{
121 a.move(-b.width(), -b.height());
122 return a;
123}
124
125inline IntPoint operator+(const IntPoint& a, const IntSize& b)
126{
127 return IntPoint(a.x() + b.width(), a.y() + b.height());
128}
129
130inline IntSize operator-(const IntPoint& a, const IntPoint& b)
131{
132 return IntSize(a.x() - b.x(), a.y() - b.y());
133}
134
135inline IntPoint operator-(const IntPoint& a, const IntSize& b)
136{
137 return IntPoint(a.x() - b.width(), a.y() - b.height());
138}
139
140inline bool operator==(const IntPoint& a, const IntPoint& b)
141{
142 return a.x() == b.x() && a.y() == b.y();
143}
144
145inline bool operator!=(const IntPoint& a, const IntPoint& b)
146{
147 return a.x() != b.x() || a.y() != b.y();
148}
149
150} // namespace WebCore
151
152#endif // IntPoint_h
IntSize.h
WebCore::IntPoint
Definition: IntPoint.h:64
WebCore::IntPoint::x
int x() const
Definition: IntPoint.h:69
WebCore::IntPoint::IntPoint
IntPoint(int x, int y)
Definition: IntPoint.h:67
WebCore::IntPoint::y
int y() const
Definition: IntPoint.h:70
WebCore::IntPoint::setX
void setX(int x)
Definition: IntPoint.h:72
WebCore::IntPoint::setY
void setY(int y)
Definition: IntPoint.h:73
WebCore::IntPoint::move
void move(int dx, int dy)
Definition: IntPoint.h:75
WebCore::IntPoint::IntPoint
IntPoint()
Definition: IntPoint.h:66
WebCore::IntSize
Definition: IntSize.h:57
WebCore::IntSize::width
int width() const
Definition: IntSize.h:62
WebCore::IntSize::height
int height() const
Definition: IntSize.h:63
WebCore
Definition: CSSHelper.h:7
WebCore::operator+=
FloatPoint & operator+=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:103
WebCore::operator!=
bool operator!=(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:135
WebCore::operator==
bool operator==(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:130
WebCore::operator-=
FloatPoint & operator-=(FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:109
WebCore::operator+
FloatPoint operator+(const FloatPoint &a, const FloatSize &b)
Definition: FloatPoint.h:115
WebCore::operator-
FloatSize operator-(const FloatPoint &a, const FloatPoint &b)
Definition: FloatPoint.h:120
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal