Drag[en]gine Script Module DragonScript  1.23
Dragengine.Gui.SharedListModel Class Reference

Shared implementation of ListModel. More...

Inheritance diagram for Dragengine.Gui.SharedListModel:
Dragengine.Gui.ListModel

Public Member Functions

void addListener (ListModelListener listener)
 Add listener. More...
 
SharedListModel destructor ()
 Destroy shared list model. More...
 
Object getAt (int index)
 Element at index. More...
 
int getCount ()
 Count of elements. More...
 
ListModel getModel ()
 Linked model. More...
 
int getSelected ()
 Index of the selected element or -1 if there is no selected element. More...
 
bool has (Object element)
 Element is present. More...
 
int indexOf (Object element)
 Index of element or -1 if absent. More...
 
SharedListModel new (ListModel model)
 Create shared list model linked to ListModel. More...
 
void notifyContentChanged (int indexFrom, int indexTo)
 Notify all that the content of the model in the given range changed. More...
 
void removeListener (ListModelListener listener)
 Remove listener. More...
 
void setAutoSelect (bool autoSelect)
 Set to automatically select items. More...
 
void setSelected (int index)
 Set index of selected element or -1 if none is no selected element. More...
 
void setSelectedElement (Object element)
 Set selected element. More...
 

Public Attributes

bool pAutoSelect
 
Array pListeners
 
ListModel pModel
 
int pSelected
 
Object pSelectedObject
 
SharedModelListener pSharedModelListener
 

Detailed Description

Shared implementation of ListModel.

Version
1.17

ListModel implementation allowing to use another ListModel instance as shared model. This allows to use the same ListModel across multiple SharedListModel but with different selection state. This reduces coding effort and improves UI performance.

The typical use case is to use a globally accessible DefaultListModel storing the data you want to display in different parts of the UI using ComboBox or ListBox. Then for each ComboBox and ListBox use an instance of SharedListModel linked to the global DefaultListModel. Now you can changed the global DefaultListModel and all ComboBox and ListBox linked to it by SharedListModel are updated automatically while keeping their unique selection state.

Member Function Documentation

◆ addListener()

void Dragengine.Gui.SharedListModel.addListener ( ListModelListener  listener)

Add listener.

Implements Dragengine.Gui.ListModel.

◆ destructor()

SharedListModel Dragengine.Gui.SharedListModel.destructor ( )

Destroy shared list model.

◆ getAt()

Object Dragengine.Gui.SharedListModel.getAt ( int  index)

Element at index.

Exceptions
EOutOfBoundsindex is less than 0 or larger than or equal to getCount().

Implements Dragengine.Gui.ListModel.

◆ getCount()

int Dragengine.Gui.SharedListModel.getCount ( )

Count of elements.

Implements Dragengine.Gui.ListModel.

◆ getModel()

ListModel Dragengine.Gui.SharedListModel.getModel ( )

Linked model.

◆ getSelected()

int Dragengine.Gui.SharedListModel.getSelected ( )

Index of the selected element or -1 if there is no selected element.

Implements Dragengine.Gui.ListModel.

◆ has()

bool Dragengine.Gui.SharedListModel.has ( Object  element)

Element is present.

Implements Dragengine.Gui.ListModel.

◆ indexOf()

int Dragengine.Gui.SharedListModel.indexOf ( Object  element)

Index of element or -1 if absent.

Implements Dragengine.Gui.ListModel.

◆ new()

SharedListModel Dragengine.Gui.SharedListModel.new ( ListModel  model)

Create shared list model linked to ListModel.

◆ notifyContentChanged()

void Dragengine.Gui.SharedListModel.notifyContentChanged ( int  indexFrom,
int  indexTo 
)

Notify all that the content of the model in the given range changed.

Parameters
indexFromIndex of first element that changed
indexToIndex of last element that changed

Implements Dragengine.Gui.ListModel.

◆ removeListener()

void Dragengine.Gui.SharedListModel.removeListener ( ListModelListener  listener)

Remove listener.

Implements Dragengine.Gui.ListModel.

◆ setAutoSelect()

void Dragengine.Gui.SharedListModel.setAutoSelect ( bool  autoSelect)

Set to automatically select items.

If no item is selected and an item is added it is selected. If selected item is removed selects the next suitible item if the list is not empty.

If auto select is set to true while no item is selected the first item in the list is selected if the list is not empty.

◆ setSelected()

void Dragengine.Gui.SharedListModel.setSelected ( int  index)

Set index of selected element or -1 if none is no selected element.

Implements Dragengine.Gui.ListModel.

◆ setSelectedElement()

void Dragengine.Gui.SharedListModel.setSelectedElement ( Object  element)

Set selected element.

Behaves the same as calling setSelected(indexOf(element)).

Member Data Documentation

◆ pAutoSelect

bool Dragengine.Gui.SharedListModel.pAutoSelect

◆ pListeners

Array Dragengine.Gui.SharedListModel.pListeners

◆ pModel

ListModel Dragengine.Gui.SharedListModel.pModel

◆ pSelected

int Dragengine.Gui.SharedListModel.pSelected

◆ pSelectedObject

Object Dragengine.Gui.SharedListModel.pSelectedObject

◆ pSharedModelListener

SharedModelListener Dragengine.Gui.SharedListModel.pSharedModelListener

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