(demo (make <Text-tag> :parent t :lmargin1 "1c" :lmargin2 "1c"))
(hot (apply make <Text-tag> :parent t
(if (= (winfo 'depth *root*) 1)
(list :background "black" :foreground "white")
(list :relief "raised" :border-width 1
:background "SeaGreen3"))))
(last-line '()))
(pack t :expand #t :fill "both")
(pack quit :expand #f :fill "x")
;; Associate binfings to tags
(bind demo "<Button-1>"
(lambda ()
(invoke-demo-binding t (text-index t 'current))))
(bind demo "<Enter>"
(lambda (x y)
(set! last-line (text-index t (format #f "@~A,~A linestart" x y)))
(tag-add hot last-line (cons (car last-line) "end"))))
(bind demo "<Leave>"
(lambda ()
(tag-remove hot '(1 . 0) "end")))
(bind demo "<Motion>"
(lambda (x y)
(let ((new-line (text-index t (format #f "@~A,~A linestart" x y))))
(unless (equal? new-line last-line)
(tag-remove hot '(1 . 0) "end")
(tag-add hot new-line (cons (car new-line) "end"))
(set! last-line new-line)))))
;; Create the text for the text widget.
(text-insert t "end"
"Tk Widget Demonstrations\n\n" (list title)
"This application provides a front end for several short scripts that demonstrate what you can do with Tk widgets. Each of the numbered lines below describes a demonstration; you can click on it to invoke the demonstration. Once the demonstration window appears, you can click the \"See Code\" button to see the Tcl/Tk code that created the demonstration. If you wish, you can edit the code and click the \"Rerun Demo\" button in the code window to reinvoke the demonstration with the modified code.\n" '()
"\nLabels, buttons, checkbuttons, and radiobuttons\n" (list title)
"1. Labels (text and bitmaps).\n" (list demo 'demo-label)
"2. Buttons.\n" (list demo 'demo-button)
"3. Checkbuttons (select any of a group).\n" (list demo 'demo-check)
"4. Radiobuttons (select one of a group).\n" (list demo 'demo-radio)
"5. A 15-puzzle game made out of buttons.\n" (list demo 'demo-puzzle)
"6. Iconic buttons that use bitmaps.\n" (list demo 'demo-icon)
"7. Two labels displaying images.\n" (list demo 'demo-image1)
"8. A simple user interface for viewing images.\n" (list demo 'demo-image2)
;;;;;;
"\nListboxes\n" (list title)
"1. 50 states.\n" (list demo 'demo-states)
"2. Colors: change the color scheme for the application.\n"
(list demo 'demo-colors)
"3. A collection of famous sayings.\n" (list demo 'demo-sayings)
;;;;;;
"\nEntries\n" title
"1. Without scrollbars.\n" (list demo 'demo-entry1)