diff options
author | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-06 20:38:29 +0000 |
---|---|---|
committer | avi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-06 20:38:29 +0000 |
commit | 1924d1048439d9990701a28f8709e01c21a08197 (patch) | |
tree | 5557c8c94257ea22ad69a36b6800a9d38a463a4f /base/gfx/rect.cc | |
parent | 74873f0b403a944de45c4abb2cd6c8ed5a5f4783 (diff) | |
download | chromium_src-1924d1048439d9990701a28f8709e01c21a08197.zip chromium_src-1924d1048439d9990701a28f8709e01c21a08197.tar.gz chromium_src-1924d1048439d9990701a28f8709e01c21a08197.tar.bz2 |
Fixing up the basic set of geometry.
Review URL: http://chrome-reviews.prom.corp.google.com/1211
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/gfx/rect.cc')
-rw-r--r-- | base/gfx/rect.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc index dda7e67..0ee3b6d 100644 --- a/base/gfx/rect.cc +++ b/base/gfx/rect.cc @@ -29,7 +29,11 @@ #include "base/gfx/rect.h" +#if defined(OS_WIN) #include <windows.h> +#elif defined(OS_MACOSX) +#include <CoreGraphics/CGGeometry.h> +#endif #include "base/logging.h" @@ -63,6 +67,7 @@ Rect::Rect(int x, int y, int width, int height) set_height(height); } +#if defined(OS_WIN) Rect::Rect(const RECT& r) : origin_(r.left, r.top) { set_width(r.right - r.left); @@ -75,6 +80,20 @@ Rect& Rect::operator=(const RECT& r) { set_height(r.bottom - r.top); return *this; } +#elif defined(OS_MACOSX) +Rect::Rect(const CGRect& r) + : origin_(r.origin.x, r.origin.y) { + set_width(r.size.width); + set_height(r.size.height); +} + +Rect& Rect::operator=(const CGRect& r) { + origin_.SetPoint(r.origin.x, r.origin.y); + set_width(r.size.width); + set_height(r.size.height); + return *this; +} +#endif void Rect::set_width(int width) { if (width < 0) { @@ -119,6 +138,7 @@ bool Rect::operator==(const Rect& other) const { return origin_ == other.origin_ && size_ == other.size_; } +#if defined(OS_WIN) RECT Rect::ToRECT() const { RECT r; r.left = x(); @@ -127,6 +147,11 @@ RECT Rect::ToRECT() const { r.bottom = bottom(); return r; } +#elif defined(OS_MACOSX) +CGRect Rect::ToCGRect() const { + return CGRectMake(x(), y(), width(), height()); +} +#endif bool Rect::Contains(int point_x, int point_y) const { return (point_x >= x()) && (point_x < right()) && |