From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- framework/Web/UI/WebControls/TImage.php | 122 ++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 framework/Web/UI/WebControls/TImage.php (limited to 'framework/Web/UI/WebControls/TImage.php') diff --git a/framework/Web/UI/WebControls/TImage.php b/framework/Web/UI/WebControls/TImage.php new file mode 100644 index 00000000..46e61083 --- /dev/null +++ b/framework/Web/UI/WebControls/TImage.php @@ -0,0 +1,122 @@ + + * @link http://www.xisc.com/ + * @copyright Copyright © 2004-2005, Qiang Xue + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + */ + +/** + * TImage class + * + * @author Qiang Xue + * @version $Revision: $ $Date: $ + * @package System.Web.UI.WebControls + * @since 3.0 + */ +class TImage extends TWebControl +{ + public static $IMAGE_ALIGN=array('NotSet','AbsBottom','AbsMiddle','Baseline','Bottom','Left','Middle','Right','TextTop','Top'); + // todo: TControl::resolveClientUrl() + /** + * @return string tag name of the image + */ + protected function getTagName() + { + return 'img'; + } + + protected function addAttributesToRender($writer) + { + $writer->addAttribute('src',$this->getImageUrl()); + $writer->addAttribute('alt',$this->getAlternateText()); + if(($desc=$this->getDescriptionUrl())!=='') + $writer->addAttribute('longdesc',$this->resolveClientUrl($desc)); + if(($align=$this->getImageAlign())!=='NotSet') + $writer->addAttribute('align',strtolower($align)); + parent::addAttributesToRender($writer); + } + + /** + * Renders the body content of the image. + * None will be rendered for an image. + * @param THtmlTextWriter the writer for rendering + */ + protected function renderContents($writer) + { + } + + /** + * @return string the alternative text displayed in the TImage component when the image is unavailable. + */ + public function getAlternateText() + { + return $this->getViewState('AlternateText',''); + } + + /** + * Sets the alternative text to be displayed in the TImage when the image is unavailable. + * @param string the alternative text + */ + public function setAlternateText($value) + { + $this->setViewState('AlternateText',$value,''); + } + + /** + * @return string the alignment of the image with respective to other elements on the page. + */ + public function getImageAlign() + { + return $this->getViewState('ImageAlign',''); + } + + /** + * Sets the alignment of the image with respective to other elements on the page. + * @param string the alignment of the image + */ + public function setImageAlign($value) + { + $this->setViewState('ImageAlign',TPropertyValue::ensureEnum($value,self::$IMAGE_ALIGN),'NotSet'); + } + + /** + * @return string the location of the image file to be displayed + */ + public function getImageUrl() + { + return $this->getViewState('ImageUrl',''); + } + + /** + * Sets the location of the image file to be displayed. + * @param string the location of the image file (file path or URL) + */ + public function setImageUrl($value) + { + $this->setViewState('ImageUrl',$value,''); + } + + /** + * @return string link to long description + */ + public function getDescriptionUrl() + { + return $this->getViewState('DescriptionUrl',''); + } + + /** + * Sets the link to long description + * @param string the link to long description + */ + public function setDescriptionUrl($value) + { + $this->setViewState('DescriptionUrl',$value,''); + } +} + +?> \ No newline at end of file -- cgit v1.2.3