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

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

Issue 1061733002: Remove windows/mac/ios specific code from //ui (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix default try set Created 5 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
« no previous file with comments | « ui/gfx/geometry/point.cc ('k') | ui/gfx/geometry/rect.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <iosfwd> 16 #include <iosfwd>
17 #include <string> 17 #include <string>
18 18
19 #include "ui/gfx/geometry/point.h" 19 #include "ui/gfx/geometry/point.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)
25 typedef struct tagRECT RECT;
26 #elif defined(OS_IOS)
27 #include <CoreGraphics/CoreGraphics.h>
28 #elif defined(OS_MACOSX)
29 #include <ApplicationServices/ApplicationServices.h>
30 #endif
31
32 namespace gfx { 24 namespace gfx {
33 25
34 class Insets; 26 class Insets;
35 27
36 class GFX_EXPORT Rect { 28 class GFX_EXPORT Rect {
37 public: 29 public:
38 Rect() {} 30 Rect() {}
39 Rect(int width, int height) : size_(width, height) {} 31 Rect(int width, int height) : size_(width, height) {}
40 Rect(int x, int y, int width, int height) 32 Rect(int x, int y, int width, int height)
41 : origin_(x, y), size_(width, height) {} 33 : origin_(x, y), size_(width, height) {}
42 explicit Rect(const Size& size) : size_(size) {} 34 explicit Rect(const Size& size) : size_(size) {}
43 Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {} 35 Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {}
44 36
45 #if defined(OS_WIN)
46 explicit Rect(const RECT& r);
47 #elif defined(OS_MACOSX)
48 explicit Rect(const CGRect& r);
49 #endif
50
51 ~Rect() {} 37 ~Rect() {}
52 38
53 #if defined(OS_WIN)
54 // Construct an equivalent Win32 RECT object.
55 RECT ToRECT() const;
56 #elif defined(OS_MACOSX)
57 // Construct an equivalent CoreGraphics object.
58 CGRect ToCGRect() const;
59 #endif
60
61 operator RectF() const { 39 operator RectF() const {
62 return RectF(origin().x(), origin().y(), size().width(), size().height()); 40 return RectF(origin().x(), origin().y(), size().width(), size().height());
63 } 41 }
64 42
65 int x() const { return origin_.x(); } 43 int x() const { return origin_.x(); }
66 void set_x(int x) { origin_.set_x(x); } 44 void set_x(int x) { origin_.set_x(x); }
67 45
68 int y() const { return origin_.y(); } 46 int y() const { return origin_.y(); }
69 void set_y(int y) { origin_.set_y(y); } 47 void set_y(int y) { origin_.set_y(y); }
70 48
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 224 }
247 225
248 // This is declared here for use in gtest-based unit tests but is defined in 226 // This is declared here for use in gtest-based unit tests but is defined in
249 // the gfx_test_support target. Depend on that to use this in your unit test. 227 // the gfx_test_support target. Depend on that to use this in your unit test.
250 // This should not be used in production code - call ToString() instead. 228 // This should not be used in production code - call ToString() instead.
251 void PrintTo(const Rect& rect, ::std::ostream* os); 229 void PrintTo(const Rect& rect, ::std::ostream* os);
252 230
253 } // namespace gfx 231 } // namespace gfx
254 232
255 #endif // UI_GFX_GEOMETRY_RECT_H_ 233 #endif // UI_GFX_GEOMETRY_RECT_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/point.cc ('k') | ui/gfx/geometry/rect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698