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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Report; 19 20/** 21 * Class ReportBaseText 22 */ 23class ReportBaseText extends ReportBaseElement 24{ 25 /** 26 * Text color in HTML code 27 * 28 * @var string 29 */ 30 public $color; 31 /** 32 * Style name 33 * 34 * @var string 35 */ 36 public $styleName; 37 /** 38 * Remaining width of a cel 39 * 40 * @var float User unit (points) 41 */ 42 public $wrapWidthRemaining; 43 /** 44 * Original width of a cell 45 * 46 * @var float User unit (points) 47 */ 48 public $wrapWidthCell; 49 50 /** 51 * Create a Text class - Base 52 * 53 * @param string $style The name of the text style 54 * @param string $color HTML color code 55 */ 56 public function __construct($style, $color) 57 { 58 $this->text = ''; 59 $this->color = $color; 60 $this->wrapWidthRemaining = 0; 61 $this->styleName = $style; 62 } 63 64 /** 65 * Set the width for word-wrapping. 66 * 67 * @param float $wrapwidth 68 * @param float $cellwidth 69 * 70 * @return float 71 */ 72 public function setWrapWidth(float $wrapwidth, float $cellwidth): float 73 { 74 $this->wrapWidthCell = $cellwidth; 75 if (strpos($this->text, "\n") !== false) { 76 $this->wrapWidthRemaining = $cellwidth; 77 } else { 78 $this->wrapWidthRemaining = $wrapwidth; 79 } 80 81 return $this->wrapWidthRemaining; 82 } 83 84 /** 85 * Get the style name. 86 * 87 * @return string 88 */ 89 public function getStyleName(): string 90 { 91 return $this->styleName; 92 } 93} 94