up: ZWT     index Zimbu documentation

CLASS ZWT.ListController<Titem> @public

summary

     

Display a list of items in a Panel.

This is the controller in a model-view-controller construction, where the model is a list of items and the view is a Panel.

 
Implements ZWT.I_Controller
 
CLASS  SelectEvent @public 
 
NEW(view, model, builder) @public  Display the items of model in view.
$setModel(model) @public  Set the model to be displayed. Set to NIL to not display any items.
$getModel() list<Titem> @public  Return the current model.
$setView(view) @public  Set the view to display the items in.
$getView() ZWT.Panel @public  Return the current view.
$update() @file  Fill the view with items from the model.
$update(item) @public  Update the view for item.
$update(index) @public  Update the view for the item at position index.
$add(item) ZWT.Widget @public  Add item to the list of items.
$insert(item) @public  Insert item at the start of the list of items.
$insert(item, index) @public  Insert item before item index in the list of items.
$remove(item) @public  Remove the item.
$remove(index) Titem @public  Remove the item at index.
$getItem(index) Titem @public  Get the item in the model at index. Return NIL when index is out of range.
$getWidget(index) ZWT.Widget @public  Get the Widget in the view at index. Return NIL when index is out of range.
$getWidget(item) ZWT.Widget @public  Get the Widget in the view for item in the model. Return NIL when not found.
$setHighlightIndex(index) @public  Set the highlight in the view by index.
$setHighlighted(item) @public  Set the highlight in the view for an item in the model.
$addHighlighted(index) @public  Add a highlighted item in the view by index.
$addHighlighted(item) @public  Add a highlighted item in the view for an item in the model.
$getHighlighted() ZWT.Widget @public  Return the first highlighted item in the view. NIL if there is none.
$getHighlightedItem() Titem @public  Return the first highlighted item in the model. NIL if there is none.
$getHighlightIndex() int @public  Return the lowest highlighted item index.
$setSelectionHandler(handler) @public  Set a handler for selection events. Currently only mouse clicks.
$keepSorted(on) @public  Set sorting to on.
$setSortMethod(method) @public  Set the method to use for sorting.
 
clickHandler(event) @file 
 

members (alphabetically)

     

PROC NEW(ZWT.Panel view, list<Titem> model, I_WidgetBuilder<Titem> builder) @public

     

Display the items of model in view.

The view must be a Panel, it will show the items of model. The builder is used to turn Titem into a Widget that can be added to view.

FUNC $add(Titem item) ZWT.Widget @public

     

Add item to the list of items.

Will update the model and the view.

When sorted the item will be put in the right place. When not sorted the item is added to the end of the list.

Returns the created widget.

PROC $addHighlighted(int index) @public

     

Add a highlighted item in the view by index.

PROC $addHighlighted(Titem item) @public

     

Add a highlighted item in the view for an item in the model.

FUNC $getHighlightIndex() int @public

     

Return the lowest highlighted item index.

Return -1 when there is no highlight.

FUNC $getHighlighted() ZWT.Widget @public

     

Return the first highlighted item in the view. NIL if there is none.

FUNC $getHighlightedItem() Titem @public

     

Return the first highlighted item in the model. NIL if there is none.

FUNC $getItem(int index) Titem @public

     

Get the item in the model at index. Return NIL when index is out of range.

FUNC $getModel() list<Titem> @public

     

Return the current model.

FUNC $getView() ZWT.Panel @public

     

Return the current view.

FUNC $getWidget(int index) ZWT.Widget @public

     

Get the Widget in the view at index. Return NIL when index is out of range.

FUNC $getWidget(Titem item) ZWT.Widget @public

     

Get the Widget in the view for item in the model. Return NIL when not found.

PROC $insert(Titem item) @public

     

Insert item at the start of the list of items.

Will update the model and the view.

PROC $insert(Titem item, int index) @public

     

Insert item before item index in the list of items.

Will update the model and the view.

When $keepSorted(TRUE) was called then index is ignored.

PROC $keepSorted(bool on) @public

     

Set sorting to on.

When adding items with $add() or $insert() they are put in the right place.

When on is TRUE you need to call $setSortMethod() before updating the model, otherwise an exception will be thrown.

Note that calling this method does not trigger a sort, when the items are not already sorted the result is unpredictable. When an item in the model is changed you need to call $update() to keep the items sorted.

PROC $remove(Titem item) @public

     

Remove the item.

Will update the model and the view. Does noting if the item cannot be found.

FUNC $remove(int index) Titem @public

     

Remove the item at index.

Will update the model and the view. Returns the removed item.

PROC $setHighlightIndex(int index) @public

     

Set the highlight in the view by index.

Remove highlight when index is < 0.

PROC $setHighlighted(Titem item) @public

     

Set the highlight in the view for an item in the model.

Remove highlight when item is NIL or is not in the model.

PROC $setModel(list<Titem> model) @public

     

Set the model to be displayed. Set to NIL to not display any items.

PROC $setSelectionHandler(proc<ZWT.SelectEvent> handler) @public

     

Set a handler for selection events. Currently only mouse clicks.

PROC $setSortMethod(func<Titem, Titem => int> method) @public

     

Set the method to use for sorting.

The method must return zero when the two items are equal, < 0 when the first one sorts before the second one and > 0 when the first one sorts after the second one.

If Titem has the Compare() method you can use:

 FUNC sortMethod(Titem a, Titem b) int
   RETURN a.Compare(b)
 }

PROC $setView(ZWT.Panel view) @public

     

Set the view to display the items in.

Use NIL to not display the items.

PROC $update() @file

     

Fill the view with items from the model.

This rebuilds the whole view.

PROC $update(Titem item) @public

     

Update the view for item.

Does nothing when item is not found in the model.

When $keepSorted(TRUE) was called the item will most likely be moved to another position.

PROC $update(int index) @public

     

Update the view for the item at position index.

Does nothing when index is out of range.

When $keepSorted(TRUE) was called the item will most likely be moved to another position.

shared (alphabetically)

     

PROC clickHandler(ZWT.Event event) @file

credits

      The Class hierarchy, generated Javascript and a few other things are based on the Google Web Toolkit. http://code.google.com/webtoolkit/overview.html

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0