| 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/size.h" | 5 #include "ui/gfx/geometry/size.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 SIZE Size::ToSIZE() const { | |
| 17 SIZE s; | |
| 18 s.cx = width(); | |
| 19 s.cy = height(); | |
| 20 return s; | |
| 21 } | |
| 22 #endif | |
| 23 | |
| 24 #if defined(OS_MACOSX) | |
| 25 Size& Size::operator=(const CGSize& s) { | |
| 26 set_width(s.width); | |
| 27 set_height(s.height); | |
| 28 return *this; | |
| 29 } | |
| 30 #endif | |
| 31 | |
| 32 int Size::GetArea() const { | 11 int Size::GetArea() const { |
| 33 return width() * height(); | 12 return width() * height(); |
| 34 } | 13 } |
| 35 | 14 |
| 36 void Size::Enlarge(int grow_width, int grow_height) { | 15 void Size::Enlarge(int grow_width, int grow_height) { |
| 37 SetSize(width() + grow_width, height() + grow_height); | 16 SetSize(width() + grow_width, height() + grow_height); |
| 38 } | 17 } |
| 39 | 18 |
| 40 void Size::SetToMin(const Size& other) { | 19 void Size::SetToMin(const Size& other) { |
| 41 width_ = width() <= other.width() ? width() : other.width(); | 20 width_ = width() <= other.width() ? width() : other.width(); |
| 42 height_ = height() <= other.height() ? height() : other.height(); | 21 height_ = height() <= other.height() ? height() : other.height(); |
| 43 } | 22 } |
| 44 | 23 |
| 45 void Size::SetToMax(const Size& other) { | 24 void Size::SetToMax(const Size& other) { |
| 46 width_ = width() >= other.width() ? width() : other.width(); | 25 width_ = width() >= other.width() ? width() : other.width(); |
| 47 height_ = height() >= other.height() ? height() : other.height(); | 26 height_ = height() >= other.height() ? height() : other.height(); |
| 48 } | 27 } |
| 49 | 28 |
| 50 std::string Size::ToString() const { | 29 std::string Size::ToString() const { |
| 51 return base::StringPrintf("%dx%d", width(), height()); | 30 return base::StringPrintf("%dx%d", width(), height()); |
| 52 } | 31 } |
| 53 | 32 |
| 54 } // namespace gfx | 33 } // namespace gfx |
| OLD | NEW |