summaryrefslogtreecommitdiffstats
path: root/ui/gfx/size.h
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/size.h')
-rw-r--r--ui/gfx/size.h40
1 files changed, 37 insertions, 3 deletions
diff --git a/ui/gfx/size.h b/ui/gfx/size.h
index 670e67e..5e288fe 100644
--- a/ui/gfx/size.h
+++ b/ui/gfx/size.h
@@ -10,7 +10,6 @@
#include "build/build_config.h"
#include "ui/base/ui_export.h"
-#include "ui/gfx/size_base.h"
#if defined(OS_WIN)
typedef struct tagSIZE SIZE;
@@ -21,7 +20,7 @@ typedef struct tagSIZE SIZE;
namespace gfx {
// A size has width and height values.
-class UI_EXPORT Size : public SizeBase<Size, int> {
+class UI_EXPORT Size {
public:
Size();
Size(int width, int height);
@@ -29,12 +28,43 @@ class UI_EXPORT Size : public SizeBase<Size, int> {
explicit Size(const CGSize& s);
#endif
- virtual ~Size();
+ ~Size();
#if defined(OS_MACOSX)
Size& operator=(const CGSize& s);
#endif
+ int width() const { return width_; }
+ int height() const { return height_; }
+
+ int GetArea() const { return width_ * height_; }
+
+ void SetSize(int width, int height) {
+ set_width(width);
+ set_height(height);
+ }
+
+ void Enlarge(int width, int height) {
+ set_width(width_ + width);
+ set_height(height_ + height);
+ }
+
+ void set_width(int width);
+ void set_height(int height);
+
+ bool operator==(const Size& s) const {
+ return width_ == s.width_ && height_ == s.height_;
+ }
+
+ bool operator!=(const Size& s) const {
+ return !(*this == s);
+ }
+
+ bool IsEmpty() const {
+ // Size doesn't allow negative dimensions, so testing for 0 is enough.
+ return (width_ == 0) || (height_ == 0);
+ }
+
#if defined(OS_WIN)
SIZE ToSIZE() const;
#elif defined(OS_MACOSX)
@@ -42,6 +72,10 @@ class UI_EXPORT Size : public SizeBase<Size, int> {
#endif
std::string ToString() const;
+
+ private:
+ int width_;
+ int height_;
};
} // namespace gfx