Add exclamation and question mark to the accent keys.
[chromium-blink-merge.git] / ui / gfx / point.h
blob0f8a327c5c8e6c78a78afa009e01c69c7c8cc493
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GFX_POINT_H_
6 #define UI_GFX_POINT_H_
8 #include "ui/base/ui_export.h"
9 #include "ui/gfx/point_base.h"
10 #include "ui/gfx/point_f.h"
11 #include "ui/gfx/vector2d.h"
13 #if defined(OS_WIN)
14 typedef unsigned long DWORD;
15 typedef struct tagPOINT POINT;
16 #elif defined(OS_IOS)
17 #include <CoreGraphics/CoreGraphics.h>
18 #elif defined(OS_MACOSX)
19 #include <ApplicationServices/ApplicationServices.h>
20 #endif
22 namespace gfx {
24 // A point has an x and y coordinate.
25 class UI_EXPORT Point : public PointBase<Point, int, Vector2d> {
26 public:
27 Point() : PointBase<Point, int, Vector2d>(0, 0) {}
28 Point(int x, int y) : PointBase<Point, int, Vector2d>(x, y) {}
29 #if defined(OS_WIN)
30 // |point| is a DWORD value that contains a coordinate. The x-coordinate is
31 // the low-order short and the y-coordinate is the high-order short. This
32 // value is commonly acquired from GetMessagePos/GetCursorPos.
33 explicit Point(DWORD point);
34 explicit Point(const POINT& point);
35 Point& operator=(const POINT& point);
36 #elif defined(OS_MACOSX)
37 explicit Point(const CGPoint& point);
38 #endif
40 ~Point() {}
42 #if defined(OS_WIN)
43 POINT ToPOINT() const;
44 #elif defined(OS_MACOSX)
45 CGPoint ToCGPoint() const;
46 #endif
48 operator PointF() const {
49 return PointF(x(), y());
52 // Returns a string representation of point.
53 std::string ToString() const;
56 inline bool operator==(const Point& lhs, const Point& rhs) {
57 return lhs.x() == rhs.x() && lhs.y() == rhs.y();
60 inline bool operator!=(const Point& lhs, const Point& rhs) {
61 return !(lhs == rhs);
64 inline Point operator+(const Point& lhs, const Vector2d& rhs) {
65 Point result(lhs);
66 result += rhs;
67 return result;
70 inline Point operator-(const Point& lhs, const Vector2d& rhs) {
71 Point result(lhs);
72 result -= rhs;
73 return result;
76 inline Vector2d operator-(const Point& lhs, const Point& rhs) {
77 return Vector2d(lhs.x() - rhs.x(), lhs.y() - rhs.y());
80 inline Point PointAtOffsetFromOrigin(const Vector2d& offset_from_origin) {
81 return Point(offset_from_origin.x(), offset_from_origin.y());
84 #if !defined(COMPILER_MSVC)
85 extern template class PointBase<Point, int, Vector2d>;
86 #endif
88 } // namespace gfx
90 #endif // UI_GFX_POINT_H_