[cells-devel] expander reinvigorated

Andy Chambers achambers.home at googlemail.com
Mon Mar 17 20:00:07 UTC 2008


Hi Kenny,

I never quite finished that expander stuff when I was doing it before.  I ran
into difficulties with the up/down icons but I think I know how to fix
that now.  However
there seems to be another problem.  If you try evaluate the test-window form at
the bottom, every second time, you get "Tcl Error: out of stack
space".  I think there
must be something that needs to be destroyed somewhere but none of the other
composite widgets seem to have to do that.

Any ideas?


(defmodel expander (frame-stack)
  ((label :initarg :label :accessor label :initform (c-in nil))
   (expansion :initarg :expansion :accessor expansion :initform nil)
   (expanded :initarg :expanded :accessor expanded :initform (c-in nil)))
  (:default-initargs
    :fm-parent (error "expander widget must have some kind of parent")))


(defmacro mk-expander ((&rest inits) &body body)
  `(make-instance 'expander
                  , at inits
                  :fm-parent *parent*
                  :expansion (c? (the-kids , at body))
                  :expanded (c-in t)
                  :kids (c? (the-kids
                             (mk-button-ex ((^label) (setf (expanded
(upper self expander))
                                                          (not
(expanded (upper self expander))))))
			     (^expansion)))
		  :kids-packing (c? (when (^kids)
				      (if (^expanded)
					  (format nil "pack~{ ~a~} -side top -anchor nw  -padx ~a -pady ~a"
						  (mapcar 'path (^kids))
						  (^padx) (^pady))

					  (format nil "pack forget~{ ~a~}"
						  (mapcar 'path (cdr (^kids)))))))))


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

(test-window 'expander-test)



More information about the cells-devel mailing list