home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Image / Graph / Layout / Vertical.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  3.8 KB  |  108 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Image_Graph - PEAR PHP OO Graph Rendering Utility.
  7.  *
  8.  * PHP versions 4 and 5
  9.  *
  10.  * LICENSE: This library is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU Lesser General Public License as published by
  12.  * the Free Software Foundation; either version 2.1 of the License, or (at your
  13.  * option) any later version. This library is distributed in the hope that it
  14.  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15.  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  16.  * General Public License for more details. You should have received a copy of
  17.  * the GNU Lesser General Public License along with this library; if not, write
  18.  * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19.  * 02111-1307 USA
  20.  *
  21.  * @category   Images
  22.  * @package    Image_Graph
  23.  * @subpackage Layout
  24.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  25.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  26.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  27.  * @version    CVS: $Id: Vertical.php,v 1.6 2005/02/21 20:49:55 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  */
  30.  
  31. /**
  32.  * Include file Image/Graph/Layout/Horizontal.php
  33.  */
  34. require_once 'Image/Graph/Layout/Horizontal.php';
  35.  
  36. /**
  37.  * Layout for displaying two elements on top of each other.
  38.  *
  39.  * This splits the area contained by this element in two on top of each other
  40.  * by a specified percentage (relative to the top). A layout can be nested.
  41.  * Fx. a {@link Image_Graph_Layout_Horizontal} can layout two VerticalLayout's to
  42.  * make a 2 by 2 matrix of 'element-areas'.
  43.  *
  44.  * @category   Images
  45.  * @package    Image_Graph
  46.  * @subpackage Layout
  47.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  48.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  49.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  50.  * @version    Release: 0.7.2
  51.  * @link       http://pear.php.net/package/Image_Graph
  52.  */
  53. class Image_Graph_Layout_Vertical extends Image_Graph_Layout_Horizontal
  54. {
  55.  
  56.     /**
  57.      * Gets the absolute size of one of the parts.
  58.      *
  59.      * @param string $part The name of the part - auto_part(1|2)
  60.      * @return int The number of pixels the edge should be pushed
  61.      * @since 0.3.0dev2
  62.      * @access private
  63.      */
  64.     function _getAbsolute(&$part)
  65.     {
  66.         $part1Size = $this->_part1->_getAutoSize();
  67.         $part2Size = $this->_part2->_getAutoSize();
  68.         $this->_percentage = false;
  69.         if (($part1Size !== false) and ($part2Size !== false)) {
  70.             $height = $this->_fillHeight() * $part1Size / ($part1Size + $part2Size);
  71.         } elseif ($part1Size !== false) {
  72.             $height = $part1Size;
  73.         } elseif ($part2Size !== false) {
  74.             $height = -$part2Size;
  75.         } else {
  76.             $height = $this->_fillHeight() / 2;
  77.         }
  78.  
  79.         if ($part == 'auto_part2') {
  80. //            $height = $this->_fillHeight() - $height;
  81.         }
  82.  
  83.         return $height;
  84.     }
  85.  
  86.     /**
  87.      * Splits the layout between the parts, by the specified percentage
  88.      *
  89.      * @access private
  90.      */
  91.     function _split()
  92.     {
  93.         if (($this->_part1) && ($this->_part2)) {
  94.             if ($this->_percentage !== false) {
  95.                 $split1 = 100 - $this->_percentage;
  96.                 $split2 = $this->_percentage;
  97.                 $this->_part1->_push('bottom', "$split1%");
  98.                 $this->_part2->_push('top', "$split2%");
  99.             } else {
  100.                 $this->_part1->_push('bottom', 'auto_part1');
  101.                 $this->_part2->_push('top', 'auto_part2');
  102.             }
  103.         }
  104.     }
  105.  
  106. }
  107.  
  108. ?>