1<?php
2// $Header: /cvsroot/html2ps/css.width.inc.php,v 1.19 2007/01/24 18:55:53 Konstantin Exp $
3
4require_once(HTML2PS_DIR.'css.min-width.inc.php');
5require_once(HTML2PS_DIR.'css.property.sub.class.php');
6
7class CSSCompositeWidth extends CSSPropertyHandler {
8  function CSSCompositeWidth() {
9    $this->CSSPropertyHandler(false, false);
10  }
11
12  function get_property_code() {
13    return CSS_HTML2PS_COMPOSITE_WIDTH;
14  }
15
16  function get_property_name() {
17    return '-html2ps-composite-width';
18  }
19
20  function default_value() {
21    return new WCNone();
22  }
23}
24
25class CSSWidth extends CSSSubProperty {
26  function CSSWidth($owner) {
27    $this->CSSSubProperty($owner);
28  }
29
30  function set_value(&$owner_value, &$value) {
31    $min = $owner_value->_min_width;
32    $owner_value = $value->copy();
33    $owner_value->_min_width = $min;
34  }
35
36  function &get_value(&$owner_value) {
37    return $owner_value;
38  }
39
40  function default_value() {
41    return new WCNone;
42  }
43
44  function parse($value) {
45    if ($value === 'inherit') {
46      return CSS_PROPERTY_INHERIT;
47    };
48
49    // Check if user specified empty value
50    if ($value === '') { return new WCNone; };
51
52    // Check if this value is 'auto' - default value of this property
53    if ($value === 'auto') {
54      return new WCNone;
55    };
56
57    if (substr($value,strlen($value)-1,1) == '%') {
58      // Percentage
59      return new WCFraction(((float)$value)/100);
60    } else {
61      // Constant
62      return new WCConstant(trim($value));
63    }
64  }
65
66  function get_property_code() {
67    return CSS_WIDTH;
68  }
69
70  function get_property_name() {
71    return 'width';
72  }
73}
74
75$width = new CSSCompositeWidth;
76CSS::register_css_property($width);
77CSS::register_css_property(new CSSWidth($width));
78CSS::register_css_property(new CSSMinWidth($width, '_min_width'));
79
80?>