openshot-audio  0.1.6
Classes | Public Types | Public Member Functions | List of all members
ComboBox Class Reference

#include <juce_ComboBox.h>

Inheritance diagram for ComboBox:
AsyncUpdater

Classes

class  Listener
 
struct  LookAndFeelMethods
 

Public Types

enum  ColourIds {
  backgroundColourId = 0x1000b00, textColourId = 0x1000a00, outlineColourId = 0x1000c00, buttonColourId = 0x1000d00,
  arrowColourId = 0x1000e00
}
 

Public Member Functions

 ComboBox (const String &componentName=String::empty)
 
 ~ComboBox ()
 
void setEditableText (bool isEditable)
 
bool isTextEditable () const noexcept
 
void setJustificationType (Justification justification)
 
Justification getJustificationType () const noexcept
 
void addItem (const String &newItemText, int newItemId)
 
void addItemList (const StringArray &items, int firstItemIdOffset)
 
void addSeparator ()
 
void addSectionHeading (const String &headingName)
 
void setItemEnabled (int itemId, bool shouldBeEnabled)
 
bool isItemEnabled (int itemId) const noexcept
 
void changeItemText (int itemId, const String &newText)
 
void clear (NotificationType notification=sendNotificationAsync)
 
int getNumItems () const noexcept
 
String getItemText (int index) const
 
int getItemId (int index) const noexcept
 
int indexOfItemId (int itemId) const noexcept
 
int getSelectedId () const noexcept
 
ValuegetSelectedIdAsValue ()
 
void setSelectedId (int newItemId, NotificationType notification=sendNotificationAsync)
 
int getSelectedItemIndex () const
 
void setSelectedItemIndex (int newItemIndex, NotificationType notification=sendNotificationAsync)
 
String getText () const
 
void setText (const String &newText, NotificationType notification=sendNotificationAsync)
 
void showEditor ()
 
virtual void showPopup ()
 
void hidePopup ()
 
bool isPopupActive () const noexcept
 
virtual void addItemsToMenu (PopupMenu &) const
 
void addListener (Listener *listener)
 
void removeListener (Listener *listener)
 
void setTextWhenNothingSelected (const String &newMessage)
 
String getTextWhenNothingSelected () const
 
void setTextWhenNoChoicesAvailable (const String &newMessage)
 
String getTextWhenNoChoicesAvailable () const
 
void setTooltip (const String &newTooltip) override
 
void setScrollWheelEnabled (bool enabled) noexcept
 
void labelTextChanged (Label *) override
 
void enablementChanged () override
 
void colourChanged () override
 
void focusGained (Component::FocusChangeType) override
 
void focusLost (Component::FocusChangeType) override
 
void handleAsyncUpdate () override
 
String getTooltip () override
 
void mouseDown (const MouseEvent &) override
 
void mouseDrag (const MouseEvent &) override
 
void mouseUp (const MouseEvent &) override
 
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) override
 
void lookAndFeelChanged () override
 
void paint (Graphics &) override
 
void resized () override
 
bool keyStateChanged (bool) override
 
bool keyPressed (const KeyPress &) override
 
void valueChanged (Value &) override
 
void parentHierarchyChanged () override
 
 JUCE_DEPRECATED (void clear(bool))
 
 JUCE_DEPRECATED (void setSelectedId(int, bool))
 
 JUCE_DEPRECATED (void setSelectedItemIndex(int, bool))
 
 JUCE_DEPRECATED (void setText(const String &, bool))
 

Detailed Description

A component that lets the user choose from a drop-down list of choices.

The combo-box has a list of text strings, each with an associated id number, that will be shown in the drop-down list when the user clicks on the component.

The currently selected choice is displayed in the combo-box, and this can either be read-only text, or editable.

To find out when the user selects a different item or edits the text, you can register a ComboBox::Listener to receive callbacks.

See also
ComboBox::Listener

Member Enumeration Documentation

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

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

To change the colours of the menu that pops up, you can set the colour IDs in PopupMenu::ColourIDs.

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

The background colour to fill the box with.

textColourId 

The colour for the text in the box.

outlineColourId 

The colour for an outline around the box.

buttonColourId 

The base colour for the button (a LookAndFeel class will probably use variations on this).

arrowColourId 

The colour for the arrow shape that pops up the menu

Constructor & Destructor Documentation

ComboBox::ComboBox ( const String componentName = String::empty)
explicit

Creates a combo-box.

On construction, the text field will be empty, so you should call the setSelectedId() or setText() method to choose the initial value before displaying it.

Parameters
componentNamethe name to set for the component (see Component::setName())
ComboBox::~ComboBox ( )

Destructor.

Member Function Documentation

void ComboBox::addItem ( const String newItemText,
int  newItemId 
)

Adds an item to be shown in the drop-down list.

Parameters
newItemTextthe text of the item to show in the list
newItemIdan associated ID number that can be set or retrieved - see getSelectedId() and setSelectedId(). Note that this value can not be 0!
See also
setItemEnabled, addSeparator, addSectionHeading, getNumItems, getItemText, getItemId
void ComboBox::addItemList ( const StringArray items,
int  firstItemIdOffset 
)

Adds an array of items to the drop-down list. The item ID of each item will be its index in the StringArray + firstItemIdOffset.

void ComboBox::addItemsToMenu ( PopupMenu menu) const
virtual

Adds the items in this ComboBox to the given menu.

void ComboBox::addListener ( Listener listener)

Registers a listener that will be called when the box's content changes.

void ComboBox::addSectionHeading ( const String headingName)

Adds a heading to the drop-down list, so that you can group the items into different sections.

The headings are indented slightly differently to set them apart from the items on the list, and obviously can't be selected. You might want to add separators between your sections too.

See also
addItem, addSeparator
void ComboBox::addSeparator ( )

Adds a separator line to the drop-down list.

This is like adding a separator to a popup menu. See PopupMenu::addSeparator().

void ComboBox::changeItemText ( int  itemId,
const String newText 
)

Changes the text for an existing item.

void ComboBox::clear ( NotificationType  notification = sendNotificationAsync)

Removes all the items from the drop-down list.

If this call causes the content to be cleared, and a change-message will be broadcast according to the notification parameter.

See also
addItem, getNumItems
void ComboBox::colourChanged ( )
override
void ComboBox::enablementChanged ( )
override
void ComboBox::focusGained ( Component::FocusChangeType  )
override
void ComboBox::focusLost ( Component::FocusChangeType  )
override
int ComboBox::getItemId ( int  index) const
noexcept

Returns the ID for one of the items in the list. Note that this doesn't include headers or separators.

Parameters
indexthe item's index from 0 to (getNumItems() - 1)
String ComboBox::getItemText ( int  index) const

Returns the text for one of the items in the list. Note that this doesn't include headers or separators.

Parameters
indexthe item's index from 0 to (getNumItems() - 1)
Justification ComboBox::getJustificationType ( ) const
noexcept

Returns the current justification for the text box.

See also
setJustificationType
int ComboBox::getNumItems ( ) const
noexcept

Returns the number of items that have been added to the list.

Note that this doesn't include headers or separators.

int ComboBox::getSelectedId ( ) const
noexcept

Returns the ID of the item that's currently shown in the box.

If no item is selected, or if the text is editable and the user has entered something which isn't one of the items in the list, then this will return 0.

See also
setSelectedId, getSelectedItemIndex, getText
Value& ComboBox::getSelectedIdAsValue ( )
inline

Returns a Value object that can be used to get or set the selected item's ID.

You can call Value::referTo() on this object to make the combo box control another Value object.

int ComboBox::getSelectedItemIndex ( ) const

Returns the index of the item that's currently shown in the box.

If no item is selected, or if the text is editable and the user has entered something which isn't one of the items in the list, then this will return -1.

See also
setSelectedItemIndex, getSelectedId, getText
String ComboBox::getText ( ) const

Returns the text that is currently shown in the combo-box's text field.

If the ComboBox has editable text, then this text may have been edited by the user; otherwise it will be one of the items from the list, or possibly an empty string if nothing was selected.

See also
setText, getSelectedId, getSelectedItemIndex
String ComboBox::getTextWhenNoChoicesAvailable ( ) const

Returns the text shown when no items have been added to the list.

See also
setTextWhenNoChoicesAvailable
String ComboBox::getTextWhenNothingSelected ( ) const

Returns the text that is shown when no item is selected.

See also
setTextWhenNothingSelected
String ComboBox::getTooltip ( )
inlineoverride
void ComboBox::handleAsyncUpdate ( )
overridevirtual

Called back to do whatever your class needs to do.

This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.

Implements AsyncUpdater.

void ComboBox::hidePopup ( )

Hides the combo box's popup list, if it's currently visible.

int ComboBox::indexOfItemId ( int  itemId) const
noexcept

Returns the index in the list of a particular item ID. If no such ID is found, this will return -1.

bool ComboBox::isItemEnabled ( int  itemId) const
noexcept

Returns true if the given item is enabled.

bool ComboBox::isPopupActive ( ) const
inlinenoexcept

Returns true if the popup menu is currently being shown.

bool ComboBox::isTextEditable ( ) const
noexcept

Returns true if the text is directly editable.

See also
setEditableText
ComboBox::JUCE_DEPRECATED ( void   clearbool)
ComboBox::JUCE_DEPRECATED ( void   setSelectedIdint, bool)
ComboBox::JUCE_DEPRECATED ( void   setSelectedItemIndexint, bool)
ComboBox::JUCE_DEPRECATED ( void   setTextconst String &, bool)
bool ComboBox::keyPressed ( const KeyPress key)
override
bool ComboBox::keyStateChanged ( bool  isKeyDown)
override
void ComboBox::labelTextChanged ( Label )
override
void ComboBox::lookAndFeelChanged ( )
override
void ComboBox::mouseDown ( const MouseEvent e)
override
void ComboBox::mouseDrag ( const MouseEvent e)
override
void ComboBox::mouseUp ( const MouseEvent e2)
override
void ComboBox::mouseWheelMove ( const MouseEvent e,
const MouseWheelDetails wheel 
)
override
void ComboBox::paint ( Graphics g)
override
void ComboBox::parentHierarchyChanged ( )
override
void ComboBox::removeListener ( Listener listener)

Deregisters a previously-registered listener.

void ComboBox::resized ( )
override
void ComboBox::setEditableText ( bool  isEditable)

Sets whether the text in the combo-box is editable.

The default state for a new ComboBox is non-editable, and can only be changed by choosing from the drop-down list.

void ComboBox::setItemEnabled ( int  itemId,
bool  shouldBeEnabled 
)

This allows items in the drop-down list to be selectively disabled.

When you add an item, it's enabled by default, but you can call this method to change its status.

If you disable an item which is already selected, this won't change the current selection - it just stops the user choosing that item from the list.

void ComboBox::setJustificationType ( Justification  justification)

Sets the style of justification to be used for positioning the text.

The default is Justification::centredLeft. The text is displayed using a Label component inside the ComboBox.

void ComboBox::setScrollWheelEnabled ( bool  enabled)
noexcept

This can be used to allow the scroll-wheel to nudge the chosen item. By default it's disabled, and I'd recommend leaving it disabled if there's any chance that the control might be inside a scrollable list or viewport.

void ComboBox::setSelectedId ( int  newItemId,
NotificationType  notification = sendNotificationAsync 
)

Sets one of the items to be the current selection.

This will set the ComboBox's text to that of the item that matches this ID.

Parameters
newItemIdthe new item to select
notificationdetermines the type of change notification that will be sent to listeners if the value changes
See also
getSelectedId, setSelectedItemIndex, setText
void ComboBox::setSelectedItemIndex ( int  newItemIndex,
NotificationType  notification = sendNotificationAsync 
)

Sets one of the items to be the current selection.

This will set the ComboBox's text to that of the item at the given index in the list.

Parameters
newItemIndexthe new item to select
notificationdetermines the type of change notification that will be sent to listeners if the value changes
See also
getSelectedItemIndex, setSelectedId, setText
void ComboBox::setText ( const String newText,
NotificationType  notification = sendNotificationAsync 
)

Sets the contents of the combo-box's text field.

The text passed-in will be set as the current text regardless of whether it is one of the items in the list. If the current text isn't one of the items, then getSelectedId() will return -1, otherwise it wil return the approriate ID.

Parameters
newTextthe text to select
notificationdetermines the type of change notification that will be sent to listeners if the text changes
See also
getText
void ComboBox::setTextWhenNoChoicesAvailable ( const String newMessage)

Sets the message to show when there are no items in the list, and the user clicks on the drop-down box.

By default it just says "no choices", but this lets you change it to something more meaningful.

void ComboBox::setTextWhenNothingSelected ( const String newMessage)

Sets a message to display when there is no item currently selected.

See also
getTextWhenNothingSelected
void ComboBox::setTooltip ( const String newTooltip)
override

Gives the ComboBox a tooltip.

void ComboBox::showEditor ( )

Programmatically opens the text editor to allow the user to edit the current item.

This is the same effect as when the box is clicked-on.

See also
Label::showEditor();
void ComboBox::showPopup ( )
virtual

Pops up the combo box's list. This is virtual so that you can override it with your own custom popup mechanism if you need some really unusual behaviour.

void ComboBox::valueChanged ( Value )
override

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