From 682f7ef6933f4ad485baedddf7a30367d003d7bf Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 25 Jan 2007 05:49:22 +0000 Subject: Fixed #502 --- framework/Web/UI/WebControls/TStyle.php | 62 +++++++++++++++++++++++++++- framework/Web/UI/WebControls/TWebControl.php | 16 +++++++ 2 files changed, 76 insertions(+), 2 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index cc383766..73ff4adf 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -43,6 +43,10 @@ class TStyle extends TComponent * @var string CSS style string (those not represented by specific fields of TStyle) */ private $_customStyle=null; + /** + * @var string display style + */ + private $_displayStyle='Fixed'; /** * Constructor. @@ -173,7 +177,7 @@ class TStyle extends TComponent $this->_font=new TFont; return $this->_font; } - + /** * @return boolean true if font is set. */ @@ -182,6 +186,37 @@ class TStyle extends TComponent return $this->_font !== null; } + /** + * @param TDisplayStyle control display style, default is TDisplayStyle::Fixed + */ + public function setDisplayStyle($value) + { + $this->_displayStyle = TPropertyValue::ensureEnum($value, 'TDisplayStyle'); + switch($this->_displayStyle) + { + case TDisplayStyle::None: + $this->_fields['display'] = 'none'; + break; + case TDisplayStyle::Dynamic: + $this->_fields['display'] = ''; //remove the display property + break; + case TDisplayStyle::Fixed: + $this->_fields['visibility'] = 'visible'; + break; + case TDisplayStyle::Hidden: + $this->_fields['visibility'] = 'hidden'; + break; + } + } + + /** + * @return TDisplayStyle display style + */ + public function getDisplayStyle() + { + return $this->_displayStyle; + } + /** * @return string the foreground color of the control */ @@ -362,7 +397,7 @@ class TStyle extends TComponent if($this->_class!==null) $writer->addAttribute('class',$this->_class); } - + /** * @return array list of style fields. */ @@ -372,6 +407,29 @@ class TStyle extends TComponent } } +/** + * TDisplayStyle defines the enumerable type for the possible styles + * that a web control can display. + * + * The following enumerable values are defined: + * - None: the control is not displayed and not included in the layout. + * - Dynamic: the control is displayed and included in the layout, the layout flow is dependent on the control (equivalent to display:'' in css). + * - Fixed: Similar to Dynamic with CSS "visibility" set "shown". + * - Hidden: the control is not displayed and is included in the layout. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Web.UI.WebControls + * @since 3.1 + */ +class TDisplayStyle extends TEnumerable +{ + const None='None'; + const Dynamic='Dynamic'; + const Fixed='Fixed'; + const Hidden='Hidden'; +} + /** * TTableStyle class. * TTableStyle represents the CSS style specific for HTML table. diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index a45bab05..78c1aa98 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -193,6 +193,22 @@ class TWebControl extends TControl return ''; } + /** + * @param TDisplayStyle display style of the control, default is TDisplayStyle::Fixed + */ + public function setDisplay($value) + { + $this->getStyle()->setDisplayStyle($value); + } + + /** + * @return TDisplayStyle display style of the control, default is TDisplayStyle::Fixed + */ + public function getDisplay() + { + return $this->getStyle()->getDisplayStyle(); + } + /** * @param string the css class of the control */ -- cgit v1.2.3