Lisp HUG Maillist Archive

*layout-divider-default-size* deprecated

Unable to parse email body. Email id is 7330

Trouble overriding (setf capi:layout-description)

I'd like to override (setf capi:layout-description) for a class of
mine, but the method I define is never called. I can't figure out what
I'm doing wrong.

In the example below, my method should just print a message to show
that it was called, but it doesn't.  Thanks for any help.

Mitch

;;; clear-pinboard-objects is called when clear-button is pressed.
;;; Since (setf capi:layout-description) is overridden for the
;;; my-pinboard-layout class, the pinboard shouldn't be cleared.
;;; Instead the string from the following defmethod should print

(defun clear-pinboard-objects (pinboard)
  (print "My layout-description will be called next")
  (setf (capi:layout-description pinboard) nil))

(defmethod (setf capi:layout-description)
           ((pinboard my-pinboard-layout) objects)
  (declare (ignore objects))
  (print "My layout-description was called"))

(defclass my-pinboard-layout (capi:pinboard-layout)
  ()
  (:default-initargs
   :background :red))

(capi:define-interface my-pinboard ()
  ()
  (:panes
   (clear-button
    capi:push-button
    :text "Clear? Pinboard"
    :callback-type :none
    :callback #'(lambda ()
                  (clear-pinboard-objects pinboard))))
  (:layouts
   (buttons
    capi:row-layout
    '(clear-button))
   (pinboard
    my-pinboard-layout
    nil
    :draw-pinboard-objects :local-buffer)
   (main-layout
    capi:column-layout
    '(pinboard buttons)
    :x-adjust :centre))
  (:default-initargs
   :layout 'main-layout
   :best-width 400
   :best-height 400))

(defun test-my-pinboard ()
  (capi:display (make-instance 'my-pinboard)))


Re: Trouble overriding (setf capi:layout-description)

On Sun, 06 Jan 2008 23:49:22 -0500, Mitch <mitch@bermita.com> wrote:

> (defmethod (setf capi:layout-description)
>            ((pinboard my-pinboard-layout) objects)
>   (declare (ignore objects))
>   (print "My layout-description was called"))

When you define SETF functions, the "new value" must be the first
argument, i.e. in your case it should be

  (defmethod (setf capi:layout-description)
             (objects (pinboard my-pinboard-layout))
    ...

Edi.


Updated at: 2020-12-10 08:44 UTC