Woopsi 1.0 GUI Framework for Nintendo DS Homebrew

- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes

# WoopsiUI::ListBox Class Reference

`#include <listbox.h>`

Inheritance diagram for WoopsiUI::ListBox:

List of all members.

## Public Member Functions
| ListBox (s16 x, s16 y, u16 width, u16 height, GadgetStyle *style=NULL)
virtual void | addOption (const WoopsiString &text, const u32 value)
virtual void | addOption (ListBoxDataItem *option)
virtual void | removeOption (const s32 index)
virtual void | removeAllOptions ()
virtual void | addOption (const WoopsiString &text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour)
virtual void | selectOption (const s32 index)
virtual void | deselectOption (const s32 index)
virtual void | selectAllOptions ()
virtual void | deselectAllOptions ()
virtual const s32 | getSelectedIndex () const
virtual void | setSelectedIndex (const s32 index)
virtual const ListBoxDataItem * | getSelectedOption () const
virtual void | setAllowMultipleSelections (const bool allowMultipleSelections)
virtual const bool | allowsMultipleSelections () const
virtual void | resizeCanvas ()
virtual const ListBoxDataItem * | getOption (const s32 index)
virtual void | sort ()
virtual const s32 | getOptionCount () const
virtual const u16 | getOptionHeight () const
virtual void | setSortInsertedItems (const bool sortInsertedItems)
virtual void | handleListDataChangedEvent (const ListDataEventArgs &e)
virtual void | handleListDataSelectionChangedEvent (const ListDataEventArgs &e)
virtual void | getPreferredDimensions (Rect &rect) const
virtual bool | isDoubleClick (s16 x, s16 y)
## Protected Member Functions
virtual void | drawContents (GraphicsPort *port)
virtual void | drawBorder (GraphicsPort *port)
virtual void | onClick (s16 x, s16 y)
virtual void | onDoubleClick (s16 x, s16 y)
virtual | ~ListBox ()
virtual void | setOptionSelected (const s32 index, const bool selected)
| ListBox (const ListBox &listBox)
## Protected Attributes
ListData | _options
u8 | _optionPadding
s32 | _lastSelectedIndex

## Detailed Description

Class providing a scrollable list of options. The ListBox can be set up to only allow one selection or multiple selections. Processes double-clicks and raises double-click events, so that a double-click on an option can be made to automatically select and close a window/etc. The options themselves have user-definable text and background colours for their selected and unselected states.

## Constructor & Destructor Documentation

WoopsiUI::ListBox::ListBox | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | GadgetStyle * | style = `NULL`
| ) |  |

Constructor.

Parameters:

  x | The x co-ordinate of the gadget.
  y | The y co-ordinate of the gadget.
  width | The width of the gadget.
  height | The height of the gadget.
  style | The style that the gadget should use. If this is not specified, the gadget will use the values stored in the global defaultGadgetStyle object. The gadget will copy the properties of the style into its own internal style object.

virtual WoopsiUI::ListBox::~ListBox | ( |  | ) | `[protected, virtual]`

Destructor.

WoopsiUI::ListBox::ListBox | ( | const ListBox & | listBox | ) | `[inline, protected]`

Copy constructor is protected to prevent usage.

## Member Function Documentation

virtual void WoopsiUI::ListBox::addOption | ( | const WoopsiString & | text,
|  | const u32 | value
| ) |  | `[virtual]`

Add a new option to the gadget using default colours.

Parameters:

  text | Text to show in the option.
  value | The value of the option.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::addOption | ( | ListBoxDataItem * | option | ) | `[virtual]`

Add an option to the gadget.

Parameters:

  option | The option to add.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::addOption | ( | const WoopsiString & | text,
|  | const u32 | value,
|  | const u16 | normalTextColour,
|  | const u16 | normalBackColour,
|  | const u16 | selectedTextColour,
|  | const u16 | selectedBackColour
| ) |  | `[virtual]`

Add a new option to the gadget.

Parameters:

  text | Text to show in the option.
  value | The value of the option.
  normalTextColour | Colour to draw the text with when not selected.
  normalBackColour | Colour to draw the background with when not selected.
  selectedTextColour | Colour to draw the text with when selected.
  selectedBackColour | Colour to draw the background with when selected.

Implements WoopsiUI::ListBoxBase.

virtual const bool WoopsiUI::ListBox::allowsMultipleSelections | ( |  | ) | const`[inline, virtual]`

Sets whether multiple selections are possible or not.

Returns:
  True if multiple selections are allowed.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::deselectAllOptions | ( |  | ) | `[virtual]`

Deselect all options. Raises a value changed event.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::deselectOption | ( | const s32 | index | ) | `[virtual]`

Select an option by its index. Raises a value changed event.

Parameters:

  index | The index of the option to select.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::drawBorder | ( | GraphicsPort * | port | ) | `[protected, virtual]`

Draw the area of this gadget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters:

  port | The GraphicsPort to draw to.

See also:
  redraw()

Reimplemented from WoopsiUI::ScrollingPanel.

virtual void WoopsiUI::ListBox::drawContents | ( | GraphicsPort * | port | ) | `[protected, virtual]`

Draw the area of this gadget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters:

  port | The GraphicsPort to draw to.

See also:
  redraw()

Reimplemented from WoopsiUI::ScrollingPanel.

virtual const ListBoxDataItem* WoopsiUI::ListBox::getOption | ( | const s32 | index | ) | `[inline, virtual]`

Get the specified option.

Returns:
  The specified option.

Implements WoopsiUI::ListBoxBase.

virtual const s32 WoopsiUI::ListBox::getOptionCount | ( |  | ) | const`[inline, virtual]`

Get the total number of options.

Returns:
  The number of options.

Implements WoopsiUI::ListBoxBase.

virtual const u16 WoopsiUI::ListBox::getOptionHeight | ( |  | ) | const`[virtual]`

Get the height of a single option.

Returns:
  The height of an option.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::getPreferredDimensions | ( | Rect & | rect | ) | const`[virtual]`

Insert the dimensions that this gadget wants to have into the rect passed in as a parameter. All co-ordinates are relative to the gadget's parent. Value is based on the length of the largest string in the set of options.

Parameters:

  rect | Reference to a rect to populate with data.

Reimplemented from WoopsiUI::Gadget.

virtual const s32 WoopsiUI::ListBox::getSelectedIndex | ( |  | ) | const`[virtual]`

Get the selected index. Returns -1 if nothing is selected. If more than one option is selected, the index of the first selected option is returned.

Returns:
  The selected index.

Implements WoopsiUI::ListBoxBase.

virtual const ListBoxDataItem* WoopsiUI::ListBox::getSelectedOption | ( |  | ) | const`[virtual]`

Get the selected option. Returns NULL if nothing is selected.

Returns:
  The selected option.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::handleListDataChangedEvent | ( | const ListDataEventArgs & | e | ) | `[virtual]`

Handles list data changed events.

Parameters:

  e | Event arguments.

Implements WoopsiUI::ListDataEventHandler.

virtual void WoopsiUI::ListBox::handleListDataSelectionChangedEvent | ( | const ListDataEventArgs & | e | ) | `[virtual]`

Handles list selection changed events.

Parameters:

  e | Event arguments.

Implements WoopsiUI::ListDataEventHandler.

virtual bool WoopsiUI::ListBox::isDoubleClick | ( | s16 | x,
|  | s16 | y
| ) |  | `[virtual]`

Check if the click is a double-click.

Parameters:

  x | X co-ordinate of the click.
  y | Y co-ordinate of the click.

Returns:
  True if the click is a double-click.

Reimplemented from WoopsiUI::Gadget.

virtual void WoopsiUI::ListBox::onClick | ( | s16 | x,
|  | s16 | y
| ) |  | `[protected, virtual]`

Determines which item was clicked and selects or deselects it as appropriate. Also starts the dragging system.

Parameters:

  x | The x co-ordinate of the click.
  y | The y co-ordinate of the click.

Reimplemented from WoopsiUI::ScrollingPanel.

virtual void WoopsiUI::ListBox::onDoubleClick | ( | s16 | x,
|  | s16 | y
| ) |  | `[protected, virtual]`

Selects the clicked item and deselects all others.

Parameters:

  x | The x co-ordinate of the click.
  y | The y co-ordinate of the click.

Reimplemented from WoopsiUI::Gadget.

virtual void WoopsiUI::ListBox::removeAllOptions | ( |  | ) | `[virtual]`

Remove all options from the gadget.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::removeOption | ( | const s32 | index | ) | `[virtual]`

Remove an option from the gadget by its index.

Parameters:

  index | The index of the option to remove.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::resizeCanvas | ( |  | ) | `[virtual]`

Resize the scrolling canvas to encompass all options.

virtual void WoopsiUI::ListBox::selectAllOptions | ( |  | ) | `[virtual]`

Select all options. Does nothing if the listbox does not allow multiple selections. Raises a value changed event.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::selectOption | ( | const s32 | index | ) | `[virtual]`

Select an option by its index. Raises a value changed event.

Parameters:

  index | The index of the option to select.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::setAllowMultipleSelections | ( | const bool | allowMultipleSelections | ) | `[inline, virtual]`

Sets whether multiple selections are possible or not.

Parameters:

  allowMultipleSelections | True to allow multiple selections.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::setOptionSelected | ( | const s32 | index,
|  | const bool | selected
| ) |  | `[protected, virtual]`

Select or deselect an option by its index. Does not deselect any other selected options. Set index to -1 to select nothing. Raises a value changed event.

Parameters:

  index | The index of the option to select.
  selected | True to select the option, false to deselect it.

virtual void WoopsiUI::ListBox::setSelectedIndex | ( | const s32 | index | ) | `[virtual]`

Sets the selected index. Specify -1 to select nothing. Resets any other selected options to deselected. Raises a value changed event.

Parameters:

  index | The selected index.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::setSortInsertedItems | ( | const bool | sortInsertedItems | ) | `[inline, virtual]`

Sets whether or not items added to the list are automatically sorted on insert or not.

Parameters:

  sortInsertedItems | True to enable sort on insertion.

Implements WoopsiUI::ListBoxBase.

virtual void WoopsiUI::ListBox::sort | ( |  | ) | `[virtual]`

Sort the options alphabetically by the text of the options.

Implements WoopsiUI::ListBoxBase.

## Member Data Documentation

s32 WoopsiUI::ListBox::_lastSelectedIndex`[protected]`

Index of the last option selected.

u8 WoopsiUI::ListBox::_optionPadding`[protected]`

Padding between options.

ListData WoopsiUI::ListBox::_options`[protected]`

Option storage.

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

- listbox.h