#include "econfigure.h"

using namespace event;

const char* EConfigure::eventType="Configure";
const EField* EConfigure::eventFields[]=
{
	&EField::SERIAL,
	&EField::ID,
	&EField::TIME,
	&EField::ROOT_WINDOW,
	&EField::SUB_WINDOW,
	&EField::TYPE,
	&EField::WIDGET_PATHNAME,
	&EField::SENDEVENT,

	&EField::ABOVE,
	&EField::HEIGHT,
	&EField::WIDTH,
	&EField::BORDER_WIDTH,

	&EField::OVERRIDE,
	&EField::VALUE_MASK,
	&EField::X,
	&EField::Y,

	&EField::END
};

int EConfigure::preprocessEvent(EHeader& header,Tcl_Interp* interp,int objc,Tcl_Obj* CONST objv[])
{
	string above;
	int height,width,borderWidth;
	int override;
	string valueMask;
	int x,y;

	int index=10;

	above=Tcl_GetString(objv[index++]);
	
	Tcl_GetIntFromObj(interp,objv[index++],&height);
	Tcl_GetIntFromObj(interp,objv[index++],&width);
	Tcl_GetIntFromObj(interp,objv[index++],&borderWidth);

	Tcl_GetBooleanFromObj(interp,objv[index++],&override);

	valueMask=Tcl_GetString(objv[index++]);

	Tcl_GetIntFromObj(interp,objv[index++],&x);
	Tcl_GetIntFromObj(interp,objv[index++],&y);

	for(t_listeners::iterator it=listeners.begin();it!=listeners.end();it++)
	{
		Ptr<ConfigureListener> listener=*it;
		listener->onConfigure(header,above,height,width,borderWidth,override!=0,valueMask,x,y);
	}

	return TCL_OK;
}

