[ Index ] |
|
Code source de PRADO 3.0.6 |
1 <?php 2 /** 3 * TTableCell class file 4 * 5 * @author Qiang Xue <qiang.xue@gmail.com> 6 * @link http://www.pradosoft.com/ 7 * @copyright Copyright © 2005 PradoSoft 8 * @license http://www.pradosoft.com/license/ 9 * @version $Id: TTableCell.php 1486 2006-11-03 13:22:08Z xue $ 10 * @package System.Web.UI.WebControls 11 */ 12 13 /** 14 * TTableCell class. 15 * 16 * TTableCell displays a table cell on a Web page. Content of the table cell 17 * is specified by the {@link setText Text} property. If {@link setText Text} 18 * is empty, the body contents enclosed by the table cell component tag are rendered. 19 * Note, {@link setText Text} is not HTML-encoded when displayed. So make sure 20 * it does not contain dangerous characters. 21 * 22 * The horizontal and vertical alignments of the contents in the cell 23 * are specified via {@link setHorizontalAlign HorizontalAlign} and 24 * {@link setVerticalAlign VerticalAlign} properties, respectively. 25 * 26 * The colspan and rowspan of the cell are specified via {@link setColumnSpan ColumnSpan} 27 * and {@link setRowSpan RowSpan} properties. And the {@link setWrap Wrap} property 28 * indicates whether the contents in the cell should be wrapped. 29 * 30 * @author Qiang Xue <qiang.xue@gmail.com> 31 * @version $Id: TTableCell.php 1486 2006-11-03 13:22:08Z xue $ 32 * @package System.Web.UI.WebControls 33 * @since 3.0 34 */ 35 class TTableCell extends TWebControl 36 { 37 /** 38 * @return string tag name for the table cell 39 */ 40 protected function getTagName() 41 { 42 return 'td'; 43 } 44 45 /** 46 * Creates a style object for the control. 47 * This method creates a {@link TTableItemStyle} to be used by the table cell. 48 * @return TStyle control style to be used 49 */ 50 protected function createStyle() 51 { 52 return new TTableItemStyle; 53 } 54 55 /** 56 * @return string the horizontal alignment of the contents within the table item, defaults to 'NotSet'. 57 */ 58 public function getHorizontalAlign() 59 { 60 if($this->getHasStyle()) 61 return $this->getStyle()->getHorizontalAlign(); 62 else 63 return 'NotSet'; 64 } 65 66 /** 67 * Sets the horizontal alignment of the contents within the table item. 68 * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center' 69 * @param string the horizontal alignment 70 */ 71 public function setHorizontalAlign($value) 72 { 73 $this->getStyle()->setHorizontalAlign($value); 74 } 75 76 /** 77 * @return string the vertical alignment of the contents within the table item, defaults to 'NotSet'. 78 */ 79 public function getVerticalAlign() 80 { 81 if($this->getHasStyle()) 82 return $this->getStyle()->getVerticalAlign(); 83 else 84 return 'NotSet'; 85 } 86 87 /** 88 * Sets the vertical alignment of the contents within the table item. 89 * Valid values include 'NotSet','Top','Bottom','Middle' 90 * @param string the horizontal alignment 91 */ 92 public function setVerticalAlign($value) 93 { 94 $this->getStyle()->setVerticalAlign($value); 95 } 96 97 /** 98 * @return integer the columnspan for the table cell, 0 if not set. 99 */ 100 public function getColumnSpan() 101 { 102 return $this->getViewState('ColumnSpan', 0); 103 } 104 105 /** 106 * Sets the columnspan for the table cell. 107 * @param integer the columnspan for the table cell, 0 if not set. 108 */ 109 public function setColumnSpan($value) 110 { 111 $this->setViewState('ColumnSpan', TPropertyValue::ensureInteger($value), 0); 112 } 113 114 /** 115 * @return integer the rowspan for the table cell, 0 if not set. 116 */ 117 public function getRowSpan() 118 { 119 return $this->getViewState('RowSpan', 0); 120 } 121 122 /** 123 * Sets the rowspan for the table cell. 124 * @param integer the rowspan for the table cell, 0 if not set. 125 */ 126 public function setRowSpan($value) 127 { 128 $this->setViewState('RowSpan', TPropertyValue::ensureInteger($value), 0); 129 } 130 131 /** 132 * @return boolean whether the text content wraps within a table cell. Defaults to true. 133 */ 134 public function getWrap() 135 { 136 if($this->getHasStyle()) 137 return $this->getStyle()->getWrap(); 138 else 139 return true; 140 } 141 142 /** 143 * Sets the value indicating whether the text content wraps within a table cell. 144 * @param boolean whether the text content wraps within a table cell. 145 */ 146 public function setWrap($value) 147 { 148 $this->getStyle()->setWrap($value); 149 } 150 151 /** 152 * @return string the text content of the table cell. 153 */ 154 public function getText() 155 { 156 return $this->getViewState('Text',''); 157 } 158 159 /** 160 * Sets the text content of the table cell. 161 * If the text content is empty, body content (child controls) of the cell will be rendered. 162 * @param string the text content 163 */ 164 public function setText($value) 165 { 166 $this->setViewState('Text',$value,''); 167 } 168 169 /** 170 * Adds attributes to renderer. 171 * @param THtmlWriter the renderer 172 */ 173 protected function addAttributesToRender($writer) 174 { 175 parent::addAttributesToRender($writer); 176 if(($colspan=$this->getColumnSpan())>0) 177 $writer->addAttribute('colspan',"$colspan"); 178 if(($rowspan=$this->getRowSpan())>0) 179 $writer->addAttribute('rowspan',"$rowspan"); 180 } 181 182 /** 183 * Renders body contents of the table cell. 184 * @param THtmlWriter the writer used for the rendering purpose. 185 */ 186 public function renderContents($writer) 187 { 188 if(($text=$this->getText())!=='') 189 $writer->write($text); 190 else if($this->getHasControls()) 191 parent::renderContents($writer); 192 else 193 $writer->write(' '); 194 } 195 } 196 197 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 21:07:04 2007 | par Balluche grâce à PHPXref 0.7 |