<?php
defined('ROOT_DIR') or die(__FILE__.' requires egConfig.inc.php');

include_once(ROOT_DIR.'egList.class.php');

class egDropDownListBox extends egList {

	var $name;
	var $value;
	var $selectionType;
	
	function egDropDownListBox($id, $posX, $posY, $width, $height=0, $name = "", $value = null) {
		parent::egList($id, null, $posX, $posY, $width, $height);
		$this->name = $name;
		$this->value = $value;
		$this->selectionType = 'INDEX'; // VALUE, INDEX, LABEL
	}

	function getClassName() {
        return 'egDropDownListBox';
  }

  function getContainerHTML($container = null) {
		$html = "";
		return $html;
  }

	function setSelectedItemByIndex($index) {
		$this->selectionType = 'INDEX';
		$this->value = $index;
	}

	function setSelectedItemByValue($value) {
		$this->selectionType = 'VALUE';
		$this->value = $value;
	}

	function setSelectedItemByLabel($label) {
		$this->selectionType = 'LABEL';
		$this->value = $label;
	}

  function getHTML($container = null) {
		$html = "var dropDownListBox_{$this->id} = new egDropDownListBox('{$this->id}', '{$this->posX}', '{$this->posY}', '{$this->width}', '{$this->height}', '{$container}', '{$this->name}', '{$this->value}', '{$this->selectionType}');";
		$html .= "egObjectsArray['dropDownListBox_{$this->id}'] = dropDownListBox_{$this->id};";

		foreach($this->itemsList as $id => $item) {
			$html .= "dropDownListBox_{$this->id}.addListItem('".$item->getTitle()."', '".$item->getValue()."', '".$item->getAction()."');";
		}

		return $html;
  }

	/**
 	 *
	 *  @static
	 */
  function getScriptsFiles() {
    $scriptsArray = array();
    $scriptsArray[ALL] = "egDropDownListBox_default.js";
    return $scriptsArray;
  }

	/**
 	 *
	 *  @static
	 */
  function getStylesFiles() {
    $stylesArray = array();
    $stylesArray[ALL] = "egDropDownListBox_default.css";

    $stylesArray[INTERNET_EXPLORER] = array();

    $stylesArray[INTERNET_EXPLORER][ALL] = "egDropDownListBox_ie60.css";

    $stylesArray[INTERNET_EXPLORER]['6'] = array();
    $stylesArray[INTERNET_EXPLORER]['6'][ALL] = "egDropDownListBox_ie60.css";

    $stylesArray[INTERNET_EXPLORER]['7'] = array();
    $stylesArray[INTERNET_EXPLORER]['7'][ALL] = "egDropDownListBox_ie60.css";


    $stylesArray[FIREFOX] = array();

    $stylesArray[FIREFOX][ALL] = "egDropDownListBox_default.css";

    $stylesArray[FIREFOX]['1'] = array();
    $stylesArray[FIREFOX]['1'][ALL] = "egDropDownListBox_default.css";
    $stylesArray[FIREFOX]['1']['5'] = "egDropDownListBox_default.css";

    $stylesArray[FIREFOX]['2'] = array();
    $stylesArray[FIREFOX]['2'][ALL] = "egDropDownListBox_default.css";


    return $stylesArray;
  }
}

?>