1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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 <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Report; 21 22/** 23 * Class ReportBaseCell 24 */ 25class ReportBaseCell extends ReportBaseElement 26{ 27 // Center or align the text. Possible values are: 28 // left or empty string: left align 29 // center: center align 30 // right: right align 31 // justify: justification (default value when $ishtml=false) 32 public string $align = ''; 33 34 // Whether a border should be printed around this box. 35 // 0 = no border (default) 36 // 1 = border 37 // a string containing some or all of the following characters (in any order): 38 // L: left 39 // T: top 40 // R: right 41 // B: bottom 42 /** @var int|string */ 43 public $border; 44 45 /** 46 * Border color in HTML code 47 * 48 * @var string 49 */ 50 51 public $bocolor; 52 /** 53 * The HTML color code to fill the background of this cell. 54 * 55 * @var string 56 */ 57 58 public $bgcolor; 59 /** 60 * Indicates if the cell background must be painted (1) or transparent (0). Default value: 1. 61 * If no background color is set then it will not be painted 62 * 63 * @var int 64 */ 65 66 public $fill; 67 /** 68 * Cell height DEFAULT 0 (expressed in points) 69 * The starting height of this cell. If the text wraps the height will automatically be adjusted. 70 * 71 * @var float 72 */ 73 public $height; 74 75 /** 76 * Left position in user units (X-position). Default is the current position 77 * 78 * @var mixed 79 */ 80 81 public $left; 82 /** 83 * 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> 84 * 85 * @var int 86 */ 87 88 public $newline; 89 /** 90 * The name of the Style that should be used to render the text. 91 * 92 * @var string 93 */ 94 95 public $styleName; 96 /** 97 * 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> 98 * 99 * @var int 100 */ 101 102 public $stretch; 103 /** 104 * Text color in HTML code 105 * 106 * @var string 107 */ 108 109 public $tcolor; 110 /** 111 * Top position in user units (Y-position). Default is the current position 112 * 113 * @var mixed 114 */ 115 116 public $top; 117 /** 118 * URL address 119 * 120 * @var string 121 */ 122 123 public $url; 124 /** 125 * Cell width DEFAULT 0 (expressed in points) 126 * Setting the width to 0 will make it the width from the current location to the right margin. 127 * 128 * @var float 129 */ 130 131 public $width; 132 133 /** @var bool */ 134 public $reseth; 135 136 /** 137 * CELL - Element 138 * 139 * @param int $width cell width (expressed in points) 140 * @param int $height cell height (expressed in points) 141 * @param mixed $border Border style 142 * @param string $align Text alignement 143 * @param string $bgcolor Background color code 144 * @param string $style The name of the text style 145 * @param int $ln Indicates where the current position should go after the call 146 * @param mixed $top Y-position 147 * @param mixed $left X-position 148 * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 0. 149 * @param int $stretch Stretch carachter mode 150 * @param string $bocolor Border color 151 * @param string $tcolor Text color 152 * @param bool $reseth 153 */ 154 public function __construct( 155 int $width, 156 int $height, 157 $border, 158 string $align, 159 string $bgcolor, 160 string $style, 161 int $ln, 162 $top, 163 $left, 164 int $fill, 165 int $stretch, 166 string $bocolor, 167 string $tcolor, 168 bool $reseth 169 ) { 170 $this->align = $align; 171 $this->border = $border; 172 $this->bgcolor = $bgcolor; 173 $this->bocolor = $bocolor; 174 $this->fill = $fill; 175 $this->height = $height; 176 $this->left = $left; 177 $this->newline = $ln; 178 $this->styleName = $style; 179 $this->text = ''; 180 $this->tcolor = $tcolor; 181 $this->top = $top; 182 $this->url = ''; 183 $this->stretch = $stretch; 184 $this->width = $width; 185 $this->reseth = $reseth; 186 } 187 188 /** 189 * Get the cell height 190 * 191 * @param HtmlRenderer|PdfRenderer $renderer 192 * 193 * @return float 194 */ 195 public function getHeight($renderer): float 196 { 197 return $this->height; 198 } 199 200 /** 201 * Sets the current cells URL 202 * 203 * @param string $url The URL address to save 204 * 205 * @return void 206 */ 207 public function setUrl($url): void 208 { 209 $this->url = $url; 210 } 211 212 /** 213 * Get the cell width 214 * 215 * @param HtmlRenderer|PdfRenderer $renderer 216 * 217 * @return array{0:float,1:int,2:float|int} 218 */ 219 public function getWidth($renderer): array 220 { 221 return [$this->width, 1, $this->height]; 222 } 223} 224