/* * Copyright 2010, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Michael Pfeiffer */ #ifndef RECTANGLE_H #define RECTANGLE_H #include template class Rectangle { public: Rectangle() : left(0), top(0), right(0), bottom(0) { } Rectangle(const BRect& rect) : left(static_cast(rect.left)), top(static_cast(rect.top)), right(static_cast(rect.right)), bottom(static_cast(rect.bottom)) { } Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) { } Rectangle& operator=(const BRect& rect) { left = static_cast(rect.left); top = static_cast(rect.top); right = static_cast(rect.right); bottom = static_cast(rect.bottom); return *this; } T Width() const { return right - left; } T Height() const { return bottom - top; } T left; T top; T right; T bottom; }; typedef Rectangle RectInt32; #endif