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

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.

References setRange().

Referenced by getAt(), and removeArray().

◆ 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.

References getCount(), and new().

Referenced by getContent(), moveIndex(), notifyContentChanged(), and sort().

◆ addListener()

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

Add listener.

Implements Dragengine.Gui.ListModel.

References new().

Referenced by getCount().

◆ 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.

References insert().

Referenced by notifyContentChanged().

◆ 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.

Referenced by notifyContentChanged().

◆ getAt()

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

◆ 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.

References insertAll(), and setSelected().

Referenced by notifyContentChanged().

◆ getContent()

Array Dragengine.Gui.DefaultListModel.getContent ( )

Get content as array.

References addAll(), and getCount().

◆ getCount()

◆ getSelected()

int Dragengine.Gui.DefaultListModel.getSelected ( )

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

Implements Dragengine.Gui.ListModel.

References setSelected().

Referenced by notifyContentChanged().

◆ has()

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

Element is present.

Implements Dragengine.Gui.ListModel.

Referenced by removeFrom(), and removeRange().

◆ 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().

References notifyContentChanged(), and setAt().

Referenced by collect().

◆ 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().

Referenced by getAutoSelect(), and setSelected().

◆ 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.

References getCount(), new(), and setAll().

Referenced by notifyContentChanged(), and setAutoSelect().

◆ 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.

References addAll(), getAt(), and notifyContentChanged().

Referenced by notifyContentChanged(), and setAutoSelect().

◆ new() [1/2]

DefaultListModel Dragengine.Gui.DefaultListModel.new ( )

Create default list model.

References new().

Referenced by addAll(), addListener(), getCount(), move(), new(), and notifyContentChanged().

◆ 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.

References addAll(), collect(), find(), getAt(), getAutoSelect(), getCount(), getSelected(), Dragengine.Gui.ListModel.indexOf(), move(), moveIndex(), new(), notifyContentChanged(), setAutoSelect(), setSelected(), setSelectedElement(), and sort().

Referenced by insert(), moveIndex(), notifyContentChanged(), and setAll().

◆ 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.

Referenced by getAt().

◆ 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.

References add().

◆ 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().

References has(), and Dragengine.Gui.ListModel.indexOf().

◆ removeListener()

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

Remove listener.

Implements Dragengine.Gui.ListModel.

References getCount().

Referenced by getAt().

◆ 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.

References has().

◆ 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.

References notifyContentChanged().

Referenced by move().

◆ 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().

References getAt(), and getCount().

Referenced by insert(), and setRange().

◆ 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.

References move(), and moveIndex().

Referenced by notifyContentChanged().

◆ 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.

References getAt(), and setAt().

Referenced by add().

◆ 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.

References insertAll().

Referenced by getAutoSelect(), getSelected(), and notifyContentChanged().

◆ setSelectedElement()

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

Set selected element.

Version
1.9

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

References getCount().

Referenced by notifyContentChanged().

◆ sort()

void Dragengine.Gui.DefaultListModel.sort ( )

Sort elements using element compare() method.

References addAll(), and getCount().

Referenced by notifyContentChanged().


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