本文整理汇总了PHP中GenericFormattedBox类的典型用法代码示例。如果您正苦于以下问题:PHP GenericFormattedBox类的具体用法?PHP GenericFormattedBox怎么用?PHP GenericFormattedBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GenericFormattedBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
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;
}
示例2: show
/**
* 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);
}
示例3: reflow
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);
}
示例4: reflow_static
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());
}
示例5: show_field
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;
}
示例6: reflow_absolute
/**
* 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());
}
}
示例7: reflow
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());
}
示例8: show
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;
}
示例9: reflow
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());
}
示例10: reflow_static
/**
* 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();
}
示例11: show
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;
}
示例12: reflow_anchors
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);
}
}
示例13: show
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;
}
示例14: reflow_static_normal
/**
* 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();
//.........这里部分代码省略.........
示例15: reflow_static_normal
/**
* 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);
}