diff --git a/source/clog-presentations.lisp b/source/clog-presentations.lisp index 17cf6a2..3376363 100644 --- a/source/clog-presentations.lisp +++ b/source/clog-presentations.lisp @@ -8,12 +8,44 @@ (cl:in-package :clog) -;;; clog-presentations - link Lisp classes to CLOG objects +;;; clog-presentations - link Lisp objects and CLOG objects ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-presentations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; link-slot-and-form-element ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmacro link-slot-and-form-element (object accessor clog-obj + &key (set-event #'set-on-change) + transform-to-lisp + transform-to-element) + "Biderectional link slot (ACCESSOR OBJECT) <> clog-form-element (CLOG-OBJ)" + `(progn + (link-form-element-to-slot ,clog-obj ,object ,accessor + :set-event ,set-event + :transform ,transform-to-lisp) + (link-slot-to-form-element ,object ,accessor ,clog-obj + :transform ,transform-to-element))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; link-slot-and-element ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defmacro link-slot-and-element (object accessor clog-obj + &key (set-event #'set-on-change) + transform-to-lisp + transform-to-element) + "Biderectional link slot (ACCESSOR OBJECT) <> clog-element (CLOG-OBJ)" + `(progn + (link-element-to-slot ,clog-obj ,object ,accessor + :set-event ,set-event + :transform ,transform-to-lisp) + (link-slot-to-element ,object ,accessor ,clog-obj + :transform ,transform-to-element))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; link-form-element-to-slot ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog.lisp b/source/clog.lisp index 7ee23f4..20aa70c 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -495,6 +495,8 @@ embedded in a native template application.)" (defsection @clog-presentations (:title "CLOG Presentations") "CLOG-Presentations - CLOG Presentations" + (link-slot-and-form-element macro) + (link-slot-and-element macro) (link-form-element-to-slot macro) (link-element-to-slot macro) (link-element-to-place macro) diff --git a/tutorial/29-tutorial.lisp b/tutorial/29-tutorial.lisp index a17aeae..cf05f7e 100644 --- a/tutorial/29-tutorial.lisp +++ b/tutorial/29-tutorial.lisp @@ -25,12 +25,10 @@ :label (create-label body :content "Change my-count:")))) (declare (ignore tmp)) ;; We set up direct relationships between lisp objects and clog objects - ;; any change to i1 will change my-slot - (link-form-element-to-slot i1 lisp-obj my-slot) - ;; any change to my-slot will change i1 after transforming - ;; my-slot to upercase - (link-slot-to-form-element lisp-obj my-slot i1 - :transform #'string-upcase) + ;; any change to i1 will change my-slot and any change to my-slot + ;; will change i1. + (link-slot-and-form-element lisp-obj my-slot i1 + :transform-to-element #'string-upcase) ;; any change to my-count will change t1 (link-slot-to-element lisp-obj my-count t1) ;; any change to i3 will change my-count