$package("js.ui.list");

js.ui.list.Columns = function () {
	this.column = new js.lang.Array();
}

js.ui.list.Columns.prototype.column = null;

js.ui.list.Columns.prototype.colSpan = null;

js.ui.list.Columns.prototype.visible = true;

js.ui.list.Columns.prototype.add = function(column){
	this.column.addItem(column);
	column.index = this.column.length-1;
}

js.ui.list.Columns.prototype.size = function(){
	return this.column.length;
}

js.ui.list.Columns.prototype.remove = function(column){
	this.column.removeItem(column);
	this.count = this.column.length;
	for(var i=0; i<this.column.length; i++){
		this.column[i].index = i;
	}
}
/**
 * clear all column from the cColumns
 */
js.ui.list.Columns.prototype.clear = function(){
	this.column.clear();
}
js.ui.list.Columns.prototype.getColumn = js.ui.list.Columns.prototype.getItem = function(i){
	return this.column[i];
}
js.ui.list.Columns.prototype.getColumnByIndex = function(index){
	for(var j=0; j<this.column.length; j++){
		if(this.column[j].index==index)
			return this.column[j];
	}
	return null;
}

js.ui.list.ColumnCellRenderer = function (owner){
	this.owner = owner;
}

js.ui.list.ColumnCellRenderer.prototype = new js.ui.list.AbstractListItemRenderer();

js.ui.list.ColumnCellRenderer.prototype.getNativeClass = function (){
	return "js.ui.list.ColumnCellRenderer";
}
js.ui.list.ColumnCellRenderer.prototype.bindUI = function(){
	this.__superBindUI = js.ui.list.AbstractListItemRenderer.prototype.bindUI;
	this.__superBindUI();
	this.text = this.ui.getElementsByTagName("a")[0];
}
js.ui.list.ColumnCellRenderer.prototype.paintText = function(){
	var text = this.userObject;
	if(text=='') text = "&nbsp";
	this.text.innerHTML = text;
}

js.ui.list.CheckBoxColumnCellRenderer = function (owner){
	this.owner = owner;
}

js.ui.list.CheckBoxColumnCellRenderer.prototype = new js.ui.list.AbstractListItemRenderer();

js.ui.list.CheckBoxColumnCellRenderer.prototype.getNativeClass = function (){
	return "js.ui.list.CheckBoxColumnCellRenderer";
}
js.ui.list.CheckBoxColumnCellRenderer.prototype.bindUI = function(){
	this.__superBindUI = js.ui.list.AbstractListItemRenderer.prototype.bindUI;
	this.__superBindUI();
	this.ui = this.ui.getElementsByTagName("table")[0];
	this.checkbox = this.ui.getElementsByTagName("input")[0];
}
js.ui.list.CheckBoxColumnCellRenderer.prototype.paintText = function(){
	var text = this.userObject;
	if(text=='') text = "&nbsp";
	this.checkbox.value = text;
}

/**
 * Construct js.ui.list.Column inherits from js.lang.Object.
 * @class
 * @constructor
 * @see js.lang.Object js.lang.Object is the base class for this
 */
js.ui.list.Column = function (){
}
js.ui.list.Column.prototype = new js.lang.BaseObject();

js.ui.list.Column.prototype.caption = "";
js.ui.list.Column.prototype.width = null;
js.ui.list.Column.prototype.visible = true;
js.ui.list.Column.prototype.allowSort = true;
js.ui.list.Column.prototype.renderClass = js.ui.list.ColumnCellRenderer;
js.ui.list.Column.prototype.editor = null;
js.ui.list.Column.prototype.index = 0;
js.ui.list.Column.prototype.dataType;
js.ui.list.Column.prototype.renderer;

js.ui.list.Column.prototype.createCellRenderer = function(){
	if(!this.renderClass) this.renderClass = js.ui.list.AbstractListItemRenderer;
	this.renderer = new this.renderClass();
	return this.renderer;
}



