subclass UCW's form classes in the editor layer.
[clinton/lisp-on-lines.git] / src / standard-wrappers.lisp
index bb24876..43151ca 100644 (file)
@@ -3,16 +3,21 @@
 ;;;;; Wrap a display in "back buttons"
 (deflayer wrap-back-buttons)
 
+(defvar *back-buttons-wrapped-p* nil)
+
 (defdisplay
-    :in-layer wrap-back-buttons :around
-    (description object)
-    
-    (<ucw:a :class "wiz-button previous" :action (ok component t)
-           (<:as-html "Go Back"))
-    (<:div :style "clear:both;"
-          (call-next-method))
-    (<ucw:a :class "wiz-button previous" :action (ok component t)
-           (<:as-html "Go Back")))
+  :in-layer wrap-back-buttons :around
+  (description object)
+  (if  *back-buttons-wrapped-p*
+       (call-next-method)
+       (let ((*back-buttons-wrapped-p* t))
+       
+        (<ucw:a :class "wiz-button previous" :action (ok self t)
+                (<:as-html "Go Back"))
+        (<:div :style "clear:both;"
+               (call-next-method))
+        (<ucw:a :class "wiz-button previous" :action (ok self t)
+                (<:as-html "Go Back")))))
 
 ;;;; Wrap an object display in with a link to the object
 
            (<ucw:a :action (call-display self object link)
                    (call-next-method)))))))
 
-
-
 ;;; wrap-a-form
 (deflayer wrap-form)
 
-(defdisplay ((description t) (button (eql 'standard-form-buttons)))
-  (<ucw:submit :action (ok self)
-              :value "Ok."))
+(define-layered-class description
+  :in-layer wrap-form ()
+  ((form-buttons :initarg :form-buttons :initform nil :special t :accessor form-buttons)))
+
+
+(defdisplay ((description (eql 'standard-form-buttons)) description-object)        
+  (macrolet ((submit (&key action value )
+              `(<ucw::simple-submit
+                :action (funcall ,action)
+                
+                (<:as-html ,value))))
+    (loop for button in (form-buttons description-object)
+        do 
+        (let ((button button))
+          (with-properties (button)
+            (let ((action (.get :action)))
+              (submit :value (.get :value)
+                      :action action)))))))
+
+
 
-(defdisplay :in-layer wrap-form :around (object description)
+(defdisplay :in-layer wrap-form :around (description object)
   (<ucw:form
    :action (refresh-component self)
    (with-inactive-layers (wrap-form)
 
      (call-next-method)
-     ;(display* 'standard-form-buttons)
-   )))
\ No newline at end of file
+     (display-attribute 'standard-form-buttons description))))
+
+;;;; wrap a DIV
+
+
+(deflayer wrap-div)
+
+(define-layered-class description
+  :in-layer wrap-div ()
+  ((div-attributes :accessor div-attributes :initarg :div :special t :initform nil)))
+
+(defdisplay :in-layer wrap-div :around (description object)
+ (let ((args (div-attributes description)))
+   (with-inactive-layers (wrap-div)
+     (yaclml::funcall-with-tag
+      (cons '<:div args)
+      (lambda ()
+       (call-next-method))))))
+
+     
\ No newline at end of file