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

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


class egContainer extends egWindow {
	var $containersList;
    var $objectsList;

    var $style;
    var $isShown;

    function egContainer($id, $posX = 0, $posY = 0, $width = 0, $height = 0, $isShown = false) {
        parent::egWindow($id, "", $posX, $posY, $width, $height);
        $this->containersList = array();
        $this->objectsList = array();
        $this->isShown = $isShown;
    }

    function isContainer() {
		return true;
    }

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

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

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

    function addObject(&$object) {
        if (is_object($object)) {
            $this->objectsList[$object->getClassName()."_".$object->getId()] = &$object;
			if($object->isContainer()) {
				$this->addContainer($object);
			}
        }
    }

    function getContainerHTML($container = null) {
		$html = "var container_{$this->id} = new egContainer('{$this->id}', '{$this->posX}', '{$this->posY}', '{$this->width}', '{$this->height}', '{$container}', '{$this->isShown}');";
		return $html;
	}

    function getStyle() {
		return $this->style;
    }

    function setStyle($style) {
		$this->style = $style;
    }
}
?>