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