<?xml version="1.0" encoding="UTF-8"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<!-- Композиция одного элемента: C, N, O -->
	<composition name="CCycleElement" depth="0" class="CKMButton">
		<include src="styles.xml"/>
		<image _name="img" src="rmgr:molconst2d/btnCNO.png"/>
		<image name="oText" class="CHintImage" x="7" y="4">
			<script event="onPress">
				this.parent.handleOnPress();
			</script>
			<script event="onRelease">
				this.parent.handleOnRelease();
			</script>
			<script event="onReleaseOutside">
				this.parent.handleOnRelease();
			</script>
			<script event="onMouseUp">
				this.parent.handleOnMouseUp();
			</script>
		</image>
		<script>
			this.oText.hint = "Перетащите элемент на рабочее поле для создания новой молекулы";
		</script>
		<!-- Композиция таскаемого элемента: C, N, O -->
		<composition name="dragElement" _class="CDraggableComposition" visible="false" enabled="false">
			<image name="oText"/>
		</composition>
		<script>
			this.type="6";
			this.externalSelection = null;
			this.workspace=null;
			this.btnPrefix = "btnC";
			this.typePrefix = "C:";
			function setType(atype)
			{
				this.oText.src = "rmgr:molconst2d/"+this.btnPrefix+atype+".png";
				this.oText.x = (this.img.getMediaSize().width/4-this.oText.getMediaSize().width)/2;
				this.oText.y = (this.img.getMediaSize().height-this.oText.getMediaSize().height)/2;

				this.dragElement.oText.src = "rmgr:molconst2d/"+this.btnPrefix+atype+".png";
				this.type = this.typePrefix+atype;
			}
			function handleOnPress()
			{
				this.dragElement.x = this.xMouse  + 20;
				this.dragElement.y = this.yMouse  + 5;
				seqShowDragElement.rewindAndPlay();
				seqShowSelection.rewindAndPlay();
				this.dragElement.stick( true);
				if( this.workspace != null)
				{
					this.workspace.handleDragElementPress( this);
				}
				CKMButton_handleOnPress();
				CKMButton_handleOnRelease();
			}
			function handleOnRelease()
			{
				seqShowDragElement.stop();
				seqShowSelection.stop();
				trace("#0000FF visible=false this.type="+this.type);
				this.dragElement.visible = false;
				this.dragElement.stick( false);
				if( this.workspace != null)
				{
					if( this.externalSelection==null || !this.externalSelection.visible)
						this.workspace.handleDragElementRelease( this);
				}
			}
			function handleOnMouseUp()
			{
				if( this.dragElement.visible)
				{
					this.dragElement.visible = false;
					this.dragElement.stick( false);
				}
			}
		</script>
		<sequencer name="seqShowDragElement">
			<script>
				200;
			</script>
			<script>
				trace("#0000FF visible=true this.type="+this.type);
				this.dragElement.visible = true;
			</script>
		</sequencer>

		<sequencer name="seqShowSelection">
			<script>
				500;
			</script>
			<script><![CDATA[
				//trace("externalSelection="+this.externalSelection);
				if( !(this.xMouse<0 || this.yMouse<0 || this.xMouse>this.img.getMediaSize().width/4 || this.yMouse>this.img.getMediaSize().height))
				{
					if( this.externalSelection != null)
					{
						this.externalSelection.show_sel();
					}
				}
			]]></script>
		</sequencer>
	</composition>

	<!-- Композиция одного элемента с выпадающим списком -->
	<composition name="CMultiElement" class="CCycleElement">
		<image _name="img" src="rmgr:molconst2d/btnCNOWithSel.png"/>
		<image _name="btnSel" src="rmgr:molconst2d/btnForSel.png" x="30" y="9" depth="-1">
			<script event="onPress">
				if( this.parent.externalSelection != null)
				{
					this.parent.externalSelection.show_sel();
				}
			</script>
		</image>
	</composition>
</rmml>