#include "Chart.h"

void TChart::Init(int aX, int aY, int aW, int aH, int OwnerX, int OwnerY, u32 aColor, TBvStyle aBevelOuter){
	unsigned short Left,Right,Top,Bottom;
	Bound.SetBySize(aX+OwnerX, aY+OwnerY, aW, aH);
	Content.SetBySize(aX+OwnerX, aY+OwnerY, aW, aH);
	RectDiagram.SetBySize(Content.Left + aW /3, aY+OwnerY +1, aW/3, 50);
	
	Color = aColor;
	
	for(Left=0; Left<dfValueCount; Left++){
		for(Top=0; Top<dfValueLength; Top++){
			Value[Left][Top] = 0;
		}
		vName[Left].Text[0]= 0;
		vName[Left].tUnit[0]= 0;
		vName[Left].x = Content.Left +6;
		vName[Left].y = Content.Top + 13;
		
		Axis[Left].StartX = Content.Left + 6;
		Axis[Left].StartY = Content.Bottom  - 6;;
		Axis[Left].EndX = Content.Right - 6;
		Axis[Left].EndY = Content.Top + 6;
		Axis[Left].Color = clBlue;
		Axis[Left].GridCount =10;
		
		Axis[Left].IsHoriz = 0;
		Axis[Left].IsShowGrid =1;
		Axis[Left].IsShowPointedTip =1;
		Axis[Left].GridLineType = LtSOlid;
	}
	
	BaseAxis.IsHoriz = 1;
	BaseAxis.IsShowGrid =1;
	BaseAxis.IsShowPointedTip =1;
	BaseAxis.GridLineType = LtSOlid;
	
	BaseAxis.StartX = Content.Left + 6;
	BaseAxis.StartY = Content.Bottom  - 6;
	BaseAxis.EndX = Content.Right - 6;
	BaseAxis.EndY = BaseAxis.StartY;
	BaseAxis.Color = clBlue;
	BaseAxis.GridCount =10;
}

void TChart::DrawSelf(void)
{
	RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
}

void TChart::Show(void)
{
	DrawSelf();
}

void TChart::DrawBaseAxis()
{
	if(BaseAxis.IsHoriz){
		
	}
}

void TChart::DrawAxis(short aInx)
{
	
}

void TChart::DrawAllAxis()
{
	
}

void TChart::SetName(short Inx, char *P)
{
	int i;
	if(Inx < 0)return;
	if(Inx > 1)return;
	for(i=0; i<dfNameLength; i++){
		vName[Inx].Text[i] = *P;
		if(*P == 0){
			break;
		}
	}
	vName[Inx].Text[dfNameLength-1] = 0;
}

void TChart::SetName(short Inx, const char *P)
{
	int i;
	if(Inx < 0)return;
	if(Inx > 1)return;
	for(i=0; i<dfNameLength; i++){
		vName[Inx].Text[i] = *P;
		if(*P == 0){
			break;
		}
	}
	vName[Inx].Text[dfNameLength-1] = 0;	
}

void TChart::SetNamePosition(short Inx, short aX, short aY)
{
	if(Inx < 0)return;
	if(Inx > 1)return;
	vName[Inx].x = aX + Content.Left;
	vName[Inx].y = aY + Content.Top;
}



