| 1 |
lars |
1 |
<?php
|
|
|
2 |
// $Header: /cvsroot/html2ps/box.legend.php,v 1.14 2006/07/09 09:07:44 Konstantin Exp $
|
|
|
3 |
|
|
|
4 |
class LegendBox extends GenericContainerBox {
|
|
|
5 |
function &create(&$root, &$pipeline) {
|
|
|
6 |
$box = new LegendBox($root);
|
|
|
7 |
$box->readCSS($pipeline->get_current_css_state());
|
|
|
8 |
$box->create_content($root, $pipeline);
|
|
|
9 |
|
|
|
10 |
return $box;
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
function LegendBox(&$root) {
|
|
|
14 |
// Call parent constructor
|
|
|
15 |
$this->GenericContainerBox();
|
|
|
16 |
|
|
|
17 |
$this->_current_x = 0;
|
|
|
18 |
$this->_current_y = 0;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
// Flow-control
|
|
|
22 |
function reflow(&$parent, &$context) {
|
|
|
23 |
GenericFormattedBox::reflow($parent, $context);
|
|
|
24 |
|
|
|
25 |
// Determine upper-left _content_ corner position of current box
|
|
|
26 |
$this->put_left($parent->get_left_padding());
|
|
|
27 |
$this->put_top($parent->get_top_padding());
|
|
|
28 |
|
|
|
29 |
// Legends will not wrap
|
|
|
30 |
$this->put_full_width($this->get_max_width($context));
|
|
|
31 |
|
|
|
32 |
// Reflow contents
|
|
|
33 |
$this->reflow_content($context);
|
|
|
34 |
|
|
|
35 |
// Adjust legend position
|
|
|
36 |
$height = $this->get_full_height();
|
|
|
37 |
$this->offset(units2pt(LEGEND_HORIZONTAL_OFFSET) + $this->get_extra_left(),
|
|
|
38 |
$height/2);
|
|
|
39 |
// Adjust parent position
|
|
|
40 |
$parent->offset(0, -$height/2);
|
|
|
41 |
// Adjust parent content position
|
|
|
42 |
for ($i=0; $i<count($parent->content); $i++) {
|
|
|
43 |
if ($parent->content[$i]->uid != $this->uid) {
|
|
|
44 |
$parent->content[$i]->offset(0, -$height/2);
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
$parent->_current_y -= $height/2;
|
|
|
48 |
|
|
|
49 |
$parent->extend_height($this->get_bottom_margin());
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
function show(&$driver) {
|
|
|
53 |
// draw generic box
|
|
|
54 |
return GenericContainerBox::show($driver);
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
?>
|