A button that displays a Drawable. More...
Inherits Button.
Public Types | |
| enum | ButtonStyle { ImageFitted, ImageRaw, ImageAboveTextLabel, ImageOnButtonBackground } |
Public Member Functions | |
| DrawableButton (const String &buttonName, ButtonStyle buttonStyle) | |
| Creates a DrawableButton. | |
| ~DrawableButton () | |
| Destructor. | |
| void | setImages (const Drawable *normalImage, const Drawable *overImage=0, const Drawable *downImage=0, const Drawable *disabledImage=0, const Drawable *normalImageOn=0, const Drawable *overImageOn=0, const Drawable *downImageOn=0, const Drawable *disabledImageOn=0) |
| Sets up the images to draw for the various button states. | |
| void | setButtonStyle (ButtonStyle newStyle) |
| Changes the button's style. | |
| void | setBackgroundColours (const Colour &toggledOffColour, const Colour &toggledOnColour) |
| Changes the button's background colours. | |
| const Colour & | getBackgroundColour () const throw () |
| Returns the current background colour being used. | |
| void | setEdgeIndent (int numPixelsIndent) |
| Gives the button an optional amount of space around the edge of the drawable. | |
| const Drawable * | getCurrentImage () const throw () |
| Returns the image that the button is currently displaying. | |
| const Drawable * | getNormalImage () const throw () |
| const Drawable * | getOverImage () const throw () |
| const Drawable * | getDownImage () const throw () |
Protected Member Functions | |
| void | paintButton (Graphics &g, bool isMouseOverButton, bool isButtonDown) |
A button that displays a Drawable.
Up to three Drawable objects can be given to this button, to represent the 'normal', 'over' and 'down' states.
| DrawableButton::DrawableButton | ( | const String & | buttonName, | |
| ButtonStyle | buttonStyle | |||
| ) |
Creates a DrawableButton.
After creating one of these, use setImages() to specify the drawables to use.
| buttonName | the name to give the component | |
| buttonStyle | the layout to use |
| DrawableButton::~DrawableButton | ( | ) |
Destructor.
| void DrawableButton::setImages | ( | const Drawable * | normalImage, | |
| const Drawable * | overImage = 0, |
|||
| const Drawable * | downImage = 0, |
|||
| const Drawable * | disabledImage = 0, |
|||
| const Drawable * | normalImageOn = 0, |
|||
| const Drawable * | overImageOn = 0, |
|||
| const Drawable * | downImageOn = 0, |
|||
| const Drawable * | disabledImageOn = 0 | |||
| ) |
Sets up the images to draw for the various button states.
The button will keep its own internal copies of these drawables.
| normalImage | the thing to draw for the button's 'normal' state. An internal copy will be made of the object passed-in if it is non-zero. | |
| overImage | the thing to draw for the button's 'over' state - if this is zero, the button's normal image will be used when the mouse is over it. An internal copy will be made of the object passed-in if it is non-zero. | |
| downImage | the thing to draw for the button's 'down' state - if this is zero, the 'over' image will be used instead (or the normal image as a last resort). An internal copy will be made of the object passed-in if it is non-zero. | |
| disabledImage | an image to draw when the button is disabled. If this is zero, the normal image will be drawn with a reduced opacity instead. An internal copy will be made of the object passed-in if it is non-zero. | |
| normalImageOn | same as the normalImage, but this is used when the button's toggle state is 'on'. If this is 0, the normal image is used instead | |
| overImageOn | same as the overImage, but this is used when the button's toggle state is 'on'. If this is 0, the normalImageOn is drawn instead | |
| downImageOn | same as the downImage, but this is used when the button's toggle state is 'on'. If this is 0, the overImageOn is drawn instead | |
| disabledImageOn | same as the disabledImage, but this is used when the button's toggle state is 'on'. If this is 0, the normal image will be drawn instead with a reduced opacity |
| void DrawableButton::setButtonStyle | ( | ButtonStyle | newStyle | ) |
Changes the button's style.
| void DrawableButton::setBackgroundColours | ( | const Colour & | toggledOffColour, | |
| const Colour & | toggledOnColour | |||
| ) |
Changes the button's background colours.
The toggledOffColour is the colour to use when the button's toggle state is off, and toggledOnColour when it's on.
For an ImageOnly or ImageAboveTextLabel style, the background colour is used to fill the background of the component.
For an ImageOnButtonBackground style, the colour is used to draw the button's lozenge shape and exactly how the colour's used will depend on the LookAndFeel.
| const Colour& DrawableButton::getBackgroundColour | ( | ) | const throw () |
Returns the current background colour being used.
| void DrawableButton::setEdgeIndent | ( | int | numPixelsIndent | ) |
Gives the button an optional amount of space around the edge of the drawable.
This will only apply to ImageFitted or ImageRaw styles, it won't affect the ones on a button background. If the button is too small for the given gap, a smaller gap will be used.
By default there's a gap of about 3 pixels.
| const Drawable* DrawableButton::getCurrentImage | ( | ) | const throw () |
Returns the image that the button is currently displaying.
| const Drawable* DrawableButton::getNormalImage | ( | ) | const throw () |
| const Drawable* DrawableButton::getOverImage | ( | ) | const throw () |
| const Drawable* DrawableButton::getDownImage | ( | ) | const throw () |
| void DrawableButton::paintButton | ( | Graphics & | g, | |
| bool | isMouseOverButton, | |||
| bool | isButtonDown | |||
| ) | [protected, virtual] |
For internal use only.
Implements Button.
1.6.3