1  /*
     2   Copyright aswing.org, see the LICENCE.txt.
     3  */
     4   
     5  import org.aswing.*;
     6  
     7  /**
     8   * State Model for buttons.
     9   * This model is used for check boxes and radio buttons, which are
    10   * special kinds of buttons, as well as for normal buttons.
    11   * For check boxes and radio buttons, pressing the mouse selects
    12   * the button. 
    13   * <p>
    14   * In use, a UI will invoke {@link #setSelected} when a mouse
    15   * click occurs over a check box or radio button. 
    16   * 
    17   * @author iiley
    18   */
    19  interface org.aswing.ButtonModel extends IEventDispatcher{
    20  	
    21  	/**
    22  	 * Add a listener to listen the Model's change event.
    23  	 * <p>
    24  	 * When the button's state changed, the state is all about:
    25  	 * <ul>
    26  	 * <li>enabled
    27  	 * <li>rollOver
    28  	 * <li>pressed
    29  	 * <li>released
    30  	 * <li>selected
    31  	 * </ul>
    32  	 *<br>
    33  	 * onStateChanged Event{source:ButtonModel}
    34  	 * @see org.aswing.Component#ON_STATE_CHANGED
    35  	 * @return the listener added.
    36  	 * @see EventDispatcher#addEventListener()
    37  	 */
    38  	public function addChangeListener(func:Function, obj:Object):Object;
    39  	
    40  	/**
    41  	 * Add a listener to listen the Model's selection change event.
    42  	 * When the button's selection changed, fired when diselected or selected.
    43  	 *<br>
    44  	 * onSelectionChanged Event{source:ButtonModel}
    45  	 * @see org.aswing.Component#ON_SELECTION_CHANGED
    46  	 * @return the listener added.
    47  	 * @see EventDispatcher#addEventListener()
    48  	 */	
    49  	public function addSelectionListener(func:Function, obj:Object):Object;
    50  	
    51  	/**
    52  	 * Indicates if the button can be selected or pressed by an input device (such as a mouse pointer).
    53  	 */
    54  	public function isEnabled():Boolean;
    55  	
    56  	/**
    57  	 * Indicates that the mouse is over the button.
    58  	 */
    59  	public function isRollOver():Boolean;
    60  	
    61  	/**
    62  	 * Indicates that the button has been pressed the and not be released yet.
    63  	 * <p><b>This is not same as Java Swing's, this is some like Java Swing's Armed</b>
    64  	 */
    65  	public function isPressed():Boolean;
    66  		
    67  	/**
    68  	 * Indicates if button has been released. This is some like java Swing's pressed when released inside.
    69  	 */
    70  	public function isReleased():Boolean;
    71  		
    72  	/**
    73  	 * Indicates if the button has been selected.
    74  	 */
    75  	public function isSelected():Boolean;
    76  	
    77  	
    78  	/**
    79  	 * Enables or disables the button.
    80  	 */
    81  	public function setEnabled(b:Boolean):Void;
    82  	
    83  	/**
    84  	 * Sets or clears the button's rollover state.
    85  	 */
    86  	public function setRollOver(b:Boolean):Void;
    87  	
    88  	/**
    89  	 * Sets the button to being pressed or unpressed.
    90  	 */
    91  	public function setPressed(b:Boolean):Void;
    92  	
    93  	/**
    94  	 * Sets the button to released or unreleased.
    95  	 */
    96  	public function setReleased(b:Boolean):Void;
    97  	
    98  	/**
    99  	 * Selects or deselects the button.
   100  	 */
   101  	public function setSelected(b:Boolean):Void;
   102  	
   103      /**
   104       * Identifies the group this button belongs to --
   105       * needed for radio buttons, which are mutually
   106       * exclusive within their group.
   107       *
   108       * @param group the ButtonGroup this button belongs to
   109       */
   110  	public function setGroup(group:ButtonGroup):Void;
   111  	
   112  }
   113