2.3 The viewport hierarchy

2.3.1 Changing a parent-child relationship

You must deactivate a viewport or window before you can change its parent-child relationship with another viewport or window. The children windows are moved with the function move-viewport so that they are visible in their new parent's screen clipping region.

(setq *parent2*
      (make-window :width 100 :height 100 
                   :x 110 :title "parent2"))

(setq *child2* (make-window :width 60 :height 50 :x 110 :y 50 :title "child2" :parent *parent2*))

(deactivate-viewport *parent1*) (deactivate-viewport *parent2*) (setf (viewport-parent *child1*) *parent2*) (setf (viewport-parent *child2*) *parent1*) (move-viewport *child2* 0 50) (move-viewport *child1* 110 50) (activate-viewport *parent1*) (activate-viewport *child2*) (activate-viewport *parent2*) (activate-viewport *child1*)

In the following example,*parent1* takes*child1* back again; it now has two children:

(deactivate-viewport *parent1*)
(deactivate-viewport *parent2*)
(setf (viewport-children *parent1*) (list *child1* *child2*))
(move-viewport *child1* 40 30)
(activate-viewport *parent1*)
(activate-viewport *parent2*)
(activate-viewport *child1*)
(activate-viewport *child2*)

Notice that*child1* is overlapping*child2* because*child1* is first child on the list given to viewport-children. The viewport*parent1* now has two children, and*parent2* has none. If you want*child2* to overlap*child1*, expose*child2* or hide*child1*. The sibling stack reflects the change in order between siblings.

The Window Tool Kit - 9 SEP 1996

Generated with Harlequin WebMaker