Return to Index

Choice

Parent class: Widget

The Choice widget provides a drop-down selection box that allows the user to choose from a list of choices. The widget displays the current string item, and presents a popup list when the widget is clicked on. A selection event is generated when the user changes the current selection. The drop-down menu of the Choice widget can display a multi-level submenu. Text of the form "Foo/Bar/Sap" will result in a toplevel item named "foo", a submenu "bar", and an item "sap" under the "bar" submenu. Appending "Foo/Bar/Maple" will append an item named "maple" under the "bar" submenu. The menu structure is:
   Foo
   +-    Bar
         +-    Sap
         +-    Maple


Object Events:
SelectedThe user changed the current selection.

Method Summary:
Choice::Choice();
void Choice::setChoices(const StringArray& pChoices);
StringArray Choice::getChoices();
void Choice::clear();
void Choice::append(const String& The);
int Choice::find(const String& pItem);
int Choice::getSelection();
String Choice::getSelectionString();
void Choice::setSelection(int pIndex);
void Choice::setSelection(const String& pStr);
void Choice::setString(int pIndex, const String& pStr);
String Choice::getString(int pIndex);
int Choice::getLength();



Choice::Choice
Choice::Choice();

Constructs a new Choice widget.

void Choice::setChoices
void Choice::setChoices(const StringArray& pChoices);

Sets the choices available in the drop-down list.
Parameters:
const StringArray& pChoicesThe array of strings to display.

StringArray Choice::getChoices
StringArray Choice::getChoices();

Returns a StringArray with the currently available choices.

void Choice::clear
void Choice::clear();

Removes all the choices from the list.

void Choice::append
void Choice::append(const String& The);

Appends an item to the end of the list of choices.
Parameters:
const String& Thenew choice.

int Choice::find
int Choice::find(const String& pItem);

Determines whether a given string is one of the choices.

Returns: Returns the index of the choice, or -1 if doesn't exit.
Parameters:
const String& pItemThe item to search for.

int Choice::getSelection
int Choice::getSelection();

Returns the index of the currently selected item.

String Choice::getSelectionString
String Choice::getSelectionString();

Returns the text of the currently selected item.

void Choice::setSelection
void Choice::setSelection(int pIndex);

Changes the current selection.
Parameters:
int pIndexThe index of the new selection. If the index is out of the range, nothing happens.

void Choice::setSelection
void Choice::setSelection(const String& pStr);

Changes the current selection.
Parameters:
const String& pStrThe string to make the current selection. Nothing happens if the string is not a choice.

void Choice::setString
void Choice::setString(int pIndex, const String& pStr);

Changes the text of one of the choices.
Parameters:
int pIndexThe index of the item to change.
const String& pStrThe new text for the choice.

String Choice::getString
String Choice::getString(int pIndex);

Returns the text of the item at the specified index.
Parameters:
int pIndexThe index of the item whose text to return.

int Choice::getLength
int Choice::getLength();

Returns the number of items in the choice.


Generated automatically by docgen 0.0.1
© 2003 Aron Dobos