MGUI::CTRL_LISTBOX Class Reference

Display simple list of items which user can view and select. More...

#include <mgui/listbox.h>

Inheritance diagram for MGUI::CTRL_LISTBOX:
Inheritance graph
[legend]

List of all members.

Public Types

enum  STYLE {
  STYLE_Default = 0x00, STYLE_Sorted = 0x01, STYLE_MultiSelect = 0x02, STYLE_ExtendedSelect = 0x04,
  STYLE_ResizeIfPossible = 0x08, STYLE_ExpandIfNeeded = 0x10
}

Public Member Functions

 CTRL_LISTBOX ()
virtual ~CTRL_LISTBOX ()
int AddItem (ID id, const MISTRING &string, bool resize=true)
void Create (MGUI::LAYOUT_PANE_BASE &ParentPane, int height=5, int width=0, MGUI::LAYOUT_SIZEALIGN sizealign=MGUI::LAYOUT_SIZEALIGN_Expand, STYLE style=STYLE_Default)
void DeleteAllItems ()
void DeleteItem (int index)
void DeleteItemID (ID id)
void DeselectAllItems ()
int GetCount () const
int GetIndexFromID (ID id) const
ID GetItemID (int index) const
MISTRING GetItemString (int index) const
int GetSelectedCount () const
int GetSelectedItem () const
ID GetSelectedItemID () const
ERRVALUE GetSelectedItems (SIMPLE_ARRAY< int > &items) const
int GetTopIndex () const
void IniRead (INIHANDLE IniHandle, const char *IniGroup, const char *IniField, bool notify=true)
void IniWrite (INIHANDLE IniHandle, const char *IniGroup, const char *IniField) const
int InsertItem (int index, ID id, const MISTRING &string)
bool IsItemSelected (int index) const
void SetDelegateOnChangeSelection (DELEGATE_VOID_NOPARMS delegate)
void SetDelegateOnDoubleClick (DELEGATE_VOID_NOPARMS delegate)
void SetItemSelected (int index, bool select=true)
void SetSelectedItem (int index)
void SetSelectedItemID (ID id)
void SetTopIndex (int index)

Detailed Description

Display simple list of items which user can view and select.

In a single-selection list box, the user can select only one item. In a multiple-selection list box, a range of items can be selected.


Member Enumeration Documentation

Listbox Style used by Create().

Enumerator:
STYLE_Default 
STYLE_Sorted 
STYLE_MultiSelect 

Multiple items selectable by simple toggle of each item.

STYLE_ExtendedSelect 

Multiple items selectable by SHIFT/CTRL key and mouse.

STYLE_ResizeIfPossible 

Try to expand and shrink to fit widest item. (uses scrollbar if it can't resize).

STYLE_ExpandIfNeeded 

Try to expand fit widest item. (uses scrollbar if it can't resize).


Constructor & Destructor Documentation

MGUI::CTRL_LISTBOX::CTRL_LISTBOX (  ) 

Constructor.

virtual MGUI::CTRL_LISTBOX::~CTRL_LISTBOX (  )  [virtual]

Destructor.


Member Function Documentation

int MGUI::CTRL_LISTBOX::AddItem ( ID  id,
const MISTRING string,
bool  resize = true 
)

Add item to list box with MISTRING or TEXTID.

If list box was created with STYLE_Sorted then the list will be resorted after the item is added, otherwise the item will be added to the end of the list.

Returns:
Zero-based index of item added or error < 0.
Parameters:
id ID to attach to item
string String to show in list
resize Attempt to resize if needed to fit new item string
void MGUI::CTRL_LISTBOX::Create ( MGUI::LAYOUT_PANE_BASE ParentPane,
int  height = 5,
int  width = 0,
MGUI::LAYOUT_SIZEALIGN  sizealign = MGUI::LAYOUT_SIZEALIGN_Expand,
STYLE  style = STYLE_Default 
)

Create the list box control.

Parameters:
ParentPane Parent pane
height Height in characters
width Width in 'typical' characters
void MGUI::CTRL_LISTBOX::DeleteAllItems (  ) 

Delete all items from list box.

void MGUI::CTRL_LISTBOX::DeleteItem ( int  index  ) 

Delete item from list box.

Parameters:
index Zero-based index of list box item to delete
void MGUI::CTRL_LISTBOX::DeleteItemID ( ID  id  ) 

Delete item from list box given ID.

Parameters:
id ID of item to delete
void MGUI::CTRL_LISTBOX::DeselectAllItems (  ) 

Deselect all items in multiple-selection list box.

This method should not be used on single-selection list boxes.

int MGUI::CTRL_LISTBOX::GetCount (  )  const

Retrieve number of items in the list box.

int MGUI::CTRL_LISTBOX::GetIndexFromID ( ID  id  )  const

Get index to item from ID.

Returns:
Zero-based index or -1 if no matching item found.
ID MGUI::CTRL_LISTBOX::GetItemID ( int  index  )  const

Get ID associated with list box item.

Returns:
ID specified when item was added.
Parameters:
index Zero-based index of list box item
MISTRING MGUI::CTRL_LISTBOX::GetItemString ( int  index  )  const

Get text string associated with list box item.

Returns:
String containing text, will be empty if invalid item.
Parameters:
index Zero-based index of list box item
int MGUI::CTRL_LISTBOX::GetSelectedCount (  )  const

Get number of selected items in multiple-selection list box.

Returns:
Number of selected items or 0 if none selected.
int MGUI::CTRL_LISTBOX::GetSelectedItem (  )  const

Get currently selected item in single-selection list box.

Returns:
Zero-based index of selected item or -1 if none selected.
ID MGUI::CTRL_LISTBOX::GetSelectedItemID (  )  const

Get ID of currently selected item in single-selection list box.

Returns:
ID or -1 if none selected.
ERRVALUE MGUI::CTRL_LISTBOX::GetSelectedItems ( SIMPLE_ARRAY< int > &  items  )  const

Retrieve indices of selected items in multiple-selection list box.

int MGUI::CTRL_LISTBOX::GetTopIndex (  )  const

Retrieve zero-based index of first visible item in list box.

void MGUI::CTRL_LISTBOX::IniRead ( INIHANDLE  IniHandle,
const char *  IniGroup,
const char *  IniField,
bool  notify = true 
)

Read setting from INI file.

If Create() has already been performed the control's state will be updated.

Parameters:
IniHandle Handle to INI file to read from, 0 for default
IniGroup INI group to read from
IniField INI field to read from
notify Call OnSelection() if control has already been created
void MGUI::CTRL_LISTBOX::IniWrite ( INIHANDLE  IniHandle,
const char *  IniGroup,
const char *  IniField 
) const [inline]

Write currently selected item ID to INI file.

Parameters:
IniHandle Handle to INI file to read from, 0 for default
IniGroup INI group to read from
IniField INI field to read from
int MGUI::CTRL_LISTBOX::InsertItem ( int  index,
ID  id,
const MISTRING string 
)

Insert item at specified position in list box.

Unlike the AddItem method this does not cause the list to be resorted.

Returns:
Zero-based index of item added or error < 0.
Parameters:
index Zero-based index of position at which item should be inserted
id ID to attach to item
string String to show in list
bool MGUI::CTRL_LISTBOX::IsItemSelected ( int  index  )  const

Determine if specified item in list box is selected.

Parameters:
index Zero-based index of list box item
void MGUI::CTRL_LISTBOX::SetDelegateOnChangeSelection ( DELEGATE_VOID_NOPARMS  delegate  )  [inline]

Set delegate to call when user changes selected items.

void MGUI::CTRL_LISTBOX::SetDelegateOnDoubleClick ( DELEGATE_VOID_NOPARMS  delegate  )  [inline]

Set delegate to call when user double-clicks on item.

void MGUI::CTRL_LISTBOX::SetItemSelected ( int  index,
bool  select = true 
)

Select or deselect item in multiple-selection list box.

This method should not be used on single-selection list boxes.

Parameters:
index Zero-based index of list box item.
select Specifies how to set the selection, true to select, false to deselect.
void MGUI::CTRL_LISTBOX::SetSelectedItem ( int  index  ) 

Select item in single-selection list box.

If item is not visible the list box will be scrolled to make it visible. This method should not be used on multiple-selection list boxes.

Parameters:
index Zero-based index of list box item, -1 to have no item selected
void MGUI::CTRL_LISTBOX::SetSelectedItemID ( ID  id  ) 

Select item in list box using item ID.

If item does not exist then no item will be selected. If item is not visible the list box will be scrolled to make it visible.

Parameters:
id ID of item to select
void MGUI::CTRL_LISTBOX::SetTopIndex ( int  index  ) 

Scroll list box until item specified by index is at the top or maximum scroll range reached.

Parameters:
index Zero-based index of list box item

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

Generated on Sun Oct 7 21:35:33 2012 for TNTsdk 2012 by  doxygen 1.6.1