ImageButton Class Reference

As the title suggests, this is a button containing an image. More...

Inherits Button.

List of all members.

Public Member Functions

 ImageButton (const String &name)
 Creates an ImageButton.
 ~ImageButton ()
 Destructor.
void setImages (bool resizeButtonNowToFitThisImage, bool rescaleImagesWhenButtonSizeChanges, bool preserveImageProportions, Image *normalImage, float imageOpacityWhenNormal, const Colour &overlayColourWhenNormal, Image *overImage, float imageOpacityWhenOver, const Colour &overlayColourWhenOver, Image *downImage, float imageOpacityWhenDown, const Colour &overlayColourWhenDown, float hitTestAlphaThreshold=0.0f)
 Sets up the images to draw in various states.
ImagegetNormalImage () const throw ()
 Returns the currently set 'normal' image.
ImagegetOverImage () const throw ()
 Returns the image that's drawn when the mouse is over the button.
ImagegetDownImage () const throw ()
 Returns the image that's drawn when the button is held down.

Protected Member Functions

bool hitTest (int x, int y)
void paintButton (Graphics &g, bool isMouseOverButton, bool isButtonDown)

Detailed Description

As the title suggests, this is a button containing an image.

The colour and transparency of the image can be set to vary when the button state changes.

See also:
Button, ShapeButton, TextButton

Constructor & Destructor Documentation

ImageButton::ImageButton ( const String name  )  [explicit]

Creates an ImageButton.

Use setImage() to specify the image to use. The colours and opacities that are specified here can be changed later using setDrawingOptions().

Parameters:
name the name to give the component
ImageButton::~ImageButton (  ) 

Destructor.


Member Function Documentation

void ImageButton::setImages ( bool  resizeButtonNowToFitThisImage,
bool  rescaleImagesWhenButtonSizeChanges,
bool  preserveImageProportions,
Image normalImage,
float  imageOpacityWhenNormal,
const Colour overlayColourWhenNormal,
Image overImage,
float  imageOpacityWhenOver,
const Colour overlayColourWhenOver,
Image downImage,
float  imageOpacityWhenDown,
const Colour overlayColourWhenDown,
float  hitTestAlphaThreshold = 0.0f 
)

Sets up the images to draw in various states.

Important! Bear in mind that if you pass the same image in for more than one of these parameters, this button will delete it (or release from the ImageCache) multiple times!

Parameters:
resizeButtonNowToFitThisImage if true, the button will be immediately resized to the same dimensions as the normal image
rescaleImagesWhenButtonSizeChanges if true, the image will be rescaled to fit the button when the button's size changes
preserveImageProportions if true then any rescaling of the image to fit the button will keep the image's x and y proportions correct - i.e. it won't distort its shape, although this might create gaps around the edges
normalImage the image to use when the button is in its normal state. The image passed in will be deleted (or released if it was created by the ImageCache class) when the button no longer needs it.
imageOpacityWhenNormal the opacity to use when drawing the normal image.
overlayColourWhenNormal an overlay colour to use to fill the alpha channel of the normal image - if this colour is transparent, no overlay will be drawn. The overlay will be drawn over the top of the image, so you can basically add a solid or semi-transparent colour to the image to brighten or darken it
overImage the image to use when the mouse is over the button. If you want to use the same image as was set in the normalImage parameter, this value can be 0. As for normalImage, it will be deleted or released by the button when no longer needed
imageOpacityWhenOver the opacity to use when drawing the image when the mouse is over the button
overlayColourWhenOver an overlay colour to use to fill the alpha channel of the image when the mouse is over - if this colour is transparent, no overlay will be drawn
downImage an image to use when the button is pressed down. If set to zero, the 'over' image will be drawn instead (or the normal image if there isn't an 'over' image either). This image will be deleted or released by the button when no longer needed
imageOpacityWhenDown the opacity to use when drawing the image when the button is pressed
overlayColourWhenDown an overlay colour to use to fill the alpha channel of the image when the button is pressed down - if this colour is transparent, no overlay will be drawn
hitTestAlphaThreshold if set to zero, the mouse is considered to be over the button whenever it's inside the button's bounding rectangle. If set to values higher than 0, the mouse will only be considered to be over the image when the value of the image's alpha channel at that position is greater than this level.
Image* ImageButton::getNormalImage (  )  const throw ()

Returns the currently set 'normal' image.

Image* ImageButton::getOverImage (  )  const throw ()

Returns the image that's drawn when the mouse is over the button.

If an 'over' image has been set, this will return it; otherwise it'll just return the normal image.

Image* ImageButton::getDownImage (  )  const throw ()

Returns the image that's drawn when the button is held down.

If a 'down' image has been set, this will return it; otherwise it'll return the 'over' image or normal image, depending on what's available.

bool ImageButton::hitTest ( int  x,
int  y 
) [protected, virtual]

For internal use only.

Reimplemented from Component.

void ImageButton::paintButton ( Graphics g,
bool  isMouseOverButton,
bool  isButtonDown 
) [protected, virtual]

For internal use only.

Implements Button.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:12 2010 for JUCE by  doxygen 1.6.3