source: branches/2.2/filemanager/tp/dompdf/include/list_bullet_renderer.cls.php @ 3019

Revision 3019, 4.3 KB checked in by amuller, 14 years ago (diff)

Ticket #1135 - Corrigindo CSS e adicionando filemanager

Line 
1<?php
2/**
3 * DOMPDF - PHP5 HTML to PDF renderer
4 *
5 * File: $RCSfile: list_bullet_renderer.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 * - bullet size proportional to font size, center position
44 */
45
46/* $Id: list_bullet_renderer.cls.php 186 2009-10-19 22:42:06Z eclecticgeek@gmail.com $ */
47
48/**
49 * Renders list bullets
50 *
51 * @access private
52 * @package dompdf
53 */
54class List_Bullet_Renderer extends Abstract_Renderer {
55
56  //........................................................................
57
58  function render(Frame $frame) {
59
60    $style = $frame->get_style();
61    $font_size = $style->get_font_size();
62    $line_height = $style->length_in_pt($style->line_height, $frame->get_containing_block("w"));
63
64    // Handle list-style-image
65    // If list style image is requested but missing, fall back to predefined types
66    if ( $style->list_style_image != "none" &&
67         strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR . "/res/broken_image.png") != 0) {
68
69      list($x,$y) = $frame->get_position();
70     
71      //For expected size and aspect, instead of box size, use image natural size scaled to DPI.
72      // Resample the bullet image to be consistent with 'auto' sized images
73      // See also Image_Frame_Reflower::get_min_max_width
74      // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary.
75      //$w = $frame->get_width();
76      //$h = $frame->get_height();
77      list($width, $height) = getimagesize($img);
78      $w = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI;
79      $h = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI;
80     
81      $x -= $w;
82      $y -= ($line_height - $font_size)/2; //Reverse hinting of list_bullet_positioner
83
84      $this->_canvas->image( $img, $frame->get_image_ext(), $x, $y, $w, $h);
85
86    } else {
87
88      $bullet_style = $style->list_style_type;
89
90      $fill = false;
91
92      switch ($bullet_style) {
93
94      default:
95      case "disc":
96        $fill = true;
97
98      case "circle":
99        list($x,$y) = $frame->get_position();
100        $r = ($font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/ ))/2;
101        $x -= $font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE/2);
102        $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT))/2;
103        $o = $font_size*List_Bullet_Frame_Decorator::BULLET_THICKNESS;
104        $this->_canvas->circle($x, $y, $r, $style->color, $o, null, $fill);
105        break;
106
107      case "square":
108        list($x, $y) = $frame->get_position();
109        $w = $font_size*List_Bullet_Frame_Decorator::BULLET_SIZE;
110        $x -= $w;
111        $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT-List_Bullet_Frame_Decorator::BULLET_SIZE))/2;
112        $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color);
113        break;
114     
115      case "none":
116        break;
117
118      }
119    }
120  }
121}
122?>
Note: See TracBrowser for help on using the repository browser.