Woopsi 1.3
Nintendo DS Gui Framework
Public Member Functions | Protected Member Functions | Protected Attributes
WoopsiUI::ListBox Class Reference

#include <libwoopsi/include/listbox.h>

Inheritance diagram for WoopsiUI::ListBox:
WoopsiUI::ListBoxBase WoopsiUI::ScrollingPanel WoopsiUI::ListDataEventHandler WoopsiUI::Gadget WoopsiUI::ScrollableBase

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 ListBoxDataItemgetSelectedOption () const
virtual void setAllowMultipleSelections (const bool allowMultipleSelections)
virtual const bool allowsMultipleSelections () const
virtual void resizeCanvas ()
virtual const ListBoxDataItemgetOption (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:
xThe x co-ordinate of the gadget.
yThe y co-ordinate of the gadget.
widthThe width of the gadget.
heightThe height of the gadget.
styleThe 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:
textText to show in the option.
valueThe value of the option.

Implements WoopsiUI::ListBoxBase.

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

Add an option to the gadget.

Parameters:
optionThe 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:
textText to show in the option.
valueThe value of the option.
normalTextColourColour to draw the text with when not selected.
normalBackColourColour to draw the background with when not selected.
selectedTextColourColour to draw the text with when selected.
selectedBackColourColour 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:
indexThe 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:
portThe 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:
portThe 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:
rectReference 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:
eEvent arguments.

Implements WoopsiUI::ListDataEventHandler.

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

Handles list selection changed events.

Parameters:
eEvent arguments.

Implements WoopsiUI::ListDataEventHandler.

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

Check if the click is a double-click.

Parameters:
xX co-ordinate of the click.
yY 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:
xThe x co-ordinate of the click.
yThe 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:
xThe x co-ordinate of the click.
yThe 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:
indexThe 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:
indexThe 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:
allowMultipleSelectionsTrue 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:
indexThe index of the option to select.
selectedTrue 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:
indexThe 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:
sortInsertedItemsTrue 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

Index of the last option selected.

Padding between options.

Option storage.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator