source: trunk/filemanager/tp/dompdf/include/list_bullet_positioner.cls.php @ 2000

Revision 2000, 4.1 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implementação do módulo gerenciador de arquivos

Line 
1<?php
2/**
3 * DOMPDF - PHP5 HTML to PDF renderer
4 *
5 * File: $RCSfile: list_bullet_positioner.cls.php,v $
6 * Created on: 2004-06-23
7 *
8 * Copyright (c) 2004 - Benj Carson <benjcarson@digitaljunkies.ca>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library in the file LICENSE.LGPL; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 * 02111-1307 USA
24 *
25 * Alternatively, you may distribute this software under the terms of the
26 * PHP License, version 3.0 or later.  A copy of this license should have
27 * been distributed with this file in the file LICENSE.PHP .  If this is not
28 * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
29 *
30 * The latest version of DOMPDF might be available at:
31 * http://www.digitaljunkies.ca/dompdf
32 *
33 * @link http://www.digitaljunkies.ca/dompdf
34 * @copyright 2004 Benj Carson
35 * @author Benj Carson <benjcarson@digitaljunkies.ca>
36 * @contributor Helmut Tischer <htischer@weihenstephan.org>
37 * @package dompdf
38 * @version 0.5.1
39 *
40 * Changes
41 * @contributor Helmut Tischer <htischer@weihenstephan.org>
42 * @version 20090622
43 * - try to adjust top position of bullet to top corner of subsequent font
44 */
45
46/* $Id: list_bullet_positioner.cls.php 186 2009-10-19 22:42:06Z eclecticgeek@gmail.com $ */
47
48/**
49 * Positions list bullets
50 *
51 * @access private
52 * @package dompdf
53 */
54class List_Bullet_Positioner extends Positioner {
55
56  function __construct(Frame_Decorator $frame) { parent::__construct($frame); }
57 
58  //........................................................................
59
60  function position() {
61   
62    // Bullets & friends are positioned an absolute distance to the left of
63    // the content edge of their parent element
64    $cb = $this->_frame->get_containing_block();
65    $style = $this->_frame->get_style();
66   
67    // Note: this differs from most frames in that we must position
68    // ourselves after determining our width
69    $x = $cb["x"] - $this->_frame->get_width();
70
71    $p = $this->_frame->find_block_parent();
72
73    $y = $p->get_current_line("y");
74
75    // This is a bit of a hack...
76    $n = $this->_frame->get_next_sibling();
77    if ( $n ) {
78      $style = $n->get_style();
79      $y += $style->length_in_pt( array($style->margin_top, $style->padding_top),
80                                  $n->get_containing_block("w") );
81    }
82
83        // Now the position is the left top of the block which should be marked with the bullet.
84        // We tried to find out the y of the start of the first text character within the block.
85        // But the top margin/padding does not fit, neither from this nor from the next sibling
86        // The "bit of a hack" above does not work also.
87       
88        // Instead let's position the bullet vertically centered to the block which should be marked.
89        // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent()
90        // the get_containing_block is paper width and the entire list as height.
91       
92    // if ($p) {
93    //   //$cb = $n->get_containing_block();
94    //   $cb = $p->get_containing_block();
95    //   $y += $cb["h"]/2;
96    // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':';
97    // }         
98
99        // Todo:
100        // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing
101
102    $style = $p->get_style();
103    $font_size = $style->get_font_size();
104    $line_height = $style->length_in_pt($style->line_height, $font_size);
105    $y += ($line_height - $font_size) / 2;     
106         
107    //Position is x-end y-top of character position of the bullet.   
108    $this->_frame->set_position($x, $y);
109   
110  }
111}
112?>
Note: See TracBrowser for help on using the repository browser.