function show(&$driver) { // Now set the baseline of a button box to align it vertically when flowing isude the // text line $this->default_baseline = $this->content[0]->baseline + $this->get_extra_top(); $this->baseline = $this->content[0]->baseline + $this->get_extra_top(); /** * If we're rendering the interactive form, the field content should not be rendered */ global $g_config; if ($g_config['renderforms']) { /** * Render background/borders only */ $status = GenericFormattedBox::show($driver); /** * @todo encoding name? * @todo font name? * @todo check if font is embedded for PDFLIB */ $driver->field_text($this->get_left_padding(), $this->get_top_padding(), $this->get_width() + $this->get_padding_left() + $this->get_padding_right(), $this->get_height(), $this->_value, $this->_field_name); } else { /** * Render everything, including content */ $status = GenericContainerBox::show($driver); } return $status; }
/** * Renders the background for the given box object using an output driver * * @param OutputDriver $driver Output driver to be used * @param GenericFormattedBox $box Box the background is rendered for * * @uses GenericFormattedBox * @uses OutputDriver */ function show(&$driver, &$box) { /** * Fill box with background color * * @see Color::apply * @see OutputDriver::moveto * @see OutputDriver::lineto * @see OutputDriver::closepath * @see OutputDriver::fill */ if (!$this->_color->transparent) { $this->_color->apply($driver); $driver->moveto($box->get_left_background(), $box->get_top_background()); $driver->lineto($box->get_right_background(), $box->get_top_background()); $driver->lineto($box->get_right_background(), $box->get_bottom_background()); $driver->lineto($box->get_left_background(), $box->get_bottom_background()); $driver->closepath(); $driver->fill(); } /** * Render background image * * @see BackgroundImage::show */ $this->_image->show($driver, $box, $this->_repeat, $this->_position, $this->_attachment); }
function reflow(&$parent, &$context) { // Check if there are any boxes in parent's line box if ($parent->line_box_empty()) { // The very first whitespace in the line box should not affect neither height nor baseline of the line box; // because following boxes can be smaller that assumed whitespace height // Example: <br>[whitespace]<img height="2" width="2"><br>; whitespace can overextend this line $this->width = 0; $this->height = 0; } elseif (is_a($parent->last_in_line(), "WhitespaceBox")) { // Duplicate whitespace boxes should not offset further content and affect the line box length $this->width = 0; $this->height = 0; } GenericFormattedBox::reflow($parent, $context); // Apply 'line-height' $this->_apply_line_height(); // default baseline $this->baseline = $this->default_baseline; // append to parent line box $parent->append_line($this); // Move box to the parent current point $this->guess_corner($parent); // Offset parent's current point $parent->_current_x += $this->width; // Extend parent height $parent->extend_height($this->get_bottom_margin()); // Update the value of current collapsed margin; pure text (non-span) // boxes always have zero margin $context->pop_collapsed_margin(); $context->push_collapsed_margin(0); }
function reflow_static(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // Determine the box width $this->_calc_percentage_width($parent, $context); $this->put_full_width($this->get_min_width($context, $parent->get_width())); $this->setCSSProperty(CSS_WIDTH, new WCNone()); // Check if we need a line break here $this->maybe_line_break($parent, $context); // append to parent line box $parent->append_line($this); // Determine coordinates of upper-left _margin_ corner $this->guess_corner($parent); $this->reflow_content($context); /** * After text content have been reflown, we may determine the baseline of the control item itself; * * As there will be some extra whitespace on the top of the control box, we must add this whitespace * to the calculated baseline value, so text before and after control item will be aligned * with the text inside the box. */ $this->default_baseline = $this->content[0]->baseline + $this->get_extra_top(); $this->baseline = $this->content[0]->baseline + $this->get_extra_top(); // center the button text vertically inside the button $text =& $this->content[0]; $delta = $text->get_top() - $text->get_height() / 2 - ($this->get_top() - $this->get_height() / 2); $text->offset(0, -$delta); // Offset parent current X coordinate $parent->_current_x += $this->get_full_width(); // Extends parents height $parent->extend_height($this->get_bottom_margin()); }
function show_field(&$driver) { if (is_null(GenericFormattedBox::show($driver))) { return null; } $driver->field_select($this->get_left_padding(), $this->get_top_padding(), $this->get_width() + $this->get_padding_left() + $this->get_padding_right(), $this->get_height(), $this->_name, $this->_value, $this->_options); return true; }
/** * Reflow absolutely positioned block box. Note that according to CSS 2.1 * the only types of boxes which could be absolutely positioned are * 'block' and 'table' * * @param FlowContext $context A flow context object containing the additional layout data. * * @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float' */ function reflow_absolute(&$context) { GenericFormattedBox::reflow($this->parent, $context); $position_strategy =& new StrategyPositionAbsolute(); $position_strategy->apply($this); /** * As sometimes left/right values may not be set, we need to use the "fit" width here. * If box have a width constraint, 'get_max_width' will return constrained value; * othersise, an intrictic width will be returned. * * Note that get_max_width returns width _including_ external space line margins, borders and padding; * as we're setting the "internal" - content width, we must subtract "extra" space width from the * value received * * @see GenericContainerBox::get_max_width() */ $this->put_width($this->get_max_width($context) - $this->_get_hor_extra()); /** * Update the width, as it should be calculated based upon containing block width, not real parent. * After this we should remove width constraints or we may encounter problem * in future when we'll try to call get_..._width functions for this box * * @todo Update the family of get_..._width function so that they would apply constraint * using the containing block width, not "real" parent width */ $wc = $this->getCSSProperty(CSS_WIDTH); $containing_block =& $this->_get_containing_block(); $this->put_width($wc->apply($this->get_width(), $containing_block['right'] - $containing_block['left'])); $this->setCSSProperty(CSS_WIDTH, new WCNone()); /** * Layout element's children */ $this->reflow_content($context); /** * As absolute-positioned box generated new flow contexy, extend the height to fit all floats */ $this->fitFloats($context); /** * If element have been positioned using 'right' or 'bottom' property, * we need to offset it, as we assumed it had zero width and height at * the moment we placed it */ $right = $this->getCSSProperty(CSS_RIGHT); $left = $this->getCSSProperty(CSS_LEFT); if ($left->isAuto() && !$right->isAuto()) { $this->offset(-$this->get_width(), 0); } $bottom = $this->getCSSProperty(CSS_BOTTOM); $top = $this->getCSSProperty(CSS_TOP); if ($top->isAuto() && !$bottom->isAuto()) { $this->offset(0, $this->get_height()); } }
function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // set default baseline $this->baseline = $this->default_baseline; // append to parent line box $parent->append_line($this); // Determine coordinates of upper-left _margin_ corner $this->guess_corner($parent); // Offset parent current X coordinate $parent->_current_x += $this->get_full_width(); // Extends parents height $parent->extend_height($this->get_bottom_margin()); }
function show(&$driver) { /** * If we're rendering the interactive form, the field content should not be rendered */ global $g_config; if ($g_config['renderforms']) { $status = GenericFormattedBox::show($driver); $driver->field_multiline_text($this->get_left_padding(), $this->get_top_padding(), $this->get_width() + $this->get_padding_left() + $this->get_padding_right(), $this->get_height() + $this->get_padding_top() + $this->get_padding_bottom(), $this->_value, $this->_field_name); } else { $status = GenericContainerBox::show($driver); } return $status; }
function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // Determine upper-left _content_ corner position of current box $this->put_left($parent->get_left_padding()); $this->put_top($parent->get_top_padding()); // Legends will not wrap $this->put_full_width($this->get_max_width($context)); // Reflow contents $this->reflow_content($context); // Adjust legend position $height = $this->get_full_height(); $this->offset(units2pt(LEGEND_HORIZONTAL_OFFSET) + $this->get_extra_left(), $height / 2); // Adjust parent position $parent->offset(0, -$height / 2); // Adjust parent content position for ($i = 0; $i < count($parent->content); $i++) { if ($parent->content[$i]->uid != $this->uid) { $parent->content[$i]->offset(0, -$height / 2); } } $parent->_current_y -= $height / 2; $parent->extend_height($this->get_bottom_margin()); }
/** * Layout current 'inline-block' element assument it has 'position: static' * * @param GenericContainerBox $parent The document element which should * be treated as the parent of current element * * @param FlowContext $context The flow context containing the additional layout data * * @see FlowContext * @see GenericContainerBox * * @todo re-check this layout routine; it seems that 'inline-block' boxes have * their width calculated incorrectly */ function reflow_static(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); /** * Calculate margin values if they have been set as a percentage */ $this->_calc_percentage_margins($parent); /** * Calculate width value if it had been set as a percentage */ $this->_calc_percentage_width($parent, $context); /** * Calculate 'auto' values of width and margins */ $this->_calc_auto_width_margins($parent); /** * add current box to the parent's line-box (alone) */ $parent->append_line($this); /** * Calculate position of the upper-left corner of the current box */ $this->guess_corner($parent); /** * By default, child block box will fill all available parent width; * note that actual content width will be smaller because of non-zero padding, border and margins */ $this->put_full_width($parent->get_width()); /** * Layout element's children */ $this->reflow_content($context); /** * Calculate element's baseline, as it should be aligned inside the * parent's line box vertically */ $this->default_baseline = $this->get_height() + $this->font_size; /** * Extend parent's height to fit current box */ $parent->extend_height($this->get_bottom_margin()); /** * Offset current x coordinate of parent box */ $parent->_current_x = $this->get_right_margin(); }
function show(&$driver) { // draw generic box GenericFormattedBox::show($driver); // Check if "designer" set the height or width of this image to zero; in this there will be no reason // in drawing the image at all // if ($this->get_width() < EPSILON || $this->get_height() < EPSILON || is_null($this->image->_handle)) { return true; } $driver->image_scaled($this->image, $this->get_left(), $this->get_bottom(), $this->get_width() / $this->image->sx(), $this->get_height() / $this->image->sy()); $strategy =& new StrategyLinkRenderingNormal(); $strategy->apply($this, $driver); return true; }
function reflow_anchors(&$viewport, &$anchors) { GenericFormattedBox::reflow_anchors($viewport, $anchors); $size = count($this->content); for ($i = 0; $i < $size; $i++) { $this->content[$i]->reflow_anchors($viewport, $anchors); } }
function show(&$viewport) { // draw generic box GenericFormattedBox::show($viewport); // Check if "designer" set the height or width of this image to zero; in this there will be no reason // in drawing the image at all // if ($this->get_width() < EPSILON || $this->get_height() < EPSILON) { return true; } $viewport->image_scaled($this->image, $this->get_left(), $this->get_bottom(), $this->get_width() / imagesx($this->image), $this->get_height() / imagesy($this->image)); return true; }
/** * Layout normal (non-floating) static-positioned block box. * * @param GenericContainerBox $parent The document element which should be treated as the parent of current element * @param FlowContext $context The flow context containing the additional layout data * * @see FlowContext * @see GenericContainerBox */ function reflow_static_normal(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); if ($parent) { /** * Child block will fill the whole content width of the parent block. * * 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + * 'border-right-width' + 'margin-right' = width of containing block * * See CSS 2.1 for more detailed explanation * * @link http://www.w3.org/TR/CSS21/visudet.html#blockwidth CSS 2.1. 10.3.3 Block-level, non-replaced elements in normal flow */ $this->put_full_width($parent->get_width()); /** * Calculate margin values if they have been set as a percentage; replace percentage-based values * with fixed lengths. */ $this->_calc_percentage_margins($parent); /** * Calculate width value if it had been set as a percentage; replace percentage-based value * with fixed value */ $this->_calc_percentage_width($parent, $context); /** * Calculate 'auto' values of width and margins. Unlike tables, DIV width is either constrained * by some CSS rules or expanded to the parent width; thus, we can calculate 'auto' margin * values immediately. * * @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 Calculating widths and margins */ $this->_calc_auto_width_margins($parent); /** * Collapse top margin * * @see GenericFormattedBox::collapse_margin() * * @link http://www.w3.org/TR/CSS21/box.html#collapsing-margins CSS 2.1 Collapsing margins */ $y = $this->collapse_margin($parent, $context); /** * At this moment we have top parent/child collapsed margin at the top of context object * margin stack */ /** * Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'. */ $y = $this->apply_clear($y, $context); /** * Store calculated Y coordinate as current Y coordinate in the parent box * No more content will be drawn abowe this mark; current box padding area will * start below. */ $parent->_current_y = $y; /** * Terminate current parent line-box (as current box is not inline) */ $parent->close_line($context); /** * Add current box to the parent's line-box; we will close the line box below * after content will be reflown, so the line box will contain only current box. */ $parent->append_line($this); /** * Now, place the current box upper left content corner. Note that we should not * use get_extra_top here, as _current_y value already culculated using the top margin value * of the current box! The top content edge should be offset from that level only of padding and * border width. */ $this->moveto($parent->get_left() + $this->get_extra_left(), $parent->_current_y - $this->border->top->get_width() - $this->padding->top->value); } /** * Reflow element's children */ $this->reflow_content($context); /** * After child elements have been reflown, we should the top collapsed margin stack value * replaced by the value of last child bottom collapsed margin; * if no children contained, then this value should be reset to 0. * * Note that invisible and * whitespaces boxes would not affect the collapsed margin value, so we need to * use 'get_first' function instead of just accessing the $content array. * * @see GenericContainerBox::get_first */ if (!is_null($this->get_first())) { $cm = 0; } else { $cm = $context->get_collapsed_margin(); } /** * Update the bottom value, collapsing the latter value with * current box bottom margin. * * Note that we need to remove TWO values from the margin stack: * first - the value of collapsed bottom margin of the last child AND * second - the value of collapsed top margin of current element. */ $context->pop_collapsed_margin(); $context->pop_collapsed_margin(); $context->push_collapsed_margin(max($cm, $this->margin->bottom->value)); if ($parent) { /** * Now, if there's a parent for this box, we extend its height to fit current box. * If parent generated new flow context (like table cell or floating box), its content * area should include the current box bottom margin (bottom margin does not colllapse). * See CSS 2.1 for more detailed explanations. * * @see FlowContext::container_uid() * * @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 8.3.1 Calculating widths and margins */ if ($parent->uid == $context->container_uid()) { $parent->extend_height($this->get_bottom_margin()); } else { $parent->extend_height($this->get_bottom_border()); } /** * Terminate parent's line box (it contains the current box only) */ $parent->close_line($context); /** * shift current parent 'watermark' to the current box margin edge; * all content now will be drawn below this mark (with a small exception * of elements having negative vertical margins, of course). */ $parent->_current_y = $this->get_bottom_border() - $context->get_collapsed_margin(); } /** * Check if we need to generate a page break after this element */ $this->check_page_break_after($parent, $context); }
/** * TODO: unlike block elements, table unconstrained width is determined * with its content, so it may be smaller than parent available width! */ function reflow_static_normal(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // Calculate margin values if they have been set as a percentage $this->_calc_percentage_margins($parent); // Calculate width value if it had been set as a percentage $this->_calc_percentage_width($parent, $context); $wc = $this->getCSSProperty(CSS_WIDTH); if ($wc && !$wc->isNull()) { $col_width = $this->get_table_columns_min_widths($context); $maxw = $this->get_table_columns_max_widths($context); $col_width = $this->_table_apply_colspans($col_width, $context, 'get_min_width', $col_width, $maxw); if (array_sum($col_width) > $this->get_width()) { $wc = new WCConstant(array_sum($col_width)); } } // As table width can be deterimined by its contents, we may calculate auto values // only AFTER the contents have been reflown; thus, we'll offset the table // as a whole by a value of left margin AFTER the content reflow // Do margin collapsing $y = $this->collapse_margin($parent, $context); // At this moment we have top parent/child collapsed margin at the top of context object // margin stack $y = $this->apply_clear($y, $context); // Store calculated Y coordinate as current Y in the parent box $parent->_current_y = $y; // Terminate current parent line-box $parent->close_line($context); // And add current box to the parent's line-box (alone) $parent->append_line($this); // Determine upper-left _content_ corner position of current box // Also see note above regarding margins $border = $this->getCSSProperty(CSS_BORDER); $padding = $this->getCSSProperty(CSS_PADDING); $plus = $parent->_current_x; if ($border->left) { $plus += $border->left->get_width(); } if ($padding->left) { $plus += $padding->left->value; } $this->put_left($plus); // Note that top margin already used above during maring collapsing $mins = $parent->_current_y; if ($border->top) { $mins -= $border->top->get_width(); } if ($padding->top) { $mins -= $padding->top->value; } $this->put_top($mins); /** * By default, child block box will fill all available parent width; * note that actual width will be smaller because of non-zero padding, border and margins */ $this->put_full_width($parent->get_available_width($context)); // Reflow contents $this->reflow_content($context); // Update the collapsed margin value with current box bottom margin $margin = $this->getCSSProperty(CSS_MARGIN); $context->pop_collapsed_margin(); $context->pop_collapsed_margin(); $context->push_collapsed_margin($margin->bottom->value); // Calculate margins and/or width is 'auto' values have been specified $this->_calc_auto_width_margins($parent); $this->offset($margin->left->value, 0); // Extend parent's height to fit current box $parent->extend_height($this->get_bottom_margin()); // Terminate parent's line box $parent->close_line($context); }
/** * Renders the backgroung image using the specified output driver. * * @param OutputDriver $driver an output driver object * @param GenericFormattedBox $box an box owning this background image * @param int $repeat the 'background-repeat' value * @param BackgroundPosition $position the 'background-position' value * * @uses BackgroundPosition * @uses OutputDriver */ function show(&$driver, $box, $repeat, $position, $attachment) { /** * If no image should be rendered, just return * @see BackgroundImage::$_url */ if (is_null($this->_url)) { return; } if (is_null($this->_image)) { return; } if ($attachment == BACKGROUND_ATTACHMENT_FIXED && $box->getCSSProperty(CSS_DISPLAY) == '-body') { $media =& $driver->get_media(); $left = $box->get_left_background(); $right = $box->get_right_background(); $top = $driver->offset + mm2pt($media->margins['bottom']) + mm2pt($media->real_height()); $bottom = $driver->offset + mm2pt($media->margins['bottom']); } else { $left = $box->get_left_background(); $right = $box->get_right_background(); $top = $box->get_top_background(); $bottom = $box->get_bottom_background(); } /** * Setup clipping region for padding area. Note that background image is drawn in the padding * area which in generic case is greater than content area. * * @see OutputDriver::clip() * * @link http://www.w3.org/TR/CSS21/box.html#box-padding-area CSS 2.1 definition of padding area */ $driver->save(); $driver->moveto($left, $top); $driver->lineto($right, $top); $driver->lineto($right, $bottom); $driver->lineto($left, $bottom); $driver->closepath(); $driver->clip(); /** * get real image size in device points * * @see pt2pt() * @see px2pt() */ $image_height = px2pt(imagesy($this->_image)); $image_width = px2pt(imagesx($this->_image)); /** * Get dimensions of the rectangle to be filled with the background image */ $padding_width = $right - $left; $padding_height = $top - $bottom; /** * Calculate the vertical offset from the top padding edge to the background image top edge using current * 'background-position' value. * * @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description */ if ($position->x_percentage) { $x_offset = ($padding_width - $image_width) * $position->x / 100; } else { $x_offset = $position->x; } /** * Calculate the horizontal offset from the left padding edge to the background image left edge using current * 'background-position' value * * @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description */ if ($position->y_percentage) { $y_offset = ($padding_height - $image_height) * $position->y / 100; } else { $y_offset = $position->y; } /** * Output the image (probably tiling it; depends on current value of 'background-repeat') using * current output driver's tiled image output functions. Note that px2pt(1) is an image scaling factor; as all * page element are scaled to fit the media, background images should be scaled too! * * @see OutputDriver::image() * @see OutputDriver::image_rx() * @see OutputDriver::image_ry() * @see OutputDriver::image_rxry() * * @link file:///C:/docs/css/colors.html#propdef-background-repeat CSS 2.1 'background-repeat' property description */ switch ($repeat) { case BR_NO_REPEAT: /** * 'background-repeat: no-repeat' case; no tiling at all */ $driver->image($this->_image, $left + $x_offset, $top - $image_height - $y_offset, px2pt(1)); break; case BR_REPEAT_X: /** * 'background-repeat: repeat-x' case; horizontal tiling */ $driver->image_rx($this->_image, $left + $x_offset, $top - $image_height - $y_offset, $image_width, $right, $x_offset, $y_offset, px2pt(1)); break; case BR_REPEAT_Y: /** * 'background-repeat: repeat-y' case; vertical tiling */ $driver->image_ry($this->_image, $left + $x_offset, $top - $image_height - $y_offset, $image_height, $bottom, $x_offset, $y_offset, px2pt(1)); break; case BR_REPEAT: /** * 'background-repeat: repeat' case; full tiling */ $driver->image_rx_ry($this->_image, $left + $x_offset, $top - $image_height + $y_offset, $image_width, $image_height, $right, $bottom, $x_offset, $y_offset, px2pt(1)); break; } /** * Restore the previous clipping area * * @see OutputDriver::clip() * @see OutputDriver::restore() */ $driver->restore(); }
function reflow_static_normal(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // if ($parent) { // Calculate margin values if they have been set as a percentage $this->_calc_percentage_margins($parent); // Calculate width value if it had been set as a percentage $this->_calc_percentage_width($parent, $context); if (!is_a($this->_width_constraint, "WCNone")) { $col_width = $this->get_table_columns_min_widths($context); if (array_sum($col_width) > $this->get_width()) { $this->_width_constraint = new WCNone(); } } // As table width can be deterimined by its contents, we may calculate auto values // only AFTER the contents have been reflown; thus, we'll offset the table // as a whole by a value of left margin AFTER the content reflow // Do margin collapsing $y = $this->collapse_margin($parent, $context); // At this moment we have top parent/child collapsed margin at the top of context object // margin stack $y = $this->apply_clear($y, $context); // Store calculated Y coordinate as current Y in the parent box $parent->_current_y = $y; // Terminate current parent line-box $parent->close_line($context); // And add current box to the parent's line-box (alone) $parent->append_line($this); // Determine upper-left _content_ corner position of current box // Also see note above regarding margins $this->put_left($parent->_current_x + $this->border->left->get_width() + $this->padding->left->value); // Note that top margin already used above during maring collapsing $this->put_top($parent->_current_y - $this->border->top->get_width() - $this->padding->top->value); // By default, child block box will fill all available parent width; // note that actual width will be smaller because of non-zero padding, border and margins $this->put_full_width($parent->get_available_width($context)); // } // Reflow contents $this->reflow_content($context); // Update the collapsed margin value with current box bottom margin $context->pop_collapsed_margin(); $context->pop_collapsed_margin(); $context->push_collapsed_margin($this->margin->bottom->value); // if ($parent) { // Calculate margins and/or width is 'auto' values have been specified $this->_calc_auto_width_margins($parent); $this->offset($this->margin->left->value, 0); // Extend parent's height to fit current box $parent->extend_height($this->get_bottom_margin()); // Terminate parent's line box $parent->close_line($context); // }; }
/** * Layout current checkbox element. Note that most CSS properties do not apply to the * checkboxes; i.e. margin/padding values are ignored, checkboxes always aligned to * to bottom of current line, etc. * * @param GenericContainerBox $parent * @param FlowContext $context Context object describing current flow parameters * * @return Boolean flag indicating the error/success state; 'null' value in case of critical error */ function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); /** * Check box size is constant (defined in config.inc.php) and is never affected * neither by CSS nor HTML. Call setup_dimensions once more to restore possible * changes size * * @see CHECKBOX_SIZE */ $this->setup_dimensions(); // set default baseline $this->baseline = $this->default_baseline; // // Vertical-align // $this->_apply_vertical_align($parent); /** * append to parent line box */ $parent->append_line($this); /** * Determine coordinates of upper-left margin corner */ $this->guess_corner($parent); /** * Offset parent current X coordinate */ $parent->_current_x += $this->get_full_width(); /** * Extend parents height to fit the checkbox */ $parent->extend_height($this->get_bottom_margin()); }
/** * Layout current checkbox element. Note that most CSS properties do not apply to the * checkboxes; i.e. margin/padding values are ignored, checkboxes always aligned to * to bottom of current line, etc. * * @param GenericContainerBox $parent * @param FlowContext $context Context object describing current flow parameters * * @return Boolean flag indicating the error/success state; 'null' value in case of critical error */ function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // set default baseline $this->baseline = $this->default_baseline; // // Vertical-align // $this->_apply_vertical_align($parent); /** * append to parent line box */ $parent->append_line($this); /** * Determine coordinates of upper-left margin corner */ $this->guess_corner($parent); /** * Offset parent current X coordinate */ $parent->_current_x += $this->get_full_width(); /** * Extend parents height to fit the checkbox */ $parent->extend_height($this->get_bottom_margin()); }
function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); global $g_config; $size = count($this->content); if ($g_config['mode'] == "quirks" && $size > 0) { // QUIRKS MODE: // H1-H6 and P elements should have their top/bottom margin suppressed if they occur as the first/last table cell child // correspondingly; note that we cannot do it usung CSS rules, as there's no selectors for the last child. // $first =& $this->get_first(); if (!is_null($first) && $this->_suppress_first && $first->isBlockLevel()) { $first->margin->top->value = 0; $first->margin->top->percentage = null; } $last =& $this->get_last(); if (!is_null($last) && $this->_suppress_last && $last->isBlockLevel()) { $last->margin->bottom->value = 0; $last->margin->bottom->percentage = null; } } // Determine upper-left _content_ corner position of current box $this->put_left($parent->_current_x + $this->get_extra_left()); // NOTE: Table cell margin is used as a cell-spacing value $border = $this->getCSSProperty(CSS_BORDER); $padding = $this->getCSSProperty(CSS_PADDING); $this->put_top($parent->_current_y - $border->top->get_width() - $padding->top->value); // CSS 2.1: // Floats, absolutely positioned elements, inline-blocks, table-cells, and elements with 'overflow' other than // 'visible' establish new block formatting contexts. $context->push(); $context->push_container_uid($this->uid); // Reflow cell content $this->reflow_content($context); // Extend the table cell height to fit all contained floats // // Determine the bottom edge corrdinate of the bottommost float // $float_bottom = $context->float_bottom(); if (!is_null($float_bottom)) { $this->extend_height($float_bottom); } // Restore old context $context->pop_container_uid(); $context->pop(); }
function reflow_static(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); // Note that inline boxes (actually SPANS) // are never added to the parent's line boxes // Move current box to the parent's current coordinates // Note that span box will start at the far left of the parent, NOT on its current X! // Also, note that inline box can have margins, padding and borders! $this->put_left($parent->get_left()); $this->put_top($parent->get_top() - $this->get_extra_top()); // first line of the SPAN will be offset to its parent current-x // PLUS the left padding of current span! $parent->_current_x += $this->get_extra_left(); $this->_current_x = $parent->_current_x; // Note that the same operation IS NOT applied to parent current-y! // The padding space is just extended to the top possibly OVERLAPPING the above boxes. $this->width = 0; // Reflow contents $size = count($this->content); for ($i = 0; $i < $size; $i++) { $child =& $this->content[$i]; // Add current element into _parent_ line box and reflow it $child->reflow($parent, $context); // In general, if inline box centained whitespace box only, // it could be removed during reflow function call; // let's check it and skip to next child // // if no children left AT ALL (so this box is empty), just exit // Track the real height of the inline box; it will be used by other functions // (say, functions calculating content height) $this->extend_height($child->get_bottom_margin()); } // Apply right extra space value (padding + border + margin) $parent->_current_x += $this->get_extra_right(); // Margins of inline boxes are not collapsed if ($this->get_first_data()) { $context->pop_collapsed_margin(); $context->push_collapsed_margin(0); } }
/** * Layout normal (non-floating) static-positioned block box. * * @param GenericContainerBox $parent The document element which should be treated as the parent of current element * @param FlowContext $context The flow context containing the additional layout data * * @see FlowContext * @see GenericContainerBox */ function reflow_static_normal(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); if ($parent) { /** * Child block will fill the whole content width of the parent block. * * 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + * 'border-right-width' + 'margin-right' = width of containing block * * See CSS 2.1 for more detailed explanation * * @link http://www.w3.org/TR/CSS21/visudet.html#blockwidth CSS 2.1. 10.3.3 Block-level, non-replaced elements in normal flow */ /** * Calculate margin values if they have been set as a percentage; replace percentage-based values * with fixed lengths. */ $this->_calc_percentage_margins($parent); $this->_calc_percentage_padding($parent); /** * Calculate width value if it had been set as a percentage; replace percentage-based value * with fixed value */ $this->put_full_width($parent->get_width()); $this->_calc_percentage_width($parent, $context); /** * Calculate 'auto' values of width and margins. Unlike tables, DIV width is either constrained * by some CSS rules or expanded to the parent width; thus, we can calculate 'auto' margin * values immediately. * * @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 Calculating widths and margins */ $this->_calc_auto_width_margins($parent); /** * Collapse top margin * * @see GenericFormattedBox::collapse_margin() * * @link http://www.w3.org/TR/CSS21/box.html#collapsing-margins CSS 2.1 Collapsing margins */ $y = $this->collapse_margin($parent, $context); /** * At this moment we have top parent/child collapsed margin at the top of context object * margin stack */ /** * Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'. */ $y = $this->apply_clear($y, $context); /** * Store calculated Y coordinate as current Y coordinate in the parent box * No more content will be drawn abowe this mark; current box padding area will * start below. */ $parent->_current_y = $y; /** * Terminate current parent line-box (as current box is not inline) */ $parent->close_line($context); /** * Add current box to the parent's line-box; we will close the line box below * after content will be reflown, so the line box will contain only current box. */ $parent->append_line($this); /** * Now, place the current box upper left content corner. Note that we should not * use get_extra_top here, as _current_y value already culculated using the top margin value * of the current box! The top content edge should be offset from that level only of padding and * border width. */ $border = $this->get_css_property(CSS_BORDER); $padding = $this->get_css_property(CSS_PADDING); $this->moveto($parent->get_left() + $this->get_extra_left(), $parent->_current_y - $border->top->get_width() - $padding->top->value); } /** * Reflow element's children */ $this->reflow_content($context); if ($this->get_css_property(CSS_OVERFLOW) != OVERFLOW_VISIBLE) { $this->fitFloats($context); } /** * After child elements have been reflown, we should the top collapsed margin stack value * replaced by the value of last child bottom collapsed margin; * if no children contained, then this value should be reset to 0. * * Note that invisible and * whitespaces boxes would not affect the collapsed margin value, so we need to * use 'get_first' function instead of just accessing the $content array. * * @see GenericContainerBox::get_first */ if (!is_null($this->get_first())) { $cm = 0; } else { $cm = $context->get_collapsed_margin(); } /** * Update the bottom value, collapsing the latter value with * current box bottom margin. * * Note that we need to remove TWO values from the margin stack: * first - the value of collapsed bottom margin of the last child AND * second - the value of collapsed top margin of current element. */ $margin = $this->get_css_property(CSS_MARGIN); if ($parent) { /** * Terminate parent's line box (it contains the current box only) */ $parent->close_line($context); $parent->_current_y = $this->collapse_margin_bottom($parent, $context); } }
/** * Layout current BR element. The reflow routine is somewhat similar to the block box reflow routine. * As most CSS properties do not apply to BR elements, and BR element always have parent element, * the routine is much simpler. * * @param GenericContainerBox $parent The document element which should be treated as the parent of current element * @param FlowContext $context The flow context containing the additional layout data * * @see FlowContext * @see GenericContainerBox */ function reflow(&$parent, &$context) { GenericFormattedBox::reflow($parent, $context); /** * Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'. */ $y = $this->apply_clear($parent->_current_y, $context); /** * Move current "box" to parent current coordinates. It is REQUIRED, in spite of the generated * box itself have no dimensions and will never be drawn, as several other routines uses box coordinates. */ $this->put_left($parent->_current_x); $this->put_top($y); /** * If we met a sequence of BR tags (like <BR><BR>), we'll have an only one item in the parent's * line box - whitespace; in this case we'll need to additionally offset current y coordinate by the font size, * as whitespace alone does not affect the Y-coordinate. */ if ($parent->line_box_empty()) { /** * There's no elements in the parent line box at all (e.g in the following situation: * <div><br/> .. some text here...</div>); thus, as we're initiating * a new line, we need to offset current Y coordinate by the font-size value. */ $parent->close_line($context, true); $parent->_current_y = min($this->get_bottom(), $parent->_current_y - $this->font_size); } else { /** * There's at least 1 non-whitespace element in the parent line box, we do not need to use whitespace * height; the bottom of the line box is defined by the non-whitespace elements. Top of the new line * should be equal to that value. */ $parent->close_line($context, true); } /** * We need to explicitly extend the parent's height, to make it contain the generated line, * as we don't know if it have any children _after_ this BR box. If we will not do it, * the following code will be rendred incorrectly: * <div>...some text...<br/></div> */ $parent->extend_height($parent->_current_y); }