| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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> |
| 11 #elif defined(OS_LINUX) | 11 #elif defined(USE_X11) |
| 12 #include <gdk/gdk.h> | 12 #include <gdk/gdk.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include <iostream> | 15 #include <iostream> |
| 16 | 16 |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { | 21 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 set_width(r.size.width); | 69 set_width(r.size.width); |
| 70 set_height(r.size.height); | 70 set_height(r.size.height); |
| 71 } | 71 } |
| 72 | 72 |
| 73 Rect& Rect::operator=(const CGRect& r) { | 73 Rect& Rect::operator=(const CGRect& r) { |
| 74 origin_.SetPoint(r.origin.x, r.origin.y); | 74 origin_.SetPoint(r.origin.x, r.origin.y); |
| 75 set_width(r.size.width); | 75 set_width(r.size.width); |
| 76 set_height(r.size.height); | 76 set_height(r.size.height); |
| 77 return *this; | 77 return *this; |
| 78 } | 78 } |
| 79 #elif defined(OS_LINUX) | 79 #elif defined(USE_X11) |
| 80 Rect::Rect(const GdkRectangle& r) | 80 Rect::Rect(const GdkRectangle& r) |
| 81 : origin_(r.x, r.y) { | 81 : origin_(r.x, r.y) { |
| 82 set_width(r.width); | 82 set_width(r.width); |
| 83 set_height(r.height); | 83 set_height(r.height); |
| 84 } | 84 } |
| 85 | 85 |
| 86 Rect& Rect::operator=(const GdkRectangle& r) { | 86 Rect& Rect::operator=(const GdkRectangle& r) { |
| 87 origin_.SetPoint(r.x, r.y); | 87 origin_.SetPoint(r.x, r.y); |
| 88 set_width(r.width); | 88 set_width(r.width); |
| 89 set_height(r.height); | 89 set_height(r.height); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
| 123 RECT Rect::ToRECT() const { | 123 RECT Rect::ToRECT() const { |
| 124 RECT r; | 124 RECT r; |
| 125 r.left = x(); | 125 r.left = x(); |
| 126 r.right = right(); | 126 r.right = right(); |
| 127 r.top = y(); | 127 r.top = y(); |
| 128 r.bottom = bottom(); | 128 r.bottom = bottom(); |
| 129 return r; | 129 return r; |
| 130 } | 130 } |
| 131 #elif defined(OS_LINUX) | 131 #elif defined(USE_X11) |
| 132 GdkRectangle Rect::ToGdkRectangle() const { | 132 GdkRectangle Rect::ToGdkRectangle() const { |
| 133 GdkRectangle r = {x(), y(), width(), height()}; | 133 GdkRectangle r = {x(), y(), width(), height()}; |
| 134 return r; | 134 return r; |
| 135 } | 135 } |
| 136 #elif defined(OS_MACOSX) | 136 #elif defined(OS_MACOSX) |
| 137 CGRect Rect::ToCGRect() const { | 137 CGRect Rect::ToCGRect() const { |
| 138 return CGRectMake(x(), y(), width(), height()); | 138 return CGRectMake(x(), y(), width(), height()); |
| 139 } | 139 } |
| 140 #endif | 140 #endif |
| 141 | 141 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 Point Rect::CenterPoint() const { | 224 Point Rect::CenterPoint() const { |
| 225 return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); | 225 return Point(x() + (width() + 1) / 2, y() + (height() + 1) / 2); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace gfx | 228 } // namespace gfx |
| 229 | 229 |
| 230 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { | 230 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { |
| 231 return out << r.origin() << " " << r.size(); | 231 return out << r.origin() << " " << r.size(); |
| 232 } | 232 } |
| OLD | NEW |