| 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 #include "ui/gfx/geometry/point.h" | 5 #include "ui/gfx/geometry/point.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_IOS) |
| 10 #include <CoreGraphics/CoreGraphics.h> |
| 11 #elif defined(OS_MACOSX) |
| 12 #include <ApplicationServices/ApplicationServices.h> |
| 9 #endif | 13 #endif |
| 10 | 14 |
| 11 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 12 | 16 |
| 13 namespace gfx { | 17 namespace gfx { |
| 14 | 18 |
| 15 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 16 Point::Point(DWORD point) { | 20 Point::Point(DWORD point) { |
| 17 POINTS points = MAKEPOINTS(point); | 21 POINTS points = MAKEPOINTS(point); |
| 18 x_ = points.x; | 22 x_ = points.x; |
| 19 y_ = points.y; | 23 y_ = points.y; |
| 20 } | 24 } |
| 21 | 25 |
| 22 Point::Point(const POINT& point) : x_(point.x), y_(point.y) { | 26 Point::Point(const POINT& point) : x_(point.x), y_(point.y) { |
| 23 } | 27 } |
| 24 | 28 |
| 25 Point& Point::operator=(const POINT& point) { | 29 Point& Point::operator=(const POINT& point) { |
| 26 x_ = point.x; | 30 x_ = point.x; |
| 27 y_ = point.y; | 31 y_ = point.y; |
| 28 return *this; | 32 return *this; |
| 29 } | 33 } |
| 34 #elif defined(OS_MACOSX) |
| 35 Point::Point(const CGPoint& point) : x_(point.x), y_(point.y) { |
| 36 } |
| 37 #endif |
| 30 | 38 |
| 39 #if defined(OS_WIN) |
| 31 POINT Point::ToPOINT() const { | 40 POINT Point::ToPOINT() const { |
| 32 POINT p; | 41 POINT p; |
| 33 p.x = x(); | 42 p.x = x(); |
| 34 p.y = y(); | 43 p.y = y(); |
| 35 return p; | 44 return p; |
| 36 } | 45 } |
| 46 #elif defined(OS_MACOSX) |
| 47 CGPoint Point::ToCGPoint() const { |
| 48 return CGPointMake(x(), y()); |
| 49 } |
| 37 #endif | 50 #endif |
| 38 | 51 |
| 39 void Point::SetToMin(const Point& other) { | 52 void Point::SetToMin(const Point& other) { |
| 40 x_ = x_ <= other.x_ ? x_ : other.x_; | 53 x_ = x_ <= other.x_ ? x_ : other.x_; |
| 41 y_ = y_ <= other.y_ ? y_ : other.y_; | 54 y_ = y_ <= other.y_ ? y_ : other.y_; |
| 42 } | 55 } |
| 43 | 56 |
| 44 void Point::SetToMax(const Point& other) { | 57 void Point::SetToMax(const Point& other) { |
| 45 x_ = x_ >= other.x_ ? x_ : other.x_; | 58 x_ = x_ >= other.x_ ? x_ : other.x_; |
| 46 y_ = y_ >= other.y_ ? y_ : other.y_; | 59 y_ = y_ >= other.y_ ? y_ : other.y_; |
| 47 } | 60 } |
| 48 | 61 |
| 49 std::string Point::ToString() const { | 62 std::string Point::ToString() const { |
| 50 return base::StringPrintf("%d,%d", x(), y()); | 63 return base::StringPrintf("%d,%d", x(), y()); |
| 51 } | 64 } |
| 52 | 65 |
| 53 } // namespace gfx | 66 } // namespace gfx |
| OLD | NEW |