#include <graphics.h>

#include "..\comp\Buttons\StateBu.h"

CStateButton::CStateButton(int X, int Y, int Width,int Height, char* Text) : CButton(X,Y,Width,Height,Text)
{
	CButton::Draw();
}
void CStateButton::DrawText(void) //const
{
	//Toont de text, uitgelijnd en in de juiste kleur
	setcolor((bState ? colClickedTextColor : colTextColor));
	settextjustify(taText,Center);
	settextstyle(0,0,0); //Default BIOS font
	switch(taText)
	{
		case Left:
			outtextxy(iX + iHeight,iY + (iHeight / 2),szText);
			break;
		case Center:
			outtextxy(iX + (iWidth  / 2) + iHeight,iY + (iHeight / 2),szText);
			break;
		case Right:
			outtextxy(iX + iWidth + iHeight,iY + (iHeight / 2),szText);
			break;
		default:
			break;
	}
}
void CStateButton::SetCheckState(CheckStates State)
{
	csCheckState = State;
	CButton::Draw();
	Draw();
}
void CStateButton::Draw(void)
{
	int iSize = (iHeight ) -6;
	int X = iX + 3;
	int Y = iY + 3;
	switch(csCheckState)
	{
		case Checked:
			setcolor(Green);
			line(X, Y + (iSize/2) ,X + (iSize/2), Y + iSize);
			line(X + (iSize/2) - 1, Y + iSize, X + iSize -1, Y);
			setcolor(LightGreen);
			line(X + (iSize/2), Y + iSize, X + iSize, Y);
			line(X +1, Y + (iSize/2), X + (iSize/2) + 1, Y +iSize);
			break;
		case ErrorChecked:
			setcolor(Red);
			line(X,Y,X + iSize, Y + iSize);
			line(X,Y+iSize,X+iSize,Y);
			setcolor(LightRed);
			line(X+1,Y,X + iSize, Y+iSize -1);
			line(X,Y+iSize - 1,X+iSize -1,Y);
			break;
		default:
			break;
	}
}
void CStateButton::Click(void)
{
	CButton::Click();
	Draw();
}