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; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface; |
19
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Color; |
20
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Point; |
21
|
|
|
use mrcnpdlk\Grandstream\XMLApp\Helper\Vector; |
22
|
|
|
use mrcnpdlk\Grandstream\XMLApp\MyXML; |
23
|
|
|
|
24
|
|
|
class Styles implements ModelInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var Point |
28
|
|
|
*/ |
29
|
|
|
private $oPoint; |
30
|
|
|
/** |
31
|
|
|
* @var integer |
32
|
|
|
*/ |
33
|
|
|
private $iWidth; |
34
|
|
|
/** |
35
|
|
|
* @var Color |
36
|
|
|
*/ |
37
|
|
|
private $oColorBg; |
38
|
|
|
/** |
39
|
|
|
* @var Color |
40
|
|
|
*/ |
41
|
|
|
private $oColorBorder; |
42
|
|
|
/** |
43
|
|
|
* @var Color |
44
|
|
|
*/ |
45
|
|
|
private $oColor; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Styles constructor. |
49
|
|
|
* |
50
|
|
|
* @param \mrcnpdlk\Grandstream\XMLApp\Helper\Point $oPoint |
51
|
|
|
* @param int $iWidth |
52
|
|
|
*/ |
53
|
1 |
|
public function __construct(int $iWidth = null, Point $oPoint = null) |
54
|
|
|
{ |
55
|
1 |
|
$this->oPoint = $oPoint ?? new Point(0, 0); |
56
|
1 |
|
$this->iWidth = $iWidth ?? 123; |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param Color $oColor |
61
|
|
|
* |
62
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Application\Model\Styles |
63
|
|
|
*/ |
64
|
|
|
public function setColorBg(Color $oColor) |
65
|
|
|
{ |
66
|
|
|
$this->oColorBg = $oColor; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param Color $oColor |
73
|
|
|
* |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setColorBorder(Color $oColor) |
77
|
|
|
{ |
78
|
|
|
$this->oColorBorder = $oColor; |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Font color |
85
|
|
|
* |
86
|
|
|
* @param Color $oColor |
87
|
|
|
* |
88
|
|
|
* @return $this |
89
|
|
|
*/ |
90
|
|
|
public function setColor(Color $oColor) |
91
|
|
|
{ |
92
|
|
|
$this->oColor = $oColor; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
1 |
|
public function getXml(): MyXML |
98
|
|
|
{ |
99
|
1 |
|
$oXml = new MyXML('styles'); |
100
|
1 |
|
$oXml->asObject()->addAttribute('pos_x', $this->getPoint()->getX()); |
101
|
1 |
|
$oXml->asObject()->addAttribute('pos_y', $this->getPoint()->getY()); |
102
|
1 |
|
$oXml->setWidth($this->iWidth); |
103
|
1 |
|
$oXml->setColor($this->getColor()->get()); |
104
|
1 |
|
$oXml->setColorBg($this->getColorBg()->get()); |
105
|
1 |
|
$oXml->setColorBorder($this->getColorBorder()->get()); |
106
|
|
|
|
107
|
1 |
|
return $oXml; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Helper\Point |
112
|
|
|
*/ |
113
|
1 |
|
public function getPoint() |
114
|
|
|
{ |
115
|
1 |
|
return $this->oPoint; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Helper\Color |
120
|
|
|
*/ |
121
|
1 |
|
public function getColorBg() |
122
|
|
|
{ |
123
|
1 |
|
return $this->oColorBg ?? new Color(20); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Helper\Color |
128
|
|
|
*/ |
129
|
1 |
|
public function getColorBorder() |
130
|
|
|
{ |
131
|
1 |
|
return $this->oColorBorder ?? new Color(100); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return \mrcnpdlk\Grandstream\XMLApp\Helper\Color |
136
|
|
|
*/ |
137
|
1 |
|
public function getColor() |
138
|
|
|
{ |
139
|
1 |
|
return $this->oColor ?? new Color(100); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param int $iX |
144
|
|
|
* @param int $iY |
145
|
|
|
* |
146
|
|
|
* @return $this |
147
|
|
|
*/ |
148
|
|
|
public function move(int $iX, int $iY) |
149
|
|
|
{ |
150
|
|
|
$this->getPoint()->move(new Vector($iX, $iY)); |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|