CAPI: Restoring divider position II
Hi All,
I hope this isn’t too boring. This is
the most readable and reliable version of saving and restoring a divider
position I could come up with:
(defvar *initial-width* 100)
(define-interface test ()
()
(:panes
(t1 text-input-pane :reader
divider-pane)
(t2 text-input-pane))
(:layouts
(l1 row-layout '(t1 :divider
t2)))
(:default-initargs
:create-callback (lambda
(self)
(set-divider self *initial-width*))
:iconify-callback (lambda
(self iconify)
(if iconify
(save-divider self)
(set-divider self *initial-width*)))
:activate-callback (let
((first-activation t))
(lambda (self activatep)
(when (and activatep (not first-activation))
(release-divider self))
(when
first-activation
(setf first-activation nil))))
:destroy-callback (lambda
(self)
(save-divider self))
:best-width 600))
(defun set-divider (window width
&optional (width-2 width))
"Forces divider into its
position unless width-2 is supplied."
(set-geometric-hint (divider-pane
window) :external-min-width width)
(set-geometric-hint (divider-pane
window) :external-max-width width-2))
(defun release-divider (window)
"Make the divider movable
again."
(set-divider window 10 nil))
(defmethod interface-display :after ((self
test))
(release-divider self))
(defun save-divider (window)
(with-geometry (divider-pane window)
(setf *initial-width*
%width%)))
(defun make-test ()
(display (make-instance
'test)))
Comments and optimizations are welcome.
Andreas