当前位置: 首页>>代码示例>>PHP>>正文


PHP Block_Frame_Decorator::set_line方法代码示例

本文整理汇总了PHP中Block_Frame_Decorator::set_line方法的典型用法代码示例。如果您正苦于以下问题:PHP Block_Frame_Decorator::set_line方法的具体用法?PHP Block_Frame_Decorator::set_line怎么用?PHP Block_Frame_Decorator::set_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Block_Frame_Decorator的用法示例。


在下文中一共展示了Block_Frame_Decorator::set_line方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _text_align

 /**
  * Adjust the justification of each of our lines.
  * http://www.w3.org/TR/CSS21/text.html#propdef-text-align
  */
 protected function _text_align()
 {
     $style = $this->_frame->get_style();
     $w = $this->_frame->get_containing_block("w");
     $width = $style->length_in_pt($style->width, $w);
     switch ($style->text_align) {
         default:
         case "left":
             foreach ($this->_frame->get_line_boxes() as $line) {
                 if (!$line->left) {
                     continue;
                 }
                 foreach ($line->get_frames() as $frame) {
                     if ($frame instanceof Block_Frame_Decorator) {
                         continue;
                     }
                     $frame->set_position($frame->get_position("x") + $line->left);
                 }
             }
             return;
         case "right":
             foreach ($this->_frame->get_line_boxes() as $line) {
                 // Move each child over by $dx
                 $dx = $width - $line->w - $line->right;
                 foreach ($line->get_frames() as $frame) {
                     // Block frames are not aligned by text-align
                     if ($frame instanceof Block_Frame_Decorator) {
                         continue;
                     }
                     $frame->set_position($frame->get_position("x") + $dx);
                 }
             }
             break;
         case "justify":
             // We justify all lines except the last one
             $lines = $this->_frame->get_line_boxes();
             // needs to be a variable (strict standards)
             $lines = array_splice($lines, 0, -1);
             foreach ($lines as $i => $line) {
                 if ($line->br) {
                     unset($lines[$i]);
                 }
             }
             // One space character's width. Will be used to get a more accurate spacing
             $space_width = Font_Metrics::get_text_width(" ", $style->font_family, $style->font_size);
             foreach ($lines as $i => $line) {
                 if ($line->left) {
                     foreach ($line->get_frames() as $frame) {
                         if (!$frame instanceof Text_Frame_Decorator) {
                             continue;
                         }
                         $frame->set_position($frame->get_position("x") + $line->left);
                     }
                 }
                 // Only set the spacing if the line is long enough.  This is really
                 // just an aesthetic choice ;)
                 //if ( $line["left"] + $line["w"] + $line["right"] > self::MIN_JUSTIFY_WIDTH * $width ) {
                 // Set the spacing for each child
                 if ($line->wc > 1) {
                     $spacing = ($width - ($line->left + $line->w + $line->right) + $space_width) / ($line->wc - 1);
                 } else {
                     $spacing = 0;
                 }
                 $dx = 0;
                 foreach ($line->get_frames() as $frame) {
                     if (!$frame instanceof Text_Frame_Decorator) {
                         continue;
                     }
                     $text = $frame->get_text();
                     $spaces = mb_substr_count($text, " ");
                     $char_spacing = $style->length_in_pt($style->letter_spacing);
                     $_spacing = $spacing + $char_spacing;
                     $frame->set_position($frame->get_position("x") + $dx);
                     $frame->set_text_spacing($_spacing);
                     $dx += $spaces * $_spacing;
                 }
                 // The line (should) now occupy the entire width
                 $this->_frame->set_line($i, null, $width);
                 //}
             }
             break;
         case "center":
         case "centre":
             foreach ($this->_frame->get_line_boxes() as $line) {
                 // Centre each line by moving each frame in the line by:
                 $dx = ($width + $line->left - $line->w - $line->right) / 2;
                 foreach ($line->get_frames() as $frame) {
                     // Block frames are not aligned by text-align
                     if ($frame instanceof Block_Frame_Decorator) {
                         continue;
                     }
                     $frame->set_position($frame->get_position("x") + $dx);
                 }
             }
             break;
     }
//.........这里部分代码省略.........
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:101,代码来源:block_frame_reflower.cls.php


注:本文中的Block_Frame_Decorator::set_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。