## P4A_Widget

Description

Base class for objects that permit user interation with the application.

Every P4A objects thats can be rendered should use WIDGET as base class. This class have all the basic methods to build complex widgets that must be P4A compatible.

- author: Fabrizio Balliano <fabrizio.balliano@crealabs.it>
- author: Andrea Giardina <andrea.giardina@crealabs.it>

Located in /p4a/objects/widget.php (line 48)

    P4A_Object
       |
       --P4A_Widget

Direct descendents

Class | Description
--- | ---
P4A_Box | The box: renders raw HTML.
P4A_Button | HTML "button".
P4A_Canvas | The canvas widget A cancas is a panel where we anchor widgets.
P4A_Field | A fields is a GUI element that shows its value, and this value can be changed.
P4A_Frame | The frame widget A frame is a panel where we anchor widgets.
P4A_Href | "HREF" part on a "A" tag.
P4A_Icon | The icon widget
P4A_Image | Use this whan you want to put an image in your application.
P4A_Label | The label is associated to an input field, do not use it otherwise.
P4A_Line | Line
P4A_Link | "A" HTML tag.
P4A_Menu | p4a menu system.
P4A_Menu_Item | Rapresents every menu item.
P4A_Message | P4A - PHP For Applications.
P4A_Sheet | Sheets is the way to manage layouts in MerliWork masks.
P4A_Sheet_Cell | The basic element of sheets: SHEET CELL.
P4A_Table | Tabular rapresentation of a data source.
P4A_Table_Col | Keeps the data for a single table column.
P4A_Table_Rows | Keeps all the data for all the rows.
P4A_Tab_Pane | The tab pane widget A tab pane is a collection of widgets.
P4A_Toolbar | A toolbar is a buttons/images set.

Variable Summary
array $actions
boolean $enabled
mixed $label
array $map_actions
array $properties
array $style
string $template_name
boolean $use_template
string $value
boolean $visible
array $_temp_vars
Method Summary
void addAction (string $action, [string $event = null], [boolean $require_confirmation = false], [string $confirmation_text = null], [string $confirmation_text_handler = 'confirm_general'])
void addTempVar (string $name, mixed $value)
void changeEvent (string $action, [string $event = NULL])
void clearTemplateVars ()
void clearTempVars ()
string composeStringActions ([array $params = NULL])
string composeStringClassStyle ()
string composeStringProperties ()
string composeStringStyle ()
void disable ()
void display (string $var_name, string $var_value)
void dropAction (string $action)
void dropTempVar (string $name)
void enable ([boolean $enabled = TRUE])
string fetchTemplate ()
void getAccessKey ()
void getAsString ()
void getHeight ()
string getLabel ()
string getProperty (string $property)
string getStyleProperty (string $property)
string getValue ()
string getWidth ()
void isEnabled ()
boolean isVisible ()
void onChange ([mixed $params = NULL])
void onClick ([mixed $params = NULL])
void onKeyPress ([mixed $params = NULL])
void onMouseOver ([mixed $params = NULL])
void onReturnPress ([mixed $params = NULL])
void p4a_widget ([string $name = null], [string $prefix = 'wdg'], [string $id = null])
void raise ()
void requireConfirmation (string $action, [string $confirmation_text = null], [string $confirmation_text_handler = 'confirm_general'])
void setAccessKey (mixed $key)
void setBgcolor (string $value)
void setBgimage (string $value)
void setDefaultLabel (string 0)
void setFontColor (string $value)
void setFontWeight (string $value)
void setHeight ([integer $value = null], [string $unit = 'px'])
void setInvisible ()
void setLabel (string $label)
void setProperty (string $property, string $value)
void setStyleProperty (string $property, string $value)
void setValue (string $value)
void setVisible ([boolean $visible = TRUE])
void setWidth ([integer $value = null], [string $unit = 'px'])
void unrequireConfirmation (string $action)
void unsetProperty (string $property)
void unsetStyleProperty (string $property)
void useTemplate (string $template_name)
Variables
array $actions = array() (line 83)

Keeps all the actions implemented by the widget.

- access: private

boolean $enabled = true (line 62)

Object's enabled status. If the widget is visible but not enable it won't be clickable.

- access: private

mixed $label = null (line 91)

Keeps the label associated with the widget.

The label will be displayed on the left of the widget.

- access: public

array $map_actions = array() (line 76)

Keeps the association between an action and its listener.

- access: private

array $properties = array() (line 98)

Keeps all the HTML properties for the widget.

- access: private

array $style = array() (line 105)

Keeps all the CSS properties for the widget.

- access: private

string $template_name = null (line 121)

Defines the name of the widget.

if you set it to 'menu' P4A will search for "menu/menu.tpl" in the "themes/CURRENT_THEME/widgets/" directory.

- access: public

boolean $use_template = false (line 112)

Defines if we are going to use a template for the widget.

- access: public

string $value = null (line 55)

Object's value. Used for widget with data binding.

- access: private

boolean $visible = true (line 69)

Defines object visibility.

- access: private

array $_temp_vars = array() (line 128)

Temporary variables (destroyed after rendering)

- access: private

#### Inherited Variables

Inherited from P4A_Object

> P4A_Object::$_id
> P4A_Object::$_map_actions
> P4A_Object::$_name
> P4A_Object::$_objects
> P4A_Object::$_parent_id

Methods
addAction (line 470)

Adds an action to the implemented actions stack for the widget.

- access: public

void addAction (string $action, [string $event = null], [boolean $require_confirmation = false], [string $confirmation_text = null], [string $confirmation_text_handler = 'confirm_general'])

- string $action: The action's name.
- string $event: The JavaScript event that triggers.
- boolean $require_confirmation: Action Requires confirmation?.
- string $confirmation_text: Text for confirmation.
- string $confirmation_text_handler: i18n message id for confirmation.

addTempVar (line 814)

Add a temporary variable

- access: public

void addTempVar (string $name, mixed $value)

- string $name: The URI of file.

changeEvent (line 522)

Changes the event associated to an action.

If no event is given, here we set event=action.

- access: public

void changeEvent (string $action, [string $event = NULL])

- string $action: The action's name.
- string $event: The JavaScript event that triggers.

clearTemplateVars (line 704)

Empties the template engine variables' stack.

- access: public

void clearTemplateVars ()
clearTempVars (line 835)

Clear temporary vars list

- access: public

void clearTempVars ()
composeStringActions (line 573)

Composes a string containing all the actions implemented by the widget.

Note: it will also contain the name and the value.

- access: public

string composeStringActions ([array $params = NULL])

- array $params: Parameters passed to the action handler.

Redefined in descendants as:

- P4A_Href::composeStringActions() : Composes a string containing all the actions implemented by the widget.

composeStringClassStyle (line 646)

Composes a string contaning the CSS class property for the widget.

- access: public

string composeStringClassStyle ()
composeStringProperties (line 555)

Composes a string containing all the HTML properties of the widget.

Note: it will also contain the name and the value.

- access: public

string composeStringProperties ()

Redefined in descendants as:

- P4A_Button::composeStringProperties() : Composes a string containing all the HTML properties of the widget.
- P4A_Field::composeStringProperties() : Composes a string containing all the HTML properties of the widget.

composeStringStyle (line 628)

Composes a string containing the CSS properties for the widget.

- access: public

string composeStringStyle ()
disable (line 182)

Sets the widget disabled.

- see: P4A_Widget::$enabled
- access: public

void disable ()

Redefined in descendants as:

- P4A_Toolbar::disable() : Turns off the action handler for the desidered button.

display (line 684)

Adds this variable (name and value) to the template engine variables' stack.

void display (string $var_name, string $var_value)

- string $var_name: The variable name.
- string $var_value: The variable value.

dropAction (line 543)

Removes an action from the implemented actions stack for the widget.

- access: public

void dropAction (string $action)

- string $action: The action's name.

dropTempVar (line 824)

Drop a temporary variable

- access: public

void dropTempVar (string $name)

- string $name: The URI of CSS.

enable (line 172)

Sets the widget enabled.

- see: $enable
- access: public

void enable ([boolean $enabled = TRUE])

- boolean $enabled: Visibility flag

Redefined in descendants as:

- P4A_Toolbar::enable() : Turns on the action handler for the desidered button.

fetchTemplate (line 714)

Returns the HTML rendered template.

- access: public

string fetchTemplate ()
getAccessKey (line 331)
void getAccessKey ()
getAsString (line 752)

Returns the HTML rendered widget.

This method MUST be overridden by every widget that extends P4A_this class.

- access: public

void getAsString ()

Redefined in descendants as:

- P4A_Box::getAsString() : Retuns the HTML rendered button.
- P4A_Button::getAsString() : Retuns the HTML rendered button.
- P4A_Canvas::getAsString()
- P4A_Field::getAsString() : Returns the HTML rendered field.
- P4A_Frame::getAsString()
- P4A_Fieldset::getAsString()
- P4A_Table_Navigation_Bar::getAsString()
- P4A_Href::getAsString() : HTML rendered "HREF".
- P4A_Icon::getAsString()
- P4A_Image::getAsString() : Returns the HTML rendered label.
- P4A_Label::getAsString() : Returns the HTML rendered label.
- P4A_Line::getAsString() : HTML rendered link.
- P4A_Link::getAsString() : HTML rendered link.
- P4A_Menu::getAsString() : Returns the HTML rendered widget.
- P4A_Menu_Item::getAsString() : Renders HTML
- P4A_Message::getAsString()
- P4A_Sheet::getAsString() : Renders the sheet in HTML string.
- P4A_Sheet_Cell::getAsString() : Renders the cell in HTML.
- P4A_Table::getAsString() : Returns the HTML rendered object.
- P4A_Tab_Pane::getAsString() : Returns the HTML rendered
- P4A_Toolbar::getAsString() : Returns the HTML rendered widget.
- P4A_Standard_Toolbar::getAsString()

getHeight (line 408)

Returns the height for the widget.

It's a wrapper for get_style_property().

- see: get_style_property()
- access: public

void getHeight ()
getLabel (line 265)

Returns the label for the widget.

- access: public

string getLabel ()

Redefined in descendants as:

- P4A_Field::getLabel() : Returns the label for the field.

getProperty (line 297)

Returns the value of a property.

- access: public

string getProperty (string $property)

- string $property: The property's name.

getStyleProperty (line 341)

Returns the value of a CSS property.

- access: public

string getStyleProperty (string $property)

- string $property: The property's name.

getValue (line 161)

Retuns the value of the widget.

- see: P4A_Widget::$value
- access: public

string getValue ()

Redefined in descendants as:

- P4A_Field::getValue() : Returns the value for the field.
- P4A_Label::getValue() : Only returns the value of the label.
- P4A_Message::getValue()

getWidth (line 377)

Returns the width for the widget.

It's a wrapper for get_style_property().

- see: get_style_property()
- access: public

string getWidth ()
isEnabled (line 192)

Returns true if the widget is enabled.

- see: $enable
- access: public

void isEnabled ()
isVisible (line 221)

Returns true if the widget is visible.

- access: public

boolean isVisible ()
onChange (line 780)

Wrapper used to add the handling of OnChange action.

- see: action_handler()

void onChange ([mixed $params = NULL])
onClick (line 771)

Wrapper used to add the handling of OnClick action.

- see: action_handler()

void onClick ([mixed $params = NULL])

Redefined in descendants as:

- P4A_Menu_Item::onClick() : What is executed on a click on the element.
- P4A_Table_Col::onClick()
- P4A_Table_Rows::onClick() : onClick action handler for the row.

onKeyPress (line 793)

Wrapper used to add the handling of OnKeyPress action.

- see: action_handler()

void onKeyPress ([mixed $params = NULL])
onMouseOver (line 785)
void onMouseOver ([mixed $params = NULL])
onReturnPress (line 804)

Wrapper used to add the handling of onReturnPress action.

The onReturnPress action is an onKeyPress with checking if the pressed key is return.

- see: action_handler()

void onReturnPress ([mixed $params = NULL])
p4a_widget (line 138)

Class constructor.

Sets default properties and store the object in the application object stack.

- access: private

void p4a_widget ([string $name = null], [string $prefix = 'wdg'], [string $id = null])

- string $name: Widget identifier, when you add an object to another object (such as $p4a) you can access to it by $p4a->object_name.
- string $prefix: Prefix string for ID generation.
- string $id: Object ID identifies an object in the $p4a's object collection. You can set a static ID if you want that all clients uses the same ID (tipically for web sites).

raise (line 762)

Prints the value returned by get_as_string().

It Should never be used by "normal" p4a users.

- see: get_as_string()
- access: public

void raise ()
requireConfirmation (line 495)

Requires confirmation for an action.

- access: public

void requireConfirmation (string $action, [string $confirmation_text = null], [string $confirmation_text_handler = 'confirm_general'])

- string $action: The action.
- string $confirmation_text: Text for confirmation.
- string $confirmation_text_handler: i18n message id for confirmation.

setAccessKey (line 327)
void setAccessKey (mixed $key)

Redefined in descendants as:

- P4A_Menu_Item::setAccessKey() : Sets the access key for the element.

setBgcolor (line 420)

Sets the background color for the widget.

It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setBgcolor (string $value)

- string $value: The value to be used as color.

setBgimage (line 432)

Sets the background image for the widget.

It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setBgimage (string $value)

- string $value: The url of the image.

setDefaultLabel (line 255)

Create from name a default label for the widget In rendering phase it will be added with ': '.

- see: P4A_Widget::$label
- access: public

void setDefaultLabel (string 0)

- string 0: The string to set as label.

setFontColor (line 456)

Sets the font color for the widget It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setFontColor (string $value)

- string $value: The url of the image.

setFontWeight (line 444)

Sets the font weight for the widget It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setFontWeight (string $value)

- string $value: The url of the image.

setHeight (line 390)

Sets the height for the widget.

It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setHeight ([integer $value = null], [string $unit = 'px'])

- integer $value: The value to be used as height.
- string $unit: The measure unit (px|pt|%) etc...

setInvisible (line 211)

Sets the widget invisible.

- access: public

void setInvisible ()
setLabel (line 233)

Sets the label for the widget.

In rendering phase it will be added with ': '.

- see: P4A_Widget::$label
- access: public

void setLabel (string $label)

- string $label: The string to set as label.

Redefined in descendants as:

- P4A_Button::setLabel() : Sets the label for the button.
- P4A_Field::setLabel() : Sets the label for the field.
- P4A_Link::setLabel()

setProperty (line 276)

Sets an HTML property for the widget.

- access: public

void setProperty (string $property, string $value)

- string $property: The property's name.
- string $value: The property's value.

setStyleProperty (line 312)

Sets a CSS property for the widget.

- access: public

void setStyleProperty (string $property, string $value)

- string $property: The property's name.
- string $value: The property's value.

setValue (line 150)

Sets the value of the widget.

- see: P4A_Widget::$value
- access: public

void setValue (string $value)

- string $value: The value to be setted.

Redefined in descendants as:

- P4A_Button::setValue() : Sets the value for the button.
- P4A_Field::setValue() : Sets the value for the field.
- P4A_Image::setValue() : Sets image's source from absolute url.
- P4A_Label::setValue() : Only returns the value of the label.
- P4A_Message::setValue()

setVisible (line 202)

Sets the widget visible.

- access: public

void setVisible ([boolean $visible = TRUE])

- boolean $visible: Visibility flag

setWidth (line 358)

Sets the width for the widget.

It's a wrapper for set_style_property().

- see: set_style_property()
- access: public

void setWidth ([integer $value = null], [string $unit = 'px'])

- integer $value: The value to be used as width.
- string $unit: The measure unit (px|pt|%) etc...

unrequireConfirmation (line 508)

Removes confirmation for an action.

- access: public

void unrequireConfirmation (string $action)

- string $action: The action.

unsetProperty (line 286)

Unsets an HTML property for the widget.

- access: public

void unsetProperty (string $property)

- string $property: The property's name.

unsetStyleProperty (line 322)

Unset a CSS property for the widget.

- access: public

void unsetStyleProperty (string $property)

- string $property: The property's name.

useTemplate (line 661)

Defines the template used by the widget.

- see: P4A_Widget::$template_name
- access: public

void useTemplate (string $template_name)

- string $template_name: Template name

#### Inherited Methods

Inherited From P4A_Object

> P4A_Object::actionHandler()
> P4A_Object::build()
> P4A_Object::destroy()
> P4A_Object::errorHandler()
> P4A_Object::getId()
> P4A_Object::getName()
> P4A_Object::getObjectType()
> P4A_Object::getParentID()
> P4A_Object::implementMethod()
> P4A_Object::intercept()
> P4A_Object::isActionTriggered()
> P4A_Object::p4a_object()
> P4A_Object::setName()
> P4A_Object::setParentID()
> P4A_Object::void()

Documentation generated on Fri, 26 May 2006 12:43:44 +0200 by phpDocumentor 1.3.0RC5