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 // 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. |
11 | 11 |
12 #ifndef UI_GFX_GEOMETRY_RECT_H_ | 12 #ifndef UI_GFX_GEOMETRY_RECT_H_ |
13 #define UI_GFX_GEOMETRY_RECT_H_ | 13 #define UI_GFX_GEOMETRY_RECT_H_ |
14 | 14 |
15 #include <cmath> | 15 #include <cmath> |
16 #include <iosfwd> | 16 #include <iosfwd> |
17 #include <string> | 17 #include <string> |
18 | 18 |
19 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
20 #include "ui/gfx/geometry/point.h" | 20 #include "ui/gfx/geometry/point.h" |
21 #include "ui/gfx/geometry/rect_f.h" | 21 #include "ui/gfx/geometry/rect_f.h" |
22 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
23 #include "ui/gfx/geometry/vector2d.h" | 23 #include "ui/gfx/geometry/vector2d.h" |
24 | 24 |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 typedef struct tagRECT RECT; | 26 typedef struct tagRECT RECT; |
27 #elif defined(OS_IOS) | |
28 #include <CoreGraphics/CoreGraphics.h> | |
29 #elif defined(OS_MACOSX) | 27 #elif defined(OS_MACOSX) |
30 #include <ApplicationServices/ApplicationServices.h> | 28 typedef struct CGRect CGRect; |
31 #endif | 29 #endif |
32 | 30 |
33 namespace gfx { | 31 namespace gfx { |
34 | 32 |
35 class Insets; | 33 class Insets; |
36 | 34 |
37 class GFX_EXPORT Rect { | 35 class GFX_EXPORT Rect { |
38 public: | 36 public: |
39 Rect() {} | 37 Rect() {} |
40 Rect(int width, int height) : size_(width, height) {} | 38 Rect(int width, int height) : size_(width, height) {} |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 270 } |
273 | 271 |
274 // This is declared here for use in gtest-based unit tests but is defined in | 272 // This is declared here for use in gtest-based unit tests but is defined in |
275 // the gfx_test_support target. Depend on that to use this in your unit test. | 273 // the gfx_test_support target. Depend on that to use this in your unit test. |
276 // This should not be used in production code - call ToString() instead. | 274 // This should not be used in production code - call ToString() instead. |
277 void PrintTo(const Rect& rect, ::std::ostream* os); | 275 void PrintTo(const Rect& rect, ::std::ostream* os); |
278 | 276 |
279 } // namespace gfx | 277 } // namespace gfx |
280 | 278 |
281 #endif // UI_GFX_GEOMETRY_RECT_H_ | 279 #endif // UI_GFX_GEOMETRY_RECT_H_ |
OLD | NEW |