| 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) | 15 #if defined(OS_WIN) |
| 16 typedef struct tagSIZE SIZE; | 16 typedef struct tagSIZE SIZE; |
| 17 #elif defined(OS_IOS) | |
| 18 #include <CoreGraphics/CoreGraphics.h> | |
| 19 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
| 20 #include <ApplicationServices/ApplicationServices.h> | 18 typedef struct CGSize CGSize; |
| 21 #endif | 19 #endif |
| 22 | 20 |
| 23 namespace gfx { | 21 namespace gfx { |
| 24 | 22 |
| 25 // A size has width and height values. | 23 // A size has width and height values. |
| 26 class GFX_EXPORT Size { | 24 class GFX_EXPORT Size { |
| 27 public: | 25 public: |
| 28 Size() : width_(0), height_(0) {} | 26 Size() : width_(0), height_(0) {} |
| 29 Size(int width, int height) | 27 Size(int width, int height) |
| 30 : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {} | 28 : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {} |
| 31 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
| 32 explicit Size(const CGSize& s) | 30 explicit Size(const CGSize& s); |
| 33 : width_(s.width < 0 ? 0 : s.width), | |
| 34 height_(s.height < 0 ? 0 : s.height) {} | |
| 35 #endif | 31 #endif |
| 36 | 32 |
| 37 ~Size() {} | 33 ~Size() {} |
| 38 | 34 |
| 39 #if defined(OS_MACOSX) | 35 #if defined(OS_MACOSX) |
| 40 Size& operator=(const CGSize& s); | 36 Size& operator=(const CGSize& s); |
| 41 #endif | 37 #endif |
| 42 | 38 |
| 43 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 44 SIZE ToSIZE() const; | 40 SIZE ToSIZE() const; |
| 45 #elif defined(OS_MACOSX) | 41 #elif defined(OS_MACOSX) |
| 46 CGSize ToCGSize() const { return CGSizeMake(width(), height()); } | 42 CGSize ToCGSize() const; |
| 47 #endif | 43 #endif |
| 48 | 44 |
| 49 int width() const { return width_; } | 45 int width() const { return width_; } |
| 50 int height() const { return height_; } | 46 int height() const { return height_; } |
| 51 | 47 |
| 52 void set_width(int width) { width_ = width < 0 ? 0 : width; } | 48 void set_width(int width) { width_ = width < 0 ? 0 : width; } |
| 53 void set_height(int height) { height_ = height < 0 ? 0 : height; } | 49 void set_height(int height) { height_ = height < 0 ? 0 : height; } |
| 54 | 50 |
| 55 int GetArea() const; | 51 int GetArea() const; |
| 56 | 52 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 } | 82 } |
| 87 | 83 |
| 88 // This is declared here for use in gtest-based unit tests but is defined in | 84 // 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. | 85 // 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. | 86 // This should not be used in production code - call ToString() instead. |
| 91 void PrintTo(const Size& size, ::std::ostream* os); | 87 void PrintTo(const Size& size, ::std::ostream* os); |
| 92 | 88 |
| 93 } // namespace gfx | 89 } // namespace gfx |
| 94 | 90 |
| 95 #endif // UI_GFX_GEOMETRY_SIZE_H_ | 91 #endif // UI_GFX_GEOMETRY_SIZE_H_ |
| OLD | NEW |