Commit 95a8dc37 authored by Alastair Bridgewater's avatar Alastair Bridgewater
Browse files

sheet/sheet-multiple-child-mixin: A mixin class for sheets that can have children.

  * This is a straightforward implementation of the parent side of
the sheet hierarchy protocol.

  * We can still implement SHEET-SINGLE-CHILD-MIXIN and
SHEET-LEAF-MIXIN if we care to, but they seem rather useless to me
at this point.
parent b4058627
;;;
;;; nq-clim/sheet/sheet-multiple-child-mixin
;;;
;;; From CLIM II 7.2.2.
;;;
(cl:defpackage :nq-clim/sheet/sheet-multiple-child-mixin
(:use :cl
:nq-clim/sheet/sheet-hierarchy-protocol)
(:export
"SHEET-MULTIPLE-CHILD-MIXIN"))
(cl:in-package :nq-clim/sheet/sheet-multiple-child-mixin)
(defclass sheet-multiple-child-mixin ()
((children :initform nil :reader sheet-children)))
(defmethod sheet-adopt-child ((sheet sheet-multiple-child-mixin) child)
;; Allow the child to veto the adoption (by raising an error) and to
;; take care of its own bookkeeping.
(call-next-method)
;; And, now that we're committed to the adoption, add the sheet to
;; our list of children.
(push child (slot-value sheet 'children)))
(defmethod sheet-disown-child ((sheet sheet-multiple-child-mixin) child &key (errorp t))
(declare (ignore errorp))
;; Remove the child from our list of children, or silently do
;; nothing if it's not actually on said list.
(with-slots (children) sheet
(setf children (delete child children)))
;; And allow the child to raise an error if it isn't actually a
;; child and to take care of its own bookkeeping.
(call-next-method))
;;; EOF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment