2248a4dbe7e654dd109b6e2b4ccf829beba88457
[platform/framework/web/crosswalk.git] / src / ui / gfx / geometry / point.cc
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.
4
5 #include "ui/gfx/geometry/point.h"
6
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #endif
10
11 #include "base/strings/stringprintf.h"
12
13 namespace gfx {
14
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) {
40   x_ = x_ <= other.x_ ? x_ : other.x_;
41   y_ = y_ <= other.y_ ? y_ : other.y_;
42 }
43
44 void Point::SetToMax(const Point& other) {
45   x_ = x_ >= other.x_ ? x_ : other.x_;
46   y_ = y_ >= other.y_ ? y_ : other.y_;
47 }
48
49 std::string Point::ToString() const {
50   return base::StringPrintf("%d,%d", x(), y());
51 }
52
53 }  // namespace gfx