Lisp HUG Maillist Archive

capi property editor?

Before I build one, I thought I'd check if I'd missed the obvious:

Is there a capi "property editor" pane?  

Something that displays two columns of info, the left column being the "name" 
of the property and the right column containing the "value" of the property 
and allowing edit-in-place of the "value".

thanks
pt



Re: capi property editor?

Hello Paul,

| Before I build one, I thought I'd check if I'd missed the obvious:
|
| Is there a capi "property editor" pane?
|
| Something that displays two columns of info, the left column being the
| "name" of the property and the right column containing the "value" of
| the property and allowing edit-in-place of the "value".

The simplest implementation by means of YstokGird is below. The full version
contains test interface and is attached. This file will be included in the
future release.

(defun plist-delete-callback (grid record)
  (remf (slot-value grid 'plist) (grid:cell-value grid record 'name)))

(defun plist-update-callback (grid record)
  (if (getf (grid:record-plist record) :new)
      (lw:nconcf (slot-value grid 'plist) (grid:record-data record))))

(defclass plist-grid (grid:sorted-grid)
((plist :initarg :plist :initform () :reader grid-plist))
(:default-initargs
  :column-descriptions '((name ;:title "Property Name"
                          :data-write-converter intern
                          :sort-asc string-lessp :sort-desc string-greaterp)
                         (value ;:title "Property Value"
                          :print-function prin1-to-string
                          :data-read-converter prin1-to-string
                          :data-write-converter read-from-string))
  :delete-callback 'plist-delete-callback
  :update-callback 'plist-update-callback))

(defmethod grid:fetch-grid ((grid plist-grid) (plist list) &key)
  (do ((rest (setf (slot-value grid 'plist) plist) (cddr rest)))
      ((null rest))
    (grid:add-record grid rest)))

(defmethod (setf grid-plist) (plist (grid plist-grid))
  (capi:execute-with-interface grid
    (lambda (grid plist)
      (grid:wipe-grid grid :redraw-now t)
      (grid:fetch-grid grid plist))
    grid plist)) ;(copy-list plist)?
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru

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