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 | * @package dompdf |
---|
37 | * @version 0.5.1 |
---|
38 | */ |
---|
39 | |
---|
40 | /* $Id: list_bullet_renderer.cls.php,v 1.5 2006/07/07 21:31:03 benjcarson Exp $ */ |
---|
41 | |
---|
42 | /** |
---|
43 | * Renders list bullets |
---|
44 | * |
---|
45 | * @access private |
---|
46 | * @package dompdf |
---|
47 | */ |
---|
48 | class List_Bullet_Renderer extends Abstract_Renderer { |
---|
49 | |
---|
50 | //........................................................................ |
---|
51 | |
---|
52 | function render(Frame $frame) { |
---|
53 | |
---|
54 | $style = $frame->get_style(); |
---|
55 | $line_height = $style->length_in_pt($style->line_height, $frame->get_containing_block("w")); |
---|
56 | |
---|
57 | // Handle list-style-image |
---|
58 | if ( $style->list_style_image != "none" ) { |
---|
59 | |
---|
60 | list($x,$y) = $frame->get_position(); |
---|
61 | $w = $frame->get_width(); |
---|
62 | $h = $frame->get_height(); |
---|
63 | $x += $w / 2; |
---|
64 | $y += $line_height / 2 - $h / 2; |
---|
65 | |
---|
66 | $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); |
---|
67 | |
---|
68 | } else { |
---|
69 | |
---|
70 | $bullet_style = $style->list_style_type; |
---|
71 | $bullet_size = List_Bullet_Frame_Decorator::BULLET_SIZE; |
---|
72 | |
---|
73 | $fill = false; |
---|
74 | |
---|
75 | switch ($bullet_style) { |
---|
76 | |
---|
77 | default: |
---|
78 | case "disc": |
---|
79 | $fill = true; |
---|
80 | |
---|
81 | case "circle": |
---|
82 | if ( !$fill ) |
---|
83 | $fill = false; |
---|
84 | |
---|
85 | list($x,$y) = $frame->get_position(); |
---|
86 | $x += $bullet_size / 2 + List_Bullet_Frame_Decorator::BULLET_PADDING; |
---|
87 | $y += $line_height - $bullet_size; |
---|
88 | $r = $bullet_size / 2; |
---|
89 | $this->_canvas->circle($x, $y, $r, $style->color, 0.2, null, $fill); |
---|
90 | break; |
---|
91 | |
---|
92 | case "square": |
---|
93 | list($x, $y) = $frame->get_position(); |
---|
94 | $w = $bullet_size; |
---|
95 | $x += List_Bullet_Frame_Decorator::BULLET_PADDING; |
---|
96 | $y += $line_height - $w - List_Bullet_Frame_Decorator::BULLET_PADDING; |
---|
97 | $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color); |
---|
98 | break; |
---|
99 | |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | ?> |
---|