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 // Defines a simple integer rectangle class. The containment semantics | 5 // Defines a simple integer 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 contain()) to complain in this case. | 10 // in the operations (such as contain()) to complain in this case. |
11 | 11 |
12 #ifndef BASE_GFX_RECT_H__ | 12 #ifndef BASE_GFX_RECT_H__ |
13 #define BASE_GFX_RECT_H__ | 13 #define BASE_GFX_RECT_H__ |
14 | 14 |
| 15 #include <iostream> |
| 16 |
| 17 #include "base/gfx/point.h" |
15 #include "base/gfx/size.h" | 18 #include "base/gfx/size.h" |
16 #include "base/gfx/point.h" | |
17 | 19 |
18 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
19 typedef struct tagRECT RECT; | 21 typedef struct tagRECT RECT; |
20 #elif defined(OS_LINUX) | 22 #elif defined(OS_LINUX) |
21 // It's wrong to hide GDK stuff behind OS_LINUX, but until we have a different | 23 // It's wrong to hide GDK stuff behind OS_LINUX, but until we have a different |
22 // linux target, this is less complex. | 24 // linux target, this is less complex. |
23 typedef struct _GdkRectangle GdkRectangle; | 25 typedef struct _GdkRectangle GdkRectangle; |
24 #endif | 26 #endif |
25 | 27 |
26 namespace gfx { | 28 namespace gfx { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Returns the center of this rectangle. | 150 // Returns the center of this rectangle. |
149 Point CenterPoint() const; | 151 Point CenterPoint() const; |
150 | 152 |
151 private: | 153 private: |
152 gfx::Point origin_; | 154 gfx::Point origin_; |
153 gfx::Size size_; | 155 gfx::Size size_; |
154 }; | 156 }; |
155 | 157 |
156 } // namespace gfx | 158 } // namespace gfx |
157 | 159 |
158 #ifdef UNIT_TEST | |
159 | |
160 inline std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { | 160 inline std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) { |
161 return out << r.origin() << " " << r.size(); | 161 return out << r.origin() << " " << r.size(); |
162 } | 162 } |
163 | 163 |
164 #endif // #ifdef UNIT_TEST | |
165 | |
166 #endif // BASE_GFX_RECT_H__ | 164 #endif // BASE_GFX_RECT_H__ |
167 | 165 |
OLD | NEW |