[cells-devel] celtk expander

Andy Chambers achambers.home at googlemail.com
Fri Nov 2 18:42:02 UTC 2007


Here's my effort at an expander.  It doesn't have the arrow's yet. I
was trying to get the expanding bit working correctly first.  It works
the first time (i.e. you can expand it once, then unexpand) but after
that it kills the kids and can't re-create them again.  Any hints?

(defmodel expander (frame-stack)
  ((label :initarg :label :accessor label :initform "")
   (expanded :initarg :expanded :accessor expanded :initform (c-in nil))
   (expansion :initarg :expansion :accessor expansion :initform nil))
  (:default-initargs))

(defmacro mk-expander ((&rest initargs) &rest kids)
  `(make-instance 'expander , at initargs
    :fm-parent *parent*
    :expansion (c? (the-kids , at kids))
    :expanded (c-in nil)
    :kids (c? (the-kids
	      (mk-button-ex ((^label) (setf
				       (expanded (upper self expander))
				       (not (expanded (upper self expander))))))
	      (when (^expanded)
		(^expansion))))))

;; test the expander
(defmodel test-win (window)
  ()
  (:default-initargs
   :kids (c? (the-kids
	      (mk-stack (:packing (c?pack-self))
		(mk-label :text "hi")
		(mk-expander (:label "expander")
                  (mk-stack ()
		    (mk-label :text "expanded")))
		(mk-label :text "ho"))))))

(defun test ()
  (test-window
   'test-win t))

Cheers,
Andy



More information about the cells-devel mailing list