xref: /webtrees/app/Report/ReportBaseTextbox.php (revision b6017f990d38d8c56e04c0096ce9a7e8745ad4ba)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 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 <https://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     * The starting height of this cell. If the text wraps the height will automatically be adjusted
89     *
90     * @var float
91     */
92    public $height;
93    /**
94     * Setting the width to 0 will make it the width from the current location to the right margin
95     *
96     * @var float
97     */
98    public $width;
99    /**
100     * Use cell padding or not
101     *
102     * @var bool
103     */
104    public $padding;
105    /**
106     * Resets this box last height after it’s done
107     *
108     * @var bool
109     */
110    public $reseth;
111
112    /**
113     * TextBox - Element - Base
114     *
115     * @param float  $width   Text box width
116     * @param float  $height  Text box height
117     * @param bool   $border
118     * @param string $bgcolor Background color code in HTML
119     * @param bool   $newline
120     * @param float  $left
121     * @param float  $top
122     * @param bool   $pagecheck
123     * @param string $style
124     * @param bool   $fill
125     * @param bool   $padding
126     * @param bool   $reseth
127     */
128    public function __construct(
129        float $width,
130        float $height,
131        bool $border,
132        string $bgcolor,
133        bool $newline,
134        float $left,
135        float $top,
136        bool $pagecheck,
137        string $style,
138        bool $fill,
139        bool $padding,
140        bool $reseth
141    ) {
142        $this->border    = $border;
143        $this->bgcolor   = $bgcolor;
144        $this->fill      = $fill;
145        $this->height    = $height;
146        $this->left      = $left;
147        $this->newline   = $newline;
148        $this->pagecheck = $pagecheck;
149        $this->style     = $style;
150        $this->top       = $top;
151        $this->width     = $width;
152        $this->padding   = $padding;
153        $this->reseth    = $reseth;
154    }
155
156    /**
157     * Add an element to the TextBox
158     *
159     * @param ReportBaseElement|string $element
160     *
161     * @return void
162     */
163    public function addElement($element): void
164    {
165        $this->elements[] = $element;
166    }
167}
168