/* * DISTRHO Plugin Toolkit (DPT) * Copyright (C) 2012-2013 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this * permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef DGL_GEOMETRY_HPP_INCLUDED #define DGL_GEOMETRY_HPP_INCLUDED #include "Base.hpp" START_NAMESPACE_DGL // ----------------------------------------------------------------------- template class Point { public: Point() noexcept; Point(T x, T y) noexcept; Point(const Point& pos) noexcept; T getX() const noexcept; T getY() const noexcept; void setX(T x) noexcept; void setY(T y) noexcept; void move(T x, T y) noexcept; void move(const Point& pos) noexcept; Point& operator=(const Point& pos) noexcept; Point& operator+=(const Point& pos) noexcept; Point& operator-=(const Point& pos) noexcept; bool operator==(const Point& pos) const noexcept; bool operator!=(const Point& pos) const noexcept; private: T fX, fY; template friend class Rectangle; }; // ----------------------------------------------------------------------- template class Size { public: Size() noexcept; Size(T width, T height) noexcept; Size(const Size& size) noexcept; T getWidth() const noexcept; T getHeight() const noexcept; void setWidth(T width) noexcept; void setHeight(T height) noexcept; Size& operator=(const Size& size) noexcept; Size& operator+=(const Size& size) noexcept; Size& operator-=(const Size& size) noexcept; Size& operator*=(T m) noexcept; Size& operator/=(T d) noexcept; bool operator==(const Size& size) const noexcept; bool operator!=(const Size& size) const noexcept; private: T fWidth, fHeight; template friend class Rectangle; }; // ----------------------------------------------------------------------- template class Rectangle { public: Rectangle() noexcept; Rectangle(T x, T y, T width, T height) noexcept; Rectangle(T x, T y, const Size& size) noexcept; Rectangle(const Point& pos, T width, T height) noexcept; Rectangle(const Point& pos, const Size& size) noexcept; Rectangle(const Rectangle& rect) noexcept; T getX() const noexcept; T getY() const noexcept; T getWidth() const noexcept; T getHeight() const noexcept; const Point& getPos() const noexcept; const Size& getSize() const noexcept; bool contains(T x, T y) const noexcept; bool contains(const Point& pos) const noexcept; bool containsX(T x) const noexcept; bool containsY(T y) const noexcept; void setX(T x) noexcept; void setY(T y) noexcept; void setPos(T x, T y) noexcept; void setPos(const Point& pos) noexcept; void move(T x, T y) noexcept; void move(const Point& pos) noexcept; void setWidth(T width) noexcept; void setHeight(T height) noexcept; void setSize(T width, T height) noexcept; void setSize(const Size& size) noexcept; Rectangle& operator=(const Rectangle& rect) noexcept; private: Point fPos; Size fSize; }; // ----------------------------------------------------------------------- END_NAMESPACE_DGL #endif // DGL_GEOMETRY_HPP_INCLUDED