#include "gosGml.hpp"
#include "SideCon.h"
/*
class SideCon
{
	public:
		SideCon(rect* DisplayTextArea);
		~SideCon();
		void EnableTOC(char* Input, char* fontPath, char* imagePath, char* defaultPagePath, int tabwidth=15);
		void DisableTOC();
		void EnableIndex(char* Input, char* fontPath, char* imagePath, char* defaultPagePath, int tabwidth);
		void DisableIndex();
		void KeyPress();
		void Mouse(int x, int y, DWORD buttons);
		void Draw();
		void SetScrollOffset(int y);
	private:
		SideCon(); //call me not
		SideCon(SideCon&);//don't call this
		SideCon& operator= (SideCon const &); //don't call the assignment operator

		Toc* Tocp;
		Index* Indexp;
		rect* Dim;
		rect* TocDim;
		rect* IndexDim;
		rect* InputDim;
		rect *Tab1, *Tab2;
		bool IndexOnTop;
};*/

SideCon::SideCon(rect* DisplayTextArea)
:Dim(DisplayTextArea),Tocp(0),Indexp(0),TocDim(0),IndexDim(0),InputDim(0),Tab1(0),Tab2(0),IndexOnTop(false)
{
	IndexDim = new rect;
	IndexDim->Bottom=Dim->Bottom;
	IndexDim->Top=Dim->Top;
	IndexDim->Left=Dim->Left;
	IndexDim->Right=Dim->Right;
	TocDim = new rect;
	RM=new Region();
}

SideCon::~SideCon()
{
	delete Dim;
	if(Tocp)
		delete Tocp;
	if(Indexp)
		delete Indexp;
	if(TocDim)
		delete TocDim;
	if(IndexDim)
		delete IndexDim;
	if(InputDim)
		delete InputDim;
	if(Tab1)
		delete Tab1;
	if(Tab2)
		delete Tab2;
	if(RM)
		delete RM;
}

void SideCon::EnableTOC(char* Input, char* fontPath, char* imagePath, char* defaultPagePath, int tabwidth)
{
	Tocp=new Toc(Input, fontPath, imagePath, defaultPagePath, TocDim, tabwidth);
	if(!Indexp)
		IndexOnTop=false;
}

void SideCon::EnableIndex(char* Input, char* fontPath, char* imagePath, char* defaultPagePath, int tabwidth)
{
	Indexp=new Index(Input, fontPath, imagePath, defaultPagePath, IndexDim, tabwidth);
	if(!Tocp)
		IndexOnTop=true;
}

void SideCon::DisableTOC()
{
	delete Tocp;
	Tocp=NULL;
	IndexOnTop=true;
}

void SideCon::DisableIndex()
{
	delete Indexp;
	Indexp=NULL;
	IndexOnTop=false;
}

void SideCon::KeyPress()
{
	//not yet
}

void SideCon::Mouse(int x, int y, DWORD buttons)
{
	x;y;buttons;
}

void SideCon::Draw()
{
	if(IndexOnTop)
	{
		if(Indexp)
			Indexp->Draw();
	}
	else
		if(Tocp)
			Tocp->Draw();
}

void SideCon::SetScrollOffset(int y)
{
	if(IndexOnTop)
	{
		if(Indexp)
			Indexp->SetScrollOffset(y);
	}
	else
		if(Tocp)
			Tocp->SetScrollOffset(y);
}
