/** * Show fixed positioned block box using the specified output driver * * Note that 'show_fixed' is called to box _nested_ to the fixed-positioned boxes too! * Thus, we need to check whether actual 'position' values is 'fixed' for this box * and only in that case attempt to move box * * @param OutputDriver $driver The output device driver object */ function show_fixed(&$driver) { $position = $this->get_css_property(CSS_POSITION); if ($position == POSITION_FIXED) { /** * Calculate the distance between the top page edge and top box content edge */ $bottom = $this->get_css_property(CSS_BOTTOM); $top = $this->get_css_property(CSS_TOP); if (!$top->isAuto()) { if ($top->isPercentage()) { $vertical_offset = $driver->getPageMaxHeight() / 100 * $top->getPercentage(); } else { $vertical_offset = $top->getPoints(); } } elseif (!$bottom->isAuto()) { if ($bottom->isPercentage()) { $vertical_offset = $driver->getPageMaxHeight() * (100 - $bottom->getPercentage()) / 100 - $this->get_height(); } else { $vertical_offset = $driver->getPageMaxHeight() - $bottom->getPoints() - $this->get_height(); } } else { $vertical_offset = 0; } /** * Calculate the distance between the right page edge and right box content edge */ $left = $this->get_css_property(CSS_LEFT); $right = $this->get_css_property(CSS_RIGHT); if (!$left->isAuto()) { if ($left->isPercentage()) { $horizontal_offset = $driver->getPageWidth() / 100 * $left->getPercentage(); } else { $horizontal_offset = $left->getPoints(); } } elseif (!$right->isAuto()) { if ($right->isPercentage()) { $horizontal_offset = $driver->getPageWidth() * (100 - $right->getPercentage()) / 100 - $this->get_width(); } else { $horizontal_offset = $driver->getPageWidth() - $right->getPoints() - $this->get_width(); } } else { $horizontal_offset = 0; } /** * Offset current box to the required position on the current page (note that * fixed-positioned element are placed relatively to the viewport - page in our case) */ $this->moveto($driver->getPageLeft() + $horizontal_offset, $driver->getPageTop() - $vertical_offset); } /** * After box have benn properly positioned, render it as usual. */ return GenericContainerBox::show_fixed($driver); }