<?xml version="1.0" encoding="UTF-8"?>
<rmml>
<!--
$RCSfile: rnmc_controls.xml,v $
$Revision: 957 $

last change: $Date: 2009-02-17 14:00:06 +0300 (Вт, 17 фев 2009) $
             $Author: toha $

	Lacerta Project
	version 1.0.0.1
	Copyright (C) 2007-2009 RNMC
-->
<composition name="rnmc_stdControlGroup" class="rnmc_stdMediaGroup">
<script><![CDATA[
	this.id = null;
	this.type = "stdControlGroup"
	

	this.dispatchObject = null;
	this.dispatchFunction = null;

	this.childControls = null;

	function initFromNode(srcNode){
//trace("rnmc_stdControlGroup.initFromNode");
		var xmlNode = null;
		var xmlAttributeMap = null;
		var xmlAttribute = null;

		xmlAttributeMap = srcNode.attributes;
		if (xmlAttributeMap){
			xmlAttribute =  xmlAttributeMap.getNamedItem("id");
			if (xmlAttribute != null && xmlAttribute.specified)
				this.id = xmlAttribute.value;
			xmlAttribute =  xmlAttributeMap.getNamedItem("restrictions");
			if (xmlAttribute != null && xmlAttribute.specified){
				switch((xmlAttribute.value).toLowerCase()){
				case "exclusive_visible":
					this.watchRestriction = RESTRICTION_EXCLUSIVE_VISIBLE;
 					break;
				case "exclusive_pressed":
					this.watchRestriction = RESTRICTION_EXCLUSIVE_PRESSED;
					break;
				}
			}
		}
		this.loadChildsObject(srcNode);
	}

	function loadChildsObject(srcNode){
		if (!srcNode)
			return false;

		if (this.childObjects == null)
			this.childObjects = new Array();

		xmlNode = srcNode.firstChild;
		while(xmlNode){
			if(xmlNode.nodeName == "playcontrol"){
				var newCtrl = scene.Utils.initStdPlaycontrolFromNode(xmlNode, this);
				if(newCtrl)
					this.childObjects.push(newCtrl);
			} else {
				var newObject = scene.Utils.initStdObjectFromNode(xmlNode, this);
				if(newObject)
					this.childObjects.push(newObject);
			}
/*
			} else if(xmlNode.nodeName == "group"){
				//var newCtrl = scene.Utils.initStdControlGroupFromNode(xmlNode, this);
				var newCtrl = scene.Utils.initStdMediaGroupFromNode(xmlNode, this);
				if(newCtrl){
					this.childObjects.push(newCtrl);
				}
*/
			xmlNode = xmlNode.nextSibling;
		};
		return true;	
	}
	
	
//	показывает группу
	function showObject(){
		for(var i = 0; i < this.childObjects.length; i++){
			if(this.childObjects[i].visibility == OBJECT_VISIBILITY_TRUE){
				this.childObjects[i].showObject();
			}
		}
		this.visible = true;
	}
	
	function hideObject(){
		this.visible = false;
	}


//	устанавливает объект и функцию-диспетчер
	function setDispatcher(targetObject, targetFunction){
		for(var i = 0; i <  this.childObjects.length; i++){
			if(this.childObjects[i].type == "rnmc_stdButton")
				this.childObjects[i].setReleaseCallBack(targetObject, targetFunction);
		}
	}

//	обнуляет объект и функцию-диспетчер
	function clearDispatcher(){
		for(var i = 0; i <  this.childObjects.length; i++){
			if(this.childObjects[i].type == "rnmc_stdButton")
				this.childObjects[i].clearReleaseCallBack();
		}
	}


//	============= Работа  с дочерними элементами =======================
//	показывает дочерний элемент с некоторым id
	function showChildControl(objectId){
		for(var i = 0; i < this.childObjects.length; i++){
			if(objectId && this.childObjects[i].id == objectId)
				this.childObjects[i].showObject();
		}
	}

	function hideChildControl(objectId){
		for(var i = 0; i < this.childObjects.length; i++){
			if(objectId && this.childObjects[i].id == objectId)
				this.childObjects[i].hideObject();
		}
	}

	// получение контрола с заданным именем
	function getChildControl(objectId){
		for(var i = 0; i <  this.childObjects.length; i++){
			if(this.childObjects[i].type && this.childObjects[i].type == "stdControlGroup"){
				return this.childObjects[i].getChildControl(objectId);
			} else {
				if(objectId && this.childObjects[i].id == objectId)
					return this.childObjects[i];
			}
		}
		return null;
	}
]]></script>
</composition>
</rmml>