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