/*
 * @topic T11347 Spring 2016 Inheritance Demo
 * @brief class Button extends Gadget
*/
package inheritance_demo;

public class Button extends Gadget
{
    //--------------------------------------
    // data attributes
    //--------------------------------------
    private String caption;

    private IClick eventHandler;

    //--------------------------------------
    // constructors
    //--------------------------------------
    public Button(int width, int height)
    {
        super( 0, 0, width, height );
    }//Button

    public Button(int topx, int topy, int width, int height)
    {
        super( topx, topy, width, height );
    }//Button
    
    //--------------------------------------
    // operations
    //--------------------------------------
    @Override
    public void show() {
        if ( visible ) {
            System.out.print( "Button: "+caption+" "  );
        }
        System.out.println();
    }//show
    
    @Override
    public void hide() {
        visible = false;
        show();
    }//hide

    @Override
    public void disable() {
        enabled = false;
    }//disable
    
    @Override
    public void enable() {
        enabled = true;
    }//enable

    // getters/setters
    public IClick getEventHandler() {
        return eventHandler;
    }

    public void setEventHandler(IClick eventHandler) {
        this.eventHandler = eventHandler;
    }

    public Button setCaption(String caption) {
        this.caption = caption;
        return this;
    }
    
    public String getCaption() {
        return caption;
    }

}//class Button