PageRenderTime 22ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/cocktail/domElement/php/DOMElement.hx

http://github.com/silexlabs/Cocktail
Haxe | 201 lines | 69 code | 32 blank | 100 comment | 0 complexity | 24b9760bfaec08a178c3b1a4a58e7514 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*/
 12package cocktail.domElement.php;
 13
 14
 15//import js.Dom;
 16import cocktail.domElement.abstract.AbstractDOMElement;
 17
 18/**
 19 * This is the DOMElement implementation for PHP. 
 20 * It manipulates the native HTML DOM
 21 * 
 22 * @author	Raphael HARMEL
 23 * @date	2011-08-03
 24 */
 25class DOMElement extends AbstractDOMElement
 26{
 27
 28	/**
 29	 * Class constructor
 30	 */
 31	public function new(referenceToNativeDOM:Dynamic) 
 32	{
 33		super(referenceToNativeDOM);
 34	}
 35	
 36	//////////////////////////////////////////////////////////////////////////////////////////
 37	// Overriden methods to manipulate the HTML DOM
 38	//////////////////////////////////////////////////////////////////////////////////////////
 39	
 40	/**
 41	 * Adds a native HTML DOMElement (an html element) to this DOMElement native DOMElement
 42	 * @param	domElement the html element to add to this
 43	 */
 44	override public function addChild(domElement:AbstractDOMElement):Void
 45	{
 46		super.addChild(domElement);
 47		this._nativeElement.addChild(domElement.getReferenceToNativeDOM());
 48	}
 49	
 50	/**
 51	 * Removes a native HTML DOMElement (an html element) from this DOMElement native DOMElement
 52	 * @param	domElement the html element to remove from this
 53	 */
 54	/*override public function removeChild(domElement:AbstractDOMElement):Void
 55	{
 56		super.removeChild(domElement);
 57		this._nativeElement.removeChild(domElement.getReferenceToNativeDOM());
 58	}*/
 59	
 60	/**
 61	 * Return the value of a field of the native object
 62	 * @param	propertyName the name of the field value to return
 63	 * @return might be any type
 64	 */
 65	override public function getField(propertyName:String):Dynamic
 66	{
 67		//return Reflect.field(this._nativeElement, propertyName);
 68		return this._nativeElement.get(propertyName);
 69	}
 70	
 71	
 72	//////////////////////////////////////////////////////////////////////////////////////////
 73	// Overriden Setters/Getters to manipulate the JavaScript DOMElement
 74	// set/get the following attributes : x,y,width,height,z-order
 75	//////////////////////////////////////////////////////////////////////////////////////////
 76	
 77	
 78	override public function setX(value:Int):Void 
 79	{
 80		// TODO
 81	}
 82	
 83	override public function getX():Int 
 84	{
 85		// TODO
 86		return 0;
 87	}
 88	
 89	override public function setY(value:Int):Void 
 90	{
 91		// TODO
 92	}
 93	
 94	override public function getY():Int 
 95	{
 96		// TODO
 97		return 0;
 98	}
 99	
100	override public function setWidth(value:Int):Void
101	{
102		// TODO
103	}
104	
105	override public function getWidth():Int 
106	{
107		// TODO
108		return 0;
109	}
110	
111	override public function setHeight(value:Int):Void 
112	{
113		// TODO
114	}
115	
116	override public function getHeight():Int 
117	{
118		// TODO
119		return 0;
120	}
121	
122	/**
123	 * Set rotation of the html element.
124	 * @param	value the rotation angle in deg
125	 */
126	override public function setRotation(value:Int):Void
127	{
128		// TODO
129	}
130	
131	/**
132	 * When returning the rotation, the rotation value must be extracted from
133	 * the CSS style
134	 * @return the rotation in deg
135	 */
136	override public function getRotation():Int
137	{
138		// TODO
139		return 0;
140	}
141	
142	/**
143	 * When setting the z-order on an HTML element,
144	 * all the siblings z-indexes must be updated. If they
145	 * are superior or equal to the z-index set on the current element,
146	 * they are incremented
147	 * @param	value the z index to set
148	 */
149	override public function setZIndex(value:Int) 
150	{
151		// TODO
152	}
153	
154	override public function getZIndex():Int 
155	{
156		// TODO
157		return 0;
158	}
159	
160	/**
161	 * This method create/updates the style of the div with given parameters
162	 * The resulting attribute will be as follows:
163	 *   style="x:100;y:200;z-index=5"
164	 * 
165	 * @param	property
166	 * @param	value
167	 */
168	private function setStyle(property:String, value:String):Void
169	{
170		// TODO
171		// styleHash is used to store all the style properties & values
172		var styleHash:Hash<String> = new Hash<String>();
173		
174		// gets the existing styles
175		
176		// adds the new property & value
177		
178		// build the complete style value
179		
180		// updates the style attribute value
181		
182	}
183	
184	/**
185	 * This method gets the style of the div
186	 * If style="x:100;y:200;z-index=5", calling getStyle('x') will return '100'
187	 * 
188	 * @param	property
189	 * @param	value
190	 */
191	private function getStyle(property:String):String
192	{
193		// TODO
194		// styleHash is used to store all the style properties & values
195		var styleHash:Hash<String> = new Hash<String>();
196		
197		// gets the property value in the list of existing styles
198		return '';
199	}
200	
201}