xref: /webtrees/app/Report/ReportBaseTextbox.php (revision b8fc901f205cd6af65496b916bf63547a3065a2f)
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 ReportBaseTextbox
24 */
25class ReportBaseTextbox extends ReportBaseElement
26{
27    /**
28     * Array of elements in the TextBox
29     *
30     * @var ReportBaseElement[]|string[]
31     */
32    public $elements = [];
33
34    /**
35     *  Background color in HTML code
36     *
37     * @var string
38     */
39    public $bgcolor;
40    /**
41     * Whether or not paint the background
42     *
43     * @var bool
44     */
45    public $fill;
46
47    /**
48     * Position the left corner of this box on the page(expressed in points). The default is the current position.
49     *
50     * @var float
51     */
52    public $left;
53    /**
54     * Position the top corner of this box on the page(expressed in points). the default is the current position
55     *
56     * @var float
57     */
58    public $top;
59    /**
60     * After this box is finished rendering, should the next section of text start immediately after the this box or should it start on a new line under this box. 0 = no new line, 1 = force new line. Default is 0
61     *
62     * @var bool
63     */
64    public $newline;
65
66    /** @var bool Unused? */
67    public $pagecheck;
68
69    /** @var bool Whether to print a border */
70    public $border;
71
72    /**
73     * Style of rendering
74     *
75     * <ul>
76     * <li>D or empty string: Draw (default).</li>
77     * <li>F: Fill.</li>
78     * <li>DF or FD: Draw and fill.</li>
79     * <li>CNZ: Clipping mode (using the even-odd rule to determine which regions lie inside the clipping path).</li>
80     *<li>CEO: Clipping mode (using the nonzero winding number rule to determine which regions lie inside the clipping path).</li>
81     * </ul>
82     *
83     * @var string
84     */
85    public $style;
86
87    /**
88     * @var array Border style of rectangle. Array with keys among the following:
89     * <ul>
90     * <li>all: Line style of all borders. Array like for {@link SetLineStyle SetLineStyle}.</li>
91     * <li>L, T, R, B or combinations: Line style of left, top, right or bottom border. Array like for {@link SetLineStyle SetLineStyle}.</li>
92     * </ul>
93     * Not yet in use
94     * var $borderstyle;
95     */
96
97    /**
98     * The starting height of this cell. If the text wraps the height will automatically be adjusted
99     *
100     * @var float
101     */
102    public $height;
103    /**
104     * Setting the width to 0 will make it the width from the current location to the right margin
105     *
106     * @var float
107     */
108    public $width;
109    /**
110     * Use cell padding or not
111     *
112     * @var bool
113     */
114    public $padding;
115    /**
116     * Resets this box last height after it’s done
117     *
118     * @var bool
119     */
120    public $reseth;
121
122    /**
123     * TextBox - Element - Base
124     *
125     * @param float  $width   Text box width
126     * @param float  $height  Text box height
127     * @param bool   $border
128     * @param string $bgcolor Background color code in HTML
129     * @param bool   $newline
130     * @param float  $left
131     * @param float  $top
132     * @param bool   $pagecheck
133     * @param string $style
134     * @param bool   $fill
135     * @param bool   $padding
136     * @param bool   $reseth
137     */
138    public function __construct(
139        float $width,
140        float $height,
141        bool $border,
142        string $bgcolor,
143        bool $newline,
144        float $left,
145        float $top,
146        bool $pagecheck,
147        string $style,
148        bool $fill,
149        bool $padding,
150        bool $reseth
151    ) {
152        $this->border    = $border;
153        $this->bgcolor   = $bgcolor;
154        $this->fill      = $fill;
155        $this->height    = $height;
156        $this->left      = $left;
157        $this->newline   = $newline;
158        $this->pagecheck = $pagecheck;
159        $this->style     = $style;
160        $this->top       = $top;
161        $this->width     = $width;
162        $this->padding   = $padding;
163        $this->reseth    = $reseth;
164    }
165
166    /**
167     * Add an element to the TextBox
168     *
169     * @param ReportBaseElement|string $element
170     *
171     * @return void
172     */
173    public function addElement($element)
174    {
175        $this->elements[] = $element;
176    }
177}
178