
//*****************************************************/
 // AJOUT  TYPE DE CELLULE EXCEL
//****************************************************/
// Float_ec : cellule de nombre
 function eXcell_floatec(cell){
 this.base = eXcell_ed;
 this.base(cell)
 this.getValue = function(){
 if(this.cell.childNodes.length>0)
 return this.cell.childNodes[0].innerHTML.toString()._dhx_trim()
}

}

eXcell_floatec.prototype = new eXcell_ed;
eXcell_floatec.prototype.setValue = function(val){
 val=val.replace(',','.')
 if(!val || isNaN(Number(val))){
 //alert("this vakue is not a number")
 val = 0;
}

this.cell.innerHTML = "<span style='padding-right:2px;white-space:nowrap;'>"+val+"</span>";
}

// ronowrap_ec : cellule de nombre





function eXcell_ronowrap_ec(cell){
 this.cell = cell;
 this.grid = this.cell.parentNode.grid;
 this.edit = function(){}
}
eXcell_ronowrap_ec.prototype = new eXcell;

 // FIN AJOUT  TYPE DE CELLULE EXCEL






/*********************************** TYPE HTML SANS TITLE (MC) **********************************/

function eXcell_ro_mc(cell)
{
	
	this.base = eXcell_ro;
	this.base(cell)
	this.getValue = function()
	{
		if((this.cell.childNodes.length>0)&&(this.cell.childNodes[0].innerHTML))
			return this.cell.childNodes[0].innerHTML.toString()._dhx_trim()
		return "";
	}
	
}

eXcell_ro_mc.prototype = new eXcell_ro;

eXcell_ro_mc.prototype.setValue = function(val)
{
	this.cell.innerHTML = "<span style='padding-right:2px;white-space:nowrap;'>"+val+"</span>";
}
eXcell_ro_mc.prototype.setLabel = function(val)
{
	this.cell.innerHTML = "";
}
eXcell_ro_mc.prototype.getTitle = function(){
 return ""
}
/*********************************** FIN TYPE HTML SANS LABEL (MC) **********************************/





//*****************************************************/
//  AJOUT TYPE DE CELLULE COMBO POUR GRID DANS FENETRE
//****************************************************/
 
function eXcell_combo_mc(cell){
 try{
 this.cell = cell;
 this.grid = this.cell.parentNode.grid;
 this.combo = this.grid.getCombo(this.cell._cellIndex);
 this.editable = true
}catch(er){}
 this.shiftNext=function(){

 var z=this.list.options[this.list.selectedIndex+1];
 if(z)z.selected=true;
 this.obj.value=this.list.value;

 return true;
}
 this.shiftPrev=function(){

 var z=this.list.options[this.list.selectedIndex-1];
 if(z)z.selected=true;

 this.obj.value=this.list.value;
 
 return true;
}

 this.edit = function(){
 this.val = this.getValue();
 this.text = this.cell.innerHTML._dhx_trim();
 var arPos = this.grid.getPosition(this.cell)

 
 
 this.obj = document.createElement("TEXTAREA");
 this.obj.className="dhx_combo_edit";
 this.obj.style.height=(this.cell.offsetHeight-4)+"px";

 this.obj.wrap = "soft";
 this.obj.style.textAlign = this.cell.align;
 this.obj.onclick = function(e){(e||event).cancelBubble = true}
 this.obj.value = this.text

 this.list = document.createElement("SELECT");
 this.list.editor_obj = this;
 this.list.className='dhx_combo_select';
 this.list.style.position='absolute';
 this.list.style.width=this.cell.offsetWidth+"px";
 this.list.style.left = arPos[0]-this.grid.objBox.scrollLeft+"px";
 this.list.style.top = arPos[1]+this.cell.offsetHeight-this.grid.objBox.scrollTop+"px";
 this.list.size="6";
  this.list.style.zIndex='400000';

 
 this.list.onclick = function(e){
 var ev = e||window.event;
 var cell = ev.target||ev.srcElement
 
 if(cell.tagName=="OPTION")cell=cell.parentNode;
 cell.editor_obj.setValue(cell.value);
 cell.editor_obj.editable=false;
 cell.editor_obj.detach();
}
 var comboKeys = this.combo.getKeys();
 var fl=false
 var selOptId=0;
 for(var i=0;i<comboKeys.length;i++){
 var val = this.combo.get(comboKeys[i])
 this.list.options[this.list.options.length]=new Option(val,comboKeys[i]);
 if(comboKeys[i]==this.val){
 selOptId=this.list.options.length-1;
 fl=true;
}
}

 if(fl==false){
 this.list.options[this.list.options.length]=new Option(this.text,this.val===null?"":this.val);
 selOptId=this.list.options.length-1;
}
 document.body.appendChild(this.list)
 this.cstate=1;
 if(this.editable){
 this.cell.innerHTML = "";
}
 else{
 this.obj.style.width="1px";
 this.obj.style.height="1px";
}
 this.cell.appendChild(this.obj);
 this.list.options[selOptId].selected=true;
 this.obj.focus();
 this.obj.focus();
 if(!this.editable)
 this.obj.style.visibility="hidden";
}

 this.getValue = function(){
 return((this.cell.combo_value==window.undefined)?"":this.cell.combo_value);
}
 this.getText = function(){
 return this.cell.innerHTML;
}
 this.detach = function(){
 if(this.val!=this.getValue()){
 this.cell.wasChanged = true;
 try{
	 this.grid.callEvent("onCellChanged",[this.cell.parentNode.idd,this.cell._cellIndex, this.getValue()]);
 }catch(e){}
}

 if(this.list.parentNode!=null){
 if(this.editable)
 if(this.obj.value._dhx_trim()!=this.text){
 this.setValue(this.obj.value)
}else{
 this.setValue(this.val)
}
 else
 this.setValue(this.list.value)
}
 
 if(typeof(this.grid.onEditCell)=="string")
 eval(this.grid.onEditCell+"(2,'"+this.cell.parentNode.idd+"',"+this.cell._cellIndex+");")
 else if(typeof(this.grid.onEditCell)=='function'){
 this.grid.onEditCell(2,this.cell.parentNode.idd,this.cell._cellIndex)
}
 
 if(this.list.parentNode)
 this.list.parentNode.removeChild(this.list);
 if(this.obj.parentNode)
 this.obj.parentNode.removeChild(this.obj);

 return this.val!=this.getValue();
}
}
eXcell_combo_mc.prototype = new eXcell;
eXcell_combo_mc.prototype.setValue = function(val){
 if((val||"").toString()._dhx_trim()=="")
 val=null

 if(val!==null)
 this.cell.innerHTML = this.grid.getCombo(this.cell._cellIndex).get(val)|| val;
 else
 this.cell.innerHTML="&nbsp;";

 this.cell.combo_value = val;
}
 
function eXcell_combo_mc_ro(cell){
 this.base = eXcell_combo_mc;
 this.base(cell)
 this.editable = false;
}
eXcell_combo_mc_ro.prototype = new eXcell_combo_mc;

//*****************************************************/
//  FIN AJOUT TYPE DE CELLULE COMBO POUR GRID DANS FENETRE
//****************************************************/








/*********************************** TYPE COULEUR AVEC LAB **********************************/
function eXcell_lab_mc(cell)
{
	this.base = eXcell_ro;
	this.base(cell)
	this.getValue = function() {
		if((this.cell.childNodes.length>0)&&(this.cell.childNodes[0].innerHTML))
			return this.cell.childNodes[0].innerHTML.toString()._dhx_trim()
		return "";
	}
}

eXcell_lab_mc.prototype = new eXcell_ro;
eXcell_lab_mc.prototype.setValue = function(val)
{
	var l= val.split("::")[0];
	var a= val.split("::")[1];
	var b= val.split("::")[2];
	var color = LABtoHEXA_2 (l,a,b);
	if ((val !='')&&(val !='::::::')&&(color!='#'))
		this.cell.innerHTML = "<div style='width:100%;height:"+(this.cell.offsetHeight-2)+";background-color:"+(color||"")+";border:0px;'>&nbsp;</div>";//this.setBgColor(val)
	else
		this.cell.innerHTML = "<div style='width:100%;height:"+(this.cell.offsetHeight-2)+";border:0px;'><center><img src='/common/img/forbidden.gif'></center></div>";//this.setBgColor(val)
	
	
}
eXcell_lab_mc.prototype.setLabel = function(val)
{
	this.cell.innerHTML = "";
}
eXcell_lab_mc.prototype.getTitle = function(){
return ""
}
/*********************************** FIN TYPE COULEUR AVEC LAB **********************************/

