Lisp HUG Maillist Archive

Puzzled by capi:remove-items

Hi again,

Having troubling getting REMOVE-ITEMS to work as I'd expect.  Was hoping that ':items-callback :redisplay-interface' would address the trouble, but CAPI is rejecting it.

In the example below, a series of Tabs is appended to a TAB-LAYOUT and then removed again.  There is however a 'residue' of the last Tab still visible (and selectable). As usual, I am overlooking something.    8^/


(in-package CL-USER)


(capi:define-interface tab ()
  ((items :initarg :items))
  (:panes
   (things capi:list-panel :items items))
  (:layouts
   (column capi:column-layout '(things)))
  (:default-initargs
   :layout 'column
   :visible-min-height 50
   :auto-menus nil))


(defvar *tabs* 
  `(,(make-instance 'tab 
                    :title "A"
                    :items (list :a :a :a :a))
      ,(make-instance 'tab
                    :title "B"
                    :items (list :b :b :b :b))
      ,(make-instance 'tab
                    :title "C"
                    :items (list :c :c :c :c))))


(defclass tabs (capi:tab-layout)
  ()
  (:default-initargs
   :print-function 'capi:titled-object-title
   :visible-child-function 'identity
   :items-get-function 'svref
   :items nil
;   :items-callback :redisplay-interface ;; I'm surprised this is rejected by CAPI
   :title "Tabs"
   :title-position :frame))


(defun append-tab (tabs tab)
  (capi:apply-in-pane-process tabs
     #'(lambda (tabs)
            (capi:append-items tabs (list tab))
            ;; Appended Tab contents won't display till selected-item is set!?
            (setf (capi:choice-selected-item tabs) tab))
     tabs))


(defun remove-tab (tabs tab)
  (capi:apply-in-pane-process tabs
     #'(lambda (tabs)
            (capi:remove-items tabs (list tab))) 
     tabs))


#|
(progn
  (setq tabs (make-instance 'tabs))
  (capi:contain tabs)
  ;; Append 'em
  (append-tab tabs (first *tabs*))
  (append-tab tabs (second *tabs*))
  (append-tab tabs (third *tabs*))
  ;; Remove 'em
  (remove-tab tabs (first *tabs*))
  (remove-tab tabs (second *tabs*))
  (remove-tab tabs (third *tabs*))
)
|#


Re: Puzzled by capi:remove-items

Brian Connoy wrote on Fri, 28 May 2010 10:46:58 -0400 18:46:

| Having troubling getting REMOVE-ITEMS to work as I'd expect.  Was
| hoping that ':items-callback :redisplay-interface' would address the
| trouble, but CAPI is rejecting it.
|
| In the example below, a series of Tabs is appended to a TAB-LAYOUT and
| then removed again.  There is however a 'residue' of the last Tab still
| visible (and selectable). As usual, I am overlooking something.    8^/

I see the same but do not consider this disastrous :-)

IMHO, turning blank area into a tab or leaving the tab-layout without any
tabs is anti-stylish.

Many wide-spread GUI programs show at least one tab on starting up, e.g.
with an empty new document. You can add and close tabs but one tab always
stays there.
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


Re: Puzzled by capi:remove-items

Unable to parse email body. Email id is 10338

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