3 * TInlineFrame class file.
5 * @author Jason Ragsdale <jrags@jasrags.net>
6 * @author Harry Pottash <hpottash@gmail.com>
7 * @link http://www.pradosoft.com/
8 * @copyright Copyright © 2005-2014 PradoSoft
9 * @license http://www.pradosoft.com/license/
10 * @package System.Web.UI.WebControls
16 * TInlineFrame displays an inline frame (iframe) on a Web page.
17 * The location of the frame content is specified by {@link setFrameUrl FrameUrl}.
18 * The frame's alignment is specified by {@link setAlign Align}.
19 * The {@link setMarginWidth MarginWidth} and {@link setMarginHeight MarginHeight}
20 * properties define the number of pixels to use as the left/right margins and
21 * top/bottom margins, respectively, within the inline frame.
22 * The {@link setScrollBars ScrollBars} property specifies whether scrollbars are
23 * provided for the inline frame. And {@link setDescriptionUrl DescriptionUrl}
24 * gives the URI of a long description of the frame's contents.
26 * Original Prado v2 IFrame Author Information
27 * @author Jason Ragsdale <jrags@jasrags.net>
28 * @author Harry Pottash <hpottash@gmail.com>
29 * @package System.Web.UI.WebControls
32 class TInlineFrame extends TWebControl implements IDataRenderer
35 * @return string tag name of the iframe.
37 protected function getTagName()
43 * @return TInlineFrameAlign alignment of the iframe. Defaults to TInlineFrameAlign::NotSet.
45 public function getAlign()
47 return $this->getViewState('Align',TInlineFrameAlign::NotSet);
51 * @param TInlineFrameAlign alignment of the iframe.
53 public function setAlign($value)
55 $this->setViewState('Align',TPropertyValue::ensureEnum($value,'TInlineFrameAlign'),TInlineFrameAlign::NotSet);
59 * @return string the URL to long description
61 public function getDescriptionUrl()
63 return $this->getViewState('DescriptionUrl','');
67 * @param string the URL to the long description of the image.
69 public function setDescriptionUrl($value)
71 $this->setViewState('DescriptionUrl',$value,'');
75 * @return boolean whether there should be a visual separator between the frames. Defaults to true.
77 public function getShowBorder()
79 return $this->getViewState('ShowBorder',true);
83 * @param boolean whether there should be a visual separator between the frames.
85 public function setShowBorder($value)
87 $this->setViewState('ShowBorder',TPropertyValue::ensureBoolean($value),true);
91 * @return string URL that this iframe will load content from. Defaults to ''.
93 public function getFrameUrl()
95 return $this->getViewState('FrameUrl','');
99 * @param string URL that this iframe will load content from.
101 public function setFrameUrl($value)
103 $this->setViewState('FrameUrl',$value,'');
107 * Returns the URL that this iframe will load content from
108 * This method is required by {@link IDataRenderer}.
109 * It is the same as {@link getFrameUrl()}.
110 * @return string the URL that this iframe will load content from
114 public function getData()
116 return $this->getFrameUrl();
120 * Sets the URL that this iframe will load content from.
121 * This method is required by {@link IDataRenderer}.
122 * It is the same as {@link setFrameUrl()}.
123 * @param string the URL that this iframe will load content from
127 public function setData($value)
129 $this->setFrameUrl($value);
133 * @return TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. Defaults to TInlineFrameScrollBars::Auto.
135 public function getScrollBars()
137 return $this->getViewState('ScrollBars',TInlineFrameScrollBars::Auto);
141 * @param TInlineFrameScrollBars the visibility and position of scroll bars in an iframe.
143 public function setScrollBars($value)
145 $this->setViewState('ScrollBars',TPropertyValue::ensureEnum($value,'TInlineFrameScrollBars'),TInlineFrameScrollBars::Auto);
149 * @return integer the amount of space, in pixels, that should be left between
150 * the frame's contents and the left and right margins. Defaults to -1, meaning not set.
152 public function getMarginWidth()
154 return $this->getViewState('MarginWidth',-1);
158 * @param integer the amount of space, in pixels, that should be left between
159 * the frame's contents and the left and right margins.
161 public function setMarginWidth($value)
163 if(($value=TPropertyValue::ensureInteger($value))<0)
165 $this->setViewState('MarginWidth',$value,-1);
169 * @return integer the amount of space, in pixels, that should be left between
170 * the frame's contents and the top and bottom margins. Defaults to -1, meaning not set.
172 public function getMarginHeight()
174 return $this->getViewState('MarginHeight',-1);
178 * @param integer the amount of space, in pixels, that should be left between
179 * the frame's contents and the top and bottom margins.
181 public function setMarginHeight($value)
183 if(($value=TPropertyValue::ensureInteger($value))<0)
185 $this->setViewState('MarginHeight',$value,-1);
189 * Adds attribute name-value pairs to renderer.
190 * This overrides the parent implementation with additional button specific attributes.
191 * @param THtmlWriter the writer used for the rendering purpose
193 protected function addAttributesToRender($writer)
195 if($this->getID()!=='')
196 $writer->addAttribute('name',$this->getUniqueID());
198 if(($src=$this->getFrameUrl())!=='')
199 $writer->addAttribute('src',$src);
201 if(($align=strtolower($this->getAlign()))!=='notset')
202 $writer->addAttribute('align',$align);
204 $scrollBars=$this->getScrollBars();
205 if($scrollBars===TInlineFrameScrollBars::None)
206 $writer->addAttribute('scrolling','no');
207 else if($scrollBars===TInlineFrameScrollBars::Both)
208 $writer->addAttribute('scrolling','yes');
210 if (!$this->getShowBorder())
211 $writer->addAttribute('frameborder','0');
213 if(($longdesc=$this->getDescriptionUrl())!=='')
214 $writer->addAttribute('longdesc',$longdesc);
216 if(($marginheight=$this->getMarginHeight())!==-1)
217 $writer->addAttribute('marginheight',$marginheight);
219 if(($marginwidth=$this->getMarginWidth())!==-1)
220 $writer->addAttribute('marginwidth',$marginwidth);
222 parent::addAttributesToRender($writer);
227 * TInlineFrameAlign class.
228 * TInlineFrameAlign defines the enumerable type for the possible alignments
229 * that the content in a {@link TInlineFrame} could be.
231 * The following enumerable values are defined:
232 * - NotSet: the alignment is not specified.
233 * - Left: left aligned
234 * - Right: right aligned
236 * - Middle: middle aligned
237 * - Bottom: bottom aligned
239 * @author Qiang Xue <qiang.xue@gmail.com>
240 * @package System.Web.UI.WebControls
243 class TInlineFrameAlign extends TEnumerable
245 const NotSet='NotSet';
249 const Middle='Middle';
250 const Bottom='Bottom';
254 * TInlineFrameScrollBars class.
255 * TInlineFrameScrollBars defines the enumerable type for the possible scroll bar mode
256 * that a {@link TInlineFrame} control could use.
258 * The following enumerable values are defined:
259 * - None: no scroll bars.
260 * - Auto: scroll bars automatically appeared when needed.
261 * - Both: show both horizontal and vertical scroll bars all the time.
263 * @author Qiang Xue <qiang.xue@gmail.com>
264 * @package System.Web.UI.WebControls
267 class TInlineFrameScrollBars extends TEnumerable