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

Default implementation of ListModel. More...

Inheritance diagram for Dragengine.Gui.DefaultListModel:
Dragengine.Gui.ListModel Dragengine.Gui.EditBindingsListModel

Public Member Functions

void add (Object element)
 Add element. More...
 
void addAll (Array content)
 Add elements from array. More...
 
void addListener (ListModelListener listener)
 Add listener. More...
 
Array collect (Block ablock)
 Return array with content for which block returns true. More...
 
Object find (Block ablock)
 Find first object for which block returns true. More...
 
Object getAt (int index)
 Element at index. More...
 
bool getAutoSelect ()
 Automatically select items. More...
 
Array getContent ()
 Get content as array. More...
 
int getCount ()
 Number of elements. 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...
 
void insert (int index, Object element)
 Insert element at index. More...
 
void insertAll (int index, Array content)
 Insert elements from array at index. More...
 
void move (Object object, int index)
 Move element to new location. More...
 
void moveIndex (int indexFrom, int indexTo)
 Move element to new location. More...
 
DefaultListModel new ()
 Create default list model. More...
 
DefaultListModel new (Array content)
 Create default list model with initial content. More...
 
void notifyContentChanged (int indexFrom, int indexTo)
 Notify all that the content of the model in the given range changed. More...
 
void remove (Object element)
 Remove element. More...
 
void removeArray (Array content)
 Remove elements from array. More...
 
void removeFrom (int index)
 Remove element. More...
 
void removeListener (ListModelListener listener)
 Remove listener. More...
 
void removeRange (int firstIndex, int lastIndex)
 Remove elements from range. More...
 
void setAll (Array elements)
 Replaces all elements. More...
 
void setAt (int index, Object element)
 Set element at index. More...
 
void setAutoSelect (bool autoSelect)
 Set to automatically select items. More...
 
void setContent (Array content)
 Set content from array. More...
 
void setRange (int firstIndex, int lastIndex, Array elements)
 Replaces elements in range. 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...
 
void sort ()
 Sort elements using element compare() method. More...
 
- Public Member Functions inherited from Dragengine.Gui.ListModel
int indexOf (Object element)
 Index of element or -1 if absent. More...
 

Detailed Description

Default implementation of ListModel.

Version 1.5 Changes

Added support to set Auto-Select mode. Default is enabled as before version 1.5 . If enabled adding and removing items ensures an item is selected if the list is not empty. If disabled the user is responsible to set the selection after adding or removing items. If disabled and the selected item is removed the selection will be cleared.

Member Function Documentation

◆ add()

void Dragengine.Gui.DefaultListModel.add ( Object  element)

Add element.

After adding a content changed event is send to listeners. If you have to set many elements at once performance problems can arise due to each change causing widgets to relayout. If this is the case use one of the mass editing methods.

◆ addAll()

void Dragengine.Gui.DefaultListModel.addAll ( Array  content)

Add elements from array.

After adding a content changed event is send to listeners. If you have to add many elements addAll() instead of add() for performance reasons.

◆ addListener()

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

Add listener.

Implements Dragengine.Gui.ListModel.

◆ collect()

Array Dragengine.Gui.DefaultListModel.collect ( Block  ablock)

Return array with content for which block returns true.

Version
1.11

Block is called with argument Object and has to return bool. Returns Array of Object.

◆ find()

Object Dragengine.Gui.DefaultListModel.find ( Block  ablock)

Find first object for which block returns true.

Block is called with argument Object and has to return bool.

◆ getAt()

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

Element at index.

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

Implements Dragengine.Gui.ListModel.

◆ getAutoSelect()

bool Dragengine.Gui.DefaultListModel.getAutoSelect ( )

Automatically select items.

Version
1.5

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.

◆ getContent()

Array Dragengine.Gui.DefaultListModel.getContent ( )

Get content as array.

◆ getCount()

int Dragengine.Gui.DefaultListModel.getCount ( )

Number of elements.

Implements Dragengine.Gui.ListModel.

◆ getSelected()

int Dragengine.Gui.DefaultListModel.getSelected ( )

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

Implements Dragengine.Gui.ListModel.

◆ has()

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

Element is present.

Implements Dragengine.Gui.ListModel.

◆ insert()

void Dragengine.Gui.DefaultListModel.insert ( int  index,
Object  element 
)

Insert element at index.

After inserting a content changed event is send to listeners. If you have to insert many elements at once performance problems can arise due to each change causing widgets to relayout. If this is the case use one of the mass editing methods.

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

◆ insertAll()

void Dragengine.Gui.DefaultListModel.insertAll ( int  index,
Array  content 
)

Insert elements from array at index.

After inserting a content changed event is send to listeners. If you have to insert many elements insertAll() instead of insert() for performance reasons.

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

◆ move()

void Dragengine.Gui.DefaultListModel.move ( Object  object,
int  index 
)

Move element to new location.

Version
1.11

Same as calling remove(Object) and insert(int,Object) but sending only one change notification for the entire range of content between the two positions.

◆ moveIndex()

void Dragengine.Gui.DefaultListModel.moveIndex ( int  indexFrom,
int  indexTo 
)

Move element to new location.

Version
1.11

Same as calling remove(Object) and insert(int,Object) but sending only one change notification for the entire range of content between the two positions.

◆ new() [1/2]

DefaultListModel Dragengine.Gui.DefaultListModel.new ( )

Create default list model.

◆ new() [2/2]

DefaultListModel Dragengine.Gui.DefaultListModel.new ( Array  content)

Create default list model with initial content.

◆ notifyContentChanged()

void Dragengine.Gui.DefaultListModel.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.

Reimplemented in Dragengine.Gui.EditBindingsListModel.

◆ remove()

void Dragengine.Gui.DefaultListModel.remove ( Object  element)

Remove element.

After removing a content changed event is send to listeners. If you have to remove many elements at once performance problems can arise due to each change causing widgets to relayout. If this is the case use one of the mass editing methods.

Exceptions
EOutOfBoundsElement is absent.

◆ removeArray()

void Dragengine.Gui.DefaultListModel.removeArray ( Array  content)

Remove elements from array.

After removing a content changed event is send to listeners.

Exceptions
EOutOfBoundsElement is absent.

◆ removeFrom()

void Dragengine.Gui.DefaultListModel.removeFrom ( int  index)

Remove element.

After removing a content changed event is send to listeners. If you have to remove many elements at once performance problems can arise due to each change causing widgets to relayout. If this is the case use one of the mass editing methods.

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

◆ removeListener()

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

Remove listener.

Implements Dragengine.Gui.ListModel.

◆ removeRange()

void Dragengine.Gui.DefaultListModel.removeRange ( int  firstIndex,
int  lastIndex 
)

Remove elements from range.

After removing a content changed event is send to listeners.

Exceptions
EOutOfBoundsfirstIndex is less than 0 or larger than or equal getCount().
EOutOfBoundslastIndex is less than 0 or larger than or equal getCount().
EInvalidParamlastIndex is less than firstIndex.

◆ setAll()

void Dragengine.Gui.DefaultListModel.setAll ( Array  elements)

Replaces all elements.

If range is not empty a content changed event is send to listeners. Use this method if you need to change all elements at once to cause only one change notification resulting in widgets to relayout once instead of multiple times.

Exceptions
EInvalidParamNumber of elements in elements does not equal number of elements in the model.

◆ setAt()

void Dragengine.Gui.DefaultListModel.setAt ( int  index,
Object  element 
)

Set element at index.

If element at index changed a content changed event is send to listeners. Changing many elements at once can cause performance problems due to each change causing widgets to relayout. If this is a problem use one of the mass editing methods.

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

◆ setAutoSelect()

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

Set to automatically select items.

Version
1.5

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.

◆ setContent()

void Dragengine.Gui.DefaultListModel.setContent ( Array  content)

Set content from array.

If count of elements in content is equal to getCount() operates like setAll() sending a single content changed notification unless both counts are 0. If the counts are different replaces the content as if removeAll() and addAll() is called. If elements are present sends first an elements removed notification. Then if content contains any elements an elements added notification is send.

If you just want to replace all elements without changing the number of elements use setAll().

◆ setRange()

void Dragengine.Gui.DefaultListModel.setRange ( int  firstIndex,
int  lastIndex,
Array  elements 
)

Replaces elements in range.

If range is not empty a content changed event is send to listeners. Use this method if you need to change multiple elements at once to cause only one change notification resulting in widgets to relayout once instead of multiple times.

Exceptions
EOutOfBoundsfirstIndex is less than 0 or larger than or equal getCount().
EOutOfBoundslastIndex is less than 0 or larger than or equal getCount().
EInvalidParamlastIndex is less than firstIndex.
EInvalidParamNumber of elements in elements does not equal number of elements in range.

◆ setSelected()

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

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

Implements Dragengine.Gui.ListModel.

◆ setSelectedElement()

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

Set selected element.

Version
1.9

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

◆ sort()

void Dragengine.Gui.DefaultListModel.sort ( )

Sort elements using element compare() method.


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