1a25f0a04SGreg Roach<?php 2a25f0a04SGreg Roach/** 3a25f0a04SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 5a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify 6a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by 7a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a25f0a04SGreg Roach * (at your option) any later version. 9a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful, 10a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a25f0a04SGreg Roach * GNU General Public License for more details. 13a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License 14a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a25f0a04SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Report; 19a25f0a04SGreg Roach 20a25f0a04SGreg Roach/** 21a25f0a04SGreg Roach * Class ReportBaseText 22a25f0a04SGreg Roach */ 23c1010edaSGreg Roachclass ReportBaseText extends ReportBaseElement 24c1010edaSGreg Roach{ 25a25f0a04SGreg Roach /** 26a25f0a04SGreg Roach * Text color in HTML code 27a25f0a04SGreg Roach * 28a25f0a04SGreg Roach * @var string 29a25f0a04SGreg Roach */ 30a25f0a04SGreg Roach public $color; 31a25f0a04SGreg Roach /** 32a25f0a04SGreg Roach * Style name 33a25f0a04SGreg Roach * 34a25f0a04SGreg Roach * @var string 35a25f0a04SGreg Roach */ 36a25f0a04SGreg Roach public $styleName; 37a25f0a04SGreg Roach /** 38a25f0a04SGreg Roach * Remaining width of a cel 39a25f0a04SGreg Roach * 40*589feda3SGreg Roach * @var float User unit (points) 41a25f0a04SGreg Roach */ 42a25f0a04SGreg Roach public $wrapWidthRemaining; 43a25f0a04SGreg Roach /** 44a25f0a04SGreg Roach * Original width of a cell 45a25f0a04SGreg Roach * 46*589feda3SGreg Roach * @var float User unit (points) 47a25f0a04SGreg Roach */ 48a25f0a04SGreg Roach public $wrapWidthCell; 49a25f0a04SGreg Roach 50a25f0a04SGreg Roach /** 51a25f0a04SGreg Roach * Create a Text class - Base 52a25f0a04SGreg Roach * 53a25f0a04SGreg Roach * @param string $style The name of the text style 54a25f0a04SGreg Roach * @param string $color HTML color code 55a25f0a04SGreg Roach */ 56c1010edaSGreg Roach public function __construct($style, $color) 57c1010edaSGreg Roach { 58a25f0a04SGreg Roach $this->text = ''; 59a25f0a04SGreg Roach $this->color = $color; 60a25f0a04SGreg Roach $this->wrapWidthRemaining = 0; 61a25f0a04SGreg Roach $this->styleName = $style; 62a25f0a04SGreg Roach } 63a25f0a04SGreg Roach 64a25f0a04SGreg Roach /** 6576692c8bSGreg Roach * Set the width for word-wrapping. 6676692c8bSGreg Roach * 67a25f0a04SGreg Roach * @param $wrapwidth 68a25f0a04SGreg Roach * @param $cellwidth 69a25f0a04SGreg Roach * 70*589feda3SGreg Roach * @return float 71a25f0a04SGreg Roach */ 72*589feda3SGreg Roach public function setWrapWidth($wrapwidth, $cellwidth): float 73c1010edaSGreg Roach { 74a25f0a04SGreg Roach $this->wrapWidthCell = $cellwidth; 75a25f0a04SGreg Roach if (strpos($this->text, "\n") !== false) { 76a25f0a04SGreg Roach $this->wrapWidthRemaining = $cellwidth; 77a25f0a04SGreg Roach } else { 78a25f0a04SGreg Roach $this->wrapWidthRemaining = $wrapwidth; 79a25f0a04SGreg Roach } 80a25f0a04SGreg Roach 81a25f0a04SGreg Roach return $this->wrapWidthRemaining; 82a25f0a04SGreg Roach } 83a25f0a04SGreg Roach 84a25f0a04SGreg Roach /** 8576692c8bSGreg Roach * Get the style name. 8676692c8bSGreg Roach * 87a25f0a04SGreg Roach * @return string 88a25f0a04SGreg Roach */ 898f53f488SRico Sonntag public function getStyleName(): string 90c1010edaSGreg Roach { 91a25f0a04SGreg Roach return $this->styleName; 92a25f0a04SGreg Roach } 93a25f0a04SGreg Roach} 94