<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by alex (mmlab) -->
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<include src="dragcomp.xml"/>
	<include src="imhint.xml"/>
	<composition _name="CLenseWindow" _class="CDraggableComposition" _depth="-240">
			<script >
				this.minW = 256;
				this.maxW = 512;
				this.minH = 64;
				this.maxH = 384;
				this.hotKey = 0;
			</script>
			<image _name="imFrame" src="empty" _width="256" _height="192" enabled="true" >
				<plugin _name="chem3drnd" src="rmeq:dlls\chem3drnd.dll"/>
				<script>
					this.zoom = 2;
					this.xmouse = 0;
					this.ymouse = 0;
					this.rbdown = false;
					this.resized = false;
					this.resizeLastX = 0;
					this.resizeLastY = 0;
				</script>
				<script event="onRMouseDown" ><![CDATA[
					this.rbdown = true;
					this.resized = false;
					this.resizeLastX = scene.xMouse;
					this.resizeLastY = scene.yMouse;
				]]></script>
				<script event="onRMouseUp" ><![CDATA[
					if( !this.resized)
					{
						this.zoom *= 2;
						if( this.zoom > 8)	this.zoom = 2;
					}
					this.rbdown = false;
				]]></script>
			</image> 
			<script event="onMouseMove"><![CDATA[
				if( this.imFrame.rbdown)
				{
					this.imFrame.resized = true;
					var dx = scene.xMouse - this.imFrame.resizeLastX;
					var dy = scene.yMouse - this.imFrame.resizeLastY;
					
					var nw =this.imFrame._width + dx;
					var nh =this.imFrame._height + dy;
					
					if( nw < this.minW)	nw = this.minW;
					if( nw > this.maxW)	nw = this.maxW;
					if( nh < this.minH)	nh = this.minH;
					if( nh > this.maxH)	nh = this.maxH;
					//
					if( this._x + nw >= 800)	nw = 800 - this._x;
					if( this._y + nh >= 600)	nh = 600 - this._y;
					//
					resize(nw,nh);
					this.imFrame.resizeLastX = scene.xMouse;
					this.imFrame.resizeLastY = scene.yMouse;
				}

				this.imFrame.xmouse = scene.xMouse;
				this.imFrame.ymouse = scene.yMouse;
				
				var	semiw = imFrame.width/2/this.imFrame.zoom;
				var	semih = imFrame.height/2/this.imFrame.zoom;
				
				if(this.imFrame.xmouse < semiw)
				{
					this.imFrame.xmouse = semiw;
				}
				if(this.imFrame.xmouse > 800-semiw)
				{
					this.imFrame.xmouse = 800-semiw;
				}
				if(this.imFrame.ymouse < semih)
				{
					this.imFrame.ymouse = semih;
				}
				if(this.imFrame.ymouse > 600-semih)	this.imFrame.ymouse = 600-semih;
			]]></script>
			<image _name="btop" src="rmgr:lense\frame.png" _depth="-2" />
			<image _name="bbottom" src="rmgr:lense\frame.png" _depth="-2"/>
			<image _name="bleft" src="rmgr:lense\frame.png" _depth="-2"/>
			<image _name="bright" src="rmgr:lense\frame.png" _depth="-2"/>
			<!--<image _name="icursor" src="rmgr:lense\cursor.png" _depth="-1"/>-->
			<script><![CDATA[
				this.acceptMoveBy = function(dx, dy)
				{
					var obj = new Object;
					obj.x = dx;
					obj.y = dy;
					if( this._x + this.imFrame._width + dx > 800)
						obj.x = 800 - (this._x + this.imFrame._width);
					if( this._x + dx < 0)
						obj.x = -this._x;
					if( this._y + this.imFrame._height + dy > 600)
						obj.y = 600 - (this._y + this.imFrame._height);
					if( this._y + dy < 0)	
						obj.y = -this._y;
					return obj;
				}
				
				function	resize(w, h)
				{
					btop.crop(0,0,16,1);	btop._width = w;
					bleft.crop(0,0,1,16);	bleft._height = h;
					bbottom.crop(0,15,16,1);	bbottom._width = w;	btop._y = h-1;
					bright.crop(15,0,1,16);	bright._height = h;	bright._x = w-1;
					imFrame._width = w;
					imFrame._height = h;
				}
				this.resize(256, 192);
				this.addHotspot(this.imFrame);
			]]></script>
	</composition>
	
	<composition _name="CLense">
		<composition _name="lense" _class="CLenseWindow" _visible="false" >
		</composition>
		<image _name="lenseicon" src="rmgr:lense\icon.png" _x="16" _y="540" class="CHintImage">
			<script>
				this.hint="Линза";
			</script>
			<script event="onPress">
				parent.lense._visible = !parent.lense._visible;
			</script>
		</image>
		<script>
			Key.addListener( this);
		</script>
		<script event="onKeyDown">
			if( Key.getAscii() == this.hotKey)
			{
				fireEvent("lenseicon.onPress");
			}
		</script>
	</composition>
</rmml>
