;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.presentation) ;;;;;; ;;; primitive/maker (def (component e) primitive/maker (primitive/presentation t/maker) ((initform) (use-initform :type boolean)) (:documentation "A PRIMITIVE/MAKER makers new values of primitive TYPEs.")) (def constructor primitive/maker () (setf (use-initform? -self-) (slot-boundp -self- 'initform))) (def render-xhtml :before primitive/maker (ensure-client-state-sink -self-)) (def function render-initform (component) (when (slot-boundp component 'initform) )) ;;;;;; ;;; unbound/maker (def (component e) unbound/maker (unbound/presentation primitive/maker) ()) ;;;;;; ;;; null/maker (def (component e) null/maker (null/presentation primitive/maker) ()) (def subtype-mapper *maker-type-mapping* null null/maker) ;;;;;; ;;; boolean/maker (def (component e) boolean/maker (boolean/presentation primitive/maker) ()) (def subtype-mapper *maker-type-mapping* boolean boolean/maker) (def render-xhtml boolean/maker (bind (((:read-only-slots component-value-type client-state-sink) -self-) (has-initform? (slot-boundp -self- 'initform)) (initform (when has-initform? (initform-of -self-))) (literal-initform? (member initform '(#f #t)))) (if (and (eq component-value-type 'boolean) ; FIXME is this a KLUDGE to test for a simple 'boolean type as opposed to (or null boolean)? then mark so, or use a properly named function instead. has-initform? literal-initform?) (render-checkbox-field (to-boolean (and has-initform? (eq initform #t))) ;; FIXME how is it supposed to work? where should the client value be stored when needs storage? :value-sink client-state-sink :preprocess-value #f)