1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Grandstream-XMLApp |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2017 pudelek.org.pl |
6
|
|
|
* |
7
|
|
|
* @license MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view source file |
10
|
|
|
* that is bundled with this package in the file LICENSE |
11
|
|
|
* |
12
|
|
|
* @author Marcin Pudełek <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace mrcnpdlk\Grandstream\XMLApp\Application\Model\Display; |
16
|
|
|
|
17
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Application\Model\ModelInterface; |
18
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Color; |
19
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Point; |
20
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Rectangle; |
21
|
|
|
use mrcnpdlk\Grandstream\XMLApp\MyXML; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class DisplayString |
25
|
|
|
* |
26
|
|
|
* @package mrcnpdlk\Grandstream\XMLApp\CustomScreen\Model |
27
|
|
|
*/ |
28
|
|
|
class DisplayString extends DisplayAbstract implements ModelInterface |
29
|
|
|
{ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private $sString; |
35
|
|
|
/** |
36
|
|
|
* Font type |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $sFontType; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
private $sHorAlign; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* DisplayString constructor. |
49
|
|
|
* |
50
|
|
|
* @param Rectangle $oRectangle |
51
|
|
|
* @param Point $oPoint |
52
|
|
|
* @param string $sString |
53
|
|
|
*/ |
54
|
|
|
public function __construct(Rectangle $oRectangle, Point $oPoint, string $sString) |
55
|
|
|
{ |
56
|
|
|
parent::__construct($oPoint, $oRectangle); |
57
|
|
|
$this->sString = $sString; |
58
|
|
|
$this->setFont(); |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param string|null $type |
64
|
|
|
* @param string|null $align |
65
|
|
|
* @param \mrcnpdlk\Grandstream\XMLApp\Helper\Color|null $oColor |
66
|
|
|
* @param \mrcnpdlk\Grandstream\XMLApp\Helper\Color|null $oColorBg |
67
|
|
|
*/ |
68
|
|
|
public function setFont( |
69
|
|
|
string $type = null, |
70
|
|
|
string $align = null, |
71
|
|
|
Color $oColor = null, |
72
|
|
|
Color $oColorBg = null |
73
|
|
|
) { |
74
|
|
|
$this->sFontType = $type ?? DisplayString::FONT_UNIFONT; |
75
|
|
|
$this->sHorAlign = $align ?? DisplayString::HOR_ALIGN_LEFT; |
76
|
|
|
$this->setColorFont($oColor ?? new Color(100)); |
77
|
|
|
$this->setColorBg($oColorBg ?? new Color(0)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return MyXML |
82
|
|
|
*/ |
83
|
|
|
public function getXml(): MyXML |
84
|
|
|
{ |
85
|
|
|
$oXml = new MyXML('DisplayString'); |
86
|
|
|
|
87
|
|
|
$oXml->asObject()->addAttribute('font', $this->sFontType); |
88
|
|
|
$oXml->asObject()->addAttribute('width', $this->getRectangle()->getWidth()); |
89
|
|
|
$oXml->asObject()->addAttribute('height', $this->getRectangle()->getHeight()); |
90
|
|
|
$oXml->asObject()->addAttribute('halign', $this->sHorAlign); |
91
|
|
|
$oXml->asObject()->addAttribute('color', $this->getColorFont()->get()); |
92
|
|
|
$oXml->asObject()->addAttribute('bgcolor', $this->getColorBg()->get()); |
93
|
|
|
$oXml->asObject()->addAttribute('renew-rate', 'second'); |
94
|
|
|
$oXml->asObject()->addAttribute('isrenew', 'true'); |
95
|
|
|
$oXml->asObject()->addChild('X', $this->getPoint()->getX()); |
96
|
|
|
$oXml->asObject()->addChild('Y', $this->getPoint()->getX()); |
97
|
|
|
$oXml->asObject()->addChild('DisplayStr', $this->sString); |
98
|
|
|
|
99
|
|
|
return $oXml; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|