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

Source for file ElementInterface.php

Documentation is available at ElementInterface.php

  1. <?php
  2. /**
  3.  * An interface to enforce consistency among all elements used in a
  4.  * Structures_Form.
  5.  *
  6.  * In HTML_QuickForm, all form elements extend a common base class. In PHP-GTK
  7.  * 2 this is not possible because the elements need to be added to containes.
  8.  * To be added to a container a class must extends GtkWidget. While it is not
  9.  * possible to force all form elements to inherit from the same base class we
  10.  * can use an interface to enforce some consistency.
  11.  *
  12.  * This interface defines methods to get and set values as well as retrieve
  13.  * information about an element. Individual element classes must implement at
  14.  * least the methods here but are free to implement any other methods needed.
  15.  *
  16.  * The element constructor (which cannot be defined here) must always expect
  17.  * the first argument to be the form that created the element. It does not
  18.  * necessarily have to use that value but it should expect it.
  19.  *
  20.  * Some of the comments here are specific to PHP-GTK 2 applications.
  21.  *
  22.  * A note contributors: I welcome contributions from others but I will not
  23.  * include any classes in the package that are not accompanied by a complete
  24.  * set of PHPUnit2 unit tests. Also, I am a stickler for documentation. Please
  25.  * make sure that your contributions are fully documented. Docblocks are not
  26.  * enough. There must be inline documentation. Please see Structures/Form.php
  27.  * for an example of what I mean by fully documented.
  28.  *
  29.  * @author    Scott Mattocks
  30.  * @package   Structures_Form
  31.  * @license   PHP License
  32.  * @version   0.8.0devel
  33.  * @copyright Copyright 2006 Scott Mattocks
  34.  */
  35.  
  36.     /**
  37.      * Sets an element's value.
  38.      *
  39.      * This method should set the value of the widget not just set some data
  40.      * that is retrieved later. If the widget is a GtkEntry, this method should
  41.      * call set_text(). If the widget is a GtkComboBox, this method should set
  42.      * the active row.
  43.      *
  44.      * @access public
  45.      * @param  mixed   $value The value to set for the form element.
  46.      * @return boolean true if the value was changed.
  47.      */
  48.     public function setValue($value);
  49.  
  50.     /**
  51.      * Returns element's value.
  52.      *
  53.      * This method should return the widget's value not just some data from the
  54.      * widget (i.e. set with set_data()). For example if the widget is a
  55.      * GtkEntry, this method should call get_text(). If the widget is a
  56.      * GtkComboBox, this method should return the value of the column
  57.      * identified when the element was constructed for the given row.
  58.      *
  59.      * @access public
  60.      * @return mixed 
  61.      */
  62.     public function getValue();
  63.  
  64.     /**
  65.      * Clears the current value of the element.
  66.      *
  67.      * This method should clear the current value if possible. For example, if
  68.      * the widget is a GtkEntry, this method should pass null to set_text(). If
  69.      * the value could not be cleared for some reason (the item is frozen or it
  70.      * is not possible to clear the value (selection type = browse)) this
  71.      * method should return false.
  72.      *
  73.      * @access public
  74.      * @return boolean true if the value was cleared.
  75.      */
  76.     public function clearValue();
  77.  
  78.     /**
  79.      * Returns the element type.
  80.      * 
  81.      * This method must return a string identifying the element type, such as
  82.      * text, password, submit, etc.
  83.      *
  84.      * @access public
  85.      * @return string The element type.
  86.      */
  87.     public function getType();
  88.  
  89.     /**
  90.      * Sets the element name.
  91.      *
  92.      * This method exists to maintain consistency in the interface. It should
  93.      * simply call set_name which is a GtkWidget method and should be avialable
  94.      * to all elements.
  95.      *
  96.      * @access public
  97.      * @param  string $name 
  98.      * @return void 
  99.      */
  100.     public function setName($name);
  101.  
  102.     /**
  103.      * Returns the element's name.
  104.      *
  105.      * This method exists to maintain consistency in the interface. It should
  106.      * simply call get_name which is a GtkWidget method and should be available
  107.      * to all elements.
  108.      *
  109.      * @access public
  110.      * @return string 
  111.      */
  112.     public function getName();
  113.  
  114.     /**
  115.      * Freezes the element so that its value may not be changed.
  116.      *
  117.      * Again this method exists only to maintain consistency in the interface.
  118.      * It should just pass false to set_sensitive().
  119.      *
  120.      * To make life easier down the road this method should also call
  121.      * set_data('frozen', true);
  122.      *
  123.      * @access public
  124.      * @return void 
  125.      */
  126.     public function freeze();
  127.  
  128.     /**
  129.      * Unfreezes the element so that its value may not be changed.
  130.      *
  131.      * Again this method exists only to maintain consistency in the interface.
  132.      * It should just pass true to set_sensitive().
  133.      *
  134.      * To make life easier down the road this method should also call
  135.      * set_data('frozen', false);
  136.      *
  137.      * @access public
  138.      * @return void 
  139.      */
  140.     public function unfreeze();
  141.  
  142.     /**
  143.      * Returns whether or not the element is currently frozen.
  144.      * 
  145.      * This method should just return the value from get_data('frozen')
  146.      *
  147.      * @access public
  148.      * @return boolean 
  149.      */
  150.     public function isFrozen();
  151.  
  152.     /**
  153.      * Sets the label that identifies the element.
  154.      *
  155.      * @access public
  156.      * @param  string $label 
  157.      * @return void 
  158.      */
  159.     public function setLabel($label);
  160.  
  161.     /**
  162.      * Returns the GtkLabel that identifies the element.
  163.      *
  164.      * @access public
  165.      * @return string 
  166.      */
  167.     public function getLabel();
  168.  
  169.     /**
  170.      * Adds an event handler for the element.
  171.      *
  172.      * @access public
  173.      * @param  string  $eventName The name of the event.
  174.      * @param  mixed   $callback  The callback to call when the event occurs.
  175.      * @return integer An identifier for the callback.
  176.      */
  177.     public function addEventHandler($eventName$callback);
  178. }
  179. ?>

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