From 2df9a40f504933e28ddb9974b97ae4b2bb893f86 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 2 Jan 2006 17:10:25 +0000 Subject: Added TTable sample. --- .gitattributes | 2 + .../pages/Controls/Samples/TTable/Home.page | 44 +++++++ .../pages/Controls/Samples/TTable/backimage.gif | Bin 0 -> 3636 bytes .../protected/pages/Controls/Simple.page | 6 + framework/Web/UI/WebControls/TStyle.php | 2 +- framework/Web/UI/WebControls/TTable.php | 131 ++++++++++++++++++--- 6 files changed, 166 insertions(+), 19 deletions(-) create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif diff --git a/.gitattributes b/.gitattributes index e583b6d9..53d811fb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -50,6 +50,8 @@ demos/quickstart/protected/pages/Controls/Samples/TListBox/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TPanel/Home.php -text demos/quickstart/protected/pages/Controls/Samples/TPanel/hello_world.gif -text +demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page -text +demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif -text demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.page -text demos/quickstart/protected/pages/Controls/Samples/TTextBox/Home.php -text demos/quickstart/protected/pages/Controls/Samples/config.xml -text diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page new file mode 100644 index 00000000..cec92f67 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page @@ -0,0 +1,44 @@ + + +

TTable Samples

+ + + + + + + +
+Table with default settings (looks empty): + + +
+Table with rows and customized font, background image, etc.: + + + Caption="This is table caption" + CaptionAlign="Bottom"> + + header cell 1 + header cell 2 + header cell 3 + + + cell 1 + cell 2 + cell 3 + + + cell 4 + + cell 5 + + + +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif b/demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif new file mode 100644 index 00000000..8a4b3b71 Binary files /dev/null and b/demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif differ diff --git a/demos/quickstart/protected/pages/Controls/Simple.page b/demos/quickstart/protected/pages/Controls/Simple.page index 7ee79ac0..86b819f4 100644 --- a/demos/quickstart/protected/pages/Controls/Simple.page +++ b/demos/quickstart/protected/pages/Controls/Simple.page @@ -18,6 +18,12 @@

+

TTable

+

+TTable displays an HTML table on a page. It is used together with TTableRow and TTableCell to allow programmatically manipulating HTML tables. The rows of the table is stored in Rows property. You may set the table cellspacing and cellpadding via the CellSpacing and CellPadding properties, respectively. The table caption can be specified via Caption whose alignment is specified by CaptionAlign. The GridLines property indicates how the table should display its borders, and the BackImageUrl allows the table to have a background image. +

+ +

TTextBox

TTextBox displays a text box on a Web page. The content in the text box is determined by the Text property. You can create a SingleLine, a MultiLine, or a Password text box by setting the TextMode property. The Rows and Columns properties specify their dimensions. If AutoPostBack is true, changing the content in the text box and then moving the focus out of it will cause postback action. diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index 5624b09e..4585cca3 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -397,7 +397,7 @@ class TTableStyle extends TStyle if($this->_cellSpacing>=0) { - $writer->addAttribute('cellspacing',"$this->_cellPadding"); + $writer->addAttribute('cellspacing',"$this->_cellSpacing"); if($this->_cellSpacing===0) $this->setStyleField('border-collapse','collapse'); } diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php index 4a5e84b1..4f93f8f1 100644 --- a/framework/Web/UI/WebControls/TTable.php +++ b/framework/Web/UI/WebControls/TTable.php @@ -163,6 +163,7 @@ class TTable extends TWebControl { if($this->_rows) { + $writer->writeLine(); foreach($this->_rows as $row) { $row->renderControl($writer); @@ -193,23 +194,6 @@ class TTableRow extends TWebControl return new TTableItemStyle; } - protected function addAttributesToRender($writer) - { - parent::addAttributesToRender($writer); - $border=0; - if($this->getHasStyle()) - { - if($this->getGridLines()!=='None') - { - if(($border=$this->getBorderWidth())==='') - $border=1; - else - $border=(int)$border; - } - } - $writer->addAttribute('border',"$border"); - } - public function getCells() { if(!$this->_cells) @@ -247,6 +231,7 @@ class TTableRow extends TWebControl { if($this->_cells) { + $writer->writeLine(); foreach($this->_cells as $cell) { $cell->renderControl($writer); @@ -371,7 +356,7 @@ class TTableCell extends TWebControl parent::addAttributesToRender($writer); if(($colspan=$this->getColumnSpan())>0) $writer->addAttribute('colspan',"$colspan"); - if(($rowspan=$this->getColumnSpan())>0) + if(($rowspan=$this->getRowSpan())>0) $writer->addAttribute('rowspan',"$rowspan"); } @@ -446,4 +431,114 @@ class TTableHeaderCell extends TTableCell $this->setViewState('CategoryText',$value,''); } } + + +class TTableRowCollection extends TList +{ + /** + * the table that owns this collection. + * @var TTable + */ + private $_o; + + /** + * Constructor. + * @param TTable the table that owns this collection. + */ + public function __construct(TTable $owner) + { + parent::__construct(); + $this->_o=$owner; + } + + /** + * @return TTable the table that owns this collection. + */ + protected function getOwner() + { + return $this->_o; + } + + /** + * Overrides the parent implementation with customized processing of the newly added item. + * @param mixed the newly added item + */ + protected function addedItem($item) + { + $this->_o->addedControl($item); + } + + /** + * Overrides the parent implementation with customized processing of the removed item. + * @param mixed the removed item + */ + protected function removedItem($item) + { + $this->_o->removedControl($item); + } + + /** + * Only string or instance of TControl can be added into collection. + * @param mixed the item to be added + */ + protected function canAddItem($item) + { + return ($item instanceof TTableRow); + } +} + + +class TTableCellCollection extends TList +{ + /** + * the table row that owns this collection. + * @var TTableRow + */ + private $_o; + + /** + * Constructor. + * @param TTableRow the table row that owns this collection. + */ + public function __construct(TTableRow $owner) + { + parent::__construct(); + $this->_o=$owner; + } + + /** + * @return TTableRow the table row that owns this collection. + */ + protected function getOwner() + { + return $this->_o; + } + + /** + * Overrides the parent implementation with customized processing of the newly added item. + * @param mixed the newly added item + */ + protected function addedItem($item) + { + $this->_o->addedControl($item); + } + + /** + * Overrides the parent implementation with customized processing of the removed item. + * @param mixed the removed item + */ + protected function removedItem($item) + { + $this->_o->removedControl($item); + } + + /** + * Only string or instance of TControl can be added into collection. + * @param mixed the item to be added + */ + protected function canAddItem($item) + { + return ($item instanceof TTableCell); + } +} ?> \ No newline at end of file -- cgit v1.2.3