xref: /webtrees/app/Report/ReportBaseCell.php (revision da83637ca6236094f5a00d6e54530cd25ac7aa0e)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees\Report;
17
18/**
19 * Class ReportBaseCell
20 */
21class ReportBaseCell extends ReportBaseElement
22{
23    /**
24     * Allows to center or align the text. Possible values are:<ul><li>left or empty string: left align</li><li>center: center align</li><li>right: right align</li><li>justify: justification (default value when $ishtml=false)</li></ul>
25     *
26     * @var string
27     */
28    public $align = '';
29    /**
30     * Whether or not a border should be printed around this box. 0 = no border, 1 = border. Default is 0.
31     * Or a string containing some or all of the following characters (in any order):<ul><li>L: left</li><li>T: top</li><li>R: right</li><li>B: bottom</li></ul>
32     *
33     * @var mixed
34     */
35    public $border;
36    /**
37     * Border color in HTML code
38     *
39     * @var string
40     */
41    public $bocolor;
42    /**
43     * The HTML color code to fill the background of this cell.
44     *
45     * @var string
46     */
47    public $bgcolor;
48    /**
49     * Indicates if the cell background must be painted (1) or transparent (0). Default value: 1.
50     * If no background color is set then it will not be painted
51     *
52     * @var int
53     */
54    public $fill;
55    /**
56     * Cell height DEFAULT 0 (expressed in points)
57     * The starting height of this cell. If the text wraps the height will automatically be adjusted.
58     *
59     * @var int
60     */
61    public $height;
62    /**
63     * Left position in user units (X-position). Default is the current position
64     *
65     * @var mixed
66     */
67    public $left;
68    /**
69     * Indicates where the current position should go after the call. Possible values are:<ul><li>0: to the right [DEFAULT]</li><li>1: to the beginning of the next line</li><li>2: below</li></ul>
70     *
71     * @var int
72     */
73    public $newline;
74    /**
75     * The name of the Style that should be used to render the text.
76     *
77     * @var string
78     */
79    public $styleName;
80    /**
81     * Stretch carachter mode: <ul><li>0 = disabled (default)</li><li>1 = horizontal scaling only if necessary</li><li>2 = forced horizontal scaling</li><li>3 = character spacing only if necessary</li><li>4 = forced character spacing</li></ul>
82     *
83     * @var int
84     */
85    public $stretch;
86    /**
87     * Text color in HTML code
88     *
89     * @var string
90     */
91    public $tcolor;
92    /**
93     * Top position in user units (Y-position). Default is the current position
94     *
95     * @var mixed
96     */
97    public $top;
98    /**
99     * URL address
100     *
101     * @var string
102     */
103    public $url;
104    /**
105     * Cell width DEFAULT 0 (expressed in points)
106     * Setting the width to 0 will make it the width from the current location to the right margin.
107     *
108     * @var int
109     */
110    public $width;
111
112    /** @var int Unknown */
113    public $reseth;
114
115    /**
116     * CELL - Element
117     *
118     * @param int    $width   cell width (expressed in points)
119     * @param int    $height  cell height (expressed in points)
120     * @param mixed  $border  Border style
121     * @param string $align   Text alignement
122     * @param string $bgcolor Background color code
123     * @param string $style   The name of the text style
124     * @param int    $ln      Indicates where the current position should go after the call
125     * @param mixed  $top     Y-position
126     * @param mixed  $left    X-position
127     * @param int    $fill    Indicates if the cell background must be painted (1) or transparent (0). Default value: 0.
128     * @param int    $stretch Stretch carachter mode
129     * @param string $bocolor Border color
130     * @param string $tcolor  Text color
131     * @param        $reseth
132     */
133    public function __construct(
134        $width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth
135    )
136    {
137        $this->align     = $align;
138        $this->border    = $border;
139        $this->bgcolor   = $bgcolor;
140        $this->bocolor   = $bocolor;
141        $this->fill      = $fill;
142        $this->height    = $height;
143        $this->left      = $left;
144        $this->newline   = $ln;
145        $this->styleName = $style;
146        $this->text      = '';
147        $this->tcolor    = $tcolor;
148        $this->top       = $top;
149        $this->url       = '';
150        $this->stretch   = $stretch;
151        $this->width     = $width;
152        $this->reseth    = $reseth;
153
154        return 0;
155    }
156
157    /**
158     * Get the cell height
159     *
160     * @param $renderer
161     *
162     * @return float
163     */
164    public function getHeight($renderer)
165    {
166        return $this->height;
167    }
168
169    /**
170     * Sets the current cells URL
171     *
172     * @param string $url The URL address to save
173     *
174     * @return int
175     */
176    public function setUrl($url)
177    {
178        $this->url = $url;
179
180        return 0;
181    }
182
183    /**
184     * Get the cell width
185     *
186     * @param $renderer
187     *
188     * @return float
189     */
190    public function getWidth($renderer)
191    {
192        return $this->width;
193    }
194}
195