#ifndef _TSQUARE2D_CPP
#define _TSQUARE2D_CPP
//-------------------------------------------------------
#include "TSquare2D.h"
//-------------------------------------------------------
TSquare::TSquare()
{
	SetSettings(false, TRectF(0.0f, 0.0f, 1.0f, 1.0f), TColor4(255, 255, 255, 255), TColor4(0, 0, 0, 0), NULL, 0.0f);
}
//-------------------------------------------------------
TSquare::TSquare(bool exist, const TRectF &rect, const TColor4 &enabledColor, const TColor4 &disabledColor, ITexture *texture, float angleTexture)
{
	SetSettings(exist, rect, enabledColor, disabledColor, texture, angleTexture);
}
//-------------------------------------------------------
TSquare::~TSquare()
{

}
//-------------------------------------------------------
void TSquare::SetSettings(bool exist, const TRectF &rect, const TColor4 &enabledColor, const TColor4 &disabledColor, ITexture *texture, float angleTexture)
{
	this->_angleTexture = angleTexture;
	this->_exist = exist;
	this->_rect = rect;
	this->_enabledColor = enabledColor;
	this->_disabledColor = disabledColor;
	this->_texture = texture;
}
//-------------------------------------------------------
void TSquare::SetExist(bool exist)
{
	this->_exist = exist;
}
//-------------------------------------------------------
void TSquare::SetRect(const TRectF &rect)
{
	this->_rect = rect;
}
//-------------------------------------------------------
void TSquare::SetEnabledColor(const TColor4 &enabledColor)
{
	this->_enabledColor = enabledColor;
}
//-------------------------------------------------------
void TSquare::SetDisabledColor(const TColor4 &disabledColor)
{
	this->_disabledColor = disabledColor;
}
//-------------------------------------------------------
void TSquare::SetTexture(ITexture *texture)
{
	this->_texture = texture;
}
//-------------------------------------------------------
void TSquare::SetAngleTexture(float angleTexture)
{
	this->_angleTexture = angleTexture;
}
//-------------------------------------------------------
bool TSquare::GetExist() const
{
	return this->_exist;
}
//-------------------------------------------------------
TRectF TSquare::GetRect() const
{
	return this->_rect;
}
//-------------------------------------------------------
TColor4 TSquare::GetEnabledColor() const
{
	return this->_enabledColor;
}
//-------------------------------------------------------
TColor4 TSquare::GetDisabledColor() const
{
	return this->_disabledColor;
}
//-------------------------------------------------------
ITexture* TSquare::GetTexture() const
{
	return this->_texture;
}
//-------------------------------------------------------
void TSquare::Draw(IRender2D *pRender2D)
{
	if(this->_texture != NULL)
	{
		this->_texture->Draw2D((int)_rect.x, (int)_rect.y, (uint)_rect.width, (uint)_rect.height, _angleTexture);
	}
	else
	{
		if( this->_exist )
			pRender2D->SetVerticesColors(_enabledColor, _enabledColor, _enabledColor, _enabledColor);
		else
			pRender2D->SetVerticesColors(_disabledColor, _disabledColor,  _disabledColor, _disabledColor);
		pRender2D->LineWidth(1);
		pRender2D->DrawRect(_rect,TColor4(),(E_PRIMITIVE2D_FLAGS)(PF_FILL | PF_VCA)); //полностью закрашен

		pRender2D->LineWidth(1);
		pRender2D->DrawRect(_rect,TColor4(0x000000,255)); //только рамка
	}
}
//-------------------------------------------------------
#endif