Public Member Functions

ToolbarButton Class Reference

A type of button designed to go on a toolbar. More...

Inherits ToolbarItemComponent.

List of all members.

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.

Detailed Description

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.

See also:
Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button

Constructor & Destructor Documentation

ToolbarButton::ToolbarButton ( int  itemId,
const String labelText,
Drawable normalImage,
Drawable toggledOnImage 
)

Creates a ToolbarButton.

Parameters:
itemIdthe ID for this toolbar item type. This is passed through to the ToolbarItemComponent constructor
labelTextthe 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
normalImagea 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.
toggledOnImagea 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.


Member Function Documentation

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]

Called when the button's up/down/over state changes.

Subclasses can override this if they need to do something special when the button goes up or down.

See also:
isDown, isOver

Reimplemented from Button.

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.

See also:
moved, setSize

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.

See also:
setEnabled, isEnabled

Reimplemented from Button.


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