Changeset main,9 for main/flat-menu.lisp
- Timestamp:
- 10/18/2007 01:18:47 AM (19 years ago)
- branch-nick:
- tui
- revision id:
- dsowen@fugue88.ws-20071018011847-yckzuw3bbitzatrt
- File:
-
- 1 edited
-
main/flat-menu.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/flat-menu.lisp
r8 r9 8 8 9 9 (defclass entry () 10 ((text :initarg :text))) 10 ((text :initarg :text) 11 (shortcut-pos :initarg :shortcut-pos))) 11 12 12 (defun draw-entry (entry window row column) 13 (with-slots (text) entry 14 (cdk::move-and-add-string window row column text))) 13 (defun %draw-entry (entry window row column highlight) 14 (with-slots (text shortcut-pos) entry 15 (when highlight 16 (cdk::c-wattron window 262144)) 17 (cdk::move-and-add-string window row column text) 18 (when shortcut-pos 19 (cdk::c-wattron window 131072) 20 (cdk::move-and-add-string window row (+ column shortcut-pos) (string (aref text shortcut-pos))) 21 (cdk::c-wattroff window 131072)) 22 (when highlight 23 (cdk::c-wattroff window 262144)))) 15 24 16 25 … … 23 32 (selected :type (integer 0) :initform 0 :accessor selected))) 24 33 25 (defun redraw-selected (menu with-highlight)26 (with-slots (window row column entries selected) menu27 ( when with-highlight28 (cdk::c-wattron window 262144)) 29 (draw-entry (aref entries selected) window (+ row selected) column)30 (when with-highlight31 (cdk::c-wattroff window 262144))))34 (defun draw-entry (menu i &optional highlight) 35 (with-slots (window row column entries) menu 36 (%draw-entry (aref entries i) window (+ row i) column highlight))) 37 38 (defun redraw-selected (menu highlight) 39 (with-slots (selected) menu 40 (draw-entry menu selected highlight))) 32 41 33 42 (defmethod (setf selected) :before (i (menu menu)) … … 45 54 (defmethod initialize-instance :after ((menu menu) &rest initargs) 46 55 (declare (ignore initargs)) 56 (with-slots (entries) menu 57 (dotimes (i (length entries)) 58 (draw-entry menu i))) 47 59 (setf (selected menu) 0)) 48 60 … … 67 79 (cdk::c-init-color) 68 80 (cdk::c-erase-window screen) 69 (let ((entry1 (make-instance 'entry :text "Hello, world!" ))70 (entry2 (make-instance 'entry :text "Goodbye, galaxy!" )))81 (let ((entry1 (make-instance 'entry :text "Hello, world!" :shortcut-pos 0)) 82 (entry2 (make-instance 'entry :text "Goodbye, galaxy!" :shortcut-pos 0))) 71 83 (let ((menu (make-instance 'menu :window screen :row 5 :column 10 :entries (vector entry1 entry2)))) 72 84 (activate-menu menu)
Note: See TracChangeset
for help on using the changeset viewer.
