1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Report; 19 20/** 21 * Class ReportBaseCell 22 */ 23class ReportBaseCell extends ReportBaseElement 24{ 25 /** 26 * 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> 27 * 28 * @var string 29 */ 30 public $align = ''; 31 /** 32 * Whether or not a border should be printed around this box. 0 = no border, 1 = border. Default is 0. 33 * 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> 34 * 35 * @var mixed 36 */ 37 public $border; 38 /** 39 * Border color in HTML code 40 * 41 * @var string 42 */ 43 public $bocolor; 44 /** 45 * The HTML color code to fill the background of this cell. 46 * 47 * @var string 48 */ 49 public $bgcolor; 50 /** 51 * Indicates if the cell background must be painted (1) or transparent (0). Default value: 1. 52 * If no background color is set then it will not be painted 53 * 54 * @var int 55 */ 56 public $fill; 57 /** 58 * Cell height DEFAULT 0 (expressed in points) 59 * The starting height of this cell. If the text wraps the height will automatically be adjusted. 60 * 61 * @var float 62 */ 63 public $height; 64 /** 65 * Left position in user units (X-position). Default is the current position 66 * 67 * @var mixed 68 */ 69 public $left; 70 /** 71 * 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> 72 * 73 * @var int 74 */ 75 public $newline; 76 /** 77 * The name of the Style that should be used to render the text. 78 * 79 * @var string 80 */ 81 public $styleName; 82 /** 83 * 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> 84 * 85 * @var int 86 */ 87 public $stretch; 88 /** 89 * Text color in HTML code 90 * 91 * @var string 92 */ 93 public $tcolor; 94 /** 95 * Top position in user units (Y-position). Default is the current position 96 * 97 * @var mixed 98 */ 99 public $top; 100 /** 101 * URL address 102 * 103 * @var string 104 */ 105 public $url; 106 /** 107 * Cell width DEFAULT 0 (expressed in points) 108 * Setting the width to 0 will make it the width from the current location to the right margin. 109 * 110 * @var float 111 */ 112 public $width; 113 114 /** @var bool */ 115 public $reseth; 116 117 /** 118 * CELL - Element 119 * 120 * @param int $width cell width (expressed in points) 121 * @param int $height cell height (expressed in points) 122 * @param mixed $border Border style 123 * @param string $align Text alignement 124 * @param string $bgcolor Background color code 125 * @param string $style The name of the text style 126 * @param int $ln Indicates where the current position should go after the call 127 * @param mixed $top Y-position 128 * @param mixed $left X-position 129 * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0. 130 * @param int $stretch Stretch carachter mode 131 * @param string $bocolor Border color 132 * @param string $tcolor Text color 133 * @param bool $reseth 134 */ 135 public function __construct($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, int $fill, int $stretch, string $bocolor, string $tcolor, bool $reseth) 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 155 /** 156 * Get the cell height 157 * 158 * @param ReportHtml|ReportTcpdf $renderer 159 * 160 * @return float 161 */ 162 public function getHeight($renderer): float 163 { 164 return $this->height; 165 } 166 167 /** 168 * Sets the current cells URL 169 * 170 * @param string $url The URL address to save 171 * 172 * @return void 173 */ 174 public function setUrl($url) 175 { 176 $this->url = $url; 177 } 178 179 /** 180 * Get the cell width 181 * 182 * @param ReportHtml|ReportTcpdf $renderer 183 * 184 * @return float|array 185 */ 186 public function getWidth($renderer) 187 { 188 return $this->width; 189 } 190} 191