ManiaLib 1.0b1 API Reference

Source for file FlowLayout.class.php

Documentation is available at FlowLayout.class.php

  1. <?php
  2. /**
  3.  * @author Maxime Raoust
  4.  * @copyright 2009-2010 NADEO
  5.  * @package ManiaLib
  6.  */
  7.  
  8. /**
  9.  * Flow layout
  10.  * Text-like, items fill the current line then next line etc.
  11.  * @package ManiaLib
  12.  * @subpackage GUIToolkit_Layouts
  13.  */
  14. class FlowLayout extends AbstractLayout
  15. {
  16.     /**#@+
  17.      * @ignore
  18.      */
  19.     protected $maxHeight 0;
  20.     protected $currentLineElementCount 0;
  21.     /**#@-*/
  22.  
  23.     /**
  24.      * @ignore
  25.      */
  26.     function preFilter(GuiElement $item)
  27.     {
  28.         $availableWidth $this->sizeX $this->xIndex $this->borderWidth;
  29.  
  30.         // If end of the line is reached
  31.         if($availableWidth $item->getSizeX($this->currentLineElementCount 0)
  32.         {
  33.             $this->yIndex -= $this->maxHeight $this->marginHeight;
  34.             $this->xIndex $this->borderWidth;
  35.             $this->currentLineElementCount 0;
  36.             $this->maxHeight 0;
  37.         }
  38.  
  39.     }
  40.  
  41.     /**
  42.      * @ignore
  43.      */
  44.     function postFilter(GuiElement $item)
  45.     {
  46.         $this->xIndex += $item->getSizeX($this->marginWidth;
  47.         if(!$this->maxHeight || $item->getSizeY($this->maxHeight)
  48.         {
  49.             $this->maxHeight $item->getSizeY();
  50.         }
  51.         $this->currentLineElementCount++;
  52.     }
  53. }
  54.  
  55. ?>