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