OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_GEOMETRY_POINT_H_ | 5 #ifndef UI_GFX_GEOMETRY_POINT_H_ |
6 #define UI_GFX_GEOMETRY_POINT_H_ | 6 #define UI_GFX_GEOMETRY_POINT_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ui/gfx/geometry/point_f.h" | 11 #include "ui/gfx/geometry/point_f.h" |
12 #include "ui/gfx/geometry/vector2d.h" | 12 #include "ui/gfx/geometry/vector2d.h" |
13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 typedef unsigned long DWORD; | 16 typedef unsigned long DWORD; |
17 typedef struct tagPOINT POINT; | 17 typedef struct tagPOINT POINT; |
18 #elif defined(OS_IOS) | |
19 #include <CoreGraphics/CoreGraphics.h> | |
20 #elif defined(OS_MACOSX) | 18 #elif defined(OS_MACOSX) |
21 #include <ApplicationServices/ApplicationServices.h> | 19 typedef struct CGPoint CGPoint; |
22 #endif | 20 #endif |
23 | 21 |
24 namespace gfx { | 22 namespace gfx { |
25 | 23 |
26 // A point has an x and y coordinate. | 24 // A point has an x and y coordinate. |
27 class GFX_EXPORT Point { | 25 class GFX_EXPORT Point { |
28 public: | 26 public: |
29 Point() : x_(0), y_(0) {} | 27 Point() : x_(0), y_(0) {} |
30 Point(int x, int y) : x_(x), y_(y) {} | 28 Point(int x, int y) : x_(x), y_(y) {} |
31 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
32 // |point| is a DWORD value that contains a coordinate. The x-coordinate is | 30 // |point| is a DWORD value that contains a coordinate. The x-coordinate is |
33 // the low-order short and the y-coordinate is the high-order short. This | 31 // the low-order short and the y-coordinate is the high-order short. This |
34 // value is commonly acquired from GetMessagePos/GetCursorPos. | 32 // value is commonly acquired from GetMessagePos/GetCursorPos. |
35 explicit Point(DWORD point); | 33 explicit Point(DWORD point); |
36 explicit Point(const POINT& point); | 34 explicit Point(const POINT& point); |
37 Point& operator=(const POINT& point); | 35 Point& operator=(const POINT& point); |
38 #elif defined(OS_MACOSX) | 36 #elif defined(OS_MACOSX) |
39 explicit Point(const CGPoint& point) : x_(point.x), y_(point.y) {} | 37 explicit Point(const CGPoint& point); |
40 #endif | 38 #endif |
41 | 39 |
42 ~Point() {} | 40 ~Point() {} |
43 | 41 |
44 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
45 POINT ToPOINT() const; | 43 POINT ToPOINT() const; |
46 #elif defined(OS_MACOSX) | 44 #elif defined(OS_MACOSX) |
47 CGPoint ToCGPoint() const { return CGPointMake(x(), y()); } | 45 CGPoint ToCGPoint() const; |
48 #endif | 46 #endif |
49 | 47 |
50 int x() const { return x_; } | 48 int x() const { return x_; } |
51 int y() const { return y_; } | 49 int y() const { return y_; } |
52 void set_x(int x) { x_ = x; } | 50 void set_x(int x) { x_ = x; } |
53 void set_y(int y) { y_ = y; } | 51 void set_y(int y) { y_ = y; } |
54 | 52 |
55 void SetPoint(int x, int y) { | 53 void SetPoint(int x, int y) { |
56 x_ = x; | 54 x_ = x; |
57 y_ = y; | 55 y_ = y; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 128 } |
131 | 129 |
132 // This is declared here for use in gtest-based unit tests but is defined in | 130 // This is declared here for use in gtest-based unit tests but is defined in |
133 // the gfx_test_support target. Depend on that to use this in your unit test. | 131 // the gfx_test_support target. Depend on that to use this in your unit test. |
134 // This should not be used in production code - call ToString() instead. | 132 // This should not be used in production code - call ToString() instead. |
135 void PrintTo(const Point& point, ::std::ostream* os); | 133 void PrintTo(const Point& point, ::std::ostream* os); |
136 | 134 |
137 } // namespace gfx | 135 } // namespace gfx |
138 | 136 |
139 #endif // UI_GFX_GEOMETRY_POINT_H_ | 137 #endif // UI_GFX_GEOMETRY_POINT_H_ |
OLD | NEW |