quicktime.app.ui
Class QTButton

java.lang.Object
  |
  +--quicktime.app.anim.TwoDSprite
        |
        +--quicktime.app.ui.UIElement
              |
              +--quicktime.app.ui.QTButton
All Implemented Interfaces:
Compositable, DynamicImage, ImageSettable, ImageSpec, Layerable, NotifyListener, Transformable
Direct Known Subclasses:
PressActionButton, ReleaseButton

public abstract class QTButton
extends UIElement

This abstarct class provides the basic functionality for a QTButton which takes care of the event handling of the button. It also updates the button images and sets the current image of the button as the mouse enters and leaves the button. Other classes can extend this class to provide their own button behaviour. The QTButton will fire action events as defined by these subclasses. The label of the TwoDSprite will be passed on to the action listeners.


Field Summary
protected  QTActionListener actionListener
          The QTActionListeners that will be fired when the QTButton is activated.
protected  ImageSpec pressedImage
          The image presented by the QTButton when it is in a pressed state.
protected  ImageSpec releasedImage
          The image presented by the QTButton when it is in a released state.
protected  ImageSpec rolloverImage
          If specified then the image presented by the QTButton when it is in a released state and the mouse is over the button.
 
Fields inherited from class quicktime.app.ui.UIElement
currentImage, deactiveImage
 
Fields inherited from class quicktime.app.anim.TwoDSprite
label
 
Fields inherited from interface quicktime.app.display.Layerable
kBackMostLayer
 
Constructor Summary
protected QTButton(ImageSpec releasedImage, ImageSpec pressedImage, ImageSpec deactiveImage, ImageSpec rolloverImage)
          Sets the images of the UIElement as specified.
protected QTButton(ImageSpec releasedImage, ImageSpec pressedImage, ImageSpec deactiveImage, ImageSpec rolloverImage, Matrix matrix, int layer, GraphicsMode mode)
          Sets the images and display characteristics of the UIElement as specified.
 
Method Summary
 void addActionListener(QTActionListener l)
          Add an QTActionListeners to this button.
 void addMouseTargetListener(MouseTargetListener l)
          Add a MouseTargetListener for this QTButton.
protected  void entered(QTMouseEvent e)
          This method is called by the ButtonActivator when the mouse enters the button
protected  void exited(QTMouseEvent e)
          This method is called by the ButtonActivator when the mouse exits the button
protected  void fireAction()
          This method is invoked by the event handling code so that any QTActionListeners actionPerformed methods are invoked.
 ImageSpec getDeactiveImage()
           
 ImageSpec getPressedImage()
           
 ImageSpec getReleasedImage()
           
 ImageSpec getRolloverImage()
           
 boolean isMouseInButton()
           
 boolean isPressed()
           
 void pressed()
          Subclass provides the implementation for this method, though the subclass should ensure that super.pressed() is called.
 void released()
          Subclass provides the implementation for this method, though the subclass should ensure that super.released() is called.
 void removeActionListener(QTActionListener l)
          Remove an ActionListener from this button.
 void removeMouseTargetListener(MouseTargetListener l)
          Remove a MouseTargetListener for this QTButton.
 void setDeactiveImage(ImageSpec image)
          Sets a new image for the deactive state of the button.
 void setPressedImage(ImageSpec image)
          Sets a new image for the pressed state of the button.
 void setReleasedImage(ImageSpec image)
          Sets a new image for the released state of the button.
 void setRolloverImage(ImageSpec image)
          Sets a new image for the rollover state of the button.
 
Methods inherited from class quicktime.app.ui.UIElement
addedToCompositor, getBounds, isActive, removedFromCompositor, setActive, setCurrentImage, setLocation, setSize
 
Methods inherited from class quicktime.app.anim.TwoDSprite
createSprite, equals, getDescription, getGraphicsMode, getImage, getInitialSize, getLabel, getLayer, getMatrix, getOriginalSize, getParent, getSpriteInfo, getVisible, hitTest, invalidate, isValid, notifyComplete, remove, removeNotify, setDescription, setGraphicsMode, setImage, setImageData, setLabel, setLayer, setMatrix, setNotifier, setVisible, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface quicktime.app.image.Compositable
getGraphicsMode, setGraphicsMode
 
Methods inherited from interface quicktime.app.image.ImageSpec
getDescription, getImage
 

Field Detail

releasedImage

protected ImageSpec releasedImage
The image presented by the QTButton when it is in a released state. If a rollover image is specified, then this is presented when the mouse is outside the button, and the rolloverImage is presented when the mouse is inside the button.

rolloverImage

protected ImageSpec rolloverImage
If specified then the image presented by the QTButton when it is in a released state and the mouse is over the button.

pressedImage

protected ImageSpec pressedImage
The image presented by the QTButton when it is in a pressed state.

actionListener

protected QTActionListener actionListener
The QTActionListeners that will be fired when the QTButton is activated.
Constructor Detail

QTButton

protected QTButton(ImageSpec releasedImage,
                   ImageSpec pressedImage,
                   ImageSpec deactiveImage,
                   ImageSpec rolloverImage)
            throws QTException
Sets the images of the UIElement as specified. The default location is 0,0, the default layer is 1 and there is no graphics mode assigned to the QTButton.
Parameters:
releasedImage - will be the currentImage of the UIElement
pressedImage - will be the image shown when the QTButton is pressed
deactiveImage - will be the deactiveImage of the UIElement
rolloverImage - will be the releasedImage of the UIElement when the mouse is over the button

QTButton

protected QTButton(ImageSpec releasedImage,
                   ImageSpec pressedImage,
                   ImageSpec deactiveImage,
                   ImageSpec rolloverImage,
                   Matrix matrix,
                   int layer,
                   GraphicsMode mode)
            throws QTException
Sets the images and display characteristics of the UIElement as specified.
Parameters:
releasedImage - will be the currentImage of the UIElement
pressedImage - will be the image shown when the QTButton is pressed
deactiveImage - will be the deactiveImage of the UIElement
rolloverImage - will be the releasedImage of the UIElement when the mouse is over the button
matrix - the display matrix properties of the UIElement
layer - the layer in which the UIElement will be presented
mode - the GraphicsMode of the UIElement.
Method Detail

released

public void released()
              throws QTException
Subclass provides the implementation for this method, though the subclass should ensure that super.released() is called. This method is called when the mouse button is released on the button, or the mouse leaves a pressed button.

setReleasedImage

public void setReleasedImage(ImageSpec image)
                      throws QTException
Sets a new image for the released state of the button.
Parameters:
image - the new released image

getReleasedImage

public ImageSpec getReleasedImage()
Returns:
the current image that is being used for the released state of the button

setRolloverImage

public void setRolloverImage(ImageSpec image)
                      throws QTException
Sets a new image for the rollover state of the button.
Parameters:
image - the new rollover image

getRolloverImage

public ImageSpec getRolloverImage()
Returns:
the current image that is being used for the rollover state of the button

setPressedImage

public void setPressedImage(ImageSpec image)
                     throws QTException
Sets a new image for the pressed state of the button.
Parameters:
image - the new pressed image

getPressedImage

public ImageSpec getPressedImage()
Returns:
the current image that is being used for the pressed state of the button

setDeactiveImage

public void setDeactiveImage(ImageSpec image)
                      throws QTException
Sets a new image for the deactive state of the button.
Parameters:
image - the new deactive image

getDeactiveImage

public ImageSpec getDeactiveImage()
Returns:
the current image that is being used for the deactive state of the button

pressed

public void pressed()
             throws QTException
Subclass provides the implementation for this method, though the subclass should ensure that super.pressed() is called. This method is called when the mouse button is pressed on the button and the mouse is in the buttton when pressed.

isPressed

public boolean isPressed()

isMouseInButton

public boolean isMouseInButton()

addActionListener

public void addActionListener(QTActionListener l)
Add an QTActionListeners to this button.
Parameters:
l - a new ActionListener

removeActionListener

public void removeActionListener(QTActionListener l)
Remove an ActionListener from this button.
Parameters:
l - a new QTActionListeners

addMouseTargetListener

public void addMouseTargetListener(MouseTargetListener l)
Add a MouseTargetListener for this QTButton. This listener will fire when the mouse enters or exits the button.
Parameters:
l - a new MouseTargetListener

removeMouseTargetListener

public void removeMouseTargetListener(MouseTargetListener l)
Remove a MouseTargetListener for this QTButton.
Parameters:
l - a MouseTargetListener to remove

entered

protected void entered(QTMouseEvent e)
                throws QTException
This method is called by the ButtonActivator when the mouse enters the button

exited

protected void exited(QTMouseEvent e)
               throws QTException
This method is called by the ButtonActivator when the mouse exits the button

fireAction

protected void fireAction()
This method is invoked by the event handling code so that any QTActionListeners actionPerformed methods are invoked.