PHP Class Prado\Web\UI\WebControls\TWebControl

TWebControl is the base class for controls that share a common set of UI-related properties and methods. TWebControl-derived controls are usually associated with HTML tags. They thus have tag name, attributes and body contents. You can override {@link getTagName} to specify the tag name, {@link addAttributesToRender} to specify the attributes to be rendered, and {@link renderContents} to customize the body content rendering. TWebControl encapsulates a set of properties related with CSS style fields, such as {@link getBackColor BackColor}, {@link getBorderWidth BorderWidth}, etc. Subclasses of TWebControl typically needs to override {@link addAttributesToRender} and {@link renderContents}. The former is used to render the attributes of the HTML tag associated with the control, while the latter is to render the body contents enclosed within the HTML tag.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends Prado\Web\UI\TControl, implements Prado\Web\UI\WebControls\IStyleable
Mostrar archivo Open project: pradosoft/prado Class Usage Examples

Protected Properties

Property Type Description
$_decorator this render things before and after both the open and close tag

Public Methods

Method Description
clearStyle ( ) Removes all style data.
copyBaseAttributes ( TWebControl $control ) Copies basic control attributes from another control.
getAccessKey ( ) : string
getBackColor ( ) : string
getBorderColor ( ) : string
getBorderStyle ( ) : string
getBorderWidth ( ) : string
getCssClass ( ) : string
getDecorator ( $create = true ) : TWebControlDecorator
getDisplay ( ) : TDisplayStyle
getEnsureId ( ) : whether
getFont ( ) : TFont
getForeColor ( ) : string
getHasStyle ( ) : boolean
getHeight ( ) : string
getStyle ( ) : TStyle
getTabIndex ( ) : integer
getToolTip ( ) : string
getWidth ( ) : string
onPreRender ( $param ) If your subclass overrides the onPreRender method be sure to call this method through parent::onPreRender($param); so your sub-class can be decorated, among other things.
render ( $writer ) Renders the control.
renderBeginTag ( $writer ) Renders the openning tag for the control (including attributes)
renderContents ( $writer ) Renders the body content enclosed between the control tag.
renderEndTag ( $writer ) Renders the closing tag for the control
setAccessKey ( $value ) Sets the access key of the control.
setBackColor ( $value )
setBorderColor ( $value )
setBorderStyle ( $value )
setBorderWidth ( $value )
setCssClass ( $value )
setDisplay ( $value )
setEnsureId ( $value ) Subclasses can override getEnsureId or just set this property. eg. If your subclass control does work with javascript and your class wants to flag that it requires an id to operate properly. Once set to true, it stays that way.
setForeColor ( $value )
setHeight ( $value )
setStyle ( $value ) Sets the css style string of the control.
setTabIndex ( $value ) Sets the tab index of the control.
setToolTip ( $value ) Sets the tooltip of the control.
setWidth ( $value )

Protected Methods

Method Description
addAttributesToRender ( $writer ) Adds attribute name-value pairs to renderer.
createStyle ( ) : TStyle Creates a style object to be used by the control.
getTagName ( ) : string Returns the tag name used for this control.

Method Details

addAttributesToRender() protected method

By default, the method will render 'id', 'accesskey', 'disabled', 'tabindex', 'title' and all custom attributes. The method can be overriden to provide customized attribute rendering.
protected addAttributesToRender ( $writer )

clearStyle() public method

Removes all style data.
public clearStyle ( )

copyBaseAttributes() public method

Properties including AccessKey, ToolTip, TabIndex, Enabled and Attributes are copied.
public copyBaseAttributes ( TWebControl $control )
$control TWebControl

createStyle() protected method

This method may be overriden by controls to provide customized style.
protected createStyle ( ) : TStyle
return TStyle the default style created for TWebControl

getAccessKey() public method

public getAccessKey ( ) : string
return string the access key of the control

getBackColor() public method

public getBackColor ( ) : string
return string the background color of the control

getBorderColor() public method

public getBorderColor ( ) : string
return string the border color of the control

getBorderStyle() public method

public getBorderStyle ( ) : string
return string the border style of the control

getBorderWidth() public method

public getBorderWidth ( ) : string
return string the border width of the control

getCssClass() public method

public getCssClass ( ) : string
return string the css class of the control

getDecorator() public method

public getDecorator ( $create = true ) : TWebControlDecorator
return TWebControlDecorator

getDisplay() public method

public getDisplay ( ) : TDisplayStyle
return TDisplayStyle display style of the control, default is TDisplayStyle::Fixed

getEnsureId() public method

public getEnsureId ( ) : whether
return whether this web control must have an id

getFont() public method

public getFont ( ) : TFont
return TFont the font of the control

getForeColor() public method

public getForeColor ( ) : string
return string the foreground color of the control

getHasStyle() public method

public getHasStyle ( ) : boolean
return boolean whether the control has defined any style information

getHeight() public method

public getHeight ( ) : string
return string the height of the control

getStyle() public method

public getStyle ( ) : TStyle
return TStyle the object representing the css style of the control

getTabIndex() public method

public getTabIndex ( ) : integer
return integer the tab index of the control

getTagName() protected method

By default, the tag name is 'span'. You can override this method to provide customized tag names.
protected getTagName ( ) : string
return string tag name of the control to be rendered

getToolTip() public method

public getToolTip ( ) : string
return string the tooltip of the control

getWidth() public method

public getWidth ( ) : string
return string the width of the control

onPreRender() public method

If your subclass overrides the onPreRender method be sure to call this method through parent::onPreRender($param); so your sub-class can be decorated, among other things.
public onPreRender ( $param )

render() public method

This method overrides the parent implementation by replacing it with the following sequence: - {@link renderBeginTag} - {@link renderContents} - {@link renderEndTag}
public render ( $writer )

renderBeginTag() public method

Renders the openning tag for the control (including attributes)
public renderBeginTag ( $writer )

renderContents() public method

By default, child controls and text strings will be rendered. You can override this method to provide customized content rendering.
public renderContents ( $writer )

renderEndTag() public method

Renders the closing tag for the control
public renderEndTag ( $writer )

setAccessKey() public method

Only one-character string can be set, or an exception will be raised. Pass in an empty string if you want to disable access key.
public setAccessKey ( $value )

setBackColor() public method

public setBackColor ( $value )

setBorderColor() public method

public setBorderColor ( $value )

setBorderStyle() public method

public setBorderStyle ( $value )

setBorderWidth() public method

public setBorderWidth ( $value )

setCssClass() public method

public setCssClass ( $value )

setDisplay() public method

public setDisplay ( $value )

setEnsureId() public method

Subclasses can override getEnsureId or just set this property. eg. If your subclass control does work with javascript and your class wants to flag that it requires an id to operate properly. Once set to true, it stays that way.
public setEnsureId ( $value )

setForeColor() public method

public setForeColor ( $value )

setHeight() public method

public setHeight ( $value )

setStyle() public method

The style string will be prefixed to the styles set via other control properties (e.g. Height, Width).
public setStyle ( $value )

setTabIndex() public method

Pass 0 if you want to disable tab index.
public setTabIndex ( $value )

setToolTip() public method

Pass an empty string if you want to disable tooltip.
public setToolTip ( $value )

setWidth() public method

public setWidth ( $value )

Property Details

$_decorator protected_oe property

this render things before and after both the open and close tag
protected $_decorator