#include "toolbutton.h"
#include "appwindow.h"

#ifdef __unix__
#define SEPARATOR "/"
#endif

#ifndef __unix__
#define SEPARATOR "\\\\"
#endif

void ToolButton::onButtonPress(EHeader& header,int button,const string& state,int x,int y,int x_root,int y_root)
{
	appWindow->toolButtonPressed(header.source);
}

ToolButton::ToolButton(Ptr<TclInterp>& interp,AppWindow* appWindow,const char* name)
{
	this->appWindow=appWindow;
	this->name=name;

	string fileName=string("images")+SEPARATOR+name+".gif";
		
	Ptr<TkPhoto> photo=new TkPhoto(interp,fileName.c_str());
		
	button=new TkRadioButton(interp);
	button->addButtonPressListener(this);
	button->setGroup("toolbar");
	button->setOption(TkRadioButton::OPT_IMAGE,photo);
	button->setOption(TkRadioButton::OPT_INDICATORON,new TkBoolOption(false));
}
