Commit be4d855e authored by Alastair Bridgewater's avatar Alastair Bridgewater
Browse files

sheet/sheet-parent-mixin: A mixin class for sheets that can have parents.

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

  * I'm getting a distinctly uneasy feeling with respect to the
method combination for SHEET-ADOPT-CHILD and SHEET-DISOWN-CHILD,
as though it won't really behave as intended.
parent 22a65b82
;;;
;;; nq-clim/sheet/sheet-parent-mixin
;;;
;;; From CLIM II 7.2.2.
;;;
(cl:defpackage :nq-clim/sheet/sheet-parent-mixin
(:use :cl
:nq-clim/sheet/sheet-hierarchy-protocol)
(:export
"SHEET-PARENT-MIXIN"))
(cl:in-package :nq-clim/sheet/sheet-parent-mixin)
(defclass sheet-parent-mixin ()
((parent :reader sheet-parent)))
(defmethod sheet-adopt-child :around (sheet (child sheet-parent-mixin))
(when (sheet-parent child)
(error 'sheet-already-has-parent :sheet child))
(call-next-method)
(setf (slot-value child 'parent) sheet))
(defmethod sheet-disown-child :around (sheet (child sheet-parent-mixin) &key (errorp t))
(if (eq (sheet-parent child) sheet)
(progn
(call-next-method)
(setf (slot-value child 'parent) nil))
(when errorp
(error 'sheet-is-not-child :parent sheet :sheet child))))
;;; 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