Public Types | Public Member Functions | Protected Member Functions

ToggleButton Class Reference

A button that can be toggled on/off. More...

Inherits Button.

List of all members.

Public Types

enum  ColourIds { textColourId = 0x1006501 }
 

A set of colour IDs to use to change the colour of various aspects of the button.

More...

Public Member Functions

 ToggleButton (const String &buttonText=String::empty)
 Creates a ToggleButton.
 ~ToggleButton ()
 Destructor.
void changeWidthToFitText ()
 Resizes the button to fit neatly around its current text.

Protected Member Functions

void paintButton (Graphics &g, bool isMouseOverButton, bool isButtonDown)
 Subclasses should override this to actually paint the button's contents.
void colourChanged ()
 This method is called when a colour is changed by the setColour() method.

Detailed Description

A button that can be toggled on/off.

All buttons can be toggle buttons, but this lets you create one of the standard ones which has a tick-box and a text label next to it.

See also:
Button, DrawableButton, TextButton

Member Enumeration Documentation

A set of colour IDs to use to change the colour of various aspects of the button.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also:
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator:
textColourId 

The colour to use for the button's text.


Constructor & Destructor Documentation

ToggleButton::ToggleButton ( const String buttonText = String::empty ) [explicit]

Creates a ToggleButton.

Parameters:
buttonTextthe text to put in the button (the component's name is also initially set to this string, but these can be changed later using the setName() and setButtonText() methods)
ToggleButton::~ToggleButton (  )

Destructor.


Member Function Documentation

void ToggleButton::changeWidthToFitText (  )

Resizes the button to fit neatly around its current text.

The button's height won't be affected, only its width.

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

Subclasses should override this to actually paint the button's contents.

It's better to use this than the paint method, because it gives you information about the over/down state of the button.

Parameters:
gthe graphics context to use
isMouseOverButtontrue if the button is either in the 'over' or 'down' state
isButtonDowntrue if the button should be drawn in the 'down' position

Implements Button.

void ToggleButton::colourChanged (  ) [protected, virtual]

This method is called when a colour is changed by the setColour() method.

See also:
setColour, findColour

Reimplemented from Component.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines