- Timestamp:
- 11/12/2007 07:08:49 PM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@tux-20071112190849-f4iha3mmvx2nskce
- Location:
- main/widget
- Files:
-
- 6 edited
-
generic.lisp (modified) (2 diffs)
-
label.lisp (modified) (1 diff)
-
numberbox-test.lisp (modified) (2 diffs)
-
numberbox.lisp (modified) (1 diff)
-
textbox-test.lisp (modified) (1 diff)
-
textbox.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/widget/generic.lisp
r45 r46 1 1 (defpackage #:tui-widget-generic 2 2 (:use #:cl) 3 (:export #:text #:widget #:parent-window #:column #:row #:scroll 4 #:insertion-point #:destroy #:draw #:activate)) 3 (:export #:text #:widget #:parent-window #:column #:row #:inactive-background 4 #:active-background #:scroll #:insertion-point #:destroy #:draw 5 #:activate)) 5 6 6 7 (in-package #:tui-widget-generic) … … 23 24 ((parent-window :initarg :parent-window) 24 25 (column :type (integer 0) :initarg :column) 25 (row :type (integer 0) :initarg :row))) 26 (row :type (integer 0) :initarg :row) 27 ;; TODO: initform for bg-color 28 (inactive-background :initarg :inactive-background) 29 (active-background :initarg :active-background))) 26 30 27 31 (defclass scroll () -
main/widget/label.lisp
r45 r46 30 30 31 31 (defmethod activate ((label label) &optional callback) 32 (declare (ignore callback)) 32 33 #\Tab) -
main/widget/numberbox-test.lisp
r40 r46 12 12 13 13 14 (defun create-nb (window row name) 15 (create-numberbox window row 10 name 10 16 :inactive-background '(#\Space 60) 17 :active-background '(#\Space 57))) 18 14 19 (defun test () 15 20 (with-screen (s) … … 17 22 (data2 (make-instance 'data)) 18 23 (data3 (make-instance 'data)) 19 (nbs (list (create-n umberbox s 10 10 data1 10)20 (create-n umberbox s 11 10 data2 10)21 (create-n umberbox s 12 10 data3 10))))24 (nbs (list (create-nb s 10 data1) 25 (create-nb s 11 data2) 26 (create-nb s 12 data3)))) 22 27 (setf (cdddr nbs) nbs) 23 28 (refresh s) -
main/widget/numberbox.lisp
r40 r46 32 32 (setf (text data) s))) 33 33 34 (defun create-numberbox (parent-window y x data width) 34 (defun create-numberbox (parent-window y x data width &key 35 (inactive-background '(#\Space 0)) 36 (active-background '(#\Space 0))) 35 37 (let* ((data-wrapper (make-instance 'numberbox-data :data data :width width)) 36 (textbox (create-textbox parent-window y x data-wrapper width))) 38 (textbox (create-textbox parent-window y x data-wrapper width 39 :inactive-background inactive-background 40 :active-background active-background))) 37 41 (change-class textbox 'numberbox))) 38 42 -
main/widget/textbox-test.lisp
r40 r46 14 14 (with-screen (s) 15 15 (let* ((data (make-instance 'data)) 16 (tb (create-textbox s 10 10 data 8))) 16 (tb (create-textbox s 10 10 data 8 17 :active-background '(#\Space 60)))) 17 18 (unwind-protect 18 19 (flet ((cb (key) -
main/widget/textbox.lisp
r44 r46 10 10 (defclass textbox (widget scroll insertion-point) 11 11 ((data :initarg :data) 12 (window :initarg :window))) 12 (window :initarg :window) 13 (active :type boolean :initform nil))) 13 14 14 15 … … 28 29 29 30 (defmethod draw ((textbox textbox)) 30 (with-slots (data window scroll) textbox 31 (with-slots (data window scroll inactive-background active-background active) 32 textbox 33 (setf (background window) (if active 34 active-background 35 inactive-background)) 31 36 (erase window) 32 37 (add-clipped-string window 0 (- scroll) (text data)) … … 58 63 59 64 60 (defun create-textbox (parent-window y x data width) 65 (defun create-textbox (parent-window y x data width &key 66 (inactive-background '(#\Space 0)) 67 (active-background '(#\Space 0))) 61 68 (let* ((window (tui-window::create-subwindow parent-window 1 width y x)) 62 (inst (make-instance 'textbox :data data :window window))) 69 (inst (make-instance 'textbox 70 :data data 71 :window window 72 :inactive-background inactive-background 73 :active-background active-background))) 63 74 (draw inst) 64 75 inst)) … … 79 90 80 91 (defmethod activate ((textbox textbox) &optional (callback 'nothing)) 81 (with-slots (data window) textbox 82 (cdk::c-keypad (window-pointer window) t) 83 (setf (insertion-point textbox) :end) 84 (loop 85 (let ((key (read-key window))) 86 (case key 87 (:key-left (decf (insertion-point textbox))) 88 (:key-right (incf (insertion-point textbox))) 89 (:key-home (setf (insertion-point textbox) 0)) 90 (:key-end (setf (insertion-point textbox) :end)) 91 (:key-backspace 92 (multiple-value-bind (left right) (split textbox) 93 (when (string/= left "") 94 (setf left (subseq left 0 (1- (length left)))) 95 (setf (text data) (concatenate 'string left right)) 96 (decf (insertion-point textbox))))) 97 (:key-dc 98 (multiple-value-bind (left right) (split textbox) 99 (when (string/= right "") 100 (setf right (subseq right 1)) 101 (setf (text data) (concatenate 'string left right)) 102 (setf (insertion-point textbox) (insertion-point textbox))))) 103 (t 104 (if (or (keywordp key) 105 (member key '(#\Return #\Newline #\Tab #\Esc))) 106 (let ((r (funcall callback key))) 107 (when r 108 (setf (insertion-point textbox) 0) 109 (return-from activate r))) 110 (multiple-value-bind (left right) (split textbox) 111 (setf (text data) 112 (concatenate 'string left (string key) right)) 113 (incf (insertion-point textbox)))))))))) 92 (with-slots (data window active) textbox 93 (setf active t) 94 (unwind-protect 95 (progn 96 (cdk::c-keypad (window-pointer window) t) 97 (setf (insertion-point textbox) :end) 98 (loop 99 (let ((key (read-key window))) 100 (case key 101 (:key-left (decf (insertion-point textbox))) 102 (:key-right (incf (insertion-point textbox))) 103 (:key-home (setf (insertion-point textbox) 0)) 104 (:key-end (setf (insertion-point textbox) :end)) 105 (:key-backspace 106 (multiple-value-bind (left right) (split textbox) 107 (when (string/= left "") 108 (setf left (subseq left 0 (1- (length left)))) 109 (setf (text data) (concatenate 'string left right)) 110 (decf (insertion-point textbox))))) 111 (:key-dc 112 (multiple-value-bind (left right) (split textbox) 113 (when (string/= right "") 114 (setf right (subseq right 1)) 115 (setf (text data) (concatenate 'string left right)) 116 (setf (insertion-point textbox) 117 (insertion-point textbox))))) 118 (t 119 (if (or (keywordp key) 120 (member key '(#\Return #\Newline #\Tab #\Esc))) 121 (let ((r (funcall callback key))) 122 (when r 123 (setf (insertion-point textbox) 0) 124 (return-from activate r))) 125 (multiple-value-bind (left right) (split textbox) 126 (setf (text data) 127 (concatenate 'string left (string key) right)) 128 (incf (insertion-point textbox))))))))) 129 (setf active nil))))
Note: See TracChangeset
for help on using the changeset viewer.
