Changeset main,87 for main


Ignore:
Timestamp:
02/23/2008 12:27:43 AM (18 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@fugue88.ws-20080223002743-09u28trz6kvjtdpo
Message:
  • Integrate checkboxes into forms.
  • Fixed checkbox display glitches.
  • Added keystrokes to checkbox.
  • Fixed package symbols.
Location:
main
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/form.lisp

    r80 r87  
    4141   (precision :initarg :precision)
    4242   (inactive-background :initarg :inactive-background)
     43   (active-background :initarg :active-background)))
     44
     45(defclass checkbox-def (value-widget-def)
     46  ((inactive-background :initarg :inactive-background)
    4347   (active-background :initarg :active-background)))
    4448
     
    8387                  :active-background (list ,@active-background)))
    8488
     89(defun make-checkbox-def (row column name &key read-only
     90                          (inactive-background
     91                           *default-inactive-widget-background*)
     92                          (active-background
     93                           *default-active-widget-background*))
     94  `(make-instance 'checkbox-def
     95                  :row ,row :column ,column :name ,name :read-only ,read-only
     96                  :inactive-background (list ,@inactive-background)
     97                  :active-background (list ,@active-background)))
     98
    8599(defun parse-widget-form (widget-form)
    86100  (destructuring-bind (type &rest args) widget-form
     
    88102             (:label 'make-label-def)
    89103             (:textbox 'make-textbox-def)
    90              (:numberbox 'make-numberbox-def))
     104             (:numberbox 'make-numberbox-def)
     105             (:checkbox 'make-checkbox-def))
    91106           args)))
    92107
     
    97112* (:label row column text)
    98113* (:textbox row column name display-width &key data-width read-only)
    99 * (:numberbox row column name display-width &key data-width precision read-only)"
     114* (:numberbox row column name display-width &key data-width precision read-only)
     115* (:checkbox row column name)"
    100116  (destructuring-bind (&key ((:inactive-widget-background *default-inactive-widget-background*) '(#\Nul 0))
    101117                            ((:active-widget-background *default-active-widget-background*) '(#\Nul 0)))
     
    146162                            :validator validator
    147163                            :inactive-background inactive-background
    148                             :active-background active-background))))))
     164                            :active-background active-background)))))
     165  (:method ((cbd checkbox-def) form)
     166    (with-slots (row column name inactive-background active-background) cbd
     167      (with-slots (data window scroll) form
     168        (let ((r (make-reflector data name)))
     169          (create-widget 'db-checkbox window (- row scroll) column
     170                         :data r
     171                         :inactive-background inactive-background
     172                         :active-background active-background))))))
    149173
    150174
  • main/widget/checkbox.lisp

    r84 r87  
    2626   (cue-window :initarg :cue-window)
    2727   (data-window :initarg :data-window)
    28    (active :type boolean :initform nil)))
     28   (active :type boolean :initform nil :accessor active)))
    2929
    3030
     
    3737    (setf (background data-window)
    3838          (if active active-background inactive-background))
    39     (add-clipped-string data-window 0 0 (if (checked cb) "X" " "))
     39    (add-clipped-string data-window 0 0 (if (checked cb) "X" "-"))
    4040    (setf (cursor-position data-window) '(0 0))
    4141    (refresh cue-window)))
     
    4646    (when listener
    4747      (funcall listener))))
     48
     49(defmethod (setf active) :after (flag (cb checkbox))
     50  (draw cb))
    4851
    4952
     
    6871(defmethod activate ((cb checkbox) &key (key-callback 'nothing)
    6972                     &allow-other-keys)
    70   (with-slots (data-window active) cb
    71     (with-accessors ((checked checked)) cb
    72       (set-cursor-visible t)
     73  (with-slots (data-window) cb
     74    (with-accessors ((active active) (checked checked)) cb
     75      #|(set-cursor-visible t)|#
    7376      (setf active t)
    7477      (unwind-protect
     
    7881                (let ((key (read-key data-window)))
    7982                  (case key
     83                    ((#\x #\X)
     84                     (setf checked t))
     85                    (#\-
     86                     (setf checked nil))
    8087                    (#\Space
    8188                     (setf checked (not checked)))
     
    8592                         (return r))))))))
    8693        (setf active nil)
    87         (set-cursor-visible nil)))))
     94        #|(set-cursor-visible nil)|#))))
  • main/widget/db-checkbox.lisp

    r84 r87  
    3232                          &key data &allow-other-keys)
    3333  (assert data (data) "DATA must be specified.")
     34  (loop until (remf args :data))
    3435  (let ((inst (apply 'create-widget 'checkbox parent y x args)))
    35     (change-class inst 'db-checkbox :data data)))
     36    (change-class inst 'db-checkbox :data data)
     37    (draw inst)
     38    inst))
  • main/widget/package.lisp

    r84 r87  
    11(defpackage #:tui-widget
    2   (:use #:cl #:tui-widget-generic #:tui-widget-label #:tui-widget-textbox
    3         #:tui-widget-numberbox)
     2  (:use #:cl #:tui-widget-generic #:tui-widget-db-checkbox #:tui-widget-label
     3        #:tui-widget-textbox #:tui-widget-numberbox)
    44  (:export #:text #:widget #:scroll #:insertion-point #:create-widget #:destroy
    55           #:activate
Note: See TracChangeset for help on using the changeset viewer.