A type of button designed to go on a toolbar. More...
Inherits ToolbarItemComponent.
Public Member Functions | |
| ToolbarButton (int itemId, const String &labelText, Drawable *normalImage, Drawable *toggledOnImage) | |
| Creates a ToolbarButton. | |
| ~ToolbarButton () | |
| Destructor. | |
| bool | getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int &preferredSize, int &minSize, int &maxSize) |
| This method must return the size criteria for this item, based on a given toolbar size and orientation. | |
| void | paintButtonArea (Graphics &g, int width, int height, bool isMouseOver, bool isMouseDown) |
| Your subclass should use this method to draw its content area. | |
| void | contentAreaChanged (const Rectangle< int > &newBounds) |
| Callback to indicate that the content area of this item has changed. | |
| void | buttonStateChanged () |
| Called when the button's up/down/over state changes. | |
| void | resized () |
| Called when this component's size has been changed. | |
| void | enablementChanged () |
| Callback to indicate that this component has been enabled or disabled. | |
A type of button designed to go on a toolbar.
This simple button can have two Drawable objects specified - one for normal use and another one (optionally) for the button's "on" state if it's a toggle button.
| ToolbarButton::ToolbarButton | ( | int | itemId, |
| const String & | labelText, | ||
| Drawable * | normalImage, | ||
| Drawable * | toggledOnImage | ||
| ) |
Creates a ToolbarButton.
| itemId | the ID for this toolbar item type. This is passed through to the ToolbarItemComponent constructor |
| labelText | the text to display on the button (if the toolbar is using a style that shows text labels). This is passed through to the ToolbarItemComponent constructor |
| normalImage | a drawable object that the button should use as its icon. The object that is passed-in here will be kept by this object and will be deleted when no longer needed or when this button is deleted. |
| toggledOnImage | a drawable object that the button can use as its icon if the button is in a toggled-on state (see the Button::getToggleState() method). If 0 is passed-in here, then the normal image will be used instead, regardless of the toggle state. The object that is passed-in here will be kept by this object and will be deleted when no longer needed or when this button is deleted. |
| ToolbarButton::~ToolbarButton | ( | ) |
Destructor.
| bool ToolbarButton::getToolbarItemSizes | ( | int | toolbarThickness, |
| bool | isToolbarVertical, | ||
| int & | preferredSize, | ||
| int & | minSize, | ||
| int & | maxSize | ||
| ) | [virtual] |
This method must return the size criteria for this item, based on a given toolbar size and orientation.
The preferredSize, minSize and maxSize values must all be set by your implementation method. If the toolbar is horizontal, these will be the width of the item; for a vertical toolbar, they refer to the item's height.
The preferredSize is the size that the component would like to be, and this must be between the min and max sizes. For a fixed-size item, simply set all three variables to the same value.
The toolbarThickness parameter tells you the depth of the toolbar - the same as calling Toolbar::getThickness().
The isToolbarVertical parameter tells you whether the bar is oriented horizontally or vertically.
Implements ToolbarItemComponent.
| void ToolbarButton::paintButtonArea | ( | Graphics & | g, |
| int | width, | ||
| int | height, | ||
| bool | isMouseOver, | ||
| bool | isMouseDown | ||
| ) | [virtual] |
Your subclass should use this method to draw its content area.
The graphics object that is passed-in will have been clipped and had its origin moved to fit the content area as specified get getContentArea(). The width and height parameters are the width and height of the content area.
If the component you're writing isn't a button, you can just do nothing in this method.
Implements ToolbarItemComponent.
| void ToolbarButton::contentAreaChanged | ( | const Rectangle< int > & | newBounds ) | [virtual] |
Callback to indicate that the content area of this item has changed.
This might be because the component was resized, or because the style changed and the space needed for the text label is different.
See getContentArea() for a description of what the area is.
Implements ToolbarItemComponent.
| void ToolbarButton::buttonStateChanged | ( | ) | [virtual] |
| void ToolbarButton::resized | ( | ) | [virtual] |
Called when this component's size has been changed.
A component can implement this method to do things such as laying out its child components when its width or height changes.
The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together).
If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control.
Reimplemented from ToolbarItemComponent.
| void ToolbarButton::enablementChanged | ( | ) | [virtual] |
Callback to indicate that this component has been enabled or disabled.
This can be triggered by one of the component's parent components being enabled or disabled, as well as changes to the component itself.
The default implementation of this method does nothing; your class may wish to repaint itself or something when this happens.
Reimplemented from Button.