<?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="dragDrop.xml"/>
	<include src="resimage.xml"/>

	<composition name="cOverComp">
		<composition name="imNormal" class="CResizablePaper"/>
		<composition name="imOver" class="CResizablePaper" depth="-1"/>
		<composition name="imSelect" class="CResizablePaper" depth="-1"/>
		<script>
			this.srcArr = null;
		</script>
		<script>
			function init(w,h)
				{
					imNormal.visible = true;
					imNormal.init(this.srcArr[0], 1, 1, 1, 1);
					imOver.init(this.srcArr[1], 1, 1, 1, 1);
					imSelect.init(this.srcArr[2], 1, 1, 1, 1);
					imNormal.resize(w,h);
					imOver.resize(w,h);
					imSelect.resize(w,h);
					imOver.hide();
					imSelect.hide();
					this.onRollOver = function()
						{
							this.imOver.visible = true;
						}
					this.onRollOut = function()
						{
							this.imOver.visible = false;
							this.imSelected.visible = false;
						}
					this.onRelease = function()
						{
							this.imSelected.visible = true;
						}
				}
			function rollOver()
				{
					this.imOver.show();
				}
			function rollOut()
				{
					imOver.hide();
				}
		</script>
	</composition>

 	<composition name="cItemCell" enabled="true">
		<composition name="fon" class="cOverComp" depth="0">
			<script>
				this.srcArr = new Array ("rmgr:fConstruct/table/stNormal.png","rmgr:fConstruct/table/stOver.png","rmgr:fConstruct/table/stSelect.png");
			</script>
		</composition>
		<text name="txCaption" depth="-10"/>
	</composition>

	<composition name="cItemRow" visible="true" enabled="true">
		<script>
			this.data = null;
	 		this.cells = new Array();
			this.overed = false;
		</script>
		<script event="onRelease"><![CDATA[
			trace("onRelease");
			if (this.parent.curRow!=this)
				{
					if (this.parent.curRow!=null)
						{
							for (var i=0; i<this.parent.curRow.cells.length; i++)
								{
									this.parent.curRow.cells[i].txCaption.style = this.parent.stNormal;
									this.parent.curRow.cells[i].fon.fireEvent("onRollOut");
								}
							this.overed = true;
						}
					this.parent.curRow = this;
					for (var i=0; i<this.cells.length; i++)
						{
							this.cells[i].txCaption.style = this.parent.stSelected;
							this.cells[i].fon.fireEvent("onRelease");
						}
				}
		]]></script>
		<script event="onRollOver"><![CDATA[
			if (!this.overed&&this.parent.curRow!=this)
				{
					this.overed = true;
					for (var i=0; i<this.cells.length; i++)
						{
								this.cells[i].txCaption.style = parent.stOvered;
								this.cells[i].fon.fireEvent("onRollOver");
						}
				}
		]]></script>
		<script event="onRollOut"><![CDATA[
			if (this.overed&&this.parent.curRow!=this)
				{
					this.overed = false;
					for (var i=0; i<this.cells.length; i++)
						{
								this.cells[i].txCaption.style = parent.stNormal;
								this.cells[i].fon.fireEvent("onRollOut");
						}
				}
		]]></script>
		<script><![CDATA[
			function addCells(arrCells)
				{
					var w=0
					var h=0;
					for (var i=0; i<arrCells.length; i++)
						{
							var newCell = new Composition();
							newCell._class ="cItemCell";
							newCell.name = "cell_"+i;
							newCell.parent = this;
							newCell.txCaption.style = this.parent.stNormal;
							newCell.txCaption.value = arrCells[i];
							if (i!=0) newCell.txCaption.visible = false;
							newCell.txCaption.x = parent.paddingX;
							newCell.txCaption.y = parent.paddingY;
							this.arrStyles = parent.stNormal;
							this.cells.push(newCell);
						}
				}
		]]></script>
	</composition>

	<composition name="cTableBase" visible="false" enabled="true">
		<styles name="stNormal" fontFamily="Arial" fontSize="20" color="#FF0000"/>
		<styles name="stOvered" fontFamily="Arial" fontSize="20" color="#00FF00"/>
		<styles name="stSelected" fontFamily="Arial" fontSize="20" color="#0000FF"/>

		<script><![CDATA[
			this.rows = new Array();
			this.padding = 2;
			this.paddingX = 4;
			this.paddingY = 2;
			this.curRow = null;
			this.rowsHeight = new Array();
			this.cellsWidth = new Array(400,300);

			function init(arrRows)
			{
				addRows(arrRows);
								var setHeight = false;
				var setWidth = false;
				if (this.cellsWidth.length != 0)
					setSize(true,false);
				else
					setSize(true,true);
				this.visible = true;
			}

			function addRows(arrRows)
			{
 				for (var i=0; i<arrRows.length; i++)
 					{
 						var newRow = new Composition();
 						newRow._class = "cItemRow";
 						newRow.name = "row_" +i;
 						newRow.parent = this;
 						newRow.addCells(arrRows[i]);
 						this.rows.push(newRow);
 					}
			}

			function setSize(setHeight,setWidth)
			{
				if (setHeight||setWidth)
					{
						for (var i=0; i< this.rows.length; i++)
							{
								var row =this.rows[i];
								for (var j=0; j< row.cells.length; j++)
									{
										var cell = row.cells[j];
										if (setWidth)
											{
												var w = cell.txCaption.getMediaSize().width + 2*this.paddingX;
												if (this.cellsWidth.length<=j)
													this.cellsWidth[j] =w ;
												else
													if (this.cellsWidth[j]<w)
														this.cellsWidth[j]=w;
											}
										if (setHeight)
											{
												var h = cell.txCaption.getMediaSize().height + 2*this.paddingY;
												if (this.rowsHeight.length<=i)
													this.rowsHeight[i] =h ;
												else
													if (this.rowsHeight[i] < h)
														this.rowsHeight[i] =h;
											}
									}
							}

						for (var i=0; i< this.rows.length; i++)
							{
								var row =this.rows[i];
								var x = 0;
								for (var j=0; j< row.cells.length; j++)
									{
										var cell = row.cells[j];
										cell.fon.init(this.cellsWidth[j],this.rowsHeight[i]);
										if (j!=0) cell.x = row.cells[j-1].x +this.cellsWidth[j-1] - 1;
									}
								if (i!=0) row.y = this.rows[i-1].y +this.rowsHeight[i-1] - 1;
							}

					}
			}

		]]></script>
	</composition>



</rmml>
