xref: /webtrees/app/Report/ReportBaseCell.php (revision f315390b2ef3b402a974292b894bb8d92201eb00)
1a25f0a04SGreg Roach<?php
23976b470SGreg Roach
3a25f0a04SGreg Roach/**
4a25f0a04SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify
7a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by
8a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a25f0a04SGreg Roach * (at your option) any later version.
10a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful,
11a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a25f0a04SGreg Roach * GNU General Public License for more details.
14a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16a25f0a04SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2076692c8bSGreg Roachnamespace Fisharebest\Webtrees\Report;
21a25f0a04SGreg Roach
22a25f0a04SGreg Roach/**
23a25f0a04SGreg Roach * Class ReportBaseCell
24a25f0a04SGreg Roach */
25c1010edaSGreg Roachclass ReportBaseCell extends ReportBaseElement
26c1010edaSGreg Roach{
270a709a28SGreg Roach    // Center or align the text. Possible values are:
280a709a28SGreg Roach    // left or empty string: left align
290a709a28SGreg Roach    // center: center align
300a709a28SGreg Roach    // right: right align
310a709a28SGreg Roach    // justify: justification (default value when $ishtml=false)
320a709a28SGreg Roach    public string $align = '';
330a709a28SGreg Roach
340a709a28SGreg Roach    // Whether a border should be printed around this box.
3577bab461SGreg Roach    // ''  = no border (default)
3677bab461SGreg Roach    // '1' = border
370a709a28SGreg Roach    // a string containing some or all of the following characters (in any order):
380a709a28SGreg Roach    // L: left
390a709a28SGreg Roach    // T: top
400a709a28SGreg Roach    // R: right
410a709a28SGreg Roach    // B: bottom
4277bab461SGreg Roach    public string $border;
430a709a28SGreg Roach
4477bab461SGreg Roach    // Border color in HTML code
4577bab461SGreg Roach    public string $bocolor;
460a709a28SGreg Roach
4777bab461SGreg Roach    // The HTML color code to fill the background of this cell.
4877bab461SGreg Roach    public string $bgcolor;
490a709a28SGreg Roach
50*f315390bSGreg Roach    // Indicates if the cell background must be painted (true) or transparent (false).
5177bab461SGreg Roach    // If no background color is set then it will not be painted
52*f315390bSGreg Roach    public bool $fill;
530a709a28SGreg Roach
5477bab461SGreg Roach    // Cell height DEFAULT 0 (expressed in points)
5577bab461SGreg Roach    // The starting height of this cell. If the text wraps the height will automatically be adjusted.
5677bab461SGreg Roach    public float $height;
570a709a28SGreg Roach
58a25f0a04SGreg Roach    /**
59a25f0a04SGreg Roach     * Left position in user units (X-position). Default is the current position
60a25f0a04SGreg Roach     *
61*f315390bSGreg Roach     * @var float
62a25f0a04SGreg Roach     */
630a709a28SGreg Roach
64*f315390bSGreg Roach    public float $left;
650a709a28SGreg Roach
6677bab461SGreg Roach    // Indicates where the current position should go after the call. Possible values are:
6777bab461SGreg Roach    // 0: to the right [DEFAULT]
6877bab461SGreg Roach    // 1: to the beginning of the next line
6977bab461SGreg Roach    // 2: below
7077bab461SGreg Roach    public int $newline;
710a709a28SGreg Roach
7277bab461SGreg Roach    // The name of the Style that should be used to render the text.
7377bab461SGreg Roach    public string $styleName;
740a709a28SGreg Roach
7577bab461SGreg Roach    // Stretch character mode:
7677bab461SGreg Roach    // 0 = disabled (default)
7777bab461SGreg Roach    // 1 = horizontal scaling only if necessary
7877bab461SGreg Roach    // 2 = forced horizontal scaling
7977bab461SGreg Roach    // 3 = character spacing only if necessary
8077bab461SGreg Roach    // 4 = forced character spacing
8177bab461SGreg Roach    public int $stretch;
820a709a28SGreg Roach
8377bab461SGreg Roach    // Text color in HTML code
8477bab461SGreg Roach    public string $tcolor;
8577bab461SGreg Roach
86a25f0a04SGreg Roach    /**
87a25f0a04SGreg Roach     * Top position in user units (Y-position). Default is the current position
88a25f0a04SGreg Roach     *
89*f315390bSGreg Roach     * @var float
90a25f0a04SGreg Roach     */
910a709a28SGreg Roach
92*f315390bSGreg Roach    public float $top;
930a709a28SGreg Roach
9477bab461SGreg Roach    // URL address
9577bab461SGreg Roach    public string $url = '';
960a709a28SGreg Roach
9777bab461SGreg Roach    // Cell width DEFAULT 0 (expressed in points)
9877bab461SGreg Roach    // Setting the width to 0 will make it the width from the current location to the right margin.
9977bab461SGreg Roach    public float $width;
100a25f0a04SGreg Roach
10177bab461SGreg Roach    public bool $reseth;
102a25f0a04SGreg Roach
103a25f0a04SGreg Roach    /**
104a25f0a04SGreg Roach     * CELL - Element
105a25f0a04SGreg Roach     *
10677bab461SGreg Roach     * @param float  $width   cell width (expressed in points)
10777bab461SGreg Roach     * @param float  $height  cell height (expressed in points)
10877bab461SGreg Roach     * @param string $border  Border style
10977bab461SGreg Roach     * @param string $align   Text alignment
110a25f0a04SGreg Roach     * @param string $bgcolor Background color code
111a25f0a04SGreg Roach     * @param string $style   The name of the text style
112cbc1590aSGreg Roach     * @param int    $ln      Indicates where the current position should go after the call
113*f315390bSGreg Roach     * @param float  $top     Y-position
114*f315390bSGreg Roach     * @param float  $left    X-position
115*f315390bSGreg Roach     * @param bool   $fill    Indicates if the cell background must be painted (1) or transparent (0).
116cbc1590aSGreg Roach     * @param int    $stretch Stretch carachter mode
117a25f0a04SGreg Roach     * @param string $bocolor Border color
118a25f0a04SGreg Roach     * @param string $tcolor  Text color
1198a4ee39cSGreg Roach     * @param bool   $reseth
120a25f0a04SGreg Roach     */
121b6f35a76SGreg Roach    public function __construct(
12277bab461SGreg Roach        float $width,
12377bab461SGreg Roach        float $height,
12477bab461SGreg Roach        string $border,
12524f2a3afSGreg Roach        string $align,
126b6f35a76SGreg Roach        string $bgcolor,
127b6f35a76SGreg Roach        string $style,
128b6f35a76SGreg Roach        int $ln,
129*f315390bSGreg Roach        float $top,
130*f315390bSGreg Roach        float $left,
131*f315390bSGreg Roach        bool $fill,
132b6f35a76SGreg Roach        int $stretch,
133b6f35a76SGreg Roach        string $bocolor,
134b6f35a76SGreg Roach        string $tcolor,
135b6f35a76SGreg Roach        bool $reseth
136b6f35a76SGreg Roach    ) {
137a25f0a04SGreg Roach        $this->align     = $align;
138a25f0a04SGreg Roach        $this->border    = $border;
139a25f0a04SGreg Roach        $this->bgcolor   = $bgcolor;
140a25f0a04SGreg Roach        $this->bocolor   = $bocolor;
141a25f0a04SGreg Roach        $this->fill      = $fill;
142a25f0a04SGreg Roach        $this->height    = $height;
143a25f0a04SGreg Roach        $this->left      = $left;
144a25f0a04SGreg Roach        $this->newline   = $ln;
145a25f0a04SGreg Roach        $this->styleName = $style;
146a25f0a04SGreg Roach        $this->tcolor    = $tcolor;
147a25f0a04SGreg Roach        $this->top       = $top;
148a25f0a04SGreg Roach        $this->stretch   = $stretch;
149a25f0a04SGreg Roach        $this->width     = $width;
150a25f0a04SGreg Roach        $this->reseth    = $reseth;
151a25f0a04SGreg Roach    }
152a25f0a04SGreg Roach
153a25f0a04SGreg Roach    /**
154a25f0a04SGreg Roach     * Get the cell height
155a25f0a04SGreg Roach     *
156b6f35a76SGreg Roach     * @param HtmlRenderer|PdfRenderer $renderer
157a25f0a04SGreg Roach     *
158a25f0a04SGreg Roach     * @return float
159a25f0a04SGreg Roach     */
1608f53f488SRico Sonntag    public function getHeight($renderer): float
161c1010edaSGreg Roach    {
162a25f0a04SGreg Roach        return $this->height;
163a25f0a04SGreg Roach    }
164a25f0a04SGreg Roach
165a25f0a04SGreg Roach    /**
166a25f0a04SGreg Roach     * Sets the current cells URL
167a25f0a04SGreg Roach     *
168a25f0a04SGreg Roach     * @param string $url The URL address to save
169a25f0a04SGreg Roach     *
170589feda3SGreg Roach     * @return void
171a25f0a04SGreg Roach     */
17277bab461SGreg Roach    public function setUrl(string $url): void
173c1010edaSGreg Roach    {
174a25f0a04SGreg Roach        $this->url = $url;
175a25f0a04SGreg Roach    }
176a25f0a04SGreg Roach
177a25f0a04SGreg Roach    /**
178a25f0a04SGreg Roach     * Get the cell width
179a25f0a04SGreg Roach     *
180b6f35a76SGreg Roach     * @param HtmlRenderer|PdfRenderer $renderer
181a25f0a04SGreg Roach     *
18277bab461SGreg Roach     * @return array{0:float,1:int,2:float}
183a25f0a04SGreg Roach     */
18441cfb9e2SGreg Roach    public function getWidth($renderer): array
185c1010edaSGreg Roach    {
18641cfb9e2SGreg Roach        return [$this->width, 1, $this->height];
187a25f0a04SGreg Roach    }
188a25f0a04SGreg Roach}
189