NXWidgets  1.19
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NXWidgets::CListData Class Reference

#include <clistdata.hxx>

Public Member Functions

 CListData (void)
 
virtual ~CListData (void)
 
virtual void addItem (const CNxString &text, const uint32_t value)
 
virtual void addItem (CListDataItem *item)
 
virtual void removeItem (const int index)
 
virtual void selectItem (const int index)
 
virtual void deselectItem (const int index)
 
virtual void removeAllItems (void)
 
virtual const int getSelectedIndex (void) const
 
virtual void setSelectedIndex (const int index)
 
virtual const CListDataItemgetSelectedItem (void) const
 
virtual void setAllowMultipleSelections (const bool allowMultipleSelections)
 
virtual const CListDataItemgetItem (const int index) const
 
virtual void sort (void)
 
virtual const int getItemCount (void) const
 
virtual void selectAllItems (void)
 
virtual void deselectAllItems (void)
 
virtual void setItemSelected (const int index, const bool selected)
 
virtual const bool allowsMultipleSelections (void) const
 
virtual void setSortInsertedItems (const bool sortInsertedItems)
 
void addListDataEventHandler (IListDataEventHandler *eventHandler)
 
void removeListDataEventHandler (IListDataEventHandler *eventHandler)
 

Protected Member Functions

virtual void quickSort (const int start, const int end)
 
virtual void swapItems (const int index1, const int index2)
 
const int getSortedInsertionIndex (const CListDataItem *item) const
 
void raiseDataChangedEvent (void)
 
void raiseSelectionChangedEvent (void)
 

Protected Attributes

TNxArray< CListDataItem * > m_items
 
TNxArray< IListDataEventHandler * > m_listDataEventhandlers
 
bool m_allowMultipleSelections
 
bool m_sortInsertedItems
 

Detailed Description

Class representing a list of items. Designed to be used by the CListBox class, etc, to store its data. Fires events to notify listeners when the list changes or a new selection is made.

Definition at line 107 of file clistdata.hxx.

Constructor & Destructor Documentation

◆ CListData()

CListData::CListData ( void  )

Constructor.

Definition at line 97 of file clistdata.cxx.

◆ ~CListData()

CListData::~CListData ( void  )
virtual

Destructor.

Definition at line 107 of file clistdata.cxx.

Member Function Documentation

◆ addItem() [1/2]

void CListData::addItem ( const CNxString text,
const uint32_t  value 
)
virtual

Add a new item.

Parameters
textText to show in the option.
valueThe value of the option.

Definition at line 119 of file clistdata.cxx.

◆ addItem() [2/2]

void CListData::addItem ( CListDataItem item)
virtual

Add an existing item. CListData becomes the owner of the option and will delete it when the list is deleted.

Parameters
itemThe item to add.

Definition at line 133 of file clistdata.cxx.

◆ addListDataEventHandler()

void NXWidgets::CListData::addListDataEventHandler ( IListDataEventHandler eventHandler)
inline

Add an event handler.

Parameters
eventHandlerThe event handler to add.

Definition at line 341 of file clistdata.hxx.

◆ allowsMultipleSelections()

virtual const bool NXWidgets::CListData::allowsMultipleSelections ( void  ) const
inlinevirtual

Returns whether multiple selections are possible or not.

Returns
True if multiple selections are allowed.

Definition at line 318 of file clistdata.hxx.

◆ deselectAllItems()

void CListData::deselectAllItems ( void  )
virtual

Deselect all items.

Definition at line 299 of file clistdata.cxx.

◆ deselectItem()

void CListData::deselectItem ( const int  index)
virtual

Deselect an item by its index.

Parameters
indexThe index of the item to select.

Definition at line 193 of file clistdata.cxx.

◆ getItem()

virtual const CListDataItem* NXWidgets::CListData::getItem ( const int  index) const
inlinevirtual

Get the specified item.

Returns
The specified item.

Definition at line 260 of file clistdata.hxx.

◆ getItemCount()

virtual const int NXWidgets::CListData::getItemCount ( void  ) const
inlinevirtual

Get the total number of items.

Returns
The number of items.

Definition at line 284 of file clistdata.hxx.

◆ getSelectedIndex()

const int CListData::getSelectedIndex ( void  ) const
virtual

Get the selected index. Returns -1 if nothing is selected. If more than one item is selected, the index of the first selected item is returned.

Returns
The selected index.

Definition at line 222 of file clistdata.cxx.

◆ getSelectedItem()

const CListDataItem * CListData::getSelectedItem ( void  ) const
virtual

Get the selected item. Returns NULL if nothing is selected.

Returns
The selected option.

Definition at line 255 of file clistdata.cxx.

◆ getSortedInsertionIndex()

const int CListData::getSortedInsertionIndex ( const CListDataItem item) const
protected

Return the index that an item should be inserted at to maintain a sorted list of data.

Parameters
itemThe item to insert.
Returns
The index that the item should be imserted into at.

Definition at line 423 of file clistdata.cxx.

◆ quickSort()

void CListData::quickSort ( const int  start,
const int  end 
)
protectedvirtual

Quick sort the items using their compareTo() methods.

Parameters
startThe index to start sorting at.
endThe index to stop sorting at.

Definition at line 365 of file clistdata.cxx.

◆ raiseDataChangedEvent()

void CListData::raiseDataChangedEvent ( void  )
protected

Raise a data changed event.

Definition at line 440 of file clistdata.cxx.

◆ raiseSelectionChangedEvent()

void CListData::raiseSelectionChangedEvent ( void  )
protected

Raise a selection changed event.

Definition at line 454 of file clistdata.cxx.

◆ removeAllItems()

void CListData::removeAllItems ( void  )
virtual

Remove all items.

Definition at line 202 of file clistdata.cxx.

◆ removeItem()

void CListData::removeItem ( const int  index)
virtual

Remove an item by its index.

Parameters
indexThe index of the option to remove.

Definition at line 159 of file clistdata.cxx.

◆ removeListDataEventHandler()

void CListData::removeListDataEventHandler ( IListDataEventHandler eventHandler)

Remove an event handler.

Parameters
eventHandlerThe event handler to remove.

Definition at line 346 of file clistdata.cxx.

◆ selectAllItems()

void CListData::selectAllItems ( void  )
virtual

Select all items. Does nothing if the list does not allow multiple selections.

Definition at line 282 of file clistdata.cxx.

◆ selectItem()

void CListData::selectItem ( const int  index)
virtual

Select an item by its index.

Parameters
indexThe index of the item to select.

Definition at line 182 of file clistdata.cxx.

◆ setAllowMultipleSelections()

virtual void NXWidgets::CListData::setAllowMultipleSelections ( const bool  allowMultipleSelections)
inlinevirtual

Sets whether multiple selections are possible or not.

Parameters
allowMultipleSelectionsTrue to allow multiple selections.

Definition at line 249 of file clistdata.hxx.

◆ setItemSelected()

void CListData::setItemSelected ( const int  index,
const bool  selected 
)
virtual

Select or deselect an item by its index. Does not deselect any other selected items. Set index to -1 to select nothing.

Parameters
indexThe index of the item to select.
selectedTrue to select the item, false to deselect it.

Definition at line 317 of file clistdata.cxx.

◆ setSelectedIndex()

void CListData::setSelectedIndex ( const int  index)
virtual

Sets the selected index. Specify -1 to select nothing. Resets any other selected items to deselected.

Parameters
indexThe selected index.

Definition at line 244 of file clistdata.cxx.

◆ setSortInsertedItems()

virtual void NXWidgets::CListData::setSortInsertedItems ( const bool  sortInsertedItems)
inlinevirtual

Sets whether or not items added to the list are automatically sorted on insert or not.

Parameters
sortInsertedItemsTrue to enable sort on insertion.

Definition at line 330 of file clistdata.hxx.

◆ sort()

void CListData::sort ( void  )
virtual

Sort the items using their compareTo() methods.

Definition at line 271 of file clistdata.cxx.

◆ swapItems()

void CListData::swapItems ( const int  index1,
const int  index2 
)
protectedvirtual

Swap the locations of two items in the array.

Parameters
index1The index of the first item to swap.
index2The index of the second item to swap.

Definition at line 409 of file clistdata.cxx.

Member Data Documentation

◆ m_allowMultipleSelections

bool NXWidgets::CListData::m_allowMultipleSelections
protected

If true, multiple options can be selected.

Definition at line 112 of file clistdata.hxx.

◆ m_items

TNxArray<CListDataItem*> NXWidgets::CListData::m_items
protected

Collection of list data items.

Definition at line 110 of file clistdata.hxx.

◆ m_listDataEventhandlers

TNxArray<IListDataEventHandler*> NXWidgets::CListData::m_listDataEventhandlers
protected

Collection of event handlers.

Definition at line 111 of file clistdata.hxx.

◆ m_sortInsertedItems

bool NXWidgets::CListData::m_sortInsertedItems
protected

Automatically sorts items on insertion if true.

Definition at line 114 of file clistdata.hxx.


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