class MASKING_DLL_DECLSPEC ListView

An internal helper widget for the ListBox.

Inheritance:

ListView - Widget - Rect


Public Methods

[more]int TotalItems()
Returns the number of items in the list
[more]int VisibleItems()
Returns the number of items the list can display on one screen
[more]bool Selected(int i)
Tests if item i is selected or not
[more]void Select(int i)
Selects item i.
[more]void Deselect(int i)
Deselects item i
[more]int Selection()
Returns the index of the firs selected item in the list, 0 if none are selected
[more]void ScrollToSelection()
Attempts to scroll the list to the first selected item
[more]int Focus()
Returns the index of the focused item.
[more]void SetFocus(int i)
Moves focus to item i.
[more]void InsertItem(ListItem* item, int i=0)
Inserts a new item to the list at index i
[more]ListItem* GetItem(int i)
Returns a pointer to the item with index i
[more]ListItem* GetFocusedItem()
Returns a pointer to the focused item.
[more]ListItem* GetSelectedItem()
Returns a pointer to the first selected item in the list.
[more]void DeleteItem(int i)
Deletes item i from the list
[more]void DeleteAllItems()
Clears the list
[more]int Offset()
Returns how far the list has scrolled
[more]void Sort()
Sorts the list in ascending order according to the list item text regardless of case
[more]void Sort(bool (*cmp)(const ListItem* , const ListItem* ))
Sorts the list by using the given comparison function.
[more]bool GetSingleClick()
Returns whether the list is in single click mode or not
[more]void SetSingleClick(bool single=false)
Sets the single click mode for the list on or off

Protected Fields

[more]std::vector<ListItem *> items
The actual list (vector actually) of list items
[more]int offset
Stores how far the list has scrolled
[more]int focus
The index of the item with the focus (the item under the mouse)
[more]bool multiSelect
True when the list is in multiselect mode.
[more]bool singleClick
If true then the listbox responds to single clicks on the list as activation

Protected Methods

[more]void MsgInitSkin()
Initilizes the list view with the default bitmaps, fonts and font colours as defined by the skin
[more]void Draw(Bitmap &canvas)
Draws the list view by drawing all the list items
[more]bool MsgWantfocus()
A list view takes focus so this function returns true
[more]bool MsgChar(int c)
Handles keyboard input.
[more]void MsgLPress()
Handles mouse input.
[more]void MsgLRelease()
Issues a MsgDClick() in case the singleClick flag is set
[more]void MsgDClick()
Sends MSG_ACTIVATE to the parent dialog
[more]void MsgMousemove(const Point& d)
Makes sure the focus follows the mouse
[more]void DeselectAllItems()
A helper function for deselecting all items
[more]int FindMouseItem()
Returns the index of the item the mouse is on top of.


Documentation

An internal helper widget for the ListBox.

This is the core of a ListBox. It contains a list of list items, it provides an inteface for working with this list, it draws the background and the items and it handles mouse clicks, mouse moves and keyboard input.

ostd::vector<ListItem *> items
The actual list (vector actually) of list items

oint offset
Stores how far the list has scrolled

oint focus
The index of the item with the focus (the item under the mouse)

obool multiSelect
True when the list is in multiselect mode. In this mode more than one item can be selected at once while in normal mode only one can be selected.

obool singleClick
If true then the listbox responds to single clicks on the list as activation

ovoid MsgInitSkin()
Initilizes the list view with the default bitmaps, fonts and font colours as defined by the skin

ovoid Draw(Bitmap &canvas)
Draws the list view by drawing all the list items

obool MsgWantfocus()
A list view takes focus so this function returns true

obool MsgChar(int c)
Handles keyboard input. The list can be navigated with the cursor keys, home, end, page up and page down. In multiselect mode items can be selected and deselected with spacebar. If enter is pressed (or space in normal mode) the list sends MSG_ACTIVATE to the parent dialog.

ovoid MsgLPress()
Handles mouse input. Whenever the left mouse button is pressed the item with the mouse is either selected (normal mode) or toggled (multiselect mode).

ovoid MsgLRelease()
Issues a MsgDClick() in case the singleClick flag is set

ovoid MsgDClick()
Sends MSG_ACTIVATE to the parent dialog

ovoid MsgMousemove(const Point& d)
Makes sure the focus follows the mouse

ovoid DeselectAllItems()
A helper function for deselecting all items

oint FindMouseItem()
Returns the index of the item the mouse is on top of. If no item is found this function returns -1.

oint TotalItems()
Returns the number of items in the list

oint VisibleItems()
Returns the number of items the list can display on one screen

obool Selected(int i)
Tests if item i is selected or not

ovoid Select(int i)
Selects item i. If multiselect mode is off this will first deselect the previously selected item.

ovoid Deselect(int i)
Deselects item i

oint Selection()
Returns the index of the firs selected item in the list, 0 if none are selected

ovoid ScrollToSelection()
Attempts to scroll the list to the first selected item

oint Focus()
Returns the index of the focused item. In normal mode focused and selected items are one and the same.

ovoid SetFocus(int i)
Moves focus to item i. In normal mode this also selects item i.

ovoid InsertItem(ListItem* item, int i=0)
Inserts a new item to the list at index i

oListItem* GetItem(int i)
Returns a pointer to the item with index i

oListItem* GetFocusedItem()
Returns a pointer to the focused item. If no item has focus it returns NULL!

oListItem* GetSelectedItem()
Returns a pointer to the first selected item in the list. In normal mode this is the same as the focused item. If no item is selected it returns NULL!

ovoid DeleteItem(int i)
Deletes item i from the list

ovoid DeleteAllItems()
Clears the list

oint Offset()
Returns how far the list has scrolled

ovoid Sort()
Sorts the list in ascending order according to the list item text regardless of case

ovoid Sort(bool (*cmp)(const ListItem* , const ListItem* ))
Sorts the list by using the given comparison function. The function should compare two items and return true if the first item is smaller than the second one.

obool GetSingleClick()
Returns whether the list is in single click mode or not

ovoid SetSingleClick(bool single=false)
Sets the single click mode for the list on or off


This class has no child classes.
Friends:
class MASKING_DLL_DECLSPEC ListBox
See Also:
ListItem, ListBox

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++