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

#include <libwoopsi/include/cyclebutton.h>

Inheritance diagram for WoopsiUI::CycleButton:
WoopsiUI::Button WoopsiUI::ListDataEventHandler WoopsiUI::Label WoopsiUI::Gadget

List of all members.

Public Member Functions

 CycleButton (s16 x, s16 y, u16 width, u16 height, GadgetStyle *style=NULL)
void addOption (const WoopsiString &text, const u32 value)
virtual void removeOption (const s32 index)
virtual void removeAllOptions ()
virtual void selectOption (const s32 index)
virtual const s32 getSelectedIndex () const
virtual void setSelectedIndex (const s32 index)
virtual const ListDataItemgetSelectedOption () const
const u32 getValue () const
virtual const ListDataItemgetOption (const s32 index)
virtual void sort ()
virtual const s32 getOptionCount () 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

Protected Member Functions

virtual void drawContents (GraphicsPort *port)
virtual void drawBorder (GraphicsPort *port)
virtual void drawOutline (GraphicsPort *port)
virtual void onRelease (s16 x, s16 y)
virtual void onReleaseOutside (s16 x, s16 y)
virtual void onResize (u16 width, u16 height)
virtual void calculateTextPosition ()
virtual ~CycleButton ()
 CycleButton (const CycleButton &cycleButton)

Protected Attributes

ListData _options

Detailed Description

Cycle button gadget. Displays text within the button. Clicking it cycles through its available options.


Constructor & Destructor Documentation

WoopsiUI::CycleButton::CycleButton ( s16  x,
s16  y,
u16  width,
u16  height,
GadgetStyle style = NULL 
)

Constructor for cycle buttons.

Parameters:
xThe x co-ordinate of the button, relative to its parent.
yThe y co-ordinate of the button, relative to its parent.
widthThe width of the button.
heightThe height of the button.
styleThe style that the button should use. If this is not specified, the button will use the values stored in the global defaultGadgetStyle object. The button will copy the properties of the style into its own internal style object.
virtual WoopsiUI::CycleButton::~CycleButton ( ) [inline, protected, virtual]

Destructor.

WoopsiUI::CycleButton::CycleButton ( const CycleButton cycleButton) [inline, protected]

Copy constructor is protected to prevent usage.


Member Function Documentation

void WoopsiUI::CycleButton::addOption ( const WoopsiString text,
const u32  value 
)

Add a new option to the gadget.

Parameters:
textThe text of the option.
valueThe value of the option.
virtual void WoopsiUI::CycleButton::calculateTextPosition ( ) [inline, protected, virtual]

Override method in Label class to prevent recalculation of text positions.

virtual void WoopsiUI::CycleButton::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::Button.

virtual void WoopsiUI::CycleButton::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::Button.

virtual void WoopsiUI::CycleButton::drawOutline ( GraphicsPort port) [protected, virtual]

Draws the outline of the button.

Parameters:
portGraphics port to draw to.

Reimplemented from WoopsiUI::Button.

virtual const ListDataItem* WoopsiUI::CycleButton::getOption ( const s32  index) [inline, virtual]

Get the specified option.

Returns:
The specified option.
virtual const s32 WoopsiUI::CycleButton::getOptionCount ( ) const [inline, virtual]

Get the total number of options.

Returns:
The number of options.
virtual void WoopsiUI::CycleButton::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::Label.

virtual const s32 WoopsiUI::CycleButton::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.
virtual const ListDataItem* WoopsiUI::CycleButton::getSelectedOption ( ) const [virtual]

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

Returns:
The selected option.
const u32 WoopsiUI::CycleButton::getValue ( ) const [inline]

Get the value of the current option.

Returns:
Value of the current option.
virtual void WoopsiUI::CycleButton::handleListDataChangedEvent ( const ListDataEventArgs e) [virtual]

Handles list data changed events.

Parameters:
eEvent arguments.

Implements WoopsiUI::ListDataEventHandler.

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

Handles list selection changed events.

Parameters:
eEvent arguments.

Implements WoopsiUI::ListDataEventHandler.

virtual void WoopsiUI::CycleButton::onRelease ( s16  x,
s16  y 
) [protected, virtual]

Selects the next option in the list and marks the button for redraw.

Parameters:
xThe x co-ordinate of the stylus.
yThe y co-ordinate of the stylus.

Reimplemented from WoopsiUI::Button.

virtual void WoopsiUI::CycleButton::onReleaseOutside ( s16  x,
s16  y 
) [protected, virtual]

Marks the button for redraw.

Parameters:
xThe x co-ordinate of the stylus.
yThe y co-ordinate of the stylus.

Reimplemented from WoopsiUI::Button.

virtual void WoopsiUI::CycleButton::onResize ( u16  width,
u16  height 
) [inline, protected, virtual]

Prevents the Button onResize() method from recalculating the text positions by overriding it.

Parameters:
widthThe new width.
heightThe new height.

Reimplemented from WoopsiUI::Label.

virtual void WoopsiUI::CycleButton::removeAllOptions ( ) [virtual]

Remove all options from the gadget.

virtual void WoopsiUI::CycleButton::removeOption ( const s32  index) [virtual]

Remove an option from the gadget by its index.

Parameters:
indexThe index of the option to remove.
virtual void WoopsiUI::CycleButton::selectOption ( const s32  index) [virtual]

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

Parameters:
indexThe index of the option to select.
virtual void WoopsiUI::CycleButton::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.
virtual void WoopsiUI::CycleButton::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.
virtual void WoopsiUI::CycleButton::sort ( ) [virtual]

Sort the options alphabetically by the text of the options.


Member Data Documentation

Option storage.


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