OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 Contains()) to complain in this case. | 10 // in the operations (such as Contains()) to complain in this case. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 // Returns true if the area of the rectangle is zero. | 96 // Returns true if the area of the rectangle is zero. |
97 bool IsEmpty() const { return size_.IsEmpty(); } | 97 bool IsEmpty() const { return size_.IsEmpty(); } |
98 | 98 |
99 bool operator==(const Rect& other) const; | 99 bool operator==(const Rect& other) const; |
100 | 100 |
101 bool operator!=(const Rect& other) const { | 101 bool operator!=(const Rect& other) const { |
102 return !(*this == other); | 102 return !(*this == other); |
103 } | 103 } |
104 | 104 |
| 105 // A rect is less than another rect if its origin is less than |
| 106 // the other rect's origin. If the origins are equal, then the |
| 107 // shortest rect is less than the other. If the origin and the |
| 108 // height are equal, then the narrowest rect is less than. |
| 109 // This comparison is required to use Rects in sets, or sorted |
| 110 // vectors. |
| 111 bool operator<(const Rect& other) const; |
| 112 |
105 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
106 // Construct an equivalent Win32 RECT object. | 114 // Construct an equivalent Win32 RECT object. |
107 RECT ToRECT() const; | 115 RECT ToRECT() const; |
108 #elif defined(USE_X11) | 116 #elif defined(USE_X11) |
109 GdkRectangle ToGdkRectangle() const; | 117 GdkRectangle ToGdkRectangle() const; |
110 #elif defined(OS_MACOSX) | 118 #elif defined(OS_MACOSX) |
111 // Construct an equivalent CoreGraphics object. | 119 // Construct an equivalent CoreGraphics object. |
112 CGRect ToCGRect() const; | 120 CGRect ToCGRect() const; |
113 #endif | 121 #endif |
114 | 122 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 private: | 171 private: |
164 gfx::Point origin_; | 172 gfx::Point origin_; |
165 gfx::Size size_; | 173 gfx::Size size_; |
166 }; | 174 }; |
167 | 175 |
168 } // namespace gfx | 176 } // namespace gfx |
169 | 177 |
170 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r); | 178 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r); |
171 | 179 |
172 #endif // GFX_RECT_H_ | 180 #endif // GFX_RECT_H_ |
OLD | NEW |