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/rect.h" | 5 #include "ui/gfx/rect.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
11 #elif defined(TOOLKIT_GTK) | 11 #elif defined(TOOLKIT_GTK) |
12 #include <gdk/gdk.h> | 12 #include <gdk/gdk.h> |
13 #endif | 13 #endif |
14 | 14 |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "ui/gfx/insets.h" | 17 #include "ui/gfx/insets.h" |
18 #include "ui/gfx/rect_base_impl.h" | 18 #include "ui/gfx/rect_base_impl.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 | 21 |
22 template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; | 22 template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; |
23 | 23 |
24 typedef class RectBase<Rect, Point, Size, Insets, Vector2d, int> RectBaseT; | 24 typedef class RectBase<Rect, Point, Size, Insets, Vector2d, int> RectBaseT; |
25 | 25 |
26 Rect::Rect() : RectBaseT(gfx::Point()) { | |
27 } | |
28 | |
29 Rect::Rect(int width, int height) | |
30 : RectBaseT(gfx::Size(width, height)) { | |
31 } | |
32 | |
33 Rect::Rect(int x, int y, int width, int height) | |
34 : RectBaseT(gfx::Point(x, y), gfx::Size(width, height)) { | |
35 } | |
36 | |
37 Rect::Rect(const gfx::Size& size) | |
38 : RectBaseT(size) { | |
39 } | |
40 | |
41 Rect::Rect(const gfx::Point& origin, const gfx::Size& size) | |
42 : RectBaseT(origin, size) { | |
43 } | |
44 | |
45 Rect::~Rect() {} | |
46 | |
47 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
48 Rect::Rect(const RECT& r) | 27 Rect::Rect(const RECT& r) |
49 : RectBaseT(gfx::Point(r.left, r.top)) { | 28 : RectBaseT(gfx::Point(r.left, r.top)) { |
50 set_width(std::abs(r.right - r.left)); | 29 set_width(std::abs(r.right - r.left)); |
51 set_height(std::abs(r.bottom - r.top)); | 30 set_height(std::abs(r.bottom - r.top)); |
52 } | 31 } |
53 #elif defined(OS_MACOSX) | 32 #elif defined(OS_MACOSX) |
54 Rect::Rect(const CGRect& r) | 33 Rect::Rect(const CGRect& r) |
55 : RectBaseT(gfx::Point(r.origin.x, r.origin.y)) { | 34 : RectBaseT(gfx::Point(r.origin.x, r.origin.y)) { |
56 set_width(r.size.width); | 35 set_width(r.size.width); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 101 |
123 Rect BoundingRect(const Point& p1, const Point& p2) { | 102 Rect BoundingRect(const Point& p1, const Point& p2) { |
124 int rx = std::min(p1.x(), p2.x()); | 103 int rx = std::min(p1.x(), p2.x()); |
125 int ry = std::min(p1.y(), p2.y()); | 104 int ry = std::min(p1.y(), p2.y()); |
126 int rr = std::max(p1.x(), p2.x()); | 105 int rr = std::max(p1.x(), p2.x()); |
127 int rb = std::max(p1.y(), p2.y()); | 106 int rb = std::max(p1.y(), p2.y()); |
128 return Rect(rx, ry, rr - rx, rb - ry); | 107 return Rect(rx, ry, rr - rx, rb - ry); |
129 } | 108 } |
130 | 109 |
131 } // namespace gfx | 110 } // namespace gfx |
OLD | NEW |