| 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 #ifndef UI_GFX_GEOMETRY_SIZE_H_ | 5 #ifndef UI_GFX_GEOMETRY_SIZE_H_ |
| 6 #define UI_GFX_GEOMETRY_SIZE_H_ | 6 #define UI_GFX_GEOMETRY_SIZE_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "ui/gfx/geometry/size_f.h" | 12 #include "ui/gfx/geometry/size_f.h" |
| 13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 14 | 14 |
| 15 #if defined(OS_WIN) | |
| 16 typedef struct tagSIZE SIZE; | |
| 17 #elif defined(OS_IOS) | |
| 18 #include <CoreGraphics/CoreGraphics.h> | |
| 19 #elif defined(OS_MACOSX) | |
| 20 #include <ApplicationServices/ApplicationServices.h> | |
| 21 #endif | |
| 22 | |
| 23 namespace gfx { | 15 namespace gfx { |
| 24 | 16 |
| 25 // A size has width and height values. | 17 // A size has width and height values. |
| 26 class GFX_EXPORT Size { | 18 class GFX_EXPORT Size { |
| 27 public: | 19 public: |
| 28 Size() : width_(0), height_(0) {} | 20 Size() : width_(0), height_(0) {} |
| 29 Size(int width, int height) | 21 Size(int width, int height) |
| 30 : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {} | 22 : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {} |
| 31 #if defined(OS_MACOSX) | |
| 32 explicit Size(const CGSize& s) | |
| 33 : width_(s.width < 0 ? 0 : s.width), | |
| 34 height_(s.height < 0 ? 0 : s.height) {} | |
| 35 #endif | |
| 36 | |
| 37 ~Size() {} | 23 ~Size() {} |
| 38 | 24 |
| 39 #if defined(OS_MACOSX) | |
| 40 Size& operator=(const CGSize& s); | |
| 41 #endif | |
| 42 | |
| 43 #if defined(OS_WIN) | |
| 44 SIZE ToSIZE() const; | |
| 45 #elif defined(OS_MACOSX) | |
| 46 CGSize ToCGSize() const { return CGSizeMake(width(), height()); } | |
| 47 #endif | |
| 48 | |
| 49 int width() const { return width_; } | 25 int width() const { return width_; } |
| 50 int height() const { return height_; } | 26 int height() const { return height_; } |
| 51 | 27 |
| 52 void set_width(int width) { width_ = width < 0 ? 0 : width; } | 28 void set_width(int width) { width_ = width < 0 ? 0 : width; } |
| 53 void set_height(int height) { height_ = height < 0 ? 0 : height; } | 29 void set_height(int height) { height_ = height < 0 ? 0 : height; } |
| 54 | 30 |
| 55 int GetArea() const; | 31 int GetArea() const; |
| 56 | 32 |
| 57 void SetSize(int width, int height) { | 33 void SetSize(int width, int height) { |
| 58 set_width(width); | 34 set_width(width); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 } | 62 } |
| 87 | 63 |
| 88 // This is declared here for use in gtest-based unit tests but is defined in | 64 // This is declared here for use in gtest-based unit tests but is defined in |
| 89 // the gfx_test_support target. Depend on that to use this in your unit test. | 65 // the gfx_test_support target. Depend on that to use this in your unit test. |
| 90 // This should not be used in production code - call ToString() instead. | 66 // This should not be used in production code - call ToString() instead. |
| 91 void PrintTo(const Size& size, ::std::ostream* os); | 67 void PrintTo(const Size& size, ::std::ostream* os); |
| 92 | 68 |
| 93 } // namespace gfx | 69 } // namespace gfx |
| 94 | 70 |
| 95 #endif // UI_GFX_GEOMETRY_SIZE_H_ | 71 #endif // UI_GFX_GEOMETRY_SIZE_H_ |
| OLD | NEW |