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