/**
 * Represents a grid column. This is an abstract class and should not be
 * instantiated directly.
 **/
Htk.Column = new Class
({
	Extends: Vn.Object
	,Tag: 'htk-column'
	,Properties:
	{
		value:
		{
			type: String
			,value: null
		},
		column:
		{
			type: String
			,value: null
		},
		columnIndex:
		{
			type: Number
			,value: -1
		},
		title:
		{
			 type: String
			 ,value: null
		},
		editable:
		{
			type: Boolean
			,value: false
		},
		renderer:
		{
			type: Function
			,value: false
		},
		class:
		{
			type: String
			,set: function (x)
			{
				this._userCssClass = x;
				
				if (this._cssClass)
					this._cssClass = x +' '+ this._cssClass;
				else
					this._cssClass = x;
			}
			,get: function ()
			{
				return this._userCssClass;
			}
		}
	}
	
	,_cssClass: null
	,_userCssClass: null

	/**
	 * Initializes the column.
	 **/
	,initialize: function (props)
	{
		this.td = document.createElement ('td');
		this.parent (props);
	}
	
	,renderHeader: function ()
	{
		var th = document.createElement ('th');
		
		if (this.title)
			th.appendChild (document.createTextNode (this.title));
			
		return th;
	}

	/**
	 * Draws the cell and returns its associated td.
	 *
	 * @param {HTMLTableRow} tr the table row
	 * @return {HTMLTableData} the rendered cell
	 **/
	,render: function (tr)
	{
		var td = this.td.cloneNode (true);

		if (this._cssClass)
			td.className = this._cssClass;
			
		return td;
	}

	,updateColumnIndex: function (model)
	{
		if (this.column)
			this.columnIndex = model.getColumnIndex (this.column);
	}

	,changed: function (tr, newValue)
	{
		this.signalEmit ('changed', tr.rowIndex - 1, newValue);
	}
});