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