From ac19b0fd24b3da09e1d056a1591bcf38dd4d00d2 Mon Sep 17 00:00:00 2001 From: tof <> Date: Thu, 6 Sep 2007 16:32:44 +0000 Subject: TSlider: Add handle as a child control instead of just rendering it --- framework/Web/UI/WebControls/TSlider.php | 55 +++++++++++++++----------------- 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'framework/Web/UI/WebControls/TSlider.php') diff --git a/framework/Web/UI/WebControls/TSlider.php b/framework/Web/UI/WebControls/TSlider.php index 094dbd5b..7ac8f033 100644 --- a/framework/Web/UI/WebControls/TSlider.php +++ b/framework/Web/UI/WebControls/TSlider.php @@ -208,23 +208,32 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer public function setValues($value) { $this->setViewState('Values', TPropertyValue::ensureArray($value), array()); - } - - /** - * @return TSliderHandle the control for the slider's handle. - */ - public function getHandle () - { - if ($this->_handle==null) - { - $this->_handle=prado::createComponent($this->getHandleClass(), $this); - if (!$this->_handle instanceof TSliderHandle) - { - throw new TInvalidDataTypeException('slider_handle_class_invalid', get_class($this->_handle)); - } - } - return $this->_handle; - } + } + + /** + * Create the child controls + * Override parent implementation to create the handle control + */ + public function createChildControls() + { + $this->_handle=prado::createComponent($this->getHandleClass(), $this); + if (!$this->_handle instanceof TSliderHandle) + { + throw new TInvalidDataTypeException('slider_handle_class_invalid', get_class($this->_handle)); + } + $this->getControls()->add($this->_handle); + } + + /** + * This method will return the handle control. + * @return TSliderHandle the control for the slider's handle (must inherit from TSliderHandle} + */ + public function getHandle () + { + $this->ensureChildControls(); + return $this->_handle; + } + /** * @return string Custom handle class. Defaults to TSliderHandle; @@ -360,18 +369,6 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer return "div"; } - /** - * Renders body content. - * This method renders the handle of slider - * This method overrides parent implementation - * @param THtmlWriter writer - */ - public function renderContents($writer) - { - // Render the handle - $this->getHandle()->render ($writer); - } - /** * Add the specified css classes to the track * @param THtmlWriter writer -- cgit v1.2.3