#include "CtlPanel1.h"
#include "Runtime.h"


void TCtlPanel1::Init(int aX, int aY, int aW, int aH, int OwnerX, int OwnerY, u32 aColor, TBvStyle aBevelOuter){
	unsigned short Left,Right,Top,Bottom,i;
	Bound.SetBySize(aX+OwnerX, aY+OwnerY, aW, aH);
	Color = aColor;
	BevelOuter = aBevelOuter;
	if(BevelOuter == bvRaised){	
		Left 		= Bound.Left + 1;
		Right 	= Bound.Right - 2;
		Top 		= Bound.Top + 1;
		Bottom 	= Bound.Bottom - 2;
	}else{
		Left 		= Bound.Left + 2;
		Right 	= Bound.Right - 2;
		Top 		= Bound.Top + 2;
		Bottom 	= Bound.Bottom - 2;
	}
	
	Caption.Init(Left, Top, Right-Left+1, 32, 0, 0, clNearWhite, clMedBlue);
	Content.Set(Left,Top+32,Right,Bottom);
	VScrollBarBox.Set(780,80,800,400);
	VScrollBar.Color = 0xFF007777;
	FixColColor = clMaroon;
	FixColTextColor = clNearWhite;
	TextColor = clNearBlack;
	SelectedColor = clBlue;
	SelectedTextColor = clNearWhite;
	
	Caption.Visible = 0;
	for(i=0;i<24;i++){
		SText[i].Enable = 0;
		Edit[i].Enable = 0;
		Btn[i].Enable = 0;
		
		SText[i].Visible = 0;
		Edit[i].Visible = 0;
		Btn[i].Visible = 0;
		
		SText[i].Selected = 0;
		Edit[i].Selected = 0;
		Btn[i].Selected = 0;
	}
}


void TCtlPanel1::DrawSelf(void)
{
	unsigned int i;
	if (BevelOuter == bvLowered){
		VertLineRender(Bound.Left,	Bound.Top, 	Bound.Height-1,	0xFF808080);
		HorizLineRender(Bound.Left,	Bound.Top, 	Bound.Width-1,	0xFF808080);
		
		VertLineRender(Bound.Left+1,	Bound.Top+1, 	Bound.Height-2,	0xFF404040);
		HorizLineRender(Bound.Left+1,	Bound.Top+1, 	Bound.Width-2,	0xFF404040);
	
		VertLineRender(Bound.Right-1,	Bound.Top+1, 	Bound.Height-2,	0xFFD4D0C8);
		HorizLineRender(Bound.Left+1,	Bound.Bottom-1, 	Bound.Width-2,	0xFFD4D0C8);

		VertLineRender(Bound.Right,	Bound.Top, 	  Bound.Height,	0xFFFFFFFF);
		HorizLineRender(Bound.Left,	Bound.Bottom, Bound.Width,	0xFFFFFFFF);	
	}else
	if(BevelOuter == bvRaised){
		VertLineRender(Bound.Left,		Bound.Top, 		Bound.Height -1,	0xFFFFFFFF);
		VertLineRender(Bound.Right -1,	Bound.Top +1,	Bound.Height -2,	0xFF808080);
		VertLineRender(Bound.Right,		Bound.Top,		Bound.Height,	0xFF404040);
	
		HorizLineRender(Bound.Left, 		Bound.Top, 		Bound.Width - 1, 	0xFFFFFFFF);
		HorizLineRender(Bound.Left +1, 	Bound.Bottom -1,  Bound.Width - 2, 	0xFF808080);
		HorizLineRender(Bound.Left,		Bound.Bottom,	Bound.Width,	0xFF404040);
	}
	
	//Fill Rect Box
	RectFillRender(Content.Left, Content.Top, Content.Right, Content.Bottom, Color);
	
	if(Caption.Visible)Caption.Show();
	for(i=0; i<24; i++)if(SText[i].Visible)SText[i].Show();
	for(i=0; i<24; i++)if(Edit[i].Visible)Edit[i].Show();
	for(i=0; i<24; i++)if(Btn[i].Visible)Btn[i].Show();
}

void TCtlPanel1::DrawVertScrollBar(void)
{
	
}

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

void TCtlPanel1::ReDrawItems(void)
{
	unsigned int i;
	if(Caption.Visible)Caption.Show();
	for(i=0; i<24; i++)if(SText[i].Visible)SText[i].Show();
	for(i=0; i<24; i++)if(Edit[i].Visible)Edit[i].Show();
	for(i=0; i<24; i++)if(Btn[i].Visible)Btn[i].Show();
}

void TCtlPanel1::ReDrawEdit(void)
{
	unsigned int i;
	for(i=0; i<24; i++)if(Edit[i].Visible)Edit[i].Show();
}

void TCtlPanel1::SetEditMode(unsigned int aMode)
{
	
}
		
void TCtlPanel1::Clear(void)
{
	
}
