From 635ae748a34dadc241bd264e11d3251ffffe3aac Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 25 Nov 2005 03:18:09 +0000 Subject: --- framework/Web/UI/WebControls/TButton.php | 4 +- framework/Web/UI/WebControls/TCheckBox.php | 2 +- framework/Web/UI/WebControls/TExpression.php | 2 +- framework/Web/UI/WebControls/TFont.php | 39 +++++- framework/Web/UI/WebControls/THyperLink.php | 2 +- framework/Web/UI/WebControls/TImage.php | 2 +- framework/Web/UI/WebControls/TImageButton.php | 2 +- framework/Web/UI/WebControls/TLabel.php | 4 +- framework/Web/UI/WebControls/TLiteral.php | 2 +- framework/Web/UI/WebControls/TPanel.php | 2 +- framework/Web/UI/WebControls/TStatements.php | 10 +- framework/Web/UI/WebControls/TStyle.php | 176 +++++++++++--------------- framework/Web/UI/WebControls/TTextBox.php | 4 +- framework/Web/UI/WebControls/TWebControl.php | 46 ++++--- 14 files changed, 153 insertions(+), 144 deletions(-) (limited to 'framework/Web/UI/WebControls') diff --git a/framework/Web/UI/WebControls/TButton.php b/framework/Web/UI/WebControls/TButton.php index f2979255..4eb8e093 100644 --- a/framework/Web/UI/WebControls/TButton.php +++ b/framework/Web/UI/WebControls/TButton.php @@ -58,7 +58,7 @@ class TButton extends TWebControl implements IPostBackEventHandler /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional button specific attributes. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function addAttributesToRender($writer) { @@ -90,7 +90,7 @@ class TButton extends TWebControl implements IPostBackEventHandler /** * Renders the body content enclosed between the control tag. * This overrides the parent implementation with nothing to be rendered. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function renderContents($writer) { diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 02167544..756fb2ea 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -295,7 +295,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $page=$this->getPage(); $page->ensureRenderInForm($this); $needSpan=true; - if($this->getStyleCreated()) + if($this->getHasStyle()) { $this->getStyle()->addAttributesToRender($writer); $needSpan=true; diff --git a/framework/Web/UI/WebControls/TExpression.php b/framework/Web/UI/WebControls/TExpression.php index 6cecf9c4..9168f178 100644 --- a/framework/Web/UI/WebControls/TExpression.php +++ b/framework/Web/UI/WebControls/TExpression.php @@ -49,7 +49,7 @@ class TExpression extends TControl /** * Renders the evaluation result of the expression. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function render($writer) { diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php index 468aa9f9..75917b6c 100644 --- a/framework/Web/UI/WebControls/TFont.php +++ b/framework/Web/UI/WebControls/TFont.php @@ -3,9 +3,9 @@ * TFont class file. * * @author Qiang Xue - * @link http://www.xisc.com/ - * @copyright Copyright © 2004-2005, Qiang Xue - * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ * @version $Revision: $ $Date: $ * @package System.Web.UI.WebControls */ @@ -214,7 +214,7 @@ class TFont extends TComponent */ public function mergeWith($font) { - if($font===null) + if($font===null || $font->_flags===0) return; if($font->_flags & self::IS_SET_BOLD) $this->setBold($font->getBold()); @@ -248,7 +248,7 @@ class TFont extends TComponent */ public function toString() { - if($this->getIsEmpty()) + if($this->_flags===0) return ''; $str=''; if($this->_flags & self::IS_SET_BOLD) @@ -271,6 +271,33 @@ class TFont extends TComponent $str.='font-family:'.$this->_name.';'; return $str; } -} + /** + * Adds attributes related to CSS styles to renderer. + * @param THtmlWriter the writer used for the rendering purpose + */ + public function addAttributesToRender($writer) + { + if($this->_flags===0) + return; + if($this->_flags & self::IS_SET_BOLD) + $writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal')); + if($this->_flags & self::IS_SET_ITALIC) + $writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal')); + $textDec=''; + if($this->_flags & self::IS_UNDERLINE) + $textDec.='underline'; + if($this->_flags & self::IS_OVERLINE) + $textDec.=' overline'; + if($this->_flags & self::IS_STRIKEOUT) + $textDec.=' line-through'; + $textDec=ltrim($textDec); + if($textDec!=='') + $writer->addStyleAttribute('text-decoration',$textDec); + if($this->_size!=='') + $writer->addStyleAttribute('font-size',$this->_size); + if($this->_name!=='') + $writer->addStyleAttribute('font-family',$this->_name); + } +} ?> \ No newline at end of file diff --git a/framework/Web/UI/WebControls/THyperLink.php b/framework/Web/UI/WebControls/THyperLink.php index 2b57e101..916501a7 100644 --- a/framework/Web/UI/WebControls/THyperLink.php +++ b/framework/Web/UI/WebControls/THyperLink.php @@ -47,7 +47,7 @@ class THyperLink extends TWebControl /** * Renders the body content of the hyperlink. - * @param THtmlTextWriter the writer for rendering + * @param THtmlWriter the writer for rendering */ protected function renderContents($writer) { diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php index 46e61083..0033209a 100644 --- a/framework/Web/UI/WebControls/TImage.php +++ b/framework/Web/UI/WebControls/TImage.php @@ -44,7 +44,7 @@ class TImage extends TWebControl /** * Renders the body content of the image. * None will be rendered for an image. - * @param THtmlTextWriter the writer for rendering + * @param THtmlWriter the writer for rendering */ protected function renderContents($writer) { diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index 34ab4375..724dcf5c 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -59,7 +59,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional button specific attributes. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function addAttributesToRender($writer) { diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php index 464a4cd7..15148732 100644 --- a/framework/Web/UI/WebControls/TLabel.php +++ b/framework/Web/UI/WebControls/TLabel.php @@ -41,7 +41,7 @@ class TLabel extends TWebControl /** * Adds attributes to renderer. - * @param THtmlTextWriter the renderer + * @param THtmlWriter the renderer * @throws TInvalidDataValueException if associated control cannot be found using the ID */ protected function addAttributesToRender($writer) @@ -58,7 +58,7 @@ class TLabel extends TWebControl /** * Renders the body content of the label. - * @param THtmlTextWriter the renderer + * @param THtmlWriter the renderer */ protected function renderContents($writer) { diff --git a/framework/Web/UI/WebControls/TLiteral.php b/framework/Web/UI/WebControls/TLiteral.php index 0509724a..459552f7 100644 --- a/framework/Web/UI/WebControls/TLiteral.php +++ b/framework/Web/UI/WebControls/TLiteral.php @@ -62,7 +62,7 @@ class TLiteral extends TControl /** * Renders the evaluation result of the statements. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function render($writer) { diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php index 36f70479..0f85a52f 100644 --- a/framework/Web/UI/WebControls/TPanel.php +++ b/framework/Web/UI/WebControls/TPanel.php @@ -33,7 +33,7 @@ class TPanel extends TWebControl /** * Adds attributes to renderer. - * @param THtmlTextWriter the renderer + * @param THtmlWriter the renderer */ protected function addAttributesToRender($writer) { diff --git a/framework/Web/UI/WebControls/TStatements.php b/framework/Web/UI/WebControls/TStatements.php index e0892f2b..5c1ffe1e 100644 --- a/framework/Web/UI/WebControls/TStatements.php +++ b/framework/Web/UI/WebControls/TStatements.php @@ -15,10 +15,10 @@ * * TStatements executes a set of PHP statements and renders the display * generated by the statements. The execution happens during rendering stage. - * You can set the statements via the property Statements. - * You should also specify the context object by Context property - * which is used as the object in which the statements is evaluated. - * If the Context property is not set, the TStatements component + * You can set the statements via the property Statements. + * You should also specify the context object by Context property + * which is used as the object in which the statements is evaluated. + * If the Context property is not set, the TStatements component * itself will be assumed as the context. * * @author Qiang Xue @@ -49,7 +49,7 @@ class TStatements extends TControl /** * Renders the evaluation result of the statements. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function render($writer) { diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index e1e92b1b..8a046ff1 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -3,9 +3,9 @@ * TStyle class file. * * @author Qiang Xue - * @link http://www.xisc.com/ - * @copyright Copyright © 2004-2005, Qiang Xue - * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ * @version $Revision: $ $Date: $ * @package System.Web.UI.WebControls */ @@ -23,35 +23,28 @@ class TStyle extends TComponent { /** - * @var array The enumerable type for border styles + * @var array storage of CSS fields */ - public static $ENUM_BORDER_STYLE=array('NotSet','None','Dashed','Dotted','Solid','Double','Groove','Ridge','Inset','Outset'); - + private $_data=array(); /** - * Various CSS fields + * @var TFont font object */ - const FLD_BACKCOLOR=0; - const FLD_BORDERCOLOR=1; - const FLD_BORDERWIDTH=2; - const FLD_BORDERSTYLE=3; - const FLD_FONT=4; - const FLD_FORECOLOR=5; - const FLD_HEIGHT=6; - const FLD_WIDTH=7; - const FLD_CSSCLASS=8; - const FLD_STYLE=9; - + private $_font=null; /** - * @var array storage of CSS fields + * @var string CSS class name */ - private $_data=array(); + private $_class=''; + /** + * @var string CSS style string (those not represented by specific fields of TStyle) + */ + private $_style=''; /** * @return string the background color of the control */ public function getBackColor() { - return isset($this->_data[self::FLD_BACKCOLOR])?$this->_data[self::FLD_BACKCOLOR]:''; + return isset($this->_data['background-color'])?$this->_data['background-color']:''; } /** @@ -60,9 +53,9 @@ class TStyle extends TComponent public function setBackColor($value) { if($value==='') - unset($this->_data[self::FLD_BACKCOLOR]); + unset($this->_data['background-color']); else - $this->_data[self::FLD_BACKCOLOR]=$value; + $this->_data['background-color']=$value; } /** @@ -70,7 +63,7 @@ class TStyle extends TComponent */ public function getBorderColor() { - return isset($this->_data[self::FLD_BORDERCOLOR])?$this->_data[self::FLD_BORDERCOLOR]:''; + return isset($this->_data['border-color'])?$this->_data['border-color']:''; } /** @@ -79,9 +72,9 @@ class TStyle extends TComponent public function setBorderColor($value) { if($value==='') - unset($this->_data[self::FLD_BORDERCOLOR]); + unset($this->_data['border-color']); else - $this->_data[self::FLD_BORDERCOLOR]=$value; + $this->_data['border-color']=$value; } /** @@ -89,21 +82,19 @@ class TStyle extends TComponent */ public function getBorderStyle() { - return isset($this->_data[self::FLD_BORDERSTYLE])?$this->_data[self::FLD_BORDERSTYLE]:''; + return isset($this->_data['border-style'])?$this->_data['border-style']:''; } /** * Sets the border style of the control. - * Valid values include: - * 'NotSet','None','Dashed','Dotted','Solid','Double','Groove','Ridge','Inset','Outset' * @param string the border style of the control */ public function setBorderStyle($value) { if($value==='') - unset($this->_data[self::FLD_BORDERSTYLE]); + unset($this->_data['border-style']); else - $this->_data[self::FLD_BORDERSTYLE]=TPropertyValue::ensureEnum($value,self::$ENUM_BORDER_STYLE); + $this->_data['border-style']=$value; } /** @@ -111,7 +102,7 @@ class TStyle extends TComponent */ public function getBorderWidth() { - return isset($this->_data[self::FLD_BORDERWIDTH])?$this->_data[self::FLD_BORDERWIDTH]:''; + return isset($this->_data['border-width'])?$this->_data['border-width']:''; } /** @@ -120,9 +111,9 @@ class TStyle extends TComponent public function setBorderWidth($value) { if($value==='') - unset($this->_data[self::FLD_BORDERWIDTH]); + unset($this->_data['border-width']); else - $this->_data[self::FLD_BORDERWIDTH]=$value; + $this->_data['border-width']=$value; } /** @@ -130,7 +121,7 @@ class TStyle extends TComponent */ public function getCssClass() { - return isset($this->_data[self::FLD_CSSCLASS])?$this->_data[self::FLD_CSSCLASS]:''; + return $this->_class; } /** @@ -138,10 +129,7 @@ class TStyle extends TComponent */ public function setCssClass($value) { - if($value==='') - unset($this->_data[self::FLD_CSSCLASS]); - else - $this->_data[self::FLD_CSSCLASS]=$value; + $this->_class=$value; } /** @@ -149,9 +137,9 @@ class TStyle extends TComponent */ public function getFont() { - if(!isset($this->_data[self::FLD_FONT])) - $this->_data[self::FLD_FONT]=new TFont; - return $this->_data[self::FLD_FONT]; + if($this->_font===null) + $this->_font=new TFont; + return $this->_font; } /** @@ -159,7 +147,7 @@ class TStyle extends TComponent */ public function getForeColor() { - return isset($this->_data[self::FLD_FORECOLOR])?$this->_data[self::FLD_FORECOLOR]:''; + return isset($this->_data['color'])?$this->_data['color']:''; } /** @@ -168,9 +156,9 @@ class TStyle extends TComponent public function setForeColor($value) { if($value==='') - unset($this->_data[self::FLD_FORECOLOR]); + unset($this->_data['color']); else - $this->_data[self::FLD_FORECOLOR]=$value; + $this->_data['color']=$value; } /** @@ -178,7 +166,7 @@ class TStyle extends TComponent */ public function getHeight() { - return isset($this->_data[self::FLD_HEIGHT])?$this->_data[self::FLD_HEIGHT]:''; + return isset($this->_data['height'])?$this->_data['height']:''; } /** @@ -187,9 +175,9 @@ class TStyle extends TComponent public function setHeight($value) { if($value==='') - unset($this->_data[self::FLD_HEIGHT]); + unset($this->_data['height']); else - $this->_data[self::FLD_HEIGHT]=$value; + $this->_data['height']=$value; } /** @@ -197,7 +185,7 @@ class TStyle extends TComponent */ public function getStyle() { - return isset($this->_data[self::FLD_STYLE])?$this->_data[self::FLD_STYLE]:''; + return $this->_style; } /** @@ -205,10 +193,7 @@ class TStyle extends TComponent */ public function setStyle($value) { - if($value==='') - unset($this->_data[self::FLD_STYLE]); - else - $this->_data[self::FLD_STYLE]=$value; + $this->_style=$value; } /** @@ -216,7 +201,7 @@ class TStyle extends TComponent */ public function getWidth() { - return isset($this->_data[self::FLD_WIDTH])?$this->_data[self::FLD_WIDTH]:''; + return isset($this->_data['width'])?$this->_data['width']:''; } /** @@ -225,9 +210,9 @@ class TStyle extends TComponent public function setWidth($value) { if($value==='') - unset($this->_data[self::FLD_WIDTH]); + unset($this->_data['width']); else - $this->_data[self::FLD_WIDTH]=$value; + $this->_data['width']=$value; } /** @@ -235,7 +220,7 @@ class TStyle extends TComponent */ public function getIsEmpty() { - return empty($this->_data) || (isset($this->_data[self::FLD_FONT]) && $this->_data[self::FLD_FONT]->getIsEmpty()); + return empty($this->_data) && $this->_class==='' && $this->_style==='' && (!$this->_font || $this->_font->getIsEmpty()); } /** @@ -244,7 +229,9 @@ class TStyle extends TComponent public function reset() { $this->_data=array(); - $this->flags=0; + $this->_font=null; + $this->_class=''; + $this->_style=''; } /** @@ -257,24 +244,14 @@ class TStyle extends TComponent { if($style===null) return; - if(isset($style->_data[self::FLD_BACKCOLOR])) - $this->_data[self::FLD_BACKCOLOR]=$style->_data[self::FLD_BACKCOLOR]; - if(isset($style->_data[self::FLD_BORDERCOLOR])) - $this->_data[self::FLD_BORDERCOLOR]=$style->_data[self::FLD_BORDERCOLOR]; - if(isset($style->_data[self::FLD_BORDERWIDTH])) - $this->_data[self::FLD_BORDERWIDTH]=$style->_data[self::FLD_BORDERWIDTH]; - if(isset($style->_data[self::FLD_BORDERSTYLE])) - $this->_data[self::FLD_BORDERSTYLE]=$style->_data[self::FLD_BORDERSTYLE]; - if(isset($style->_data[self::FLD_FORECOLOR])) - $this->_data[self::FLD_FORECOLOR]=$style->_data[self::FLD_FORECOLOR]; - if(isset($style->_data[self::FLD_HEIGHT])) - $this->_data[self::FLD_HEIGHT]=$style->_data[self::FLD_HEIGHT]; - if(isset($style->_data[self::FLD_WIDTH])) - $this->_data[self::FLD_WIDTH]=$style->_data[self::FLD_WIDTH]; - if(isset($style->_data[self::FLD_FONT])) - $this->getFont()->mergeWith($style->_data[self::FLD_FONT]); - if(isset($style->_data[self::FLD_CSSCLASS])) - $this->_data[self::FLD_CSSCLASS]=$style->_data[self::FLD_CSSCLASS]; + foreach($style->_data as $name=>$value) + $this->_data[$name]=$value; + if($style->_class!=='') + $this->_class=$style->_class; + if($style->_style!=='') + $this->_style=$style->_style; + if($style->_font!==null) + $this->getFont()->mergeWith($style->_font); } /** @@ -294,40 +271,35 @@ class TStyle extends TComponent */ public function toString() { - if($this->getIsEmpty()) - return ''; - if(($str=$this->getStyle())!=='') - $str=rtrim($str).';'; - if(isset($this->_data[self::FLD_BACKCOLOR])) - $str.='background-color:'.$this->_data[self::FLD_BACKCOLOR].';'; - if(isset($this->_data[self::FLD_BORDERCOLOR])) - $str.='border-color:'.$this->_data[self::FLD_BORDERCOLOR].';'; - if(isset($this->_data[self::FLD_BORDERWIDTH])) - $str.='border-width:'.$this->_data[self::FLD_BORDERWIDTH].';'; - if(isset($this->_data[self::FLD_BORDERSTYLE])) - $str.='border-style:'.$this->_data[self::FLD_BORDERSTYLE].';'; - if(isset($this->_data[self::FLD_FORECOLOR])) - $str.='color:'.$this->_data[self::FLD_FORECOLOR].';'; - if(isset($this->_data[self::FLD_HEIGHT])) - $str.='height:'.$this->_data[self::FLD_HEIGHT].';'; - if(isset($this->_data[self::FLD_WIDTH])) - $str.='width:'.$this->_data[self::FLD_WIDTH].';'; - if(isset($this->_data[self::FLD_FONT])) - $str.=$this->_data[self::FLD_FONT]->toString(); + $str=''; + foreach($this->_data as $name=>$value) + $str.=' '.$name.':'.$value.';'; + if($this->_font) + $str.=$this->_font->toString(); return $str; } /** * Adds attributes related to CSS styles to renderer. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ public function addAttributesToRender($writer) { - $str=$this->toString(); - if($str!=='') - $writer->addAttribute('style',$str); - if(isset($this->_data[self::FLD_CSSCLASS])) - $writer->addAttribute('class',$this->_data[self::FLD_CSSCLASS]); + if($this->_style!=='') + { + foreach(explode(';',$this->_style) as $style) + { + $arr=explode(':',$style); + if(isset($arr[1]) && trim($arr[0])!=='') + $writer->addStyleAttribute(trim($arr[0]),trim($arry[1])); + } + } + foreach($this->_data as $name=>$value) + $writer->addStyleAttribute($name,$value); + if($this->_font!==null) + $this->_font->addAttributesToRender($writer); + if($this->_class!=='') + $writer->addAttribute('class',$this->_class); } } diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php index 700906e8..b8c594f3 100644 --- a/framework/Web/UI/WebControls/TTextBox.php +++ b/framework/Web/UI/WebControls/TTextBox.php @@ -70,7 +70,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable /** * Adds attribute name-value pairs to renderer. * This overrides the parent implementation with additional textbox specific attributes. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function addAttributesToRender($writer) { @@ -235,7 +235,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable /** * Renders the body content of the textbox when it is in MultiLine text mode. - * @param THtmlTextWriter the writer for rendering + * @param THtmlWriter the writer for rendering */ protected function renderContents($writer) { diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index 8a9765f7..b54f0e71 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -3,9 +3,9 @@ * TWebControl class file. * * @author Qiang Xue - * @link http://www.xisc.com/ - * @copyright Copyright © 2004-2005, Qiang Xue - * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ * @version $Revision: $ $Date: $ * @package System.Web.UI.WebControls */ @@ -14,13 +14,18 @@ * TWebControl class * * TWebControl is the base class for controls that share a common set - * of UI-related properties and methods. TWebControl derived controls - * are usually corresponding to HTML tags. They thus have tag name, attributes + * of UI-related properties and methods. TWebControl-derived controls + * are usually associated with HTML tags. They thus have tag name, attributes * and body contents. You can override {@link getTagName} to specify the tag name, * {@link addAttributesToRender} to specify the attributes to be rendered, * and {@link renderContents} to customize the body content rendering. * TWebControl encapsulates a set of properties related with CSS style fields, - * such as BackColor, BorderWidth, etc. + * such as {@link getBackColor BackColor}, {@link getBorderWidth BorderWidth}, etc. + * + * Subclasses of TWebControl typically needs to override {@link addAttributesToRender} + * and {@link renderContent}. The former is used to render the attributes + * of the HTML tag associated with the control, while the latter is to render + * the body contents enclosed within the HTML tag. * * @author Qiang Xue * @version $Revision: $ $Date: $ @@ -40,14 +45,14 @@ class TWebControl extends TControl /** * Sets the access key of the control. * Only one-character string can be set, or an exception will be raised. - * Pass empty string if you want to disable access key. + * Pass in an empty string if you want to disable access key. * @param string the access key to be set * @throws TInvalidDataValueException if the access key is specified with more than one character */ public function setAccessKey($value) { if(strlen($value)>1) - throw new TInvalidDataValueException('invalid_accesskey',get_class($this)); + throw new TInvalidDataValueException('webcontrol_accesskey_invalid',get_class($this),$value); $this->setViewState('AccessKey',$value,''); } @@ -192,7 +197,10 @@ class TWebControl extends TControl $this->getStyle()->setHeight($value); } - public function getStyleCreated() + /** + * @return boolean whether the control has defined any style information + */ + public function getHasStyle() { return $this->getViewState('Style',null)!==null; } @@ -223,7 +231,7 @@ class TWebControl extends TControl if(is_string($value)) $this->getStyle()->setStyle($value); else - throw new TInvalidDataValueException('invalid_style_value',get_class($this)); + throw new TInvalidDataValueException('webcontrol_style_invalid',get_class($this)); } /** @@ -265,7 +273,7 @@ class TWebControl extends TControl /** * Sets the tooltip of the control. - * Pass empty string if you want to disable tooltip. + * Pass an empty string if you want to disable tooltip. * @param string the tooltip to be set */ public function setToolTip($value) @@ -294,8 +302,10 @@ class TWebControl extends TControl /** * Adds attribute name-value pairs to renderer. - * This method can be overriden to provide customized attributes to be rendered. - * @param THtmlTextWriter the writer used for the rendering purpose + * By default, the method will render 'id', 'accesskey', 'disabled', + * 'tabindex', 'title' and all custom attributes. + * The method can be overriden to provide customized attribute rendering. + * @param THtmlWriter the writer used for the rendering purpose */ protected function addAttributesToRender($writer) { @@ -306,7 +316,7 @@ class TWebControl extends TControl if(!$this->getEnabled()) $writer->addAttribute('disabled','disabled'); if(($tabIndex=$this->getTabIndex())>0) - $writer->addAttribute('tabindex',$tabIndex); + $writer->addAttribute('tabindex',"$tabIndex"); if(($toolTip=$this->getToolTip())!=='') $writer->addAttribute('title',$toolTip); if($style=$this->getViewState('Style',null)) @@ -325,7 +335,7 @@ class TWebControl extends TControl * - {@link renderBeginTag} * - {@link renderContents} * - {@link renderEndTag} - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function render($writer) { @@ -336,7 +346,7 @@ class TWebControl extends TControl /** * Renders the openning tag for the control (including attributes) - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function renderBeginTag($writer) { @@ -348,7 +358,7 @@ class TWebControl extends TControl * Renders the body content enclosed between the control tag. * By default, child controls and text strings will be rendered. * You can override this method to provide customized content rendering. - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function renderContents($writer) { @@ -357,7 +367,7 @@ class TWebControl extends TControl /** * Renders the closing tag for the control - * @param THtmlTextWriter the writer used for the rendering purpose + * @param THtmlWriter the writer used for the rendering purpose */ protected function renderEndTag($writer) { -- cgit v1.2.3