From ec46fdc945f591e910051aca0457097825afd34c Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 6 Dec 2005 22:53:07 +0000 Subject: --- framework/Web/UI/TClientScriptManager.php | 6 +++ framework/Web/UI/WebControls/TPanel.php | 66 ++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 6 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 03ac8479..ace11064 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -195,6 +195,12 @@ class TClientScriptManager extends TComponent } } + public function registerDefaultButtonScript($button) + { + $this->registerScriptInclude('prado:base',$this->publishScriptFile('base.js')); + return 'return Prado.DefaultButton.fire(event,\''.$button->getClientID().'\')'; + } + public function registerValidationScript() { } 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 <div> 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 * @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; @@ -154,6 +191,23 @@ class TPanel extends TWebControl $this->setViewState('GroupingText',$value,''); } + /** + * @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); } -- cgit v1.2.3