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