Changeset main,47
- Timestamp:
- 11/12/2007 08:45:41 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@tux-20071112204541-jhhqab8g511tp3xv
- Location:
- main
- Files:
-
- 2 edited
-
form-test.lisp (modified) (1 diff)
-
form.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/form-test.lisp
r45 r47 7 7 8 8 9 (defform test ((:label 0 0 "Family name:") 10 (:textbox 0 13 family-name 16) 11 (:label 1 0 " Given name:") 12 (:textbox 1 13 given-name 16) 13 (:label 2 0 " Age:") 14 (:numberbox 2 13 age 2))) 9 (defform test (:inactive-widget-background (#\Space 60) 10 :active-widget-background (#\Space 57)) 11 (:label 0 0 "Family name:") 12 (:textbox 0 13 family-name 16 13 :inactive-background (#\Space 6) 14 :active-background (#\Space 3)) 15 (:label 1 0 " Given name:") 16 (:textbox 1 13 given-name 16) 17 (:label 2 0 " Age:") 18 (:numberbox 2 13 age 2)) 15 19 16 20 (defclass test () -
main/form.lisp
r45 r47 31 31 (defclass textbox-def (value-widget-def) 32 32 ((display-width :initarg :display-width) 33 (data-width :initarg :data-width))) 33 (data-width :initarg :data-width) 34 (inactive-background :initarg :inactive-background) 35 (active-background :initarg :active-background))) 34 36 35 37 (defclass numberbox-def (value-widget-def) 36 38 ((display-width :initarg :display-width) 37 39 (data-width :initarg :data-width) 38 (precision :initarg :precision))) 40 (precision :initarg :precision) 41 (inactive-background :initarg :inactive-background) 42 (active-background :initarg :active-background))) 39 43 40 44 (defclass form-def () … … 43 47 44 48 49 (defvar *default-inactive-widget-background*) 50 (defvar *default-active-widget-background*) 51 45 52 (defun make-label-def (row column text) 46 53 `(make-instance 'label-def :row ,row :column ,column :text ,text)) 47 54 48 55 (defun make-textbox-def (row column name display-width 49 &key data-width read-only) 56 &key data-width read-only 57 (inactive-background 58 *default-inactive-widget-background*) 59 (active-background 60 *default-active-widget-background*)) 50 61 `(make-instance 'textbox-def 51 62 :row ,row :column ,column :name ',name 52 63 :display-width ,display-width :data-width ,data-width 53 :read-only ,read-only)) 64 :read-only ,read-only 65 :inactive-background ',inactive-background 66 :active-background ',active-background)) 54 67 55 68 (defun make-numberbox-def (row column name display-width 56 &key data-width precision read-only) 69 &key data-width precision read-only 70 (inactive-background 71 *default-inactive-widget-background*) 72 (active-background 73 *default-active-widget-background*)) 57 74 `(make-instance 'numberbox-def 58 75 :row ,row :column ,column :name ',name 59 76 :display-width ,display-width :data-width ,data-width 60 :precision ,precision :read-only ,read-only)) 77 :precision ,precision :read-only ,read-only 78 :inactive-background ',inactive-background 79 :active-background ',active-background)) 61 80 62 81 (defun parse-widget-form (widget-form) … … 70 89 (defvar *form-definitions* (make-hash-table :test #'eq )) 71 90 72 (defmacro defform (name (& body widgets))91 (defmacro defform (name (&rest options) &body widgets) 73 92 "Each widget is one of: 74 93 - (:label row column text) 75 94 - (:textbox row column name display-width &key data-width read-only) 76 95 - (:numberbox row column name display-width &key data-width precision read-only)" 77 (with-gensyms (elements) 78 `(let ((,elements (list ,@(mapcar 'parse-widget-form widgets)))) 79 (setf (gethash ',name *form-definitions*) 80 (make-instance 'form-def :elements (coerce ,elements 'vector)))))) 81 96 (destructuring-bind (&key ((:inactive-widget-background *default-inactive-widget-background*) '(#\Space 0)) 97 ((:active-widget-background *default-active-widget-background*) '(#\Space 0))) 98 options 99 (with-gensyms (elements) 100 `(let ((,elements (vector ,@(mapcar 'parse-widget-form widgets)))) 101 (setf (gethash ',name *form-definitions*) 102 (make-instance 'form-def :elements ,elements)))))) 82 103 83 104 … … 105 126 (create-label window row column text)))) 106 127 (:method ((tbd textbox-def) form) 107 (with-slots (row column name display-width) tbd 128 (with-slots (row column name display-width inactive-background 129 active-background) tbd 108 130 (with-slots (data window scroll) form 109 131 (let ((r (make-reflector data name))) 110 (create-textbox window (- row scroll) column r display-width))))) 132 (create-textbox window (- row scroll) column r display-width 133 :inactive-background inactive-background 134 :active-background active-background))))) 111 135 (:method ((nbd numberbox-def) form) 112 (with-slots (row column name display-width) nbd 136 (with-slots (row column name display-width inactive-background 137 active-background) nbd 113 138 (with-slots (data window scroll) form 114 139 (let ((r (make-reflector data name))) 115 (create-numberbox window (- row scroll) column r display-width)))))) 140 (create-numberbox window (- row scroll) column r display-width 141 :inactive-background inactive-background 142 :active-background active-background)))))) 116 143 117 144
Note: See TracChangeset
for help on using the changeset viewer.
