ManiaLib 1.0b1 API Reference

Source for file Panel.class.php

Documentation is available at Panel.class.php

  1. <?php
  2. /**
  3.  * @author Maxime Raoust
  4.  * @copyright 2009-2010 NADEO
  5.  * @package ManiaLib
  6.  */
  7.  
  8. /**
  9.  * Panel
  10.  * Very useful! A quad with a title and a title background
  11.  * @package ManiaLib
  12.  * @subpackage GUIToolkit_Cards
  13.  */
  14. class Panel extends Quad
  15. {
  16.     /**
  17.      * @var Label 
  18.      */
  19.     public $title;
  20.     /**
  21.      * Title background
  22.      * @var Quad 
  23.      */
  24.     public $titleBg;
  25.     
  26.     function __construct ($sx=20$sy=20)
  27.     {    
  28.         $this->sizeX $sx;
  29.         $this->sizeY $sy;
  30.  
  31.         $titleBgWidth $sx 2;
  32.         $titleWidth $sx 4;
  33.         
  34.         $this->setStyle(GuiDefaultStyles::Panel_Style);
  35.         $this->setSubStyle(GuiDefaultStyles::Panel_Substyle);
  36.         
  37.         $this->titleBg = new Quad ($titleBgWidth4);
  38.         $this->titleBg->setStyle(GuiDefaultStyles::Panel_TitleBg_Style);
  39.         $this->titleBg->setSubStyle(GuiDefaultStyles::Panel_TitleBg_Substyle);
  40.  
  41.         $this->title = new Label ($titleWidth);
  42.         $this->title->setStyle(GuiDefaultStyles::Panel_Title_Style);
  43.         $this->title->setPositionY(-0.75);
  44.     }
  45.     
  46.     function setSizeX($x)
  47.     {
  48.         parent::setSizeX($x);
  49.         $this->titleBg->setSizeX($x-2);
  50.         $this->title->setSizeX($x-4);
  51.     }
  52.     
  53.     /**
  54.      * @ignore
  55.      */
  56.     protected function postFilter()
  57.     {
  58.         // Algin the title and its bg at the top center of the main quad        
  59.         $arr GuiTools::getAlignedPos ($this"center""top");
  60.         $x $arr["x"];
  61.         $y $arr["y"];
  62.         $this->titleBg->setHalign("center");
  63.         $this->title->setHalign("center");
  64.         
  65.         // Draw them
  66.         Manialink::beginFrame($x$y-1$this->posZ+1);
  67.             $this->titleBg->save();
  68.             $this->title->save();
  69.         Manialink::endFrame();
  70.     }
  71. }
  72.  
  73. ?>