<?xml version="1.0" encoding="Win-1251"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<!-- описание сцены -->
	<include src="workplace.xml"/>
	<include src="ListFormulaComp.xml"/>
	<include src="DragDrop.xml"/>
	<include src="TaskAnswers.xml"/>
	<include src="chemEditor.xml"/>
	<include src="chemEqualPanel.xml"/>
	<composition name="CChemCalc" depth="-1" userEvents="editEqual">
		<composition name="oDragDrop" class="CDragDrop"/>
		<image name="background" src="fon.png"/>
		<script src="Tools.mjs"/>
		<script src="BaseOperation.mjs"/>
		<script src="StepenOperation.mjs"/>
		<script src="Expression.mjs"/>
		<script src="Formula.mjs"/>
		<script src="FormulaVariant.mjs"/>
		<script src="FormulaList.mjs"/>
		<composition name="chemEditor" class="CChemEditor" depth="-500" visible="false"/>
		<sequencer name="equalEditing" playing="true" loop="true">
			<script>
				"editEqual";
			</script>
			<script>
				this.chemEditor.openEditor( Event.chemPanel);
			</script>
		</sequencer>
		<composition name="btnAddEqualPanel" class="CTextButton" x="0" y="0" depth="-50" enabled="true">
			<text name="txCaption" value="Добавить уравнение реакции"/>
			<script><![CDATA[
				this.init(4, [stEdit, stEdit, stEdit, stEdit]);
			]]></script>
		</composition>
		<script>
			this.priority = new Object();
			this.priority["="] = 0;
			this.priority["-"] = 2; // унарный минус
			this.priority["lg"] = 2;
			this.priority["+"] = 2;
			this.priority["-"] = 2;
			this.priority["·"] = 3;
			this.priority["*"] = 3;
			this.oListDataComp = null;
			this.oListOriginalDataComp = null;
			this.oListTemporaryDataComp = null;
			this.oListFormulaComp = null;
			this.oFormulaDataList = null;
		</script>
		<script><![CDATA[
			function loadTask(filename)
			{
				var id = 1;
				if (this.oListOriginalDataComp!=null)
				{
					this.oListOriginalDataComp.parent = null;
					this.oListOriginalDataComp = null;
				}
				this.oListOriginalDataComp = new Composition();
				this.oListOriginalDataComp._class = "CListDataComp";
				this.oListOriginalDataComp.parent = this;
				this.oListOriginalDataComp.width = this.oListOriginalDataComp.getMediaSize().width;
				this.oListOriginalDataComp.height = this.oListOriginalDataComp.getMediaSize().height;
				this.oListOriginalDataComp.linewidth = 25;
				this.oListOriginalDataComp.padding = 42;//38;

				if (this.oWorkPlace==null)
				{
					this.oWorkPlace = new Composition();
					this.oWorkPlace._class = "CWorkPlace";
					this.oWorkPlace.parent = this;
					this.oWorkPlace.x = 265;
					this.oWorkPlace.y = 158;
				}
				this.oWorkPlace.Clear();

				this.oFormulaList = new CFormulaList();

				var	xml = new XML();
				xml.src = getFullPath(filename);
				var XMLF = xml.XMLDocument.firstChild.childNodes;
				var len = XMLF.length;
				for (var i=0; i<len; i++)
				{
					var child = XMLF.item(i);

					if (child.nodeName=="tasktext")
					{
						if (this.oTaskText==null)
						{
							this.oTaskText = new Composition();
							this.oTaskText._class = "CTaskText";
							this.oTaskText.parent = this;
							this.oTaskText.x = 265;
							this.oTaskText.y = 5;
						}
						this.oTaskText.loadTask(child, id);
					}
					else if (child.nodeName=="data")
					{
						if (this.oFormulaDataList!=null)
						{
							this.oFormulaDataList == null;
						}
						this.oFormulaDataList = new CFormulaDataList();
						this.oFormulaDataList.Create(child);
					}
					else if (child.nodeName=="answers")
					{
						if (this.oAnswerList==null)
						{
							this.oAnswerList = new Composition();
							this.oAnswerList._class = "CAnswerList";
							this.oAnswerList.parent = this;
							this.oAnswerList.width = this.oAnswerList.getMediaSize().width;
							this.oAnswerList.height = this.oAnswerList.getMediaSize().height;
						}
						this.oAnswerList.Create(child);
						this.oAnswerList.width = this.oAnswerList.getMediaSize().width;
						this.oAnswerList.height = this.oAnswerList.getMediaSize().height;
					}
					else if (child.nodeName=="formulaList")
						this.oFormulaList.Create( child);
					else if (child.nodeName=="chemEquals")
					{
						var dataFile = ":\\" + child.getAttribute( 'data');
						if (resourceExists( dataFile))
						{
							this.chemEditor.initEditor( Player.module.extract( getFullPath( dataFile)));
							var equals = child.getAttribute( 'equals');
							if (equals == null)
								equals = 1;
							equals = Number( equals);
							for (var j = 0;  j < equals;  j++)
							{
								var panel = new Composition();
								panel._class = 'CChemEqualPanel';
								panel.name = 'chemEqualPanel' + j;
								panel.x = 262;
								panel.y = 117 + 55 * j;
								panel.depth = -50;
								panel.parent = this;
							}
						}
					}
				}

				if (this.oListFormulaComp==null)
				{
					this.oListFormulaComp = new Composition();
					this.oListFormulaComp._class = "CListFormulaComp";
					this.oListFormulaComp.parent = this;
					this.oListFormulaComp.width = this.oListFormulaComp.getMediaSize().width;
					this.oListFormulaComp.height = this.oListFormulaComp.getMediaSize().height;
					this.oListFormulaComp.x = 2;
					this.oListFormulaComp.y = 271;
					this.oListFormulaComp.Width = 255;
					this.oListFormulaComp.Height = 314;
				}
				this.oListFormulaComp.Reset(this.oFormulaList);
				this.oListFormulaComp.Init();

				this.oListOriginalDataComp.x = 2;
				this.oListOriginalDataComp.y = 20;
				this.oListOriginalDataComp.Width = 255;
				this.oListOriginalDataComp.Height = 215;
				this.oListOriginalDataComp.Reset(this.oFormulaDataList);
				this.oListOriginalDataComp.ShowFormulaList();

				this.oListOriginalDataComp.Init();

				if (this.oListTemporaryDataComp==null)
				{
					this.oListTemporaryDataComp = new Composition();
					this.oListTemporaryDataComp._class = "CListDataComp";
					this.oListTemporaryDataComp.parent = this;
					this.oListTemporaryDataComp.width = this.oListTemporaryDataComp.getMediaSize().width;
					this.oListTemporaryDataComp.height = this.oListTemporaryDataComp.getMediaSize().height;

					this.oListTemporaryDataComp.x = 900;
					this.oListTemporaryDataComp.y = 149;
					this.oListTemporaryDataComp.numberFormulsOnPage = 5; // кол-во формул на странице
					this.oListTemporaryDataComp.ImTempData = new Button();
					this.oListTemporaryDataComp.ImTempData.hitArea = "[0, 0, 175, 430]";
					this.oListTemporaryDataComp.ImTempData.parent = this.oListTemporaryDataComp;
					this.oListTemporaryDataComp.ImTempData.x = 0;
					this.oListTemporaryDataComp.ImTempData.y = 0;
					this.oListTemporaryDataComp.Width = 120;
					this.oListTemporaryDataComp.Height = 435;
					this.oListTemporaryDataComp.oFormulaData = null;
					this.oListTemporaryDataComp.linewidth = 25;
					this.oListTemporaryDataComp.padding = 48;

					this.oListTemporaryDataComp.ImTempData.onRollOver=function()
					{
						if (this.parent!=null)
						{
							this.parent.parent.oDragDrop.targetObject = this.parent;
						}
					}
					this.oListTemporaryDataComp.ImTempData.onRollOut = function()
					{
						this.parent.parent.oDragDrop.targetObject = null;
					}
					this.oListTemporaryDataComp.onDroppedIn = function()
					{
						var _b=0;
						if ((this.parent.oDragDrop.DragObject.Name == "FormulaData")||(this.parent.oDragDrop.DragObject.Name == "FormulaList"))
						{
							return;
						}
						for (var i = 0; i<this.numberFormuls; i++)
						{
							if ((scene.oChemCalc.oWorkPlace.oFormula.left==this.oFormulaComp[i].oFormula.left)
								&&(scene.oChemCalc.oWorkPlace.oFormula.value==this.oFormulaComp[i].oFormula.value))
							{
								_b=1;
								break;
							}
						}
						if (_b==0)
						{
							this.oFormulaData = new CFormulaData();
							this.oFormulaData.left = scene.oChemCalc.oWorkPlace.oFormula.left;
							this.oFormulaData.type = scene.oChemCalc.oWorkPlace.oFormula.type;
							this.oFormulaData.oExpression = null;
							this.oFormulaData.value = scene.oChemCalc.oWorkPlace.oFormula.value;
							trace("Chemcalc oListTemporaryDataComp oFormulaData Value "+this.oFormulaData.value);
							this.addFormula();

							this.oFormulaComp[this.numberFormuls-1].x = this.parent.oDragDrop.dragImage.x - this.x;
							this.oFormulaComp[this.numberFormuls-1].y = this.parent.oDragDrop.dragImage.y - this.y;
							this.oFormulaComp[this.numberFormuls-1].depth = 0;
							this.oFormulaComp[this.numberFormuls-1].Reset();
						}
						this.ShowFormulaList();
					}
				}

				this.oListTemporaryDataComp.Init();
			}

			function LoadTextTask(filename)
			{
				var text = " ";
				var xml = new XML();
				xml.src = filename;
				var XMLF = xml.XMLDocument.firstChild.childNodes;
				var len = XMLF.length;
				for (var i=0; i<len; i++)
				{
					var child = XMLF.item(i);
					if (child.nodeName=="tasktext")
					{
						text = getXMLText(child);
						break;
					}
				}
				this.xml = null;
				return text;
			}
			]]></script>
	</composition>
	<!--<scene >
		<script>
			this.oChemCalc = new Composition();
			this.oChemCalc._class = "CChemCalc";
			this.oChemCalc.parent = scene;
			this.oChemCalc.loadTask("../../chemvuz/tasks/tasks/task01.xml");
		</script>
		<script>
		</script>
	</scene>-->
</rmml>
