Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: ui/gfx/geometry/rect.h

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 16 #include <string>
17 17
18 #include "ui/gfx/geometry/point.h" 18 #include "ui/gfx/geometry/point.h"
19 #include "ui/gfx/geometry/rect_base.h" 19 #include "ui/gfx/geometry/rect_base.h"
20 #include "ui/gfx/geometry/rect_f.h" 20 #include "ui/gfx/geometry/rect_f.h"
21 #include "ui/gfx/geometry/size.h" 21 #include "ui/gfx/geometry/size.h"
22 #include "ui/gfx/geometry/vector2d.h" 22 #include "ui/gfx/geometry/vector2d.h"
23 23
24 #if defined(OS_WIN) 24 #if defined(OS_WIN)
25 typedef struct tagRECT RECT; 25 typedef struct tagRECT RECT;
26 #elif defined(TOOLKIT_GTK)
27 typedef struct _GdkRectangle GdkRectangle;
28 #elif defined(OS_IOS) 26 #elif defined(OS_IOS)
29 #include <CoreGraphics/CoreGraphics.h> 27 #include <CoreGraphics/CoreGraphics.h>
30 #elif defined(OS_MACOSX) 28 #elif defined(OS_MACOSX)
31 #include <ApplicationServices/ApplicationServices.h> 29 #include <ApplicationServices/ApplicationServices.h>
32 #endif 30 #endif
33 31
34 namespace gfx { 32 namespace gfx {
35 33
36 class Insets; 34 class Insets;
37 35
38 class GFX_EXPORT Rect 36 class GFX_EXPORT Rect
39 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> { 37 : public RectBase<Rect, Point, Size, Insets, Vector2d, int> {
40 public: 38 public:
41 Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point()) {} 39 Rect() : RectBase<Rect, Point, Size, Insets, Vector2d, int>(Point()) {}
42 40
43 Rect(int width, int height) 41 Rect(int width, int height)
44 : RectBase<Rect, Point, Size, Insets, Vector2d, int> 42 : RectBase<Rect, Point, Size, Insets, Vector2d, int>
45 (Size(width, height)) {} 43 (Size(width, height)) {}
46 44
47 Rect(int x, int y, int width, int height) 45 Rect(int x, int y, int width, int height)
48 : RectBase<Rect, Point, Size, Insets, Vector2d, int> 46 : RectBase<Rect, Point, Size, Insets, Vector2d, int>
49 (Point(x, y), Size(width, height)) {} 47 (Point(x, y), Size(width, height)) {}
50 48
51 #if defined(OS_WIN) 49 #if defined(OS_WIN)
52 explicit Rect(const RECT& r); 50 explicit Rect(const RECT& r);
53 #elif defined(OS_MACOSX) 51 #elif defined(OS_MACOSX)
54 explicit Rect(const CGRect& r); 52 explicit Rect(const CGRect& r);
55 #elif defined(TOOLKIT_GTK)
56 explicit Rect(const GdkRectangle& r);
57 #endif 53 #endif
58 54
59 explicit Rect(const gfx::Size& size) 55 explicit Rect(const gfx::Size& size)
60 : RectBase<Rect, Point, Size, Insets, Vector2d, int>(size) {} 56 : RectBase<Rect, Point, Size, Insets, Vector2d, int>(size) {}
61 57
62 Rect(const gfx::Point& origin, const gfx::Size& size) 58 Rect(const gfx::Point& origin, const gfx::Size& size)
63 : RectBase<Rect, Point, Size, Insets, Vector2d, int>(origin, size) {} 59 : RectBase<Rect, Point, Size, Insets, Vector2d, int>(origin, size) {}
64 60
65 ~Rect() {} 61 ~Rect() {}
66 62
67 #if defined(OS_WIN) 63 #if defined(OS_WIN)
68 // Construct an equivalent Win32 RECT object. 64 // Construct an equivalent Win32 RECT object.
69 RECT ToRECT() const; 65 RECT ToRECT() const;
70 #elif defined(TOOLKIT_GTK)
71 GdkRectangle ToGdkRectangle() const;
72 #elif defined(OS_MACOSX) 66 #elif defined(OS_MACOSX)
73 // Construct an equivalent CoreGraphics object. 67 // Construct an equivalent CoreGraphics object.
74 CGRect ToCGRect() const; 68 CGRect ToCGRect() const;
75 #endif 69 #endif
76 70
77 operator RectF() const { 71 operator RectF() const {
78 return RectF(origin().x(), origin().y(), size().width(), size().height()); 72 return RectF(origin().x(), origin().y(), size().width(), size().height());
79 } 73 }
80 74
81 std::string ToString() const; 75 std::string ToString() const;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 return ScaleToEnclosedRect(rect, scale, scale); 130 return ScaleToEnclosedRect(rect, scale, scale);
137 } 131 }
138 132
139 #if !defined(COMPILER_MSVC) 133 #if !defined(COMPILER_MSVC)
140 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>; 134 extern template class RectBase<Rect, Point, Size, Insets, Vector2d, int>;
141 #endif 135 #endif
142 136
143 } // namespace gfx 137 } // namespace gfx
144 138
145 #endif // UI_GFX_GEOMETRY_RECT_H_ 139 #endif // UI_GFX_GEOMETRY_RECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698