#ifndef INCLUDED_MATH_RECTANGLE
#define INCLUDED_MATH_RECTANGLE

#include "Point.h"

//////////////////////////////////////////////////////////////
namespace Dubious {
namespace Math {

/// @brief Simple Rectangle
///
/// Simple rectangle class represented by a point and a size.
///	It is templated so that the compiler can tell the difference
///	between a rectangle with Y up (ie in OpenGL) or with the Y 
///	down (ie in Windows).
template <int T>
class Rectangle
{
public:
	Rectangle()
	{}

	/// @brief Constructor.  Creates a rectangle at the given position
	///	at the given size
	/// @param Origin - [in] origin of the rectangle.  Whether this is top
	///	left or bottom left depends on which direction the Y axis grows in
	/// @param Dimensions - [in] The size of the rectangle.
	Rectangle( const Point& Origin, const Size& Dimensions ) 
		: m_Origin( Origin )
		, m_Dimensions( Dimensions )
	{}

	/// @brief Check to see if the point is in the Rectangle
	/// @returns true if the point is in the Rectangle
	bool				Contains( const Point& P ) const
	{
		return P.X() >= m_Origin.X() && P.Y() >= m_Origin.Y() &&
			   P.X() <= m_Origin.X()+m_Dimensions.X() &&
			   P.Y() <= m_Origin.Y()+m_Dimensions.Y();
	}

	/// @brief Read only accessor
	/// @returns the origin
	const Point         Origin() const { return m_Origin; }

	/// @brief Read only accessor
	/// @returns the size
	const Size          Dimensions() const { return m_Dimensions; }

private:
	Point               m_Origin;
	Size                m_Dimensions;
};

//////////////////////////////////////////////////////////////
typedef Rectangle<0> RectangleYUp;
typedef Rectangle<1> RectangleYDown;

}
}

#endif
