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. |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include <ApplicationServices/ApplicationServices.h> | 30 #include <ApplicationServices/ApplicationServices.h> |
31 #endif | 31 #endif |
32 | 32 |
33 namespace gfx { | 33 namespace gfx { |
34 | 34 |
35 class Insets; | 35 class Insets; |
36 | 36 |
37 class UI_EXPORT Rect | 37 class UI_EXPORT Rect |
38 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { | 38 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { |
39 public: | 39 public: |
40 Rect(); | 40 Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int> (Point()) {} |
41 Rect(int width, int height); | 41 |
42 Rect(int x, int y, int width, int height); | 42 Rect(int width, int height) |
43 : RectBase<Rect, Point, Size, Insets, Vector2d, int> (Size(width, height)) | |
44 {} | |
45 | |
46 Rect(int x, int y, int width, int height) | |
47 : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point(x, y), | |
48 Size(width, height)) {} | |
danakj
2012/11/29 18:36:44
the rect_f.h changes look a lot cleaner than these
jamesr
2012/11/29 22:40:40
I can try to reformat to match that. There's no r
| |
49 | |
43 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
44 explicit Rect(const RECT& r); | 51 explicit Rect(const RECT& r); |
45 #elif defined(OS_MACOSX) | 52 #elif defined(OS_MACOSX) |
46 explicit Rect(const CGRect& r); | 53 explicit Rect(const CGRect& r); |
47 #elif defined(TOOLKIT_GTK) | 54 #elif defined(TOOLKIT_GTK) |
48 explicit Rect(const GdkRectangle& r); | 55 explicit Rect(const GdkRectangle& r); |
49 #endif | 56 #endif |
50 explicit Rect(const gfx::Size& size); | |
51 Rect(const gfx::Point& origin, const gfx::Size& size); | |
52 | 57 |
53 ~Rect(); | 58 explicit Rect(const gfx::Size& size) |
59 : RectBase<Rect, Point, Size, Insets, Vector2d, int> (size) {} | |
60 | |
61 Rect(const gfx::Point& origin, const gfx::Size& size) | |
62 : RectBase<Rect, Point, Size, Insets, Vector2d, int> (origin, size) {} | |
danakj
2012/11/29 18:36:44
should be 4 spaces before : right?
| |
63 | |
64 ~Rect() {} | |
54 | 65 |
55 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
56 // Construct an equivalent Win32 RECT object. | 67 // Construct an equivalent Win32 RECT object. |
57 RECT ToRECT() const; | 68 RECT ToRECT() const; |
58 #elif defined(TOOLKIT_GTK) | 69 #elif defined(TOOLKIT_GTK) |
59 GdkRectangle ToGdkRectangle() const; | 70 GdkRectangle ToGdkRectangle() const; |
60 #elif defined(OS_MACOSX) | 71 #elif defined(OS_MACOSX) |
61 // Construct an equivalent CoreGraphics object. | 72 // Construct an equivalent CoreGraphics object. |
62 CGRect ToCGRect() const; | 73 CGRect ToCGRect() const; |
63 #endif | 74 #endif |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 // contained within the rect, because they will appear on one of these edges. | 107 // contained within the rect, because they will appear on one of these edges. |
97 UI_EXPORT Rect BoundingRect(const Point& p1, const Point& p2); | 108 UI_EXPORT Rect BoundingRect(const Point& p1, const Point& p2); |
98 | 109 |
99 #if !defined(COMPILER_MSVC) | 110 #if !defined(COMPILER_MSVC) |
100 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; | 111 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; |
101 #endif | 112 #endif |
102 | 113 |
103 } // namespace gfx | 114 } // namespace gfx |
104 | 115 |
105 #endif // UI_GFX_RECT_H_ | 116 #endif // UI_GFX_RECT_H_ |
OLD | NEW |