Drag[en]gine Script Module DragonScript
1.23
|
Default implementation of ListModel. More...
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... | |
Default implementation of ListModel.
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.
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.
void Dragengine.Gui.DefaultListModel.addAll | ( | Array | content | ) |
void Dragengine.Gui.DefaultListModel.addListener | ( | ListModelListener | listener | ) |
Add listener.
Implements Dragengine.Gui.ListModel.
Array Dragengine.Gui.DefaultListModel.collect | ( | Block | ablock | ) |
Return array with content for which block returns true.
Block is called with argument Object and has to return bool. Returns Array of Object.
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.
Object Dragengine.Gui.DefaultListModel.getAt | ( | int | index | ) |
Element at index.
EOutOfBounds | index is less than 0 or larger than or equal to getCount(). |
Implements Dragengine.Gui.ListModel.
bool Dragengine.Gui.DefaultListModel.getAutoSelect | ( | ) |
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.
Array Dragengine.Gui.DefaultListModel.getContent | ( | ) |
Get content as array.
int Dragengine.Gui.DefaultListModel.getCount | ( | ) |
Number of elements.
Implements Dragengine.Gui.ListModel.
int Dragengine.Gui.DefaultListModel.getSelected | ( | ) |
Index of the selected element or -1 if there is no selected element.
Implements Dragengine.Gui.ListModel.
bool Dragengine.Gui.DefaultListModel.has | ( | Object | element | ) |
Element is present.
Implements Dragengine.Gui.ListModel.
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.
EOutOfBounds | index is less than 0 or larger than getCount(). |
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.
EOutOfBounds | index is less than 0 or larger than getCount(). |
void Dragengine.Gui.DefaultListModel.move | ( | Object | object, |
int | index | ||
) |
Move element to new location.
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.
void Dragengine.Gui.DefaultListModel.moveIndex | ( | int | indexFrom, |
int | indexTo | ||
) |
Move element to new location.
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.
DefaultListModel Dragengine.Gui.DefaultListModel.new | ( | ) |
Create default list model.
DefaultListModel Dragengine.Gui.DefaultListModel.new | ( | Array | content | ) |
Create default list model with initial content.
void Dragengine.Gui.DefaultListModel.notifyContentChanged | ( | int | indexFrom, |
int | indexTo | ||
) |
Notify all that the content of the model in the given range changed.
indexFrom | Index of first element that changed |
indexTo | Index of last element that changed |
Implements Dragengine.Gui.ListModel.
Reimplemented in Dragengine.Gui.EditBindingsListModel.
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.
EOutOfBounds | Element is absent. |
void Dragengine.Gui.DefaultListModel.removeArray | ( | Array | content | ) |
Remove elements from array.
After removing a content changed event is send to listeners.
EOutOfBounds | Element is absent. |
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.
EOutOfBounds | index is less than 0 or larger than or equal getCount(). |
void Dragengine.Gui.DefaultListModel.removeListener | ( | ListModelListener | listener | ) |
Remove listener.
Implements Dragengine.Gui.ListModel.
void Dragengine.Gui.DefaultListModel.removeRange | ( | int | firstIndex, |
int | lastIndex | ||
) |
Remove elements from range.
After removing a content changed event is send to listeners.
EOutOfBounds | firstIndex is less than 0 or larger than or equal getCount(). |
EOutOfBounds | lastIndex is less than 0 or larger than or equal getCount(). |
EInvalidParam | lastIndex is less than firstIndex. |
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.
EInvalidParam | Number of elements in elements does not equal number of elements in the model. |
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.
EOutOfBounds | index is less than 0 or larger than or equal to getCount(). |
void Dragengine.Gui.DefaultListModel.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.
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().
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.
EOutOfBounds | firstIndex is less than 0 or larger than or equal getCount(). |
EOutOfBounds | lastIndex is less than 0 or larger than or equal getCount(). |
EInvalidParam | lastIndex is less than firstIndex. |
EInvalidParam | Number of elements in elements does not equal number of elements in range. |
void Dragengine.Gui.DefaultListModel.setSelected | ( | int | index | ) |
Set index of selected element or -1 if none is no selected element.
Implements Dragengine.Gui.ListModel.
void Dragengine.Gui.DefaultListModel.setSelectedElement | ( | Object | element | ) |
Set selected element.
Behaves the same as calling setSelected(indexOf(element)).
void Dragengine.Gui.DefaultListModel.sort | ( | ) |
Sort elements using element compare() method.