More examples


Editing local values (using :plist)

(let* ((name "Noé")
(email "n@algo.be")
(salary 0.0)
(year 2000) ;; property list
(data (list 'name name 'email email 'salary salary 'year year))
(compound (loop for pname in data by #'cddr
`(;; must be a property name in plist, see :accessor documentation however :name ,pname ;; just to allow Dialogue to define input validation functions
:value-type ,(case pname
(salary 'float)
(year 'fixnum)
(t 'string))
:prompt ,(string-capitalize pname)))))
(dialogue compound
:main t
:data data
:edit :plist ; !
:title "Plist")
(setf name (getf data 'name)
email (getf data 'email)
salary (getf data 'salary)
year (getf data 'year))
(values name email salary year))


:name :sash1
:style :vertical
:layout-data (:height 200 :width 400
:horizontalalignment ,*swt.fill*
:grabexcesshorizontalspace t
:verticalalignment ,*swt.fill*
:grabexcessverticalspace t)
((:type :text :style (:multi :border)
:initial-value "1st text control in Sash#1")
(:type :text :style (:multi :border)
:initial-value "2nd text control in Sash#1")
:name :sash2
:style :horizontal
((:type :text :style (:multi :border :wrap)
:initial-value "1st text control in Sash#2")
(:type :text :style (:multi :border) :initial-value "2nd in Sash#2")
(:type :text :style (:multi :border) :initial-value "3rd in Sash#2")))
(lambda (shell) shell
;; Setting the weights of :sash1
(set-sash-weights (find-control :sash1 :test-di) (list 1 1 2)))
:exit-controls nil :name :test-di
:title "2 nested sashforms")


Cells editor

Viewing one array of numbers

;;; the array to edit
(setf *alpha-array
      (let* ((rows-number 5)
             (columns-number 4)
             (array (make-array (list rows-number columns-number))))
        (loop for i from 0 below rows-number do
              (loop for j from 0 below columns-number do
                    (setf (aref array i j)
                          (if (= i j)
                            (+ (* i columns-number) j)))))

 :row-headers '("A" "B" "CCC")
 ;; to format each cell value
 (lambda (table array ri ci table-item) ; RowIndice ColumnIndice
   (declare (ignore table))
   (CED-settext table-item ci (format nil "~a" (aref array ri ci))))
 ;; cell-indices: (RowIndice ColumnIndice)
 (lambda (event table array cell-indices table-item)
   (declare (ignore event table))
   (let ((ri (first cell-indices))
         (ci (second cell-indices)))
      (format nil
              "row indice: ~d~%column indice: ~d~%array value: ~a~%SWT table value: ~a"
              ri ci
              (aref array ri ci)
              (CED-gettext table-item ci))))))


Editing an array of numbers

(let ((cells-ed-name :cells-editor-test))
   :name cells-ed-name
   (lambda (event table array cell-indices table-item)
     (let ((ci (second cell-indices))
           (new-content "Visited"))
       ;; CED-settext-and-pack: set text of cell CI in table-item if New-Content
       ;; is different from the current content
       (unless (CED-settext-and-pack new-content cells-ed-name ci table-item)

3 views, 1 array of CLOS instances (3 slots to view)

Viewing alpha values:

Viewing omega values:

(defclass test-data ()
  ((alpha-value :accessor alpha-value :initarg :alpha-value)
   (beta-value :accessor beta-value :initarg :beta-value)
   (omega-value :accessor omega-value :initarg :omega-value)
   (what-to-view :accessor what-to-view :initform "Alpha values"
                 :allocation :class)))

(let ((cells-editor-name :cells-editor-test))
   :name cells-editor-name
   ;; set alignement in the 3 first columns
   :alignement '(:right :left :center)
   :multi-view-combo-range `("Alpha values" "Beta values" "Omega values")
   (lambda (event control-data) event
     (setf (class-slot-value 'test-data 'what-to-view)
           (get-control-value control-data)))
   (lambda (table array ri ci table-item)
     (let* ((instance (aref array ri ci))
            (what-to-view (class-slot-value 'test-data 'what-to-view))
            (reader (cond ((string= what-to-view "Alpha values")
                          ((string= what-to-view "Beta values")
                          (t #'omega-value))))
       (CED-settext table-item ci 
                    (format nil "~a" (funcall reader instance)))))))