JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Types | Public Member Functions | Static Public Member Functions
Toolbar Class Reference

A toolbar component. More...

Inherits Component, DragAndDropContainer, and DragAndDropTarget.

List of all members.

Public Types

enum  ToolbarItemStyle { iconsOnly, iconsWithText, textOnly }
 Options for the way items should be displayed. More...
enum  CustomisationFlags {
  allowIconsOnlyChoice = 1, allowIconsWithTextChoice = 2, allowTextOnlyChoice = 4, showResetToDefaultsButton = 8,
  allCustomisationOptionsEnabled = (allowIconsOnlyChoice | allowIconsWithTextChoice | allowTextOnlyChoice | showResetToDefaultsButton)
}
 Flags used by the showCustomisationDialog() method. More...
enum  ColourIds {
  backgroundColourId = 0x1003200, separatorColourId = 0x1003210, buttonMouseOverBackgroundColourId = 0x1003220, buttonMouseDownBackgroundColourId = 0x1003230,
  labelTextColourId = 0x1003240, editingModeOutlineColourId = 0x1003250
}
 A set of colour IDs to use to change the colour of various aspects of the toolbar. More...

Public Member Functions

 Toolbar ()
 Creates an empty toolbar component.
 ~Toolbar ()
 Destructor.
void setVertical (bool shouldBeVertical)
 Changes the bar's orientation.
bool isVertical () const noexcept
 Returns true if the bar is set to be vertical, or false if it's horizontal.
int getThickness () const noexcept
 Returns the depth of the bar.
int getLength () const noexcept
 Returns the length of the bar.
void clear ()
 Deletes all items from the bar.
void addItem (ToolbarItemFactory &factory, int itemId, int insertIndex=-1)
 Adds an item to the toolbar.
void removeToolbarItem (int itemIndex)
 Deletes one of the items from the bar.
int getNumItems () const noexcept
 Returns the number of items currently on the toolbar.
int getItemId (int itemIndex) const noexcept
 Returns the ID of the item with the given index.
ToolbarItemComponentgetItemComponent (int itemIndex) const noexcept
 Returns the component being used for the item with the given index.
void addDefaultItems (ToolbarItemFactory &factoryToUse)
 Clears this toolbar and adds to it the default set of items that the specified factory creates.
ToolbarItemStyle getStyle () const noexcept
 Returns the toolbar's current style.
void setStyle (const ToolbarItemStyle &newStyle)
 Changes the toolbar's current style.
void showCustomisationDialog (ToolbarItemFactory &factory, int optionFlags=allCustomisationOptionsEnabled)
 Pops up a modal dialog box that allows this toolbar to be customised by the user.
void setEditingActive (bool editingEnabled)
 Turns on or off the toolbar's editing mode, in which its items can be rearranged by the user.
String toString () const
 Returns a string that represents the toolbar's current set of items.
bool restoreFromString (ToolbarItemFactory &factoryToUse, const String &savedVersion)
 Restores a set of items that was previously stored in a string by the toString() method.
void paint (Graphics &g)
void resized ()
void buttonClicked (Button *)
void mouseDown (const MouseEvent &)
bool isInterestedInDragSource (const SourceDetails &)
void itemDragMove (const SourceDetails &)
void itemDragExit (const SourceDetails &)
void itemDropped (const SourceDetails &)
void updateAllItemPositions (bool animate)

Static Public Member Functions

static ToolbarItemComponentcreateItem (ToolbarItemFactory &, int itemId)

Detailed Description

A toolbar component.

A toolbar contains a horizontal or vertical strip of ToolbarItemComponents, and looks after their order and layout.

Items (icon buttons or other custom components) are added to a toolbar using a ToolbarItemFactory - each type of item is given a unique ID number, and a toolbar might contain more than one instance of a particular item type.

Toolbars can be interactively customised, allowing the user to drag the items around, and to drag items onto or off the toolbar, using the ToolbarItemPalette component as a source of new items.

See also:
ToolbarItemFactory, ToolbarItemComponent, ToolbarItemPalette

Member Enumeration Documentation

Options for the way items should be displayed.

See also:
setStyle, getStyle
Enumerator:
iconsOnly 

Means that the toolbar should just contain icons.

iconsWithText 

Means that the toolbar should have text labels under each icon.

textOnly 

Means that the toolbar only display text labels for each item.

Flags used by the showCustomisationDialog() method.

Enumerator:
allowIconsOnlyChoice 

If this flag is specified, the customisation dialog can show the "icons only" option on its choice of toolbar styles.

allowIconsWithTextChoice 

If this flag is specified, the customisation dialog can show the "icons with text" option on its choice of toolbar styles.

allowTextOnlyChoice 

If this flag is specified, the customisation dialog can show the "text only" option on its choice of toolbar styles.

showResetToDefaultsButton 

If this flag is specified, the customisation dialog can show a button to reset the toolbar to its default set of items.

allCustomisationOptionsEnabled 

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

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:
backgroundColourId 

A colour to use to fill the toolbar's background.

For more control over this, override LookAndFeel::paintToolbarBackground().

separatorColourId 

A colour to use to draw the separator lines.

buttonMouseOverBackgroundColourId 

A colour used to paint the background of buttons when the mouse is over them.

buttonMouseDownBackgroundColourId 

A colour used to paint the background of buttons when the mouse is held down on them.

labelTextColourId 

A colour to use for drawing the text under buttons when the style is set to iconsWithText or textOnly.

editingModeOutlineColourId 

A colour to use for an outline around buttons when the customisation dialog is active and the mouse moves over them.


Constructor & Destructor Documentation

Creates an empty toolbar component.

To add some icons or other components to your toolbar, you'll need to create a ToolbarItemFactory class that can create a suitable set of ToolbarItemComponents.

See also:
ToolbarItemFactory, ToolbarItemComponents

Destructor.

Any items on the bar will be deleted when the toolbar is deleted.


Member Function Documentation

void Toolbar::setVertical ( bool  shouldBeVertical)

Changes the bar's orientation.

See also:
isVertical
bool Toolbar::isVertical ( ) const

Returns true if the bar is set to be vertical, or false if it's horizontal.

You can change the bar's orientation with setVertical().

int Toolbar::getThickness ( ) const

Returns the depth of the bar.

If the bar is horizontal, this will return its height; if it's vertical, it will return its width.

See also:
getLength
int Toolbar::getLength ( ) const

Returns the length of the bar.

If the bar is horizontal, this will return its width; if it's vertical, it will return its height.

See also:
getThickness
void Toolbar::clear ( )

Deletes all items from the bar.

void Toolbar::addItem ( ToolbarItemFactory factory,
int  itemId,
int  insertIndex = -1 
)

Adds an item to the toolbar.

The factory's ToolbarItemFactory::createItem() will be called by this method to create the component that will actually be added to the bar.

The new item will be inserted at the specified index (if the index is -1, it will be added to the right-hand or bottom end of the bar).

Once added, the component will be automatically deleted by this object when it is no longer needed.

See also:
ToolbarItemFactory
void Toolbar::removeToolbarItem ( int  itemIndex)

Deletes one of the items from the bar.

int Toolbar::getNumItems ( ) const

Returns the number of items currently on the toolbar.

See also:
getItemId, getItemComponent
int Toolbar::getItemId ( int  itemIndex) const

Returns the ID of the item with the given index.

If the index is less than zero or greater than the number of items, this will return 0.

See also:
getNumItems

Returns the component being used for the item with the given index.

If the index is less than zero or greater than the number of items, this will return 0.

See also:
getNumItems
void Toolbar::addDefaultItems ( ToolbarItemFactory factoryToUse)

Clears this toolbar and adds to it the default set of items that the specified factory creates.

See also:
ToolbarItemFactory::getDefaultItemSet

Returns the toolbar's current style.

See also:
ToolbarItemStyle, setStyle
void Toolbar::setStyle ( const ToolbarItemStyle newStyle)

Changes the toolbar's current style.

See also:
ToolbarItemStyle, getStyle, ToolbarItemComponent::setStyle

Pops up a modal dialog box that allows this toolbar to be customised by the user.

The dialog contains a ToolbarItemPalette and various controls for editing other aspects of the toolbar. The dialog box will be opened modally, but the method will return immediately.

The factory is used to determine the set of items that will be shown on the palette.

The optionFlags parameter is a bitwise-or of values from the CustomisationFlags enum.

See also:
ToolbarItemPalette
void Toolbar::setEditingActive ( bool  editingEnabled)

Turns on or off the toolbar's editing mode, in which its items can be rearranged by the user.

(In most cases it's easier just to use showCustomisationDialog() instead of trying to enable editing directly).

See also:
ToolbarItemPalette

Returns a string that represents the toolbar's current set of items.

This lets you later restore the same item layout using restoreFromString().

See also:
restoreFromString
bool Toolbar::restoreFromString ( ToolbarItemFactory factoryToUse,
const String savedVersion 
)

Restores a set of items that was previously stored in a string by the toString() method.

The factory object is used to create any item components that are needed.

See also:
toString
void Toolbar::paint ( Graphics g) [virtual]

Reimplemented from Component.

void Toolbar::resized ( ) [virtual]

Reimplemented from Component.

void Toolbar::mouseDown ( const MouseEvent ) [virtual]

Reimplemented from Component.

bool Toolbar::isInterestedInDragSource ( const SourceDetails ) [virtual]

Implements DragAndDropTarget.

void Toolbar::itemDragMove ( const SourceDetails ) [virtual]

Reimplemented from DragAndDropTarget.

void Toolbar::itemDragExit ( const SourceDetails ) [virtual]

Reimplemented from DragAndDropTarget.

void Toolbar::itemDropped ( const SourceDetails ) [virtual]

Implements DragAndDropTarget.

void Toolbar::updateAllItemPositions ( bool  animate)
static ToolbarItemComponent* Toolbar::createItem ( ToolbarItemFactory ,
int  itemId 
) [static]

The documentation for this class was generated from the following file: