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