collection collects together a set of items, and provides functionality for accessing and displaying them.
The items in the collection.
A function that prints an item.
A comparison function between two items.
A function which returns the length of items.
A function that returns the
A function that maps a function over the items.
Specifies that the collection should accept input. The default value is
An object used for lookup of help.
The main use of
collection is as a part of the class choice, which provides selection capabilities on top of the collection handling, and which is used by list panels, button panels and menus amongst others.
The items in the collection are printed by print-collection-item.
Items can be instances of the CAPI class
item or any Lisp object. The main difference is that non-CAPI items use the callbacks specified for the collection, while the CAPI
items will use their callbacks in preference if these are specified.
must be a sequence, but this can be changed by specifying
should take as arguments the items and an index, and should return the indexed item. The default is
should take the items as an argument and should return the number of them.
should take as arguments the items, a function
and a flag
, and should call
on each of the items in turn. If
is non-nil, then it should also return the results of these calls in a list.
should be a one argument function which returns a string. The default is
princ-to-string. To display an item, the collection call
with the item, and then draws the resulting string (the way it draws is different between the subclasses of choice). The time when
is called is not defined; it may happen before the string is needed for drawing, and may be cached so not called each time the item is drawn. The function choice-update-item can be used to flush the cache when needed.
should be suitable for comparing the items in your collection, returning a boolean. For example, if there are both strings and integers amongst your
, you should supply
cl:equal. The default value of
You can change the items using
(setf collection-items). Note that there is an optimization append-items that is sometimes useful when adding items.
are interpreted as described in element.
The following code uses
push-button-panel, a subclass of
(capi:contain (make-instance 'capi:push-button-panel
:items '(one two three)))
:items '(one two three)
The following example provides a collection with all values from 1 to 6 by providing an
#'(lambda (items index) (1+ index))
#'(lambda (items) items)))
Here is an example demonstrating the use of CAPI items in a collections list of items to get more specific callbacks.
(defun specific-callback (data interface)
(capi:display-message "Specific callback for ~S"
(defun generic-callback (data interface)
(capi:display-message "Ordinary callback for ~S"
:items (list (make-instance
2 3 4)
CAPI User Guide and Reference Manual (Windows version) - 3 Aug 2017