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

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


// extends egList, egContainer
class egDropDownPropertyList extends egList {
	var $containersList;
	// for compatibilty with egContainer class
	var $objectsList;

	var $selectionType;
	var $value;

	function egDropDownPropertyList($id, $title, $posX, $posY, $width, $height=0) {
		parent::egList($id, $title, $posX, $posY, $width, $height);
		$this->containersList = array();
		$this->objectsList = array();
		$this->selectionType = 'INDEX'; // INDEX, LABEL
		$this->value = 0;
	}

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

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

	function addItem(&$page) {
		$this->addListItem($page);
	}

	function isContainer() {
    return true;
  }

	function getClassName() {
    return 'egDropDownPropertyList';
  }

	function getContainerName() {
		return $this->id;
	}

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

	function addContainer(&$container) {
		if (is_object($container)) {
			$this->containersList[$container->getId()] = &$container;
		}
	}

  function getHTML($container = null) {
		$html = "var dropDownPropertyList_{$this->id} = new egDropDownPropertyList('{$this->id}', '{$this->posX}', '{$this->posY}', '{$this->width}', '{$this->height}', '{$container}', '{$this->value}', '{$this->selectionType}');";

		foreach($this->itemsList as $id => $page) {
			$html .= "dropDownPropertyList_{$this->id}.addListItem('".$page->getTitle()."', '".$page->getContainer()."', '".$page->getAction()."');";
		}

		return $html;
  }

	/**
 	 *
	 *  @static
	 */
  function getScriptsFiles() {
    $scriptsArray = array();
    $scriptsArray[ALL] = "egDropDownPropertyList_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;
  }
}
?>