|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* TPanelStyle class file |
|
4
|
|
|
* |
|
5
|
|
|
* @author Qiang Xue <[email protected]> |
|
6
|
|
|
* @link https://github.com/pradosoft/prado |
|
7
|
|
|
* @copyright Copyright © 2005-2016 The PRADO Group |
|
8
|
|
|
* @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
|
9
|
|
|
* @package System.Web.UI.WebControls |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Includes TStyle class file |
|
14
|
|
|
*/ |
|
15
|
|
|
Prado::using('System.Web.UI.WebControls.TStyle'); |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* TPanelStyle class. |
|
19
|
|
|
* TPanelStyle represents the CSS style specific for panel HTML tag. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Qiang Xue <[email protected]> |
|
22
|
|
|
* @package System.Web.UI.WebControls |
|
23
|
|
|
* @since 3.0 |
|
24
|
|
|
*/ |
|
25
|
|
|
class TPanelStyle extends TStyle |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var string the URL of the background image for the panel component |
|
29
|
|
|
*/ |
|
30
|
|
|
private $_backImageUrl=null; |
|
31
|
|
|
/** |
|
32
|
|
|
* @var string alignment of the content in the panel. |
|
33
|
|
|
*/ |
|
34
|
|
|
private $_direction=null; |
|
35
|
|
|
/** |
|
36
|
|
|
* @var string horizontal alignment of the contents within the panel |
|
37
|
|
|
*/ |
|
38
|
|
|
private $_horizontalAlign=null; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var string visibility and position of scroll bars |
|
41
|
|
|
*/ |
|
42
|
|
|
private $_scrollBars=null; |
|
43
|
|
|
/** |
|
44
|
|
|
* @var boolean whether the content wraps within the panel |
|
45
|
|
|
*/ |
|
46
|
|
|
private $_wrap=null; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Returns an array with the names of all variables of this object that should NOT be serialized |
|
50
|
|
|
* because their value is the default one or useless to be cached for the next page loads. |
|
51
|
|
|
* Reimplement in derived classes to add new variables, but remember to also to call the parent |
|
52
|
|
|
* implementation first. |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function _getZappableSleepProps(&$exprops) |
|
55
|
|
|
{ |
|
56
|
|
|
parent::_getZappableSleepProps($exprops); |
|
57
|
|
|
if ($this->_backImageUrl===null) |
|
58
|
|
|
$exprops[] = "\0TPanelStyle\0_backImageUrl"; |
|
59
|
|
|
if ($this->_direction===null) |
|
60
|
|
|
$exprops[] = "\0TPanelStyle\0_direction"; |
|
61
|
|
|
if ($this->_horizontalAlign===null) |
|
62
|
|
|
$exprops[] = "\0TPanelStyle\0_horizontalAlign"; |
|
63
|
|
|
if ($this->_scrollBars===null) |
|
64
|
|
|
$exprops[] = "\0TPanelStyle\0_scrollBars"; |
|
65
|
|
|
if ($this->_wrap===null) |
|
66
|
|
|
$exprops[] = "\0TPanelStyle\0_wrap"; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Adds attributes related to CSS styles to renderer. |
|
71
|
|
|
* This method overrides the parent implementation. |
|
72
|
|
|
* @param THtmlWriter the writer used for the rendering purpose |
|
73
|
|
|
*/ |
|
74
|
|
|
public function addAttributesToRender($writer) |
|
75
|
|
|
{ |
|
76
|
|
|
if(($url=trim($this->getBackImageUrl()))!=='') |
|
77
|
|
|
$this->setStyleField('background-image','url('.$url.')'); |
|
78
|
|
|
|
|
79
|
|
|
switch($this->getScrollBars()) |
|
80
|
|
|
{ |
|
81
|
|
|
case TScrollBars::Horizontal: $this->setStyleField('overflow-x','scroll'); break; |
|
|
|
|
|
|
82
|
|
|
case TScrollBars::Vertical: $this->setStyleField('overflow-y','scroll'); break; |
|
|
|
|
|
|
83
|
|
|
case TScrollBars::Both: $this->setStyleField('overflow','scroll'); break; |
|
|
|
|
|
|
84
|
|
|
case TScrollBars::Auto: $this->setStyleField('overflow','auto'); break; |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
if(($align=$this->getHorizontalAlign())!==THorizontalAlign::NotSet) |
|
88
|
|
|
$this->setStyleField('text-align',strtolower($align)); |
|
89
|
|
|
|
|
90
|
|
|
if(!$this->getWrap()) |
|
91
|
|
|
$this->setStyleField('white-space','nowrap'); |
|
92
|
|
|
|
|
93
|
|
|
if(($direction=$this->getDirection())!==TContentDirection::NotSet) |
|
94
|
|
|
{ |
|
95
|
|
|
if($direction===TContentDirection::LeftToRight) |
|
96
|
|
|
$this->setStyleField('direction','ltr'); |
|
97
|
|
|
else |
|
98
|
|
|
$this->setStyleField('direction','rtl'); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
parent::addAttributesToRender($writer); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* @return string the URL of the background image for the panel component. |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getBackImageUrl() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->_backImageUrl===null?'':$this->_backImageUrl; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Sets the URL of the background image for the panel component. |
|
114
|
|
|
* @param string the URL |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setBackImageUrl($value) |
|
117
|
|
|
{ |
|
118
|
|
|
$this->_backImageUrl=$value; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @return TContentDirection alignment of the content in the panel. Defaults to TContentDirection::NotSet. |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getDirection() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->_direction===null?TContentDirection::NotSet:$this->_direction; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* @param TContentDirection alignment of the content in the panel. |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setDirection($value) |
|
133
|
|
|
{ |
|
134
|
|
|
$this->_direction=TPropertyValue::ensureEnum($value,'TContentDirection'); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @return boolean whether the content wraps within the panel. Defaults to true. |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getWrap() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->_wrap===null?true:$this->_wrap; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Sets the value indicating whether the content wraps within the panel. |
|
147
|
|
|
* @param boolean whether the content wraps within the panel. |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setWrap($value) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->_wrap=TPropertyValue::ensureBoolean($value); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return THorizontalAlign the horizontal alignment of the contents within the panel, defaults to THorizontalAlign::NotSet. |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getHorizontalAlign() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->_horizontalAlign===null?THorizontalAlign::NotSet:$this->_horizontalAlign; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Sets the horizontal alignment of the contents within the panel. |
|
164
|
|
|
* @param THorizontalAlign the horizontal alignment |
|
165
|
|
|
*/ |
|
166
|
|
|
public function setHorizontalAlign($value) |
|
167
|
|
|
{ |
|
168
|
|
|
$this->_horizontalAlign=TPropertyValue::ensureEnum($value,'THorizontalAlign'); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return TScrollBars the visibility and position of scroll bars in a panel control, defaults to TScrollBars::None. |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getScrollBars() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->_scrollBars===null?TScrollBars::None:$this->_scrollBars; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @param TScrollBars the visibility and position of scroll bars in a panel control. |
|
181
|
|
|
*/ |
|
182
|
|
|
public function setScrollBars($value) |
|
183
|
|
|
{ |
|
184
|
|
|
$this->_scrollBars=TPropertyValue::ensureEnum($value,'TScrollBars'); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Sets the style attributes to default values. |
|
189
|
|
|
* This method overrides the parent implementation by |
|
190
|
|
|
* resetting additional TPanelStyle specific attributes. |
|
191
|
|
|
*/ |
|
192
|
|
|
public function reset() |
|
193
|
|
|
{ |
|
194
|
|
|
parent::reset(); |
|
195
|
|
|
$this->_backImageUrl=null; |
|
196
|
|
|
$this->_direction=null; |
|
197
|
|
|
$this->_horizontalAlign=null; |
|
198
|
|
|
$this->_scrollBars=null; |
|
199
|
|
|
$this->_wrap=null; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
/** |
|
203
|
|
|
* Copies the fields in a new style to this style. |
|
204
|
|
|
* If a style field is set in the new style, the corresponding field |
|
205
|
|
|
* in this style will be overwritten. |
|
206
|
|
|
* @param TStyle the new style |
|
207
|
|
|
*/ |
|
208
|
|
|
public function copyFrom($style) |
|
209
|
|
|
{ |
|
210
|
|
|
parent::copyFrom($style); |
|
211
|
|
|
if($style instanceof TPanelStyle) |
|
212
|
|
|
{ |
|
213
|
|
|
if($style->_backImageUrl!==null) |
|
214
|
|
|
$this->_backImageUrl=$style->_backImageUrl; |
|
215
|
|
|
if($style->_direction!==null) |
|
216
|
|
|
$this->_direction=$style->_direction; |
|
217
|
|
|
if($style->_horizontalAlign!==null) |
|
218
|
|
|
$this->_horizontalAlign=$style->_horizontalAlign; |
|
219
|
|
|
if($style->_scrollBars!==null) |
|
220
|
|
|
$this->_scrollBars=$style->_scrollBars; |
|
221
|
|
|
if($style->_wrap!==null) |
|
222
|
|
|
$this->_wrap=$style->_wrap; |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/** |
|
227
|
|
|
* Merges the style with a new one. |
|
228
|
|
|
* If a style field is not set in this style, it will be overwritten by |
|
229
|
|
|
* the new one. |
|
230
|
|
|
* @param TStyle the new style |
|
231
|
|
|
*/ |
|
232
|
|
|
public function mergeWith($style) |
|
233
|
|
|
{ |
|
234
|
|
|
parent::mergeWith($style); |
|
235
|
|
|
if($style instanceof TPanelStyle) |
|
236
|
|
|
{ |
|
237
|
|
|
if($this->_backImageUrl===null && $style->_backImageUrl!==null) |
|
238
|
|
|
$this->_backImageUrl=$style->_backImageUrl; |
|
239
|
|
|
if($this->_direction===null && $style->_direction!==null) |
|
240
|
|
|
$this->_direction=$style->_direction; |
|
241
|
|
|
if($this->_horizontalAlign===null && $style->_horizontalAlign!==null) |
|
242
|
|
|
$this->_horizontalAlign=$style->_horizontalAlign; |
|
243
|
|
|
if($this->_scrollBars===null && $style->_scrollBars!==null) |
|
244
|
|
|
$this->_scrollBars=$style->_scrollBars; |
|
245
|
|
|
if($this->_wrap===null && $style->_wrap!==null) |
|
246
|
|
|
$this->_wrap=$style->_wrap; |
|
247
|
|
|
} |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* TContentDirection class. |
|
253
|
|
|
* TContentDirection defines the enumerable type for the possible directions that a panel can be at. |
|
254
|
|
|
* |
|
255
|
|
|
* The following enumerable values are defined: |
|
256
|
|
|
* - NotSet: the direction is not specified |
|
257
|
|
|
* - LeftToRight: content in a panel is left to right |
|
258
|
|
|
* - RightToLeft: content in a panel is right to left |
|
259
|
|
|
* |
|
260
|
|
|
* @author Qiang Xue <[email protected]> |
|
261
|
|
|
* @package System.Web.UI.WebControls |
|
262
|
|
|
* @since 3.0.4 |
|
263
|
|
|
*/ |
|
264
|
|
|
class TContentDirection extends TEnumerable |
|
265
|
|
|
{ |
|
266
|
|
|
const NotSet='NotSet'; |
|
267
|
|
|
const LeftToRight='LeftToRight'; |
|
268
|
|
|
const RightToLeft='RightToLeft'; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* TScrollBars class. |
|
273
|
|
|
* TScrollBars defines the enumerable type for the possible scroll bar mode |
|
274
|
|
|
* that a {@link TPanel} control could use. |
|
275
|
|
|
* |
|
276
|
|
|
* The following enumerable values are defined: |
|
277
|
|
|
* - None: no scroll bars. |
|
278
|
|
|
* - Auto: scroll bars automatically appeared when needed. |
|
279
|
|
|
* - Both: show both horizontal and vertical scroll bars all the time. |
|
280
|
|
|
* - Horizontal: horizontal scroll bar only |
|
281
|
|
|
* - Vertical: vertical scroll bar only |
|
282
|
|
|
* |
|
283
|
|
|
* @author Qiang Xue <[email protected]> |
|
284
|
|
|
* @package System.Web.UI.WebControls |
|
285
|
|
|
* @since 3.0.4 |
|
286
|
|
|
*/ |
|
287
|
|
|
class TScrollBars extends TEnumerable |
|
288
|
|
|
{ |
|
289
|
|
|
const None='None'; |
|
290
|
|
|
const Auto='Auto'; |
|
291
|
|
|
const Both='Both'; |
|
292
|
|
|
const Horizontal='Horizontal'; |
|
293
|
|
|
const Vertical='Vertical'; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
|
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.