#include "tk_rectoption.h"

const char* TkRectOption::type="TkRectOption";

const char* TkRectOption::getType() const
{
	return type;
}

void TkRectOption::doSerialize(TiXmlElement& element) const
{
	element.SetAttribute("x",x);
	element.SetAttribute("y",y);
	element.SetAttribute("width",width);
	element.SetAttribute("height",height);
}

void TkRectOption::doDeserialize(const TiXmlElement& element)
{
	element.Attribute("x",&x);
	element.Attribute("y",&y);
	element.Attribute("width",&width);
	element.Attribute("height",&height);
}

TkRectOption::TkRectOption()
{
	this->x=0;
	this->y=0;
	this->width=0;
	this->height=0;
}

TkRectOption::TkRectOption(int x,int y,int width,int height)
{
	this->x=x;
	this->y=y;
	this->width=width;
	this->height=height;
}

const string& TkRectOption::toString() const
{
	char buf[128];
	sprintf(buf,"%dx%d+%d+%d",width,height,x,y);
	return *(new string(buf));
}

void TkRectOption::fromObject(Tcl_Obj* object)
{
	sscanf(Tcl_GetString(object),"%dx%d+%d+%d",&width,&height,&x,&y);
}
