| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/gfx/rect.h" | 5 #include "base/gfx/rect.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_MACOSX) | 9 #elif defined(OS_MACOSX) |
| 10 #include <CoreGraphics/CGGeometry.h> | 10 #include <CoreGraphics/CGGeometry.h> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 set_width(width); | 37 set_width(width); |
| 38 set_height(height); | 38 set_height(height); |
| 39 } | 39 } |
| 40 | 40 |
| 41 Rect::Rect(int x, int y, int width, int height) | 41 Rect::Rect(int x, int y, int width, int height) |
| 42 : origin_(x, y) { | 42 : origin_(x, y) { |
| 43 set_width(width); | 43 set_width(width); |
| 44 set_height(height); | 44 set_height(height); |
| 45 } | 45 } |
| 46 | 46 |
| 47 Rect::Rect(const gfx::Point& origin, const gfx::Size& size) |
| 48 : origin_(origin), size_(size) { |
| 49 } |
| 50 |
| 47 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
| 48 Rect::Rect(const RECT& r) | 52 Rect::Rect(const RECT& r) |
| 49 : origin_(r.left, r.top) { | 53 : origin_(r.left, r.top) { |
| 50 set_width(r.right - r.left); | 54 set_width(r.right - r.left); |
| 51 set_height(r.bottom - r.top); | 55 set_height(r.bottom - r.top); |
| 52 } | 56 } |
| 53 | 57 |
| 54 Rect& Rect::operator=(const RECT& r) { | 58 Rect& Rect::operator=(const RECT& r) { |
| 55 origin_.SetPoint(r.left, r.top); | 59 origin_.SetPoint(r.left, r.top); |
| 56 set_width(r.right - r.left); | 60 set_width(r.right - r.left); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); | 234 AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); |
| 231 AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); | 235 AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); |
| 232 return Rect(new_x, new_y, new_width, new_height); | 236 return Rect(new_x, new_y, new_width, new_height); |
| 233 } | 237 } |
| 234 | 238 |
| 235 Point Rect::CenterPoint() const { | 239 Point Rect::CenterPoint() const { |
| 236 return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); | 240 return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); |
| 237 } | 241 } |
| 238 | 242 |
| 239 } // namespace gfx | 243 } // namespace gfx |
| 240 | |
| OLD | NEW |