diff options
author | xue <> | 2006-01-02 17:10:25 +0000 |
---|---|---|
committer | xue <> | 2006-01-02 17:10:25 +0000 |
commit | 2df9a40f504933e28ddb9974b97ae4b2bb893f86 (patch) | |
tree | 16bf90aff95dd4f8f4c26978c439ac48dd209a27 | |
parent | 2d0739422a41237f48d2ff7c079043fa7f0b2944 (diff) |
Added TTable sample.
-rw-r--r-- | .gitattributes | 2 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TTable/Home.page | 44 | ||||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif | bin | 0 -> 3636 bytes | |||
-rw-r--r-- | demos/quickstart/protected/pages/Controls/Simple.page | 6 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TStyle.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TTable.php | 131 |
6 files changed, 166 insertions, 19 deletions
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 @@ +<com:TContent ID="body">
+
+<h1>TTable Samples</h1>
+
+<table class="sampletable">
+
+<tr><td class="samplenote">
+Table with default settings (looks empty):
+</td><td class="sampleaction">
+<com:TTable />
+</td></tr>
+
+<tr><td class="samplenote">
+Table with rows and customized font, background image, etc.:
+</td><td class="sampleaction">
+<com:TTable
+ GridLines="Both"
+ CellSpacing="0"
+ CellPadding="2"
+ BackImageUrl=<%~backimage.gif%>
+ Caption="This is table caption"
+ CaptionAlign="Bottom">
+ <com:TTableRow BackColor="gray" ForeColor="white">
+ <com:TTableHeaderCell>header cell 1</com:TTableHeaderCell>
+ <com:TTableHeaderCell>header cell 2</com:TTableHeaderCell>
+ <com:TTableHeaderCell>header cell 3</com:TTableHeaderCell>
+ </com:TTableRow>
+ <com:TTableRow HorizontalAlign="Right">
+ <com:TTableCell Text="text">cell 1</com:TTableCell>
+ <com:TTableCell>cell 2</com:TTableCell>
+ <com:TTableCell BackColor="red">cell 3</com:TTableCell>
+ </com:TTableRow>
+ <com:TTableRow>
+ <com:TTableCell ForeColor="red">cell 4</com:TTableCell>
+ <com:TTableCell ColumnSpan="2" HorizontalAlign="Center">
+ cell 5
+ </com:TTableCell>
+ </com:TTableRow>
+</com:TTable>
+</td></tr>
+
+</table>
+
+</com:TContent>
\ 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 Binary files differnew file mode 100644 index 00000000..8a4b3b71 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TTable/backimage.gif 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 @@ </p>
<com:RunBar PagePath="Controls.Samples.TPanel.Home" />
+<h2>TTable</h2>
+<p>
+<tt>TTable</tt> displays an HTML table on a page. It is used together with <tt>TTableRow</tt> and <tt>TTableCell</tt> to allow programmatically manipulating HTML tables. The rows of the table is stored in <tt>Rows</tt> property. You may set the table cellspacing and cellpadding via the <tt>CellSpacing</tt> and <tt>CellPadding</tt> properties, respectively. The table caption can be specified via <tt>Caption</tt> whose alignment is specified by <tt>CaptionAlign</tt>. The <tt>GridLines</tt> property indicates how the table should display its borders, and the <tt>BackImageUrl</tt> allows the table to have a background image.
+</p>
+<com:RunBar PagePath="Controls.Samples.TTable.Home" />
+
<h2>TTextBox</h2>
<p>
<tt>TTextBox</tt> displays a text box on a Web page. The content in the text box is determined by the <tt>Text</tt> property. You can create a <tt>SingleLine</tt>, a <tt>MultiLine</tt>, or a <tt>Password</tt> text box by setting the <tt>TextMode</tt> property. The <tt>Rows</tt> and <tt>Columns</tt> properties specify their dimensions. If <tt>AutoPostBack</tt> 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 |