ManiaLib 1.0b1 API Reference

Source for file AbstractLayout.class.php

Documentation is available at AbstractLayout.class.php

  1. <?php
  2. /**
  3.  * @author Maxime Raoust
  4.  * @copyright 2009-2010 NADEO
  5.  * @package ManiaLib
  6.  */
  7.  
  8. /**
  9.  * Abstract layout
  10.  * Abstract class used for building layouts
  11.  * @package ManiaLib
  12.  * @subpackage GUIToolkit_Layouts
  13.  */
  14. abstract class AbstractLayout extends GuiComponent
  15. {
  16.     /**#@+
  17.      * @ignore
  18.      */
  19.     public $xIndex 0;
  20.     public $yIndex 0;
  21.     public $zIndex 0;
  22.     protected $marginWidth;
  23.     protected $marginHeight;
  24.     protected $borderWidth;
  25.     protected $borderHeight;
  26.     /**#@-*/
  27.     
  28.     /**
  29.      * Default constructor is used to set the size of the layout, just like
  30.      * GuiElement
  31.      * @param float Layout's width
  32.      * @param float Layout's height
  33.      */
  34.     function __construct($sizeX=20$sizeY=20)
  35.     {
  36.         $this->sizeX $sizeX;
  37.         $this->sizeY $sizeY;
  38.     }
  39.         
  40.     /**
  41.      * Sets the horizontal margin between two elements of the layout
  42.      * @param float 
  43.      */
  44.     function setMarginWidth($marginWidth)
  45.     {
  46.         $this->marginWidth $marginWidth;
  47.     }
  48.     
  49.     /**
  50.      * Sets the vertical margin between two elements of the layout
  51.      * @param float 
  52.      */
  53.     function setMarginHeight($marginHeight)
  54.     {
  55.         $this->marginHeight $marginHeight;
  56.     }
  57.     
  58.     /**
  59.      * Sets the margin between two elements of the layout
  60.      * @param Horizontal margin
  61.      * @param Vertical margin
  62.      */
  63.     function setMargin($marginWidth 0$marginHeight 0)
  64.     {
  65.         $this->marginWidth $marginWidth;
  66.         $this->marginHeight $marginHeight;
  67.     }
  68.     
  69.     /**
  70.      * Returns the horizontal margin between two elements of the layout
  71.      * @return float 
  72.      */
  73.     function getMarginWidth()
  74.     {
  75.         return $this->marginWidth;
  76.     }
  77.     
  78.     /**
  79.      * Returns the vertical margin between two elements of the layout
  80.      * @return float 
  81.      */
  82.     function getMarginHeight()
  83.     {
  84.         return $this->marginHeight;
  85.     }
  86.     
  87.     /**
  88.      * Sets the width between the layout outer border and its content
  89.      * @param float 
  90.      */
  91.     function setBorderWidth($borderWidth)
  92.     {
  93.         $this->borderWidth $borderWidth;
  94.         $this->xIndex $borderWidth;
  95.     }
  96.     
  97.     /**
  98.      * Sets the height between the layout outer border and its content
  99.      * @param float 
  100.      */
  101.     function setBorderHeight($borderHeight)
  102.     {
  103.         $this->borderHeight $borderHeight;
  104.         $this->yIndex = - $borderHeight;
  105.     }
  106.     
  107.     /**
  108.      * Sets the gap between the layout outer border and its content
  109.      * @param Border width
  110.      * @param Border height
  111.      */
  112.     function setBorder($borderWidth 0$borderHeight 0)
  113.     {
  114.         $this->borderWidth $borderWidth;
  115.         $this->xIndex $borderWidth;
  116.         $this->borderHeight $borderHeight;
  117.         $this->yIndex = - $borderHeight;
  118.     }
  119.     
  120.     /**
  121.      * Returns the width between the layout outer border and its content
  122.      * @return float 
  123.      */
  124.     function getBorderWidth()
  125.     {
  126.         return $this->borderWidth;
  127.     }
  128.     
  129.     /**
  130.      * Returns the height between the layout outer border and its content
  131.      * @return float 
  132.      */
  133.     function getBorderHeight()
  134.     {
  135.         return $this->borderHeight;
  136.     }
  137.     
  138.     /**
  139.      * Override this method to perform an action before rendering an item.
  140.      * Typical use: look for overflow
  141.      * @ignore
  142.      */
  143.     function preFilter(GuiElement $item
  144.     {    
  145.     }
  146.  
  147.     /**
  148.      * Override this method to perform an action after rendering an an item.
  149.      * Typical use: update x,y,z indexes for the next item
  150.      * @ignore
  151.      */
  152.     function postFilter(GuiElement $item)
  153.     {
  154.     }
  155. }
  156.  
  157. ?>