Source for file GuiTools.class.php
Documentation is available at GuiTools.class.php
* @copyright 2009-2010 NADEO
* Misc helpers for the GUI toolkit
* Returns the X position of an element in relation to another element and
* according to their respective alignments
* @param int X position of the parent element
* @param int Width of the parent element
* @param string Horizontal alignement of the parent element
* @param string Horizontal alignement of the element you want to place
* @return int Calculated X position of the element you want to place
final public static function getAlignedPosX($posX, $sizeX, $halign, $newAlign)
$alignmentString =
$halign.
'|'.
$newAlign;
throw
new Exception('GUITools: Unsupported positions');
return $posX +
$factor *
$sizeX;
* Returns the Y position of an element in relation to another element and
* according to their respective alignments
* @param int Y position of the parent element
* @param int Height of the parent element
* @param string Vertical alignement of the parent element
* @param string Vertical alignement of the element you want to place
* @return int Calculated Y position of the element you want to place
final public static function getAlignedPosY($posY, $sizeY, $valign, $newAlign)
return self::getAlignedPosX($posY, $sizeY, $valign, $newAlign);
* Returns the position of an element in relation to another element and
* according to their respective alignments
* @param GuiElement Parent element
* @param string Horizontal alignement of the element you want to place
* @param string Vertical alignement of the element you want to place
* @return array Calculated position of the element you want to place. The
* array contains 2 elements with "x" and "y" indexes
final public static function getAlignedPos(GuiElement $object, $newHalign, $newValign)
$newPosX =
self::getAlignedPosX(
$newPosY =
self::getAlignedPosY(
return array('x' =>
$newPosX, 'y' =>
$newPosY);