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