PageRenderTime 29ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/test/src/mouse/MouseTests.hx

http://github.com/silexlabs/Cocktail
Haxe | 109 lines | 66 code | 25 blank | 18 comment | 0 complexity | 110d5e6601762625161378f8ebdfb82f MD5 | raw file
  1/*
  2This file is part of Silex - see http://projects.silexlabs.org/?/silex
  3
  4Silex is Š 2010-2011 Silex Labs and is released under the GPL License:
  5
  6This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 
  7
  8This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9
 10To read the license please visit http://www.gnu.org/copyleft/gpl.html
 11*/
 12
 13package mouse;
 14
 15/**
 16 * Units tests for mouse events
 17 * @author Yannick DOMINGUEZ
 18 */
 19
 20import haxe.Log;
 21import cocktail.domElement.abstract.AbstractDOMElement;
 22import cocktail.domElement.DOMElement;
 23import cocktail.domElement.ImageDOMElement;
 24import cocktail.resource.ResourceLoaderManager;
 25import utest.Assert;
 26import utest.Runner;
 27import utest.ui.Report;
 28import utest.ui.common.HeaderDisplayMode;
 29import cocktail.domElement.DOMElementData;
 30import cocktail.domElement.GraphicDOMElement;
 31import cocktail.mouse.Mouse;
 32import cocktail.nativeElement.NativeElementManager;
 33import cocktail.nativeElement.NativeElementData;
 34import cocktail.mouse.MouseData;
 35
 36class MouseTests 
 37{
 38	
 39	public static function main()
 40	{
 41		new MouseTests();
 42	}
 43	
 44	public function new() 
 45	{
 46		
 47		var stageDOMElement:DOMElement = new DOMElement(NativeElementManager.getRoot());
 48		
 49		var graphicDOMElement:GraphicDOMElement = new GraphicDOMElement(NativeElementManager.createNativeElement(graphic));
 50		
 51		graphicDOMElement.width = 200;
 52		graphicDOMElement.height = 200;
 53		graphicDOMElement.x = 50;
 54		graphicDOMElement.y = 50;
 55		
 56		graphicDOMElement.beginFill(monochrome( { color:0x00FF00, alpha:100 } ), LineStyleValue.none);
 57		graphicDOMElement.drawRect(0, 0, 200, 200);
 58		graphicDOMElement.endFill();
 59		
 60		stageDOMElement.addChild(graphicDOMElement);
 61	
 62		graphicDOMElement.onMouseDown = onDOMElementPress;
 63		
 64		graphicDOMElement.onMouseUp = onDOMElementRelease;
 65		
 66		graphicDOMElement.onMouseOver = onDOMElementRollOver;
 67		
 68		graphicDOMElement.onMouseOut = onDOMElementRollOut;
 69
 70		graphicDOMElement.onMouseMove = onDOMElementMouseMove;
 71		
 72		graphicDOMElement.onMouseDoubleClick = onDOMElementDoubleClick;
 73	}
 74	
 75	/////////////////////////////////////////////////////////////////////////////////////
 76	// DOMElement mouse events callbacks
 77	////////////////////////////////////////////////////////////////////////////////////
 78	
 79	private function onDOMElementPress(mouseEventData:MouseEventData):Void
 80	{
 81		Log.trace("mouse down");
 82	}
 83	
 84	private function onDOMElementDoubleClick(mouseEventData:MouseEventData):Void
 85	{
 86		Log.trace("mouse double click");
 87	}
 88	
 89	private function onDOMElementRelease(mouseEventData:MouseEventData):Void
 90	{
 91		Log.trace("mouse release");
 92	}
 93	
 94	private function onDOMElementRollOver(mouseEventData:MouseEventData):Void
 95	{
 96		Log.trace("mouse roll over");
 97	}
 98	
 99	private function onDOMElementRollOut(mouseEventData:MouseEventData):Void
100	{
101		Log.trace("mouse roll out");
102	}
103	
104	private function onDOMElementMouseMove(mouseEventData:MouseEventData):Void
105	{
106		Log.trace("mouse move");
107	}
108	
109}