Return to Index

ListBox

Parent class: Widget

The ListBox widget displays a scrolling list of text lines. A user can select one line at a time, and the text list can be manipulated with the standard addition and removal functions.


Object Events:
SelectedAn event generated when the user selects an item. The event's getIndex() returns the index of the selection.

Method Summary:
ListBox::ListBox();
void ListBox::append(const String& s);
void ListBox::prepend(const String& s);
void ListBox::insert(const String& s, int index);
void ListBox::remove(int index);
int ListBox::find(const String& s);
void ListBox::clear();
int ListBox::getLength();
String ListBox::getText(int i);
void ListBox::setText(int index, const String& pStr);
void ListBox::setData(const StringArray& pStrs);
int ListBox::getSelection();
void ListBox::setSelection(int pIndex);
void ListBox::deselect();
bool ListBox::isLineVisible();
void ListBox::setTopLine(int i);
int ListBox::getTopLine();
void ListBox::setMiddleLine(int i);
void ListBox::setBottomLine(int i);
int ListBox::getScrollPos();
int ListBox::setScrollPos();



ListBox::ListBox
ListBox::ListBox();

Constructs a new ListBox widget.

void ListBox::append
void ListBox::append(const String& s);

Appends the specified string to the end of the list.
Parameters:
const String& sThe string to append.

void ListBox::prepend
void ListBox::prepend(const String& s);

Prepends the specified string to the beginning of the list.
Parameters:
const String& sThe string to prepend.

void ListBox::insert
void ListBox::insert(const String& s, int index);

Inserts a string to a specified location in the list.
Parameters:
const String& sThe string to insert.
int indexThe insertion index.

void ListBox::remove
void ListBox::remove(int index);

Removes the string at the given index. If the index is out of range, nothing happens.
Parameters:
int indexThe index of the string to remove.

int ListBox::find
int ListBox::find(const String& s);

Searches the list for a string.

Returns: Returns the index of the first occurence if found, otherwise returns -1.
Parameters:
const String& sThe string to search for.

void ListBox::clear
void ListBox::clear();

Empties the list box.

int ListBox::getLength
int ListBox::getLength();

Returns the number of items in the list.

String ListBox::getText
String ListBox::getText(int i);

Returns the text at the specified index.
Parameters:
int iSpecifies which string to return.

void ListBox::setText
void ListBox::setText(int index, const String& pStr);

Changes the text displayed at the given index.
Parameters:
int indexThe index of the item to change.
const String& pStrThe new text.

void ListBox::setData
void ListBox::setData(const StringArray& pStrs);

Clears the list and inserts the items in the string array.
Parameters:
const StringArray& pStrsThe strings.

int ListBox::getSelection
int ListBox::getSelection();

Returns the index of the currently selected item, or -1 if no item is selected.

void ListBox::setSelection
void ListBox::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 ListBox::deselect
void ListBox::deselect();

Unselects any selected items in the list.

bool ListBox::isLineVisible
bool ListBox::isLineVisible();

Returns whether the ith line visible.

void ListBox::setTopLine
void ListBox::setTopLine(int i);

Scrolls the list box to set the ith element as the top line.
Parameters:
int iThe line index.

int ListBox::getTopLine
int ListBox::getTopLine();

Returns the index of the current top line visible.

void ListBox::setMiddleLine
void ListBox::setMiddleLine(int i);

Scrolls the list box to make the ith line the middle line in the view.
Parameters:
int iThe item's index.

void ListBox::setBottomLine
void ListBox::setBottomLine(int i);

Scrolls the list box to make the ith line the bottom line in the view.
Parameters:
int iThe item's index.

int ListBox::getScrollPos
int ListBox::getScrollPos();

Returns the current scroll position as an integer value.

int ListBox::setScrollPos
int ListBox::setScrollPos();

Sets the current scroll position.


Generated automatically by docgen 0.0.1
© 2003 Aron Dobos