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