summaryrefslogtreecommitdiffstats
path: root/base/gfx/rect.cc
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-05 18:04:07 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-05 18:04:07 +0000
commit66d3a8e27c79e8d8cf6f3db37f2c20226b71c7d8 (patch)
treedd1744434e0bf229fdf63fd46c220d742cf19a60 /base/gfx/rect.cc
parent4d562a7e2538a1396a4dbeae66aea33f4f4afcd3 (diff)
downloadchromium_src-66d3a8e27c79e8d8cf6f3db37f2c20226b71c7d8.zip
chromium_src-66d3a8e27c79e8d8cf6f3db37f2c20226b71c7d8.tar.gz
chromium_src-66d3a8e27c79e8d8cf6f3db37f2c20226b71c7d8.tar.bz2
Fix basic geometric types.
Review URL: http://chrome-reviews.prom.corp.google.com/1106 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@381 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/gfx/rect.cc')
-rw-r--r--base/gfx/rect.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/base/gfx/rect.cc b/base/gfx/rect.cc
index dda7e67..f9a88d4 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)
+#import <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,16 @@ RECT Rect::ToRECT() const {
r.bottom = bottom();
return r;
}
+#elif defined(OS_MACOSX)
+CGRect Rect::ToCGRect() const {
+ CGRect r;
+ r.origin.x = x();
+ r.origin.y = y();
+ r.size.width = width();
+ r.size.height = height();
+ return r;
+}
+#endif
bool Rect::Contains(int point_x, int point_y) const {
return (point_x >= x()) && (point_x < right()) &&