1<?php 2 3require_once(HTML2PS_DIR.'width.constraint.php'); 4 5function merge_width_constraint($wc1, $wc2) { 6 if ($wc1->isNull()) { 7 return $wc2; 8 }; 9 10 if ($wc1->isConstant() && !$wc2->isNull()) { 11 return $wc2; 12 }; 13 14 if ($wc1->isFraction() && $wc2->isFraction()) { 15 return $wc2; 16 }; 17 18 return $wc1; 19} 20 21// the second parameter of 'apply' method may be null; it means that 22// parent have 'fit' width and depends on the current constraint itself 23 24class WCNone extends WidthConstraint { 25 function WCNone() { 26 $this->WidthConstraint(); 27 } 28 29 function applicable(&$box) { return false; } 30 31 function _apply($w, $pw) { return $w; } 32 function apply_inverse($w, $pw) { return $pw; } 33 34 function &_copy() { 35 $copy =& new WCNone(); 36 return $copy; 37 } 38 39 function _units2pt($base) { 40 } 41 42 function isNull() { return true; } 43} 44 45class WCConstant extends WidthConstraint { 46 var $width; 47 48 function WCConstant($width) { 49 $this->WidthConstraint(); 50 $this->width = $width; 51 } 52 53 function applicable(&$box) { 54 return true; 55 } 56 57 function _apply($w, $pw) { 58 return $this->width; 59 } 60 61 function apply_inverse($w, $pw) { 62 return $pw; 63 } 64 65 function &_copy() { 66 $copy =& new WCConstant($this->width); 67 return $copy; 68 } 69 70 function _units2pt($base) { 71 $this->width = units2pt($this->width, $base); 72 } 73 74 function isConstant() { 75 return true; 76 } 77} 78 79class WCFraction extends WidthConstraint { 80 var $fraction; 81 82 function applicable(&$box) { 83 if (is_null($box->parent)) { return false; }; 84 $parent_wc = $box->parent->get_css_property(CSS_WIDTH); 85 return $box->isCell() || $parent_wc->applicable($box->parent); 86 } 87 88 function WCFraction($fraction) { 89 $this->WidthConstraint(); 90 $this->fraction = $fraction; 91 } 92 93 function _apply($w, $pw) { 94 if (!is_null($pw)) { 95 return $pw * $this->fraction; 96 } else { 97 return $w; 98 }; 99 } 100 101 function apply_inverse($w, $pw) { 102 if ($this->fraction > 0) { return $w / $this->fraction; } else { return 0; }; 103 } 104 105 function &_copy() { 106 $copy =& new WCFraction($this->fraction); 107 return $copy; 108 } 109 110 function _units2pt($base) { 111 } 112 113 function isFraction() { 114 return true; 115 } 116} 117 118?>