Structures_Form
[ class tree: Structures_Form ] [ index: Structures_Form ] [ all elements ]

Class: Structures_Form_ElementInterface

Source Location: /Structures_Form-0.8.0devel/Form/ElementInterface.php

Class Overview


An interface to enforce consistency among all elements used in a Structures_Form.


Author(s):

  • Scott Mattocks

Version:

  • 0.8.0devel

Copyright:

  • Copyright 2006 Scott Mattocks

Methods


Inherited Variables

Inherited Methods


Class Details

[line 35]
An interface to enforce consistency among all elements used in a Structures_Form.

In HTML_QuickForm, all form elements extend a common base class. In PHP-GTK 2 this is not possible because the elements need to be added to containes. To be added to a container a class must extends GtkWidget. While it is not possible to force all form elements to inherit from the same base class we can use an interface to enforce some consistency.

This interface defines methods to get and set values as well as retrieve information about an element. Individual element classes must implement at least the methods here but are free to implement any other methods needed.

The element constructor (which cannot be defined here) must always expect the first argument to be the form that created the element. It does not necessarily have to use that value but it should expect it.

Some of the comments here are specific to PHP-GTK 2 applications.

A note contributors: I welcome contributions from others but I will not include any classes in the package that are not accompanied by a complete set of PHPUnit2 unit tests. Also, I am a stickler for documentation. Please make sure that your contributions are fully documented. Docblocks are not enough. There must be inline documentation. Please see Structures/Form.php for an example of what I mean by fully documented.

  • Author: Scott Mattocks
  • Version: 0.8.0devel
  • Copyright: Copyright 2006 Scott Mattocks
  • License: PHP


[ Top ]


Method Detail

addEventHandler   [line 178]

integer addEventHandler( string $eventName, mixed $callback)

Adds an event handler for the element.
  • Return: An identifier for the callback.
  • Access: public

Parameters:

string   $eventName   —  The name of the event.
mixed   $callback   —  The callback to call when the event occurs.

[ Top ]

clearValue   [line 77]

boolean clearValue( )

Clears the current value of the element.

This method should clear the current value if possible. For example, if the widget is a GtkEntry, this method should pass null to set_text(). If the value could not be cleared for some reason (the item is frozen or it is not possible to clear the value (selection type = browse)) this method should return false.

  • Return: true if the value was cleared.
  • Access: public

[ Top ]

freeze   [line 127]

void freeze( )

Freezes the element so that its value may not be changed.

Again this method exists only to maintain consistency in the interface. It should just pass false to set_sensitive().

To make life easier down the road this method should also call set_data('frozen', true);

  • Access: public

[ Top ]

getLabel   [line 168]

string getLabel( )

Returns the GtkLabel that identifies the element.
  • Access: public

[ Top ]

getName   [line 113]

string getName( )

Returns the element's name.

This method exists to maintain consistency in the interface. It should simply call get_name which is a GtkWidget method and should be available to all elements.

  • Access: public

[ Top ]

getType   [line 88]

string getType( )

Returns the element type.

This method must return a string identifying the element type, such as text, password, submit, etc.

  • Return: The element type.
  • Access: public

[ Top ]

getValue   [line 63]

mixed getValue( )

Returns element's value.

This method should return the widget's value not just some data from the widget (i.e. set with set_data()). For example if the widget is a GtkEntry, this method should call get_text(). If the widget is a GtkComboBox, this method should return the value of the column identified when the element was constructed for the given row.

  • Access: public

[ Top ]

isFrozen   [line 151]

boolean isFrozen( )

Returns whether or not the element is currently frozen.

This method should just return the value from get_data('frozen')

  • Access: public

[ Top ]

setLabel   [line 160]

void setLabel( string $label)

Sets the label that identifies the element.
  • Access: public

Parameters:

string   $label   — 

[ Top ]

setName   [line 101]

void setName( string $name)

Sets the element name.

This method exists to maintain consistency in the interface. It should simply call set_name which is a GtkWidget method and should be avialable to all elements.

  • Access: public

Parameters:

string   $name   — 

[ Top ]

setValue   [line 49]

boolean setValue( mixed $value)

Sets an element's value.

This method should set the value of the widget not just set some data that is retrieved later. If the widget is a GtkEntry, this method should call set_text(). If the widget is a GtkComboBox, this method should set the active row.

  • Return: true if the value was changed.
  • Access: public

Parameters:

mixed   $value   —  The value to set for the form element.

[ Top ]

unfreeze   [line 141]

void unfreeze( )

Unfreezes the element so that its value may not be changed.

Again this method exists only to maintain consistency in the interface. It should just pass true to set_sensitive().

To make life easier down the road this method should also call set_data('frozen', false);

  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:44:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.