Display simple list of items which user can view and select. More...
#include <mgui/listbox.h>

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) |
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.
Listbox Style used by Create().
| MGUI::CTRL_LISTBOX::CTRL_LISTBOX | ( | ) |
Constructor.
| virtual MGUI::CTRL_LISTBOX::~CTRL_LISTBOX | ( | ) | [virtual] |
Destructor.
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.
| 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.
| 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.
| index | Zero-based index of list box item to delete |
| void MGUI::CTRL_LISTBOX::DeleteItemID | ( | ID | id | ) |
Delete item from list box given ID.
| 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.
| ID MGUI::CTRL_LISTBOX::GetItemID | ( | int | index | ) | const |
Get ID associated with list box item.
| index | Zero-based index of list box item |
| MISTRING MGUI::CTRL_LISTBOX::GetItemString | ( | int | index | ) | const |
Get text string associated with list box item.
| index | Zero-based index of list box item |
| int MGUI::CTRL_LISTBOX::GetSelectedCount | ( | ) | const |
Get number of selected items in multiple-selection list box.
| int MGUI::CTRL_LISTBOX::GetSelectedItem | ( | ) | const |
Get currently selected item in single-selection list box.
| ID MGUI::CTRL_LISTBOX::GetSelectedItemID | ( | ) | const |
Get ID of currently selected item in single-selection list box.
| 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.
| 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.
| IniHandle | Handle to INI file to read from, 0 for default | |
| IniGroup | INI group to read from | |
| IniField | INI field to read from |
Insert item at specified position in list box.
Unlike the AddItem method this does not cause the list to be resorted.
| 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.
| 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.
| 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.
| 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.
| 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.
| index | Zero-based index of list box item |
1.6.1