| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_COMMON_GFX_INSETS_H__ | |
| 6 #define CHROME_COMMON_GFX_INSETS_H__ | |
| 7 | |
| 8 namespace gfx { | |
| 9 | |
| 10 // | |
| 11 // An insets represents the borders of a container (the space the container must | |
| 12 // leave at each of its edges). | |
| 13 // | |
| 14 | |
| 15 class Insets { | |
| 16 public: | |
| 17 Insets() : top_(0), left_(0), bottom_(0), right_(0) {} | |
| 18 Insets(int top, int left, int bottom, int right) | |
| 19 : top_(top), left_(left), bottom_(bottom), right_(right) { } | |
| 20 | |
| 21 ~Insets() {} | |
| 22 | |
| 23 int top() const { return top_; } | |
| 24 int left() const { return left_; } | |
| 25 int bottom() const { return bottom_; } | |
| 26 int right() const { return right_; } | |
| 27 | |
| 28 // Returns the total width taken up by the insets, which is the sum of the | |
| 29 // left and right insets. | |
| 30 int width() const { return left_ + right_; } | |
| 31 | |
| 32 // Returns the total height taken up by the insets, which is the sum of the | |
| 33 // top and bottom insets. | |
| 34 int height() const { return top_ + bottom_; } | |
| 35 | |
| 36 void Set(int top, int left, int bottom, int right) { | |
| 37 top_ = top; | |
| 38 left_ = left; | |
| 39 bottom_ = bottom; | |
| 40 right_ = right; | |
| 41 } | |
| 42 | |
| 43 bool operator==(const Insets& insets) const { | |
| 44 return top_ == insets.top_ && left_ == insets.left_ && | |
| 45 bottom_ == insets.bottom_ && right_ == insets.right_; | |
| 46 } | |
| 47 | |
| 48 bool operator!=(const Insets& insets) const { | |
| 49 return !(*this == insets); | |
| 50 } | |
| 51 | |
| 52 Insets& operator+=(const Insets& insets) { | |
| 53 top_ += insets.top_; | |
| 54 left_ += insets.left_; | |
| 55 bottom_ += insets.bottom_; | |
| 56 right_ += insets.right_; | |
| 57 return *this; | |
| 58 } | |
| 59 | |
| 60 private: | |
| 61 int top_; | |
| 62 int left_; | |
| 63 int bottom_; | |
| 64 int right_; | |
| 65 }; | |
| 66 | |
| 67 } // namespace | |
| 68 | |
| 69 #endif // CHROME_COMMON_GFX_INSETS_H__ | |
| OLD | NEW |