MAUI::ListBox Class Reference

#include <MAUI/ListBox.h>

Inheritance diagram for MAUI::ListBox:

MAUI::Widget MAUtil::TimerListener MAUI::WidgetListener List of all members.

Detailed Description

The MAUI ListBox is a very generic and flexible container that enables laying out widgets in vertical or horizontal lists. Unlike list boxes you might find in other UI toolkits, this one doesn't only support text-based items - it supports putting in any type of widget. You could add an image followed by a label, followed by another, nested ListBox. Furthermore, the navigation is decoupled from input. For instance, it provides functions such as selectNextItem() rather than assuming that the way of doing this should always be done by pressing the "down" key.


Public Types

enum  ListBoxOrientation { LBO_HORIZONTAL, LBO_VERTICAL }
enum  ListBoxAnimationType { LBA_NONE, LBA_LINEAR }

Public Member Functions

 ListBox (int x, int y, int width, int height, Widget *parent)
 ListBox (int x, int y, int width, int height, Widget *parent, ListBoxOrientation orientation, ListBoxAnimationType animType=LBA_NONE, bool wrapping=false)
virtual ~ListBox ()
void add (Widget *w)
void draw (bool forceDraw=false)
void update ()
void selectNextItem (bool shouldFireListeners=true)
void selectPreviousItem (bool shouldFireListeners=true)
void addItemSelectedListener (ItemSelectedListener *listener)
void setSelectedIndex (int selectedIndex)
void setOrientation (ListBoxOrientation orientation)
void setAnimationType (ListBoxAnimationType type)
void setWrapping (bool wrapping=true)
ListBoxAnimationType getAnimationType () const
bool isWrapping () const
int getSelectedIndex () const
void setAutoSize (bool as=true)
void setWidth (int w)
void setHeight (int h)
bool listFrontOutsideBounds () const
bool listBackOutsideBounds () const
int getScrollOffset () const
void setParent (Widget *w)
WidgetgetParent ()
Vector< Widget * > & getChildren ()
const Vector< Widget * > & getChildren () const
void requestRepaint ()
virtual bool isTransparent () const
virtual void setSkin (WidgetSkin *widgetSkin)
void setDrawBackground (bool b=true)
void setBackgroundColor (int col)
WidgetwidgetAt (const Point &p)
WidgetwidgetAt (int x, int y)
virtual void setPosition (int x, int y)
const PointgetPosition () const
const PointgetPaddedPosition () const
int getWidth () const
int getHeight () const
virtual const RectgetBounds ()
virtual bool contains (const Point &p)
virtual bool contains (int x, int y)
virtual void setSelected (bool selected=true)
bool isSelected () const
virtual void setEnabled (bool enabled=true)
bool isEnabled () const
virtual void trigger ()
void addWidgetListener (WidgetListener *wl)
void removeWidgetListener (WidgetListener *wl)
Vector< WidgetListener * > & getWidgetListeners ()
void setInputManager (InputManager *inputManager)
virtual void setPaddingLeft (int l)
virtual void setPaddingTop (int t)
virtual void setPaddingRight (int r)
virtual void setPaddingBottom (int b)
int getPaddingLeft () const
int getPaddingTop () const
int getPaddingRight () const
int getPaddingBottom () const
const RectgetPaddedBounds () const
virtual void setParameter (const String &name, const String &value)

Protected Member Functions

void runTimerEvent ()
void drawWidget ()
void rebuild ()
void boundsChanged (Widget *widget, const Rect &bounds)
void drawBackground ()
void updateAbsolutePosition ()
void updateAbsolutePositionChildren (int x, int y)
void updatePaddedBounds ()
bool isDirty () const
void setDirty (bool d=true)

Protected Attributes

bool mustRebuild
Vector< ItemSelectedListener * > itemSelectedListeners
bool wrapping
ListBoxAnimationType animationType
ListBoxOrientation orientation
int yOffsetFrom
int yOffsetTo
int yOffset
int yOffsetInc
int animTimeStart
int selectedIndex
bool autoSize
Vector< Widget * > children
Widgetparent
Rect bounds
int relX
int relY
bool dirty
WidgetSkinskin
int backColor
bool shouldDrawBackground
bool selected
bool enabled
Vector< WidgetListener * > widgetListeners
InputManagermInputManager
Rect paddedBounds
int paddingLeft
int paddingTop
int paddingBottom
int paddingRight


Member Enumeration Documentation

enum MAUI::ListBox::ListBoxOrientation
 

Enumerator:
LBO_HORIZONTAL 
LBO_VERTICAL 

enum MAUI::ListBox::ListBoxAnimationType
 

Enumerator:
LBA_NONE 
LBA_LINEAR 


Constructor & Destructor Documentation

MAUI::ListBox::ListBox int  x,
int  y,
int  width,
int  height,
Widget parent
 

Constructor.

Parameters:
x the horizontal position of the ListBox relative to its parent's top left padded corner.
y the vertical position of the ListBox relative to its parent's top left padded corner
width the width of the ListBox.
height the height of the ListBox.
parent pointer to the parent widget. Passing anything else than NULL causes the ListBox to be added to the parent's children.

MAUI::ListBox::ListBox int  x,
int  y,
int  width,
int  height,
Widget parent,
ListBoxOrientation  orientation,
ListBoxAnimationType  animType = LBA_NONE,
bool  wrapping = false
 

Constructor.

Parameters:
x the horizontal position of the ListBox relative to its parent's top left padded corner.
y the vertical position of the ListBox relative to its parent's top left padded corner
width the width of the ListBox.
height the height of the ListBox.
parent pointer to the parent widget. Passing anything else than NULL causes the ListBox to be added to the parent's children.
orientation controls the orientation of the ListBox
animType controls the type of animation used when scrolling the listbox content.
wrapping controls the behavior of the listbox when navigating. When set to true, the listbox will wrap around to selecting the first element when moving beyond the last one, and equivalently wrap around to the last one when moving back beyond the first one.

virtual MAUI::ListBox::~ListBox  )  [virtual]
 

Destructor


Member Function Documentation

void MAUI::ListBox::add Widget w  )  [virtual]
 

Addes the Widget w as a child of the listbox

Reimplemented from MAUI::Widget.

void MAUI::ListBox::draw bool  forceDraw = false  )  [virtual]
 

Renders the listbox

Reimplemented from MAUI::Widget.

void MAUI::ListBox::update  )  [virtual]
 

Reimplemented from MAUI::Widget.

void MAUI::ListBox::selectNextItem bool  shouldFireListeners = true  ) 
 

Navigates to the next item in the listbox - down if the orientation is vertical, right if it's horizontal.

void MAUI::ListBox::selectPreviousItem bool  shouldFireListeners = true  ) 
 

Navigates to the previous item in the listbox - up if the orientation is vertical, left if it's horizontal.

void MAUI::ListBox::addItemSelectedListener ItemSelectedListener listener  ) 
 

Adds a item selection listener

void MAUI::ListBox::setSelectedIndex int  selectedIndex  ) 
 

Specifies which item in the ListBox should be selected

void MAUI::ListBox::setOrientation ListBoxOrientation  orientation  ) 
 

Sets the orientation of the ListBox

void MAUI::ListBox::setAnimationType ListBoxAnimationType  type  ) 
 

Sets the type of animation to be used by the ListBox

void MAUI::ListBox::setWrapping bool  wrapping = true  ) 
 

Controls the wrapping behavior of the ListBox

ListBoxAnimationType MAUI::ListBox::getAnimationType  )  const
 

Returns the type of animation used by the List Box

bool MAUI::ListBox::isWrapping  )  const
 

Returns whether the ListBox will wrap around when moving beyond the first or last element

int MAUI::ListBox::getSelectedIndex  )  const
 

Returns the index of the ListBox's currently selected child widget

void MAUI::ListBox::setAutoSize bool  as = true  ) 
 

Sets autosizing on a ListBox. This autosizes the children of the listbox in the opposite direction of the orientation. I.e. if the list box is vertically oriented, the widgets will be resized to the width of the listbox (the padded width), and vice versa.

void MAUI::ListBox::setWidth int  w  )  [virtual]
 

Overloaded setWidth. If autosizing is set and the orientation is vertical on the ListBox this will set the width of the children.

Reimplemented from MAUI::Widget.

void MAUI::ListBox::setHeight int  h  )  [virtual]
 

Overloaded setHeight. If autosizing is set and the orientation is horizontal on the ListBox this will set the height of the children.

Reimplemented from MAUI::Widget.

bool MAUI::ListBox::listFrontOutsideBounds  )  const
 

Returns true if child widgets is outside of the front of the list.

bool MAUI::ListBox::listBackOutsideBounds  )  const
 

Returns true if child widgets is outside of the back of the list.

int MAUI::ListBox::getScrollOffset  )  const
 

Returns the listboxes' current scroll offset in pixels.

void MAUI::ListBox::runTimerEvent  )  [protected, virtual]
 

Implements MAUtil::TimerListener.

void MAUI::ListBox::drawWidget  )  [protected, virtual]
 

This is the only function that is absolutely neccesary to implement when inheriting Widget to create a custom widget. It is responsible for painting the widget. When it is called, the widget must respect its own padded bounds and not extend rendering beyond that area.

Implements MAUI::Widget.

void MAUI::ListBox::rebuild  )  [protected]
 

void MAUI::ListBox::boundsChanged Widget widget,
const Rect bounds
[protected, virtual]
 

This function is called whenever the widget being listened to is resized or moved.

Reimplemented from MAUI::WidgetListener.

void MAUI::Widget::setParent Widget w  )  [inherited]
 

Function used to set the parent of a widget. The widget will not be added to the parent as a child. The widget cannot have a parent already.

Widget* MAUI::Widget::getParent  )  [inherited]
 

Function to retrieve the parent of a widget.

Vector<Widget*>& MAUI::Widget::getChildren  )  [inherited]
 

Function to retrieve a reference to the list of childrens for a widget.

const Vector<Widget*>& MAUI::Widget::getChildren  )  const [inherited]
 

const version of getChildren()

void MAUI::Widget::requestRepaint  )  [inherited]
 

Registers an idle listener with the current environment that will redraw the widget and anything else that may be made dirty by doing so. For instance, if the widget is transparent its parent also has to be repainted, and so on recursively.

virtual bool MAUI::Widget::isTransparent  )  const [virtual, inherited]
 

Returns whether or not the widget is transparent. A widget is transparent if it has a skin that is transparent in the current selection state (selected/unselected) or if it has no solid background color.

virtual void MAUI::Widget::setSkin WidgetSkin widgetSkin  )  [virtual, inherited]
 

Assigns a widget skin to be used during the rendering of the widget. What The skin applies to varies depending on the widget. Labels extend the skin over their entire area, while listboxes apply the skin to each individual item they contain.

void MAUI::Widget::setDrawBackground bool  b = true  )  [inherited]
 

Sets the background drawing state. If b is true, the Widget's background will be drawn - otherwise not. In most cases, the background is either a constant color or a skin.

void MAUI::Widget::setBackgroundColor int  col  )  [inherited]
 

Widget* MAUI::Widget::widgetAt const Point p  )  [inherited]
 

Returns a pointer to the first child widget or deeper descendant, surrounding the point. Returns NULL if no widget is found.

Widget* MAUI::Widget::widgetAt int  x,
int  y
[inherited]
 

virtual void MAUI::Widget::setPosition int  x,
int  y
[virtual, inherited]
 

Sets the widget's position relative to its parent.

Reimplemented in MAUI::Layout.

const Point& MAUI::Widget::getPosition  )  const [inherited]
 

Gets the widget's position relative to its parent.

const Point& MAUI::Widget::getPaddedPosition  )  const [inherited]
 

Gets the widget's padded position relative to its parent.

int MAUI::Widget::getWidth  )  const [inherited]
 

Returns the width of the widget

int MAUI::Widget::getHeight  )  const [inherited]
 

Returns the height of the widget

virtual const Rect& MAUI::Widget::getBounds  )  [virtual, inherited]
 

Returns a Rect containing the absolute screen position of the widget together with its dimensions.

virtual bool MAUI::Widget::contains const Point p  )  [virtual, inherited]
 

Check if widget surrounds position 'p'.

virtual bool MAUI::Widget::contains int  x,
int  y
[virtual, inherited]
 

Check if widget surrounds position 'x' and 'y'.

virtual void MAUI::Widget::setSelected bool  selected = true  )  [virtual, inherited]
 

Set widget selected state (default: true).

Reimplemented in MAUI::EditBox.

bool MAUI::Widget::isSelected  )  const [inherited]
 

Is widget selected?.

virtual void MAUI::Widget::setEnabled bool  enabled = true  )  [virtual, inherited]
 

Set Widget enabled state

Reimplemented in MAUI::EditBox.

bool MAUI::Widget::isEnabled  )  const [inherited]
 

Is Widget enabled ?

virtual void MAUI::Widget::trigger  )  [virtual, inherited]
 

This function is called whenever the widget is "triggered", which is roughly equivalent to having been "clicked" on. However, sice MAUI is independant of input facilities, the more input-neutral concept of triggering is used.

Reimplemented in MAUI::Layout.

void MAUI::Widget::addWidgetListener WidgetListener wl  )  [inherited]
 

Add WidgetListener.

void MAUI::Widget::removeWidgetListener WidgetListener wl  )  [inherited]
 

Remove WidgetListener.

Vector<WidgetListener*>& MAUI::Widget::getWidgetListeners  )  [inherited]
 

returns a reference the the vector of Widget listeners

void MAUI::Widget::setInputManager InputManager inputManager  )  [inherited]
 

Sets the input manager to use for this widget

virtual void MAUI::Widget::setPaddingLeft int  l  )  [virtual, inherited]
 

Set left padding width.

Reimplemented in MAUI::Label.

virtual void MAUI::Widget::setPaddingTop int  t  )  [virtual, inherited]
 

Set top padding height.

Reimplemented in MAUI::Label.

virtual void MAUI::Widget::setPaddingRight int  r  )  [virtual, inherited]
 

Set right padding width.

Reimplemented in MAUI::Label.

virtual void MAUI::Widget::setPaddingBottom int  b  )  [virtual, inherited]
 

Set bottom padding height.

Reimplemented in MAUI::Label.

int MAUI::Widget::getPaddingLeft  )  const [inherited]
 

Get left padding width.

int MAUI::Widget::getPaddingTop  )  const [inherited]
 

Get top padding height.

int MAUI::Widget::getPaddingRight  )  const [inherited]
 

Get right padding width.

int MAUI::Widget::getPaddingBottom  )  const [inherited]
 

Get bottom padding height.

const Rect& MAUI::Widget::getPaddedBounds  )  const [inherited]
 

virtual void MAUI::Widget::setParameter const String name,
const String value
[virtual, inherited]
 

Reimplemented in MAUI::Label.

void MAUI::Widget::drawBackground  )  [protected, inherited]
 

void MAUI::Widget::updateAbsolutePosition  )  [protected, inherited]
 

This function is used to regenerate the absolute positions of each widget in the tree. This is done in a depth first manner where each widget takes the parent absolute position and adds it to their own relative position to calculate their absolute position.

void MAUI::Widget::updateAbsolutePositionChildren int  x,
int  y
[protected, inherited]
 

the recursive function used by updateAbsolutePosition().

void MAUI::Widget::updatePaddedBounds  )  [protected, inherited]
 

Used to recalculate the padded bounds from the global bounds.

bool MAUI::Widget::isDirty  )  const [protected, inherited]
 

Returns the dirty state of the widget, indicating whether it requires to be redrawn or not. When a widget calls requestRepaint(), it's dirty state is set to true. Normally, you shouldn't have to use isDirty() or setDirty() unless possibly when implementing your own widgets.

void MAUI::Widget::setDirty bool  d = true  )  [protected, inherited]
 

Sets the dirty state of the widget.


Member Data Documentation

bool MAUI::ListBox::mustRebuild [protected]
 

Vector<ItemSelectedListener*> MAUI::ListBox::itemSelectedListeners [protected]
 

bool MAUI::ListBox::wrapping [protected]
 

ListBoxAnimationType MAUI::ListBox::animationType [protected]
 

ListBoxOrientation MAUI::ListBox::orientation [protected]
 

int MAUI::ListBox::yOffsetFrom [protected]
 

int MAUI::ListBox::yOffsetTo [protected]
 

int MAUI::ListBox::yOffset [protected]
 

int MAUI::ListBox::yOffsetInc [protected]
 

int MAUI::ListBox::animTimeStart [protected]
 

int MAUI::ListBox::selectedIndex [protected]
 

bool MAUI::ListBox::autoSize [protected]
 

Vector<Widget*> MAUI::Widget::children [protected, inherited]
 

Widget* MAUI::Widget::parent [protected, inherited]
 

Rect MAUI::Widget::bounds [protected, inherited]
 

int MAUI::Widget::relX [protected, inherited]
 

int MAUI::Widget::relY [protected, inherited]
 

bool MAUI::Widget::dirty [protected, inherited]
 

WidgetSkin* MAUI::Widget::skin [protected, inherited]
 

int MAUI::Widget::backColor [protected, inherited]
 

bool MAUI::Widget::shouldDrawBackground [protected, inherited]
 

bool MAUI::Widget::selected [protected, inherited]
 

bool MAUI::Widget::enabled [protected, inherited]
 

Vector<WidgetListener*> MAUI::Widget::widgetListeners [protected, inherited]
 

InputManager* MAUI::Widget::mInputManager [protected, inherited]
 

Rect MAUI::Widget::paddedBounds [protected, inherited]
 

int MAUI::Widget::paddingLeft [protected, inherited]
 

int MAUI::Widget::paddingTop [protected, inherited]
 

int MAUI::Widget::paddingBottom [protected, inherited]
 

int MAUI::Widget::paddingRight [protected, inherited]
 


Generated on Sat Feb 13 00:15:39 2010 for MoSync 2 beta 1 by  doxygen 1.4.6-NO