NextPrevUpTopContentsIndex

map-pane-children

Generic Function
Summary

Calls a function on each of a pane's children.

Package

capi

Signature

map-pane-children pane function &key visible test reverse

Arguments

pane

A CAPI pane.

function

A function of one argument.

visible

A boolean. The default value is nil .

test

A function of one argument, or nil . The default is nil .

reverse

A boolean. The default value is nil .

Description

map-pane-children applies function to pane 's immediate children.

If visible is true, then function is applied only to the visible children.

If test is non- nil , it is a function which is applied first to each child, and only those for which test returns a true value are then passed to function .

If reverse is non- nil , the order in which the children are processed is reversed.

Example

This example constructs a pinboard containing random ellipses. A repainting function is mapped over them, restricted to those with width greater than height.

(defun random-color () 
  (aref #(:red :blue :green :yellow :cyan 
          :magenta :pink :purple :black :white) 
        (random 10)))
 
(defun random-origin () 
  (list (random 350) (random 250)))
 
(defun random-size () 
  (list (+ 10 (random 40)) 
        (+ 10 (random 40))))
 
(setf ellipses
      (capi:contain 
       (make-instance 
        'capi:pinboard-layout 
        :children 
        (loop for i below 40
              for origin = (random-origin)
              for size = (random-size)
              collect 
              (make-instance 'capi:ellipse 
                             :x (first origin) 
                             :y (second origin)
                             :width (first size) 
                             :height (second size)
                             :graphics-args 
                             (list :foreground 
                                   (random-color)) 
                             :filled t)))))
 
(defun repaint (ellipse) 
  (setf (capi:pinboard-object-graphics-args ellipse)
       (list :foreground (random-color)))
  (capi:redraw-pinboard-object ellipse t))
 
(defun widep (ellipse)
  (capi:with-geometry ellipse
      (> capi:%width% capi:%height%)))
 
(capi:map-pane-children ellipses 'repaint :test 'widep)
See also

map-pane-descendant-children


LispWorks CAPI Reference Manual - 25 Jul 2006

NextPrevUpTopContentsIndex