Woopsi 1.0
GUI Framework for Nintendo DS Homebrew
|
#include <listdata.h>
Public Member Functions | |
ListData () | |
virtual | ~ListData () |
virtual void | addItem (const WoopsiString &text, const u32 value) |
virtual void | addItem (ListDataItem *item) |
virtual void | removeItem (const s32 index) |
virtual void | selectItem (const s32 index) |
virtual void | deselectItem (const s32 index) |
virtual void | removeAllItems () |
virtual const s32 | getSelectedIndex () const |
virtual void | setSelectedIndex (const s32 index) |
virtual const ListDataItem * | getSelectedItem () const |
virtual void | setAllowMultipleSelections (const bool allowMultipleSelections) |
virtual const ListDataItem * | getItem (const s32 index) const |
virtual void | sort () |
virtual const s32 | getItemCount () const |
virtual void | selectAllItems () |
virtual void | deselectAllItems () |
virtual void | setItemSelected (const s32 index, const bool selected) |
virtual const bool | allowsMultipleSelections () const |
virtual void | setSortInsertedItems (const bool sortInsertedItems) |
void | addListDataEventHandler (ListDataEventHandler *eventHandler) |
void | removeListDataEventHandler (ListDataEventHandler *eventHandler) |
Protected Member Functions | |
virtual void | quickSort (const s32 start, const s32 end) |
virtual void | swapItems (const s32 index1, const s32 index2) |
const s32 | getSortedInsertionIndex (const ListDataItem *item) const |
void | raiseDataChangedEvent () |
void | raiseSelectionChangedEvent () |
Protected Attributes | |
WoopsiArray< ListDataItem * > | _items |
WoopsiArray < ListDataEventHandler * > | _listDataEventhandlers |
bool | _allowMultipleSelections |
bool | _sortInsertedItems |
Class representing a list of items. Designed to be used by the ListBox class, etc, to store its data. Fires events to notify listeners when the list changes or a new selection is made.
WoopsiUI::ListData::ListData | ( | ) |
Constructor.
virtual WoopsiUI::ListData::~ListData | ( | ) | [virtual] |
Destructor.
virtual void WoopsiUI::ListData::addItem | ( | const WoopsiString & | text, |
const u32 | value | ||
) | [virtual] |
Add a new item.
text | Text to show in the option. |
value | The value of the option. |
virtual void WoopsiUI::ListData::addItem | ( | ListDataItem * | item | ) | [virtual] |
Add an existing item. ListData becomes the owner of the option and will delete it when the list is deleted.
item | The item to add. |
void WoopsiUI::ListData::addListDataEventHandler | ( | ListDataEventHandler * | eventHandler | ) | [inline] |
Add an event handler.
eventHandler | The event handler to add. |
virtual const bool WoopsiUI::ListData::allowsMultipleSelections | ( | ) | const [inline, virtual] |
Returns whether multiple selections are possible or not.
virtual void WoopsiUI::ListData::deselectAllItems | ( | ) | [virtual] |
Deselect all items.
virtual void WoopsiUI::ListData::deselectItem | ( | const s32 | index | ) | [virtual] |
Deselect an item by its index.
index | The index of the item to select. |
virtual const ListDataItem* WoopsiUI::ListData::getItem | ( | const s32 | index | ) | const [inline, virtual] |
Get the specified item.
virtual const s32 WoopsiUI::ListData::getItemCount | ( | ) | const [inline, virtual] |
Get the total number of items.
virtual const s32 WoopsiUI::ListData::getSelectedIndex | ( | ) | const [virtual] |
Get the selected index. Returns -1 if nothing is selected. If more than one item is selected, the index of the first selected item is returned.
virtual const ListDataItem* WoopsiUI::ListData::getSelectedItem | ( | ) | const [virtual] |
Get the selected item. Returns NULL if nothing is selected.
const s32 WoopsiUI::ListData::getSortedInsertionIndex | ( | const ListDataItem * | item | ) | const [protected] |
Return the index that an item should be inserted at to maintain a sorted list of data.
item | The item to insert. |
virtual void WoopsiUI::ListData::quickSort | ( | const s32 | start, |
const s32 | end | ||
) | [protected, virtual] |
Quick sort the items using their compareTo() methods.
start | The index to start sorting at. |
end | The index to stop sorting at. |
void WoopsiUI::ListData::raiseDataChangedEvent | ( | ) | [protected] |
Raise a data changed event.
void WoopsiUI::ListData::raiseSelectionChangedEvent | ( | ) | [protected] |
Raise a selection changed event.
virtual void WoopsiUI::ListData::removeAllItems | ( | ) | [virtual] |
Remove all items.
virtual void WoopsiUI::ListData::removeItem | ( | const s32 | index | ) | [virtual] |
Remove an item by its index.
index | The index of the option to remove. |
void WoopsiUI::ListData::removeListDataEventHandler | ( | ListDataEventHandler * | eventHandler | ) |
Remove an event handler.
eventHandler | The event handler to remove. |
virtual void WoopsiUI::ListData::selectAllItems | ( | ) | [virtual] |
Select all items. Does nothing if the list does not allow multiple selections.
virtual void WoopsiUI::ListData::selectItem | ( | const s32 | index | ) | [virtual] |
Select an item by its index.
index | The index of the item to select. |
virtual void WoopsiUI::ListData::setAllowMultipleSelections | ( | const bool | allowMultipleSelections | ) | [inline, virtual] |
Sets whether multiple selections are possible or not.
allowMultipleSelections | True to allow multiple selections. |
virtual void WoopsiUI::ListData::setItemSelected | ( | const s32 | index, |
const bool | selected | ||
) | [virtual] |
Select or deselect an item by its index. Does not deselect any other selected items. Set index to -1 to select nothing.
index | The index of the item to select. |
selected | True to select the item, false to deselect it. |
virtual void WoopsiUI::ListData::setSelectedIndex | ( | const s32 | index | ) | [virtual] |
Sets the selected index. Specify -1 to select nothing. Resets any other selected items to deselected.
index | The selected index. |
virtual void WoopsiUI::ListData::setSortInsertedItems | ( | const bool | sortInsertedItems | ) | [inline, virtual] |
Sets whether or not items added to the list are automatically sorted on insert or not.
sortInsertedItems | True to enable sort on insertion. |
virtual void WoopsiUI::ListData::sort | ( | ) | [virtual] |
Sort the items using their compareTo() methods.
virtual void WoopsiUI::ListData::swapItems | ( | const s32 | index1, |
const s32 | index2 | ||
) | [protected, virtual] |
Swap the locations of two items in the array.
index1 | The index of the first item to swap. |
index2 | The index of the second item to swap. |
bool WoopsiUI::ListData::_allowMultipleSelections [protected] |
If true, multiple options can be selected.
WoopsiArray<ListDataItem*> WoopsiUI::ListData::_items [protected] |
Collection of list data items.
Collection of event handlers.
bool WoopsiUI::ListData::_sortInsertedItems [protected] |
Automatically sorts items on insertion if true.