summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TPanel.php
diff options
context:
space:
mode:
authorxue <>2005-12-06 22:53:07 +0000
committerxue <>2005-12-06 22:53:07 +0000
commitec46fdc945f591e910051aca0457097825afd34c (patch)
treeb79765ec299229678242267a7bfdf7e3c3f31349 /framework/Web/UI/WebControls/TPanel.php
parent03142d666493516ca86dede5380344f8c05b7633 (diff)
Diffstat (limited to 'framework/Web/UI/WebControls/TPanel.php')
-rw-r--r--framework/Web/UI/WebControls/TPanel.php66
1 files changed, 60 insertions, 6 deletions
diff --git a/framework/Web/UI/WebControls/TPanel.php b/framework/Web/UI/WebControls/TPanel.php
index 5cdfa307..22e41c20 100644
--- a/framework/Web/UI/WebControls/TPanel.php
+++ b/framework/Web/UI/WebControls/TPanel.php
@@ -14,7 +14,20 @@
* TPanel class
*
* TPanel represents a component that acts as a container for other component.
- * It is especially useful when you want to generate components programmatically or hide/show a group of components.
+ * It is especially useful when you want to generate components programmatically
+ * or hide/show a group of components.
+ *
+ * By default, TPanel displays a &lt;div&gt; element on a page.
+ * Children of TPanel are displayed as the body content of the element.
+ * The property {@link setWrap Wrap} can be used to set whether the body content
+ * should wrap or not. {@link setHorizontalAlign HorizontalAlign} governs how
+ * the content is aligned horizontally, and {@link getDirection Direction} indicates
+ * the content direction (left to right or right to left). You can set
+ * {@link setBackImageUrl BackImageUrl} to give a background image to the panel,
+ * and you can ste {@link setGroupingText GroupingText} so that the panel is
+ * displayed as a field set with a legend text. Finally, you can specify
+ * a default button to be fired when users press 'return' key within the panel
+ * by setting the {@link setDefaultButton DefaultButton} property.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -23,7 +36,11 @@
*/
class TPanel extends TWebControl
{
+ /**
+ * @var string ID path to the default button
+ */
private $_defaultButton='';
+
/**
* @return string tag name of the panel
*/
@@ -35,13 +52,20 @@ class TPanel extends TWebControl
/**
* Adds attributes to renderer.
* @param THtmlWriter the renderer
+ * @throws TInvalidDataValueException if default button is not right.
*/
protected function addAttributesToRender($writer)
{
parent::addAttributesToRender($writer);
if(($url=trim($this->getBackImageUrl()))!=='')
$writer->addStyleAttribute('background-image','url('.$url.')');
- //this.AddScrollingAttribute(this.ScrollBars, writer);
+ switch($this->getScrollBars())
+ {
+ case 'Horizontal': $writer->addStyleAttribute('overflow-x','scroll'); break;
+ case 'Vertical': $writer->addStyleAttribute('overflow-y','scroll'); break;
+ case 'Both': $writer->addStyleAttribute('overflow','scroll'); break;
+ case 'Auto': $writer->addStyleAttribute('overflow','auto'); break;
+ }
if(($align=$this->getHorizontalAlign())!=='')
$writer->addStyleAttribute('text-align',$align);
if(!$this->getWrap())
@@ -51,9 +75,12 @@ class TPanel extends TWebControl
if(($butt=$this->getDefaultButton())!=='')
{
if(($button=$this->findControl($butt))===null)
- throw new TInvalidOperationException('panel_defaultbutton_invalid');
+ throw new TInvalidDataValueException('panel_defaultbutton_invalid',$butt);
else
- $this->getPage()->getClientScript()->registerDefaultButtonScript($button,$writer);
+ {
+ $onkeypress=$this->getPage()->getClientScript()->registerDefaultButtonScript($button);
+ $writer->addAttribute('onkeypress',$onkeypress);
+ }
}
}
@@ -75,7 +102,7 @@ class TPanel extends TWebControl
}
/**
- * @return string the horizontal alignment of the contents within the panel.
+ * @return string the horizontal alignment of the contents within the panel, defaults to empty string (meaning not set).
*/
public function getHorizontalAlign()
{
@@ -128,11 +155,21 @@ class TPanel extends TWebControl
$this->setViewState('Direction',$value,'');
}
+ /**
+ * @return string the ID path to the default button. Defaults to empty.
+ */
public function getDefaultButton()
{
return $this->_defaultButton;
}
+ /**
+ * Specifies the default button for the panel.
+ * The default button will be fired (clicked) whenever a user enters 'return'
+ * key within the panel.
+ * The button must be locatable via the function call {@link TControl::findControl findControl}.
+ * @param string the ID path to the default button.
+ */
public function setDefaultButton($value)
{
$this->_defaultButton=$value;
@@ -155,6 +192,23 @@ class TPanel extends TWebControl
}
/**
+ * @return string the visibility and position of scroll bars in a panel control, defaults to None.
+ */
+ public function getScrollBars()
+ {
+ return $this->getViewState('ScrollBars','None');
+ }
+
+ /**
+ * @param string the visibility and position of scroll bars in a panel control.
+ * Valid values include None, Auto, Both, Horizontal and Vertical.
+ */
+ public function setScrollBars($value)
+ {
+ $this->setViewState('ScrollBars',TPropertyValue::ensureEnum($value,array('None','Auto','Both','Horizontal','Vertical')),'None');
+ }
+
+ /**
* Renders the openning tag for the control (including attributes)
* @param THtmlWriter the writer used for the rendering purpose
*/
@@ -176,7 +230,7 @@ class TPanel extends TWebControl
*/
protected function renderEndTag($writer)
{
- if(($text=$this->getGroupingText())!=='')
+ if($this->getGroupingText()!=='')
$writer->renderEndTag();
parent::renderEndTag($writer);
}