Changeset tag,last-working,9


Ignore:
Timestamp:
10/18/2007 01:18:47 AM (19 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@fugue88.ws-20071018011847-yckzuw3bbitzatrt
Message:

Added code to draw the shortcut-key specially.
Changed drawing code again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tag/last-working/flat-menu.lisp

    r8 r9  
    88
    99(defclass entry ()
    10   ((text :initarg :text)))
     10  ((text :initarg :text)
     11   (shortcut-pos :initarg :shortcut-pos)))
    1112
    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))))
    1524
    1625
     
    2332   (selected :type (integer 0) :initform 0 :accessor selected)))
    2433
    25 (defun redraw-selected (menu with-highlight)
    26   (with-slots (window row column entries selected) menu
    27     (when with-highlight
    28       (cdk::c-wattron window 262144))
    29     (draw-entry (aref entries selected) window (+ row selected) column)
    30     (when with-highlight
    31       (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)))
    3241
    3342(defmethod (setf selected) :before (i (menu menu))
     
    4554(defmethod initialize-instance :after ((menu menu) &rest initargs)
    4655  (declare (ignore initargs))
     56  (with-slots (entries) menu
     57    (dotimes (i (length entries))
     58      (draw-entry menu i)))
    4759  (setf (selected menu) 0))
    4860
     
    6779    (cdk::c-init-color)
    6880    (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)))
    7183      (let ((menu (make-instance 'menu :window screen :row 5 :column 10 :entries (vector entry1 entry2))))
    7284        (activate-menu menu)
Note: See TracChangeset for help on using the changeset viewer.