Vaca::ListBox Class Reference

#include <ListBox.h>

Inheritance diagram for Vaca::ListBox:

Vaca::Widget Vaca::Component Vaca::Referenceable Vaca::NonCopyable Vaca::DragListBox

List of all members.


Detailed Description

List box control.

Widget to manage a list of strings.

Public Member Functions

 ListBox (Widget *parent, Style style=ListBoxStyle)
 Creates a ListBox.
virtual ~ListBox ()
int addItem (const String &text)
 (LB_ADDSTRING)
void insertItem (int itemIndex, const String &text)
 (LB_INSERTSTRING)
void removeItem (int itemIndex)
int getItemCount ()
 (LB_GETCOUNT)
Rect getItemBounds (int itemIndex)
 Returns the rectangle that the item itemIndex uses (LB_GETITEMRECT).
String getItemText (int itemIndex)
 (LB_GETTEXT and LB_GETTEXTLEN)
void setItemText (int itemIndex, const String &text)
int getCurrentItem ()
 Returns the current selected item index (LB_GETCURSEL).
void setCurrentItem (int itemIndex)
 Changes the current selected item to the itemIndex only (LB_SETCURSEL).
std::vector< int > getSelectedItems ()
 Returns the set of selected items (it's useful for ListBoxes with the LBS_MULTIPLESEL style).

Public Attributes

Signal1< void, Event & > Action
Signal1< void, Event & > SelChange

Protected Member Functions

virtual void onPreferredSize (Size &sz)
 It should calculates the preferred size for this widget.
virtual void onAction (Event &ev)
 When the user press double-click in some item (LBN_DBLCLK).
virtual void onSelChange (Event &ev)
 When the user changes the current selected item (LBN_SELCHANGE).
virtual bool onReflectedCommand (int id, int code, LRESULT &lResult)
 This method can be used to handle command notifications (WM_COMMAND(W32)) reflected from the parent.


Constructor & Destructor Documentation

ListBox::ListBox ( Widget parent,
Style  style = ListBoxStyle 
)

Creates a ListBox.

The default background color for a ListBox is System::getColor(COLOR_WINDOW).

Parameters:
parent The parent Widget.
style Add the LBS_MULTIPLESEL if you want a multiselection ListBox.

ListBox::~ListBox (  )  [virtual]


Member Function Documentation

int ListBox::addItem ( const String text  ) 

(LB_ADDSTRING)

void ListBox::insertItem ( int  itemIndex,
const String text 
)

(LB_INSERTSTRING)

void ListBox::removeItem ( int  itemIndex  ) 

int ListBox::getItemCount (  ) 

(LB_GETCOUNT)

Rect ListBox::getItemBounds ( int  itemIndex  ) 

Returns the rectangle that the item itemIndex uses (LB_GETITEMRECT).

itemIndex is zero-based.

String ListBox::getItemText ( int  itemIndex  ) 

(LB_GETTEXT and LB_GETTEXTLEN)

void ListBox::setItemText ( int  itemIndex,
const String text 
)

int ListBox::getCurrentItem (  ) 

Returns the current selected item index (LB_GETCURSEL).

Returns -1 if there aren't selection at all.

void ListBox::setCurrentItem ( int  itemIndex  ) 

Changes the current selected item to the itemIndex only (LB_SETCURSEL).

std::vector< int > ListBox::getSelectedItems (  ) 

Returns the set of selected items (it's useful for ListBoxes with the LBS_MULTIPLESEL style).

void ListBox::onPreferredSize ( Size sz  )  [protected, virtual]

It should calculates the preferred size for this widget.

Parameters:
sz It's for input and output. You should put the preferred size in this value, but also you should read the input value to know if you must to fit the widget in some size. The possible values for sz are:
  • sz = Size(0, 0) to calculate the preferred size without restrictions.
  • sz = Size(width, 0) to calculate the preferred size with restricted <= width.
  • sz = Size(0, height) to calculate the preferred size with restricted <= height.

Reimplemented from Vaca::Widget.

void ListBox::onAction ( Event ev  )  [protected, virtual]

When the user press double-click in some item (LBN_DBLCLK).

void ListBox::onSelChange ( Event ev  )  [protected, virtual]

When the user changes the current selected item (LBN_SELCHANGE).

bool ListBox::onReflectedCommand ( int  id,
int  code,
LRESULT &  lResult 
) [protected, virtual]

This method can be used to handle command notifications (WM_COMMAND(W32)) reflected from the parent.

Parameters:
id Identifier of the control or menu item.
code Notification code.
lResult Result to return by the wndProc method.
Win32 Specific:
Don't confuse with onCommand: onReflectedCommand is used to handle commands that this widget by self generated, were sent to the parent, and finally were reflected to this widget again by the parent.

Reimplemented from Vaca::Widget.


Member Data Documentation

See also:
onAction

See also:
onSelChange