1<?php 2 3/** 4 * @package HTML2PS 5 * @subpackage Document 6 * Represents the 'background-postitions' CSS property value 7 * 8 * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position CSS 2.1 'background-position' property description 9 */ 10class BackgroundPosition { 11 /** 12 * @var string X-offset value 13 * @access public 14 */ 15 var $x; 16 17 /** 18 * @var string Y-offset value 19 * @access public 20 */ 21 var $y; 22 23 /** 24 * @var boolean Indicates whether $x value contains absolute (false) or percentage (true) value 25 * @access public 26 */ 27 var $x_percentage; 28 29 /** 30 * @var boolean Indicates whether $y value contains absolute (false) or percentage (true) value 31 * @access public 32 */ 33 var $y_percentage; 34 35 /** 36 * Constructs new 'background-position' value object 37 * 38 * @param float $x X-offset value 39 * @param boolean $x_percentage A flag indicating that $x value should be treated as percentage 40 * @param float $y Y-offset value 41 * @param boolean $y_percentage A flag indicating that $y value should be treated as percentage 42 */ 43 function BackgroundPosition($x, $x_percentage, $y, $y_percentage) { 44 $this->x = $x; 45 $this->x_percentage = $x_percentage; 46 $this->y = $y; 47 $this->y_percentage = $y_percentage; 48 } 49 50 /** 51 * A "deep copy" routine; it is required for compatibility with PHP 5 52 * 53 * @return BackgroundPosition A copy of current object 54 */ 55 function ©() { 56 $value =& new BackgroundPosition($this->x, $this->x_percentage, 57 $this->y, $this->y_percentage); 58 return $value; 59 } 60 61 /** 62 * Test is current value is equal to default 'background-position' CSS property value 63 */ 64 function is_default() { 65 return 66 $this->x == 0 && 67 $this->x_percentage && 68 $this->y == 0 && 69 $this->y_percentage; 70 } 71 72 /** 73 * Converts the absolute lengths to the device points 74 * 75 * @param float $font_size Font size to use during conversion of 'ex' and 'em' units 76 */ 77 function units2pt($font_size) { 78 if (!$this->x_percentage) { 79 $this->x = units2pt($this->x, $font_size); 80 }; 81 82 if (!$this->y_percentage) { 83 $this->y = units2pt($this->y, $font_size); 84 }; 85 } 86} 87 88?>