/* * DISTRHO Plugin Toolkit (DPT) * Copyright (C) 2012-2013 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * For a full copy of the license see the LGPL.txt file */ #ifndef __DGL_GEOMETRY_HPP__ #define __DGL_GEOMETRY_HPP__ #include "Base.hpp" START_NAMESPACE_DGL // ------------------------------------------------- template class Point { public: Point(); Point(T x, T y); Point(const Point& pos); T getX() const; T getY() const; void setX(T x); void setY(T y); void move(T x, T y); void move(const Point& pos); Point& operator=(const Point& pos); Point& operator+=(const Point& pos); Point& operator-=(const Point& pos); bool operator==(const Point& pos) const; bool operator!=(const Point& pos) const; private: T fX, fY; template friend class Rectangle; }; // ------------------------------------------------- template class Size { public: Size(); Size(T width, T height); Size(const Size& size); T getWidth() const; T getHeight() const; void setWidth(T width); void setHeight(T height); Size& operator=(const Size& size); Size& operator+=(const Size& size); Size& operator-=(const Size& size); Size& operator*=(T m); Size& operator/=(T d); bool operator==(const Size& size) const; bool operator!=(const Size& size) const; private: T fWidth, fHeight; template friend class Rectangle; }; // ------------------------------------------------- template class Rectangle { public: Rectangle(); Rectangle(T x, T y, T width, T height); Rectangle(T x, T y, const Size& size); Rectangle(const Point& pos, T width, T height); Rectangle(const Point& pos, const Size& size); Rectangle(const Rectangle& rect); T getX() const; T getY() const; T getWidth() const; T getHeight() const; const Point& getPos() const; const Size& getSize() const; bool contains(T x, T y) const; bool contains(const Point& pos) const; bool containsX(T x) const; bool containsY(T y) const; void setX(T x); void setY(T y); void setPos(T x, T y); void setPos(const Point& pos); void move(T x, T y); void move(const Point& pos); void setWidth(T width); void setHeight(T height); void setSize(T width, T height); void setSize(const Size& size); Rectangle& operator=(const Rectangle& rect); private: Point fPos; Size fSize; }; // ------------------------------------------------- END_NAMESPACE_DGL #endif // __DGL_GEOMETRY_HPP__