Changeset main,47


Ignore:
Timestamp:
11/12/2007 08:45:41 PM (19 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@tux-20071112204541-jhhqab8g511tp3xv
Message:

Added color to forms.

Location:
main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/form-test.lisp

    r45 r47  
    77
    88
    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))
    1519
    1620(defclass test ()
  • main/form.lisp

    r45 r47  
    3131(defclass textbox-def (value-widget-def)
    3232  ((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)))
    3436
    3537(defclass numberbox-def (value-widget-def)
    3638  ((display-width :initarg :display-width)
    3739   (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)))
    3943
    4044(defclass form-def ()
     
    4347
    4448
     49(defvar *default-inactive-widget-background*)
     50(defvar *default-active-widget-background*)
     51
    4552(defun make-label-def (row column text)
    4653  `(make-instance 'label-def :row ,row :column ,column :text ,text))
    4754
    4855(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*))
    5061  `(make-instance 'textbox-def
    5162                  :row ,row :column ,column :name ',name
    5263                  :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))
    5467
    5568(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*))
    5774  `(make-instance 'numberbox-def
    5875                  :row ,row :column ,column :name ',name
    5976                  :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))
    6180
    6281(defun parse-widget-form (widget-form)
     
    7089(defvar *form-definitions* (make-hash-table :test #'eq ))
    7190
    72 (defmacro defform (name (&body widgets))
     91(defmacro defform (name (&rest options) &body widgets)
    7392  "Each widget is one of:
    7493- (:label row column text)
    7594- (:textbox row column name display-width &key data-width read-only)
    7695- (: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))))))
    82103
    83104
     
    105126        (create-label window row column text))))
    106127  (: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
    108130      (with-slots (data window scroll) form
    109131        (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)))))
    111135  (: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
    113138      (with-slots (data window scroll) form
    114139        (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))))))
    116143
    117144
Note: See TracChangeset for help on using the changeset viewer.