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

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

Issue 8066006: ui/gfx: Add ToString() function to Rect class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « printing/page_setup_unittest.cc ('k') | ui/gfx/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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_RECT_H_ 12 #ifndef UI_GFX_RECT_H_
13 #define UI_GFX_RECT_H_ 13 #define UI_GFX_RECT_H_
14 #pragma once 14 #pragma once
15 15
16 #include <iosfwd> 16 #include <string>
17 17
18 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
19 #include "ui/gfx/size.h" 19 #include "ui/gfx/size.h"
20 20
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 typedef struct tagRECT RECT; 22 typedef struct tagRECT RECT;
23 #elif defined(TOOLKIT_USES_GTK) 23 #elif defined(TOOLKIT_USES_GTK)
24 typedef struct _GdkRectangle GdkRectangle; 24 typedef struct _GdkRectangle GdkRectangle;
25 #endif 25 #endif
26 26
(...skipping 16 matching lines...) Expand all
43 explicit Rect(const CGRect& r); 43 explicit Rect(const CGRect& r);
44 #elif defined(TOOLKIT_USES_GTK) 44 #elif defined(TOOLKIT_USES_GTK)
45 explicit Rect(const GdkRectangle& r); 45 explicit Rect(const GdkRectangle& r);
46 #endif 46 #endif
47 #if defined(USE_WAYLAND) 47 #if defined(USE_WAYLAND)
48 explicit Rect(const cairo_rectangle_int_t& r); 48 explicit Rect(const cairo_rectangle_int_t& r);
49 #endif 49 #endif
50 explicit Rect(const gfx::Size& size); 50 explicit Rect(const gfx::Size& size);
51 Rect(const gfx::Point& origin, const gfx::Size& size); 51 Rect(const gfx::Point& origin, const gfx::Size& size);
52 52
53 ~Rect() {} 53 ~Rect();
54 54
55 #if defined(OS_WIN) 55 #if defined(OS_WIN)
56 Rect& operator=(const RECT& r); 56 Rect& operator=(const RECT& r);
57 #elif defined(OS_MACOSX) 57 #elif defined(OS_MACOSX)
58 Rect& operator=(const CGRect& r); 58 Rect& operator=(const CGRect& r);
59 #elif defined(TOOLKIT_USES_GTK) 59 #elif defined(TOOLKIT_USES_GTK)
60 Rect& operator=(const GdkRectangle& r); 60 Rect& operator=(const GdkRectangle& r);
61 #endif 61 #endif
62 #if defined(USE_WAYLAND) 62 #if defined(USE_WAYLAND)
63 Rect& operator=(const cairo_rectangle_int_t& r); 63 Rect& operator=(const cairo_rectangle_int_t& r);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 Point CenterPoint() const; 178 Point CenterPoint() const;
179 179
180 // Return a rectangle that has the same center point but with a size capped 180 // Return a rectangle that has the same center point but with a size capped
181 // at given |size|. 181 // at given |size|.
182 Rect Center(const gfx::Size& size) const; 182 Rect Center(const gfx::Size& size) const;
183 183
184 // Returns true if this rectangle shares an entire edge (i.e., same width or 184 // Returns true if this rectangle shares an entire edge (i.e., same width or
185 // same height) with the given rectangle, and the rectangles do not overlap. 185 // same height) with the given rectangle, and the rectangles do not overlap.
186 bool SharesEdgeWith(const gfx::Rect& rect) const; 186 bool SharesEdgeWith(const gfx::Rect& rect) const;
187 187
188 std::string ToString() const;
189
188 private: 190 private:
189 gfx::Point origin_; 191 gfx::Point origin_;
190 gfx::Size size_; 192 gfx::Size size_;
191 }; 193 };
192 194
193 UI_EXPORT std::ostream& operator<<(std::ostream& out, const gfx::Rect& r);
194
195 } // namespace gfx 195 } // namespace gfx
196 196
197 #endif // UI_GFX_RECT_H_ 197 #endif // UI_GFX_RECT_H_
OLDNEW
« no previous file with comments | « printing/page_setup_unittest.cc ('k') | ui/gfx/rect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698