Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Handles the '##PAGES##' text field.
4
 *
5
 */
6
class BoxTextFieldPages extends TextBoxString {
7
  function BoxTextFieldPages() {
8
    $this->TextBoxString("", "iso-8859-1");
9
  }
10
 
11
  function from_box(&$box) {
12
    $field = new BoxTextFieldPages;
13
 
14
    $field->copy_style($box);
15
 
16
    $field->words      = array("000");
17
    $field->encodings  = array("iso-8859-1");
18
    $field->_left      = $box->_left;
19
    $field->_top       = $box->_top;
20
    $field->baseline   = $box->baseline;
21
 
22
    return $field;
23
  }
24
 
25
  function show(&$viewport) {
26
    $font = $this->get_css_property(CSS_FONT);
27
 
28
    $this->words[0] = sprintf("%d", $viewport->expected_pages);
29
 
30
    $field_width = $this->width;
31
    $field_left  = $this->_left;
32
 
33
    if ($font->size->getPoints() > 0) {
34
      $value_width = $viewport->stringwidth($this->words[0],
35
                                            $this->_get_font_name($viewport, 0),
36
                                            $this->encodings[0],
37
                                            $font->size->getPoints());
38
      if (is_null($value_width)) {
39
        return null;
40
      };
41
    } else {
42
      $value_width = 0;
43
    };
44
    $this->width  = $value_width;
45
    $this->_left += ($field_width - $value_width) / 2;
46
 
47
    if (is_null(TextBoxString::show($viewport))) {
48
      return null;
49
    };
50
 
51
    $this->width = $field_width;
52
    $this->_left = $field_left;
53
 
54
    return true;
55
  }
56
 
57
  function show_fixed(&$viewport) {
58
    $font = $this->get_css_property(CSS_FONT);
59
 
60
    $this->words[0] = sprintf("%d", $viewport->expected_pages);
61
 
62
    $field_width = $this->width;
63
    $field_left  = $this->_left;
64
 
65
    if ($font->size->getPoints() > 0) {
66
      $value_width = $viewport->stringwidth($this->words[0],
67
                                            $this->_get_font_name($viewport, 0),
68
                                            $this->encodings[0],
69
                                            $font->size->getPoints());
70
      if (is_null($value_width)) {
71
        return null;
72
      };
73
    } else {
74
      $value_width = 0;
75
    };
76
    $this->width  = $value_width;
77
    $this->_left += ($field_width - $value_width) / 2;
78
 
79
    if (is_null(TextBoxString::show_fixed($viewport))) {
80
      return null;
81
    };
82
 
83
    $this->width = $field_width;
84
    $this->_left = $field_left;
85
 
86
    return true;
87
  }
88
}
89
?>