| 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 #ifndef GFX_INSETS_H_ | 5 #ifndef GFX_INSETS_H_ |
| 6 #define GFX_INSETS_H_ | 6 #define GFX_INSETS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "ui/gfx/insets.h" |
| 10 | 10 // TODO(sail): remove this file once all includes have been updated. |
| 11 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 12 #include <gtk/gtkstyle.h> | |
| 13 #endif | |
| 14 | |
| 15 #include <string> | |
| 16 | |
| 17 namespace gfx { | |
| 18 | |
| 19 // | |
| 20 // An insets represents the borders of a container (the space the container must | |
| 21 // leave at each of its edges). | |
| 22 // | |
| 23 | |
| 24 class Insets { | |
| 25 public: | |
| 26 Insets() : top_(0), left_(0), bottom_(0), right_(0) {} | |
| 27 Insets(int top, int left, int bottom, int right) | |
| 28 : top_(top), | |
| 29 left_(left), | |
| 30 bottom_(bottom), | |
| 31 right_(right) {} | |
| 32 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 33 explicit Insets(const GtkBorder& border) | |
| 34 : top_(border.top), | |
| 35 left_(border.left), | |
| 36 bottom_(border.bottom), | |
| 37 right_(border.right) {} | |
| 38 #endif | |
| 39 | |
| 40 ~Insets() {} | |
| 41 | |
| 42 int top() const { return top_; } | |
| 43 int left() const { return left_; } | |
| 44 int bottom() const { return bottom_; } | |
| 45 int right() const { return right_; } | |
| 46 | |
| 47 // Returns the total width taken up by the insets, which is the sum of the | |
| 48 // left and right insets. | |
| 49 int width() const { return left_ + right_; } | |
| 50 | |
| 51 // Returns the total height taken up by the insets, which is the sum of the | |
| 52 // top and bottom insets. | |
| 53 int height() const { return top_ + bottom_; } | |
| 54 | |
| 55 // Returns true if the insets are empty. | |
| 56 bool empty() const { return width() == 0 && height() == 0; } | |
| 57 | |
| 58 void Set(int top, int left, int bottom, int right) { | |
| 59 top_ = top; | |
| 60 left_ = left; | |
| 61 bottom_ = bottom; | |
| 62 right_ = right; | |
| 63 } | |
| 64 | |
| 65 bool operator==(const Insets& insets) const { | |
| 66 return top_ == insets.top_ && left_ == insets.left_ && | |
| 67 bottom_ == insets.bottom_ && right_ == insets.right_; | |
| 68 } | |
| 69 | |
| 70 bool operator!=(const Insets& insets) const { | |
| 71 return !(*this == insets); | |
| 72 } | |
| 73 | |
| 74 Insets& operator+=(const Insets& insets) { | |
| 75 top_ += insets.top_; | |
| 76 left_ += insets.left_; | |
| 77 bottom_ += insets.bottom_; | |
| 78 right_ += insets.right_; | |
| 79 return *this; | |
| 80 } | |
| 81 | |
| 82 // Returns a string representation of the insets. | |
| 83 std::string ToString() const; | |
| 84 | |
| 85 private: | |
| 86 int top_; | |
| 87 int left_; | |
| 88 int bottom_; | |
| 89 int right_; | |
| 90 }; | |
| 91 | |
| 92 } // namespace gfx | |
| 93 | 11 |
| 94 #endif // GFX_INSETS_H_ | 12 #endif // GFX_INSETS_H_ |
| OLD | NEW |