Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBSelectItemSourceList< T > Class Template Reference

TBSelectItemSourceList is a item provider for list widgets (TBSelectList and TBSelectDropdown). More...

#include <tb_select_item.h>

Inheritance diagram for tb::TBSelectItemSourceList< T >:
tb::TBSelectItemSource tb::TBTypedObject

Public Member Functions

 TBOBJECT_SUBCLASS (TBSelectItemSourceList, TBSelectItemSource)
 
virtual const TBStrGetItemString (int index) const
 Get the string of a item. More...
 
virtual TBSelectItemSourceGetItemSubSource (int index)
 Get the source to be used if this item should open a sub menu. More...
 
virtual TBID GetItemImage (int index) const
 Get the skin image to be painted before the text for this item. More...
 
virtual TBID GetItemID (int index) const
 Get the id of the item. More...
 
virtual int GetNumItems () const
 Get the number of items.
 
virtual TBWidgetCreateItemWidget (int index, TBSelectItemViewer *viewer)
 Create the item representation widget(s). More...
 
bool AddItem (T *item, int index)
 Add a new item at the given index. More...
 
bool AddItem (T *item)
 Add a new item last. More...
 
T * GetItem (int index)
 Get the item at the given index. More...
 
const T * GetItem (int index) const
 Get the item at the given index. More...
 
T * FindItemByID (TBID id)
 Get the item at the given index. More...
 
const T * FindItemByID (TBID id) const
 Get the item at the given index. More...
 
void DeleteItem (int index)
 Delete the item at the given index. More...
 
void DeleteAllItems ()
 Delete all items. More...
 
- Public Member Functions inherited from tb::TBSelectItemSource
 TBOBJECT_SUBCLASS (TBSelectItemSource, TBTypedObject)
 
virtual bool Filter (int index, const TBStr &filter)
 Return true if an item matches the given filter text. More...
 
virtual int FindIDIndex (TBID id) const
 Get the index of the first item having this id or -1 if not found.
 
void SetSort (TB_SORT sort)
 Set sort type. More...
 
TB_SORT GetSort () const
 
void InvokeItemChanged (int index, TBSelectItemViewer *exclude_viewer=nullptr)
 Invoke OnItemChanged on all open viewers for this source. More...
 
void InvokeItemAdded (int index)
 
void InvokeItemRemoved (int index)
 
void InvokeAllItemsRemoved ()
 
- Public Member Functions inherited from tb::TBTypedObject
virtual bool IsOfTypeId (const TB_TYPE_ID type_id) const
 Returns true if the class or the base class matches the type id.
 
template<class T >
T * SafeCastTo () const
 Returns this object as the given type or nullptr if it's not that type. More...
 
template<class T >
bool IsOfType () const
 Return true if this object can safely be casted to the given type. More...
 
virtual const char * GetClassName () const
 Get the classname of the object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from tb::TBTypedObject
template<class T >
static TB_TYPE_ID GetTypeId ()
 A static template method that returns a unique id for each type. More...
 

Detailed Description

template<class T>
class tb::TBSelectItemSourceList< T >

TBSelectItemSourceList is a item provider for list widgets (TBSelectList and TBSelectDropdown).

It stores items of the type specified by the template in an array.

Member Function Documentation

template<class T>
bool tb::TBSelectItemSourceList< T >::AddItem ( T *  item,
int  index 
)
inline

Add a new item at the given index.

template<class T>
bool tb::TBSelectItemSourceList< T >::AddItem ( T *  item)
inline

Add a new item last.

template<class T>
virtual TBWidget* tb::TBSelectItemSourceList< T >::CreateItemWidget ( int  index,
TBSelectItemViewer viewer 
)
inlinevirtual

Create the item representation widget(s).

By default, it will create a TBTextField for string-only items, and other types for items that also has image or submenu.

Reimplemented from tb::TBSelectItemSource.

template<class T>
void tb::TBSelectItemSourceList< T >::DeleteAllItems ( )
inline

Delete all items.

template<class T>
void tb::TBSelectItemSourceList< T >::DeleteItem ( int  index)
inline

Delete the item at the given index.

template<class T>
T* tb::TBSelectItemSourceList< T >::FindItemByID ( TBID  id)
inline

Get the item at the given index.

template<class T>
const T* tb::TBSelectItemSourceList< T >::FindItemByID ( TBID  id) const
inline

Get the item at the given index.

template<class T>
T* tb::TBSelectItemSourceList< T >::GetItem ( int  index)
inline

Get the item at the given index.

template<class T>
const T* tb::TBSelectItemSourceList< T >::GetItem ( int  index) const
inline

Get the item at the given index.

template<class T>
virtual TBID tb::TBSelectItemSourceList< T >::GetItemID ( int  ) const
inlinevirtual

Get the id of the item.

Reimplemented from tb::TBSelectItemSource.

template<class T>
virtual TBID tb::TBSelectItemSourceList< T >::GetItemImage ( int  ) const
inlinevirtual

Get the skin image to be painted before the text for this item.

Reimplemented from tb::TBSelectItemSource.

template<class T>
virtual const TBStr& tb::TBSelectItemSourceList< T >::GetItemString ( int  index) const
inlinevirtual

Get the string of a item.

If a item has more than one string, return the one that should be used for inline-find (pressing keys in the list will scroll to the item starting with the same letters), and for sorting the list.

Implements tb::TBSelectItemSource.

template<class T>
virtual TBSelectItemSource* tb::TBSelectItemSourceList< T >::GetItemSubSource ( int  )
inlinevirtual

Get the source to be used if this item should open a sub menu.

Reimplemented from tb::TBSelectItemSource.


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