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 // A template for a simple rectangle class. The containment semantics | 5 // A template for a simple rectangle class. The containment semantics |
6 // are array-like; that is, the coordinate (x, y) is considered to be | 6 // are array-like; that is, the coordinate (x, y) is considered to be |
7 // contained by the rectangle, but the coordinate (x + width, y) is not. | 7 // contained by the rectangle, but the coordinate (x + width, y) is not. |
8 // The class will happily let you create malformed rectangles (that is, | 8 // The class will happily let you create malformed rectangles (that is, |
9 // rectangles with negative width and/or height), but there will be assertions | 9 // rectangles with negative width and/or height), but there will be assertions |
10 // in the operations (such as Contains()) to complain in this case. | 10 // in the operations (such as Contains()) to complain in this case. |
11 | 11 |
12 #ifndef UI_GFX_RECT_BASE_H_ | 12 #ifndef UI_GFX_RECT_BASE_H_ |
13 #define UI_GFX_RECT_BASE_H_ | 13 #define UI_GFX_RECT_BASE_H_ |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 template<typename Class, | 21 template<typename Class, |
22 typename PointClass, | 22 typename PointClass, |
23 typename SizeClass, | 23 typename SizeClass, |
24 typename InsetsClass, | 24 typename InsetsClass, |
25 typename VectorClass, | 25 typename VectorClass, |
26 typename Type> | 26 typename Type> |
27 class UI_EXPORT RectBase { | 27 class GFX_EXPORT RectBase { |
28 public: | 28 public: |
29 Type x() const { return origin_.x(); } | 29 Type x() const { return origin_.x(); } |
30 void set_x(Type x) { origin_.set_x(x); } | 30 void set_x(Type x) { origin_.set_x(x); } |
31 | 31 |
32 Type y() const { return origin_.y(); } | 32 Type y() const { return origin_.y(); } |
33 void set_y(Type y) { origin_.set_y(y); } | 33 void set_y(Type y) { origin_.set_y(y); } |
34 | 34 |
35 Type width() const { return size_.width(); } | 35 Type width() const { return size_.width(); } |
36 void set_width(Type width) { size_.set_width(width); } | 36 void set_width(Type width) { size_.set_width(width); } |
37 | 37 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ~RectBase() {} | 159 ~RectBase() {} |
160 | 160 |
161 private: | 161 private: |
162 PointClass origin_; | 162 PointClass origin_; |
163 SizeClass size_; | 163 SizeClass size_; |
164 }; | 164 }; |
165 | 165 |
166 } // namespace gfx | 166 } // namespace gfx |
167 | 167 |
168 #endif // UI_GFX_RECT_BASE_H_ | 168 #endif // UI_GFX_RECT_BASE_H_ |
OLD | NEW |