A PropertyComponent that shows its value as a combo box. More...
Inherits PropertyComponent, and ComboBox::Listener.
Public Member Functions | |
| ChoicePropertyComponent (const Value &valueToControl, const String &propertyName, const StringArray &choices, const Array< var > &correspondingValues) | |
| Creates the component. | |
| ~ChoicePropertyComponent () | |
| Destructor. | |
| virtual void | setIndex (int newIndex) |
| Called when the user selects an item from the combo box. | |
| virtual int | getIndex () const |
| Returns the index of the item that should currently be shown. | |
| const StringArray & | getChoices () const |
| Returns the list of options. | |
| void | refresh () |
| Updates the property component if the item it refers to has changed. | |
| void | comboBoxChanged (ComboBox *) |
| Called when a ComboBox has its selected item changed. | |
Protected Member Functions | |
| ChoicePropertyComponent (const String &propertyName) | |
| Creates the component. | |
Protected Attributes | |
| StringArray | choices |
| The list of options that will be shown in the combo box. | |
A PropertyComponent that shows its value as a combo box.
This type of property component contains a list of options and has a combo box to choose one.
Your subclass's constructor must add some strings to the choices StringArray and these are shown in the list.
The getIndex() method will be called to find out which option is the currently selected one. If you call refresh() it will call getIndex() to check whether the value has changed, and will update the combo box if needed.
If the user selects a different item from the list, setIndex() will be called to let your class process this.
| ChoicePropertyComponent::ChoicePropertyComponent | ( | const String & | propertyName ) | [protected] |
Creates the component.
Your subclass's constructor must add a list of options to the choices member variable.
| ChoicePropertyComponent::ChoicePropertyComponent | ( | const Value & | valueToControl, |
| const String & | propertyName, | ||
| const StringArray & | choices, | ||
| const Array< var > & | correspondingValues | ||
| ) |
Creates the component.
| valueToControl | the value that the combo box will read and control |
| propertyName | the name of the property |
| choices | the list of possible values that the drop-down list will contain |
| correspondingValues | a list of values corresponding to each item in the 'choices' StringArray. These are the values that will be read and written to the valueToControl value. This array must contain the same number of items as the choices array |
| ChoicePropertyComponent::~ChoicePropertyComponent | ( | ) |
Destructor.
| virtual void ChoicePropertyComponent::setIndex | ( | int | newIndex ) | [virtual] |
Called when the user selects an item from the combo box.
Your subclass must use this callback to update the value that this component represents. The index is the index of the chosen item in the choices StringArray.
| virtual int ChoicePropertyComponent::getIndex | ( | ) | const [virtual] |
Returns the index of the item that should currently be shown.
This is the index of the item in the choices StringArray that will be shown.
| const StringArray& ChoicePropertyComponent::getChoices | ( | ) | const |
Returns the list of options.
| void ChoicePropertyComponent::refresh | ( | ) | [virtual] |
Updates the property component if the item it refers to has changed.
A subclass must implement this method, and other objects may call it to force it to refresh itself.
The subclass should be economical in the amount of work is done, so for example it should check whether it really needs to do a repaint rather than just doing one every time this method is called, as it may be called when the value being displayed hasn't actually changed.
Implements PropertyComponent.
| void ChoicePropertyComponent::comboBoxChanged | ( | ComboBox * | comboBoxThatHasChanged ) | [virtual] |
Called when a ComboBox has its selected item changed.
Implements ComboBox::Listener.
StringArray ChoicePropertyComponent::choices [protected] |
The list of options that will be shown in the combo box.
Your subclass must populate this array in its constructor. If any empty strings are added, these will be replaced with horizontal separators (see ComboBox::addSeparator() for more info).