Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TPanel.php

Documentation is available at TPanel.php

  1. <?php
  2. namespace Adianti\Widget\Container;
  3.  
  4. use Adianti\Widget\Base\TElement;
  5. use Adianti\Widget\Base\TStyle;
  6.  
  7. /**
  8.  * Panel Container: Allows to organize the widgets using fixed (absolute) positions
  9.  *
  10.  * @version    7.4
  11.  * @package    widget
  12.  * @subpackage container
  13.  * @author     Pablo Dall'Oglio
  14.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  15.  * @license    http://www.adianti.com.br/framework-license
  16.  */
  17. class TPanel extends TElement
  18. {
  19.     private $style;
  20.     private $width;
  21.     private $height;
  22.     
  23.     /**
  24.      * Class Constructor
  25.      * @param  $width   Panel's width
  26.      * @param  $height  Panel's height
  27.      */
  28.     public function __construct($width$height)
  29.     {
  30.         parent::__construct('div');
  31.         
  32.         $this->{'id''tpanel_' mt_rand(10000000001999999999);
  33.         
  34.         // creates the panel style
  35.         $this->style new TStyle('style_'.$this->{'id'});
  36.         $this->style-> position 'relative';
  37.         $this->width $width;
  38.         $this->height $height;
  39.         
  40.         $this->{'class''style_'.$this->{'id'};
  41.     }
  42.     
  43.     /**
  44.      * Set the panel's size
  45.      * @param $width Panel width
  46.      * @param $height Panel height
  47.      */
  48.     public function setSize($width$height)
  49.     {
  50.         $this->width $width;
  51.         $this->height $height;
  52.     }
  53.     
  54.     /**
  55.      * Returns the frame size
  56.      * @return array(width, height)
  57.      */
  58.     public function getSize()
  59.     {
  60.         return array($this->width$this->height);
  61.     }
  62.     
  63.     /**
  64.      * Put a widget inside the panel
  65.      * @param  $widget = widget to be shown
  66.      * @param  $col    = column in pixels.
  67.      * @param  $row    = row in pixels.
  68.      */
  69.     public function put($widget$col$row)
  70.     {
  71.         // creates a layer to put the widget inside
  72.         $layer new TElement('div');
  73.         // define the layer position
  74.         $layer-> style "position:absolute; left:{$col}px; top:{$row}px;";
  75.         // add the widget to the layer
  76.         $layer->add($widget);
  77.         
  78.         // add the widget to the container
  79.         parent::add($layer);
  80.     }
  81.     
  82.     /**
  83.      * Show the widget
  84.      */
  85.     public function show()
  86.     {
  87.         $this->style-> width  $this->width.'px';
  88.         $this->style-> height $this->height.'px';
  89.         $this->style->show();
  90.         
  91.         parent::show();
  92.     }
  93. }