module.exports = new Class
({
	Extends: Htk.Column
	,Tag: 'htk-column-button'
	,Properties:
	{
		image:
		{
			type: String
			,value: null
		},
		icon:
		{
			type: String
			,set: function (x)
			{
				this._icon = x;
				this.image = 'image/icon/light/'+ x + '.svg';
			}
			,get: function ()
			{
				return this._icon;
			}
		},
		tip:
		{
			type: String
			,value: null
		}
	}
	
	,initialize: function (props)
	{
		this._cssClass = 'cell-button';
		this.parent (props);
	}

	,render: function (tr)
	{
		var td = this.parent (tr);

		var button = this.createElement ('button');
		button.addEventListener ('click', 
			this.buttonClicked.bind (this, this.value, tr, button));
		td.appendChild (button);
	
		var img = this.createElement ('img');
		img.src = this.image;
		button.appendChild (img);

		if (this.tip)
		{
			button.title = _(this.tip);
			img.title = _(this.tip);
		}

		return td;
	}

	,buttonClicked: function (value, tr, button)
	{
		this.signalEmit ('clicked', value, tr.rowIndex - 1, button);
	}
});