diff --git a/.gitattributes b/.gitattributes index 653ddf81ab665f2f839557aa378095437cd893de..586a5a714408b44e2d59d961a332d6a9298e5860 100644 --- a/.gitattributes +++ b/.gitattributes @@ -118,3 +118,6 @@ evalkit_llava/lib/libreadline.so.8 filter=lfs diff=lfs merge=lfs -text evalkit_llava/lib/libtinfow.so.6.4 filter=lfs diff=lfs merge=lfs -text evalkit_llava/lib/libncursesw.so filter=lfs diff=lfs merge=lfs -text evalkit_llava/lib/python3.10/site-packages/setuptools/_vendor/more_itertools/__pycache__/more.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text +evalkit_llava/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text +evalkit_llava/lib/libreadline.so filter=lfs diff=lfs merge=lfs -text +evalkit_llava/lib/python3.10/lib-dynload/array.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text diff --git a/evalkit_llava/lib/libreadline.so b/evalkit_llava/lib/libreadline.so new file mode 100644 index 0000000000000000000000000000000000000000..3d1ca162d3248c9d4e76c84be87174ab49829fe1 --- /dev/null +++ b/evalkit_llava/lib/libreadline.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b6a9d66a73115c872272bb479c8f29df1bf7d9b16e5913e083d64b7753ce1c6 +size 411464 diff --git a/evalkit_llava/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so b/evalkit_llava/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..9592dbb3b24ff7d766b21626b3f4809a2d9536e6 --- /dev/null +++ b/evalkit_llava/lib/python3.10/lib-dynload/_lzma.cpython-310-x86_64-linux-gnu.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebfdcab2537ab089e99839348e41c28e8ce2b63d58d095f94c9f80a753748b0b +size 145376 diff --git a/evalkit_llava/lib/python3.10/lib-dynload/array.cpython-310-x86_64-linux-gnu.so b/evalkit_llava/lib/python3.10/lib-dynload/array.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..7f4a8b1c4a2334b4d1caee553b66de7ed7bb214a --- /dev/null +++ b/evalkit_llava/lib/python3.10/lib-dynload/array.cpython-310-x86_64-linux-gnu.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12e45ee9da9d37cf82992df35fed43551d3f6990306c9cc7652b776334253b6f +size 231120 diff --git a/evalkit_llava/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip b/evalkit_llava/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip new file mode 100644 index 0000000000000000000000000000000000000000..400905eecf0385de4d3b8e50b9892e1302b2b894 --- /dev/null +++ b/evalkit_llava/lib/python3.10/site-packages/pkg_resources/tests/data/my-test-package-zip/my-test-package.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01845c437f4655e3cf9cc4fc4e49cfd607431f22675e1b611129a90239f34822 +size 1809 diff --git a/evalkit_llava/lib/tk8.6/button.tcl b/evalkit_llava/lib/tk8.6/button.tcl new file mode 100644 index 0000000000000000000000000000000000000000..9b13607710a078ed34458ad8179f1d80c2a2d9c5 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/button.tcl @@ -0,0 +1,782 @@ +# button.tcl -- +# +# This file defines the default bindings for Tk label, button, +# checkbutton, and radiobutton widgets and provides procedures +# that help in implementing those bindings. +# +# Copyright (c) 1992-1994 The Regents of the University of California. +# Copyright (c) 1994-1996 Sun Microsystems, Inc. +# Copyright (c) 2002 ActiveState Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +#------------------------------------------------------------------------- +# The code below creates the default class bindings for buttons. +#------------------------------------------------------------------------- + +if {[tk windowingsystem] eq "aqua"} { + + bind Radiobutton { + tk::ButtonEnter %W + } + bind Radiobutton <1> { + tk::ButtonDown %W + } + bind Radiobutton { + tk::ButtonUp %W + } + bind Checkbutton { + tk::ButtonEnter %W + } + bind Checkbutton <1> { + tk::ButtonDown %W + } + bind Checkbutton { + tk::ButtonUp %W + } + bind Checkbutton { + tk::ButtonLeave %W + } +} +if {"win32" eq [tk windowingsystem]} { + bind Checkbutton { + tk::CheckRadioInvoke %W select + } + bind Checkbutton { + tk::CheckRadioInvoke %W select + } + bind Checkbutton { + tk::CheckRadioInvoke %W deselect + } + bind Checkbutton <1> { + tk::CheckRadioDown %W + } + bind Checkbutton { + tk::ButtonUp %W + } + bind Checkbutton { + tk::CheckRadioEnter %W + } + bind Checkbutton { + tk::ButtonLeave %W + } + + bind Radiobutton <1> { + tk::CheckRadioDown %W + } + bind Radiobutton { + tk::ButtonUp %W + } + bind Radiobutton { + tk::CheckRadioEnter %W + } +} +if {"x11" eq [tk windowingsystem]} { + bind Checkbutton { + if {!$tk_strictMotif} { + tk::CheckInvoke %W + } + } + bind Radiobutton { + if {!$tk_strictMotif} { + tk::CheckRadioInvoke %W + } + } + bind Checkbutton <1> { + tk::CheckInvoke %W + } + bind Radiobutton <1> { + tk::CheckRadioInvoke %W + } + bind Checkbutton { + tk::CheckEnter %W + } + bind Radiobutton { + tk::ButtonEnter %W + } + bind Checkbutton { + tk::CheckLeave %W + } +} + +bind Button { + tk::ButtonInvoke %W +} +bind Checkbutton { + tk::CheckRadioInvoke %W +} +bind Radiobutton { + tk::CheckRadioInvoke %W +} +bind Button <> { + tk::ButtonInvoke %W +} +bind Checkbutton <> { + tk::CheckRadioInvoke %W +} +bind Radiobutton <> { + tk::CheckRadioInvoke %W +} + +bind Button {} +bind Button { + tk::ButtonEnter %W +} +bind Button { + tk::ButtonLeave %W +} +bind Button <1> { + tk::ButtonDown %W +} +bind Button { + tk::ButtonUp %W +} + +bind Checkbutton {} + +bind Radiobutton {} +bind Radiobutton { + tk::ButtonLeave %W +} + +if {"win32" eq [tk windowingsystem]} { + +######################### +# Windows implementation +######################### + +# ::tk::ButtonEnter -- +# The procedure below is invoked when the mouse pointer enters a +# button widget. It records the button we're in and changes the +# state of the button to active unless the button is disabled. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonEnter w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + set Priv($w,relief) [$w cget -relief] + if {$Priv(buttonWindow) eq $w} { + $w configure -relief sunken -state active + set Priv($w,prelief) sunken + } elseif {[set over [$w cget -overrelief]] ne ""} { + $w configure -relief $over + set Priv($w,prelief) $over + } + } + set Priv(window) $w +} + +# ::tk::ButtonLeave -- +# The procedure below is invoked when the mouse pointer leaves a +# button widget. It changes the state of the button back to inactive. +# Restore any modified relief too. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + $w configure -state normal + } + + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + set Priv(window) "" +} + +# ::tk::ButtonDown -- +# The procedure below is invoked when the mouse button is pressed in +# a button widget. It records the fact that the mouse is in the button, +# saves the button's relief so it can be restored later, and changes +# the relief to sunken. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonDown w { + variable ::tk::Priv + + # Only save the button's relief if it does not yet exist. If there + # is an overrelief setting, Priv($w,relief) will already have been set, + # and the current value of the -relief option will be incorrect. + + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w + $w configure -relief sunken -state active + set Priv($w,prelief) sunken + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set delay [$w cget -repeatdelay] + set Priv(repeated) 0 + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } + } +} + +# ::tk::ButtonUp -- +# The procedure below is invoked when the mouse button is released +# in a button widget. It restores the button's relief and invokes +# the command as long as the mouse hasn't left the button. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {$Priv(buttonWindow) eq $w} { + set Priv(buttonWindow) "" + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + $w configure -state normal + + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } + } + } +} + +# ::tk::CheckRadioEnter -- +# The procedure below is invoked when the mouse pointer enters a +# checkbutton or radiobutton widget. It records the button we're in +# and changes the state of the button to active unless the button is +# disabled. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckRadioEnter w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + if {$Priv(buttonWindow) eq $w} { + $w configure -state active + } + if {[set over [$w cget -overrelief]] ne ""} { + set Priv($w,relief) [$w cget -relief] + set Priv($w,prelief) $over + $w configure -relief $over + } + } + set Priv(window) $w +} + +# ::tk::CheckRadioDown -- +# The procedure below is invoked when the mouse button is pressed in +# a button widget. It records the fact that the mouse is in the button, +# saves the button's relief so it can be restored later, and changes +# the relief to sunken. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckRadioDown w { + variable ::tk::Priv + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w + set Priv(repeated) 0 + $w configure -state active + } +} + +} + +if {"x11" eq [tk windowingsystem]} { + +##################### +# Unix implementation +##################### + +# ::tk::ButtonEnter -- +# The procedure below is invoked when the mouse pointer enters a +# button widget. It records the button we're in and changes the +# state of the button to active unless the button is disabled. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonEnter {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + # On unix the state is active just with mouse-over + $w configure -state active + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + set Priv($w,relief) [$w cget -relief] + if {$Priv(buttonWindow) eq $w} { + $w configure -relief sunken + set Priv($w,prelief) sunken + } elseif {[set over [$w cget -overrelief]] ne ""} { + $w configure -relief $over + set Priv($w,prelief) $over + } + } + set Priv(window) $w +} + +# ::tk::ButtonLeave -- +# The procedure below is invoked when the mouse pointer leaves a +# button widget. It changes the state of the button back to inactive. +# Restore any modified relief too. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + $w configure -state normal + } + + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + set Priv(window) "" +} + +# ::tk::ButtonDown -- +# The procedure below is invoked when the mouse button is pressed in +# a button widget. It records the fact that the mouse is in the button, +# saves the button's relief so it can be restored later, and changes +# the relief to sunken. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonDown w { + variable ::tk::Priv + + # Only save the button's relief if it does not yet exist. If there + # is an overrelief setting, Priv($w,relief) will already have been set, + # and the current value of the -relief option will be incorrect. + + if {![info exists Priv($w,relief)]} { + set Priv($w,relief) [$w cget -relief] + } + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w + $w configure -relief sunken + set Priv($w,prelief) sunken + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set delay [$w cget -repeatdelay] + set Priv(repeated) 0 + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } + } +} + +# ::tk::ButtonUp -- +# The procedure below is invoked when the mouse button is released +# in a button widget. It restores the button's relief and invokes +# the command as long as the mouse hasn't left the button. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {$w eq $Priv(buttonWindow)} { + set Priv(buttonWindow) "" + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } + } + } +} + +} + +if {[tk windowingsystem] eq "aqua"} { + +#################### +# Mac implementation +#################### + +# ::tk::ButtonEnter -- +# The procedure below is invoked when the mouse pointer enters a +# button widget. It records the button we're in and changes the +# state of the button to active unless the button is disabled. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonEnter {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + + # If there's an -overrelief value, set the relief to that. + + if {$Priv(buttonWindow) eq $w} { + $w configure -state active + } elseif {[set over [$w cget -overrelief]] ne ""} { + set Priv($w,relief) [$w cget -relief] + set Priv($w,prelief) $over + $w configure -relief $over + } + } + set Priv(window) $w +} + +# ::tk::ButtonLeave -- +# The procedure below is invoked when the mouse pointer leaves a +# button widget. It changes the state of the button back to +# inactive. If we're leaving the button window with a mouse button +# pressed (Priv(buttonWindow) == $w), restore the relief of the +# button too. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonLeave w { + variable ::tk::Priv + if {$w eq $Priv(buttonWindow)} { + $w configure -state normal + } + + # Restore the original button relief if it was changed by Tk. + # That is signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + set Priv(window) "" +} + +# ::tk::ButtonDown -- +# The procedure below is invoked when the mouse button is pressed in +# a button widget. It records the fact that the mouse is in the button, +# saves the button's relief so it can be restored later, and changes +# the relief to sunken. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonDown w { + variable ::tk::Priv + + if {[$w cget -state] ne "disabled"} { + set Priv(buttonWindow) $w + $w configure -state active + + # If this button has a repeatdelay set up, get it going with an after + after cancel $Priv(afterId) + set Priv(repeated) 0 + if { ![catch {$w cget -repeatdelay} delay] } { + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } + } + } +} + +# ::tk::ButtonUp -- +# The procedure below is invoked when the mouse button is released +# in a button widget. It restores the button's relief and invokes +# the command as long as the mouse hasn't left the button. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonUp w { + variable ::tk::Priv + if {$Priv(buttonWindow) eq $w} { + set Priv(buttonWindow) "" + $w configure -state normal + + # Restore the button's relief if it was cached. + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + # Clean up the after event from the auto-repeater + after cancel $Priv(afterId) + + if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} { + # Only invoke the command if it wasn't already invoked by the + # auto-repeater functionality + if { $Priv(repeated) == 0 } { + uplevel #0 [list $w invoke] + } + } + } +} + +} + +################## +# Shared routines +################## + +# ::tk::ButtonInvoke -- +# The procedure below is called when a button is invoked through +# the keyboard. It simulate a press of the button via the mouse. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::ButtonInvoke w { + if {[winfo exists $w] && [$w cget -state] ne "disabled"} { + set oldRelief [$w cget -relief] + set oldState [$w cget -state] + $w configure -state active -relief sunken + after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief] + } +} + +# ::tk::ButtonInvokeEnd -- +# The procedure below is called after a button is invoked through +# the keyboard. It simulate a release of the button via the mouse. +# +# Arguments: +# w - The name of the widget. +# oldState - Old state to be set back. +# oldRelief - Old relief to be set back. + +proc ::tk::ButtonInvokeEnd {w oldState oldRelief} { + if {[winfo exists $w]} { + $w configure -state $oldState -relief $oldRelief + uplevel #0 [list $w invoke] + } +} + +# ::tk::ButtonAutoInvoke -- +# +# Invoke an auto-repeating button, and set it up to continue to repeat. +# +# Arguments: +# w button to invoke. +# +# Results: +# None. +# +# Side effects: +# May create an after event to call ::tk::ButtonAutoInvoke. + +proc ::tk::ButtonAutoInvoke {w} { + variable ::tk::Priv + after cancel $Priv(afterId) + set delay [$w cget -repeatinterval] + if {$Priv(window) eq $w} { + incr Priv(repeated) + uplevel #0 [list $w invoke] + } + if {$delay > 0} { + set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]] + } +} + +# ::tk::CheckRadioInvoke -- +# The procedure below is invoked when the mouse button is pressed in +# a checkbutton or radiobutton widget, or when the widget is invoked +# through the keyboard. It invokes the widget if it +# isn't disabled. +# +# Arguments: +# w - The name of the widget. +# cmd - The subcommand to invoke (one of invoke, select, or deselect). + +proc ::tk::CheckRadioInvoke {w {cmd invoke}} { + if {[$w cget -state] ne "disabled"} { + uplevel #0 [list $w $cmd] + } +} + +# Special versions of the handlers for checkbuttons on Unix that do the magic +# to make things work right when the checkbutton indicator is hidden; +# radiobuttons don't need this complexity. + +# ::tk::CheckInvoke -- +# The procedure below invokes the checkbutton, like ButtonInvoke, but handles +# what to do when the checkbutton indicator is missing. Only used on Unix. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckInvoke {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + # Additional logic to switch the "selected" colors around if necessary + # (when we're indicator-less). + + if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} { + if {[$w cget -selectcolor] eq $Priv($w,aselectcolor)} { + $w configure -selectcolor $Priv($w,selectcolor) + } else { + $w configure -selectcolor $Priv($w,aselectcolor) + } + } + uplevel #0 [list $w invoke] + } +} + +# ::tk::CheckEnter -- +# The procedure below enters the checkbutton, like ButtonEnter, but handles +# what to do when the checkbutton indicator is missing. Only used on Unix. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckEnter {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + # On unix the state is active just with mouse-over + $w configure -state active + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + set Priv($w,relief) [$w cget -relief] + if {$Priv(buttonWindow) eq $w} { + $w configure -relief sunken + set Priv($w,prelief) sunken + } elseif {[set over [$w cget -overrelief]] ne ""} { + $w configure -relief $over + set Priv($w,prelief) $over + } + + # Compute what the "selected and active" color should be. + + if {![$w cget -indicatoron] && [$w cget -selectcolor] ne ""} { + set Priv($w,selectcolor) [$w cget -selectcolor] + lassign [winfo rgb $w [$w cget -selectcolor]] r1 g1 b1 + lassign [winfo rgb $w [$w cget -activebackground]] r2 g2 b2 + set Priv($w,aselectcolor) \ + [format "#%04x%04x%04x" [expr {($r1+$r2)/2}] \ + [expr {($g1+$g2)/2}] [expr {($b1+$b2)/2}]] + # use uplevel to work with other var resolvers + if {[uplevel #0 [list set [$w cget -variable]]] + eq [$w cget -onvalue]} { + $w configure -selectcolor $Priv($w,aselectcolor) + } + } + } + set Priv(window) $w +} + +# ::tk::CheckLeave -- +# The procedure below leaves the checkbutton, like ButtonLeave, but handles +# what to do when the checkbutton indicator is missing. Only used on Unix. +# +# Arguments: +# w - The name of the widget. + +proc ::tk::CheckLeave {w} { + variable ::tk::Priv + if {[$w cget -state] ne "disabled"} { + $w configure -state normal + } + + # Restore the original button "selected" color; but only if the user + # has not changed it in the meantime. + + if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} { + if {[$w cget -selectcolor] eq $Priv($w,selectcolor) + || ([info exist Priv($w,aselectcolor)] && + [$w cget -selectcolor] eq $Priv($w,aselectcolor))} { + $w configure -selectcolor $Priv($w,selectcolor) + } + } + unset -nocomplain Priv($w,selectcolor) Priv($w,aselectcolor) + + # Restore the original button relief if it was changed by Tk. That is + # signaled by the existence of Priv($w,prelief). + + if {[info exists Priv($w,relief)]} { + if {[info exists Priv($w,prelief)] && \ + $Priv($w,prelief) eq [$w cget -relief]} { + $w configure -relief $Priv($w,relief) + } + unset -nocomplain Priv($w,relief) Priv($w,prelief) + } + + set Priv(window) "" +} + +return + +# Local Variables: +# mode: tcl +# fill-column: 78 +# End: diff --git a/evalkit_llava/lib/tk8.6/choosedir.tcl b/evalkit_llava/lib/tk8.6/choosedir.tcl new file mode 100644 index 0000000000000000000000000000000000000000..33a66b19b3d9a77b8d794c1eb95e86e8ecd01bc2 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/choosedir.tcl @@ -0,0 +1,310 @@ +# choosedir.tcl -- +# +# Choose directory dialog implementation for Unix/Mac. +# +# Copyright (c) 1998-2000 by Scriptics Corporation. +# All rights reserved. + +# Make sure the tk::dialog namespace, in which all dialogs should live, exists +namespace eval ::tk::dialog {} +namespace eval ::tk::dialog::file {} + +# Make the chooseDir namespace inside the dialog namespace +namespace eval ::tk::dialog::file::chooseDir { + namespace import -force ::tk::msgcat::* +} + +# ::tk::dialog::file::chooseDir:: -- +# +# Implements the TK directory selection dialog. +# +# Arguments: +# args Options parsed by the procedure. +# +proc ::tk::dialog::file::chooseDir:: {args} { + variable ::tk::Priv + set dataName __tk_choosedir + upvar ::tk::dialog::file::$dataName data + Config $dataName $args + + if {$data(-parent) eq "."} { + set w .$dataName + } else { + set w $data(-parent).$dataName + } + + # (re)create the dialog box if necessary + # + if {![winfo exists $w]} { + ::tk::dialog::file::Create $w TkChooseDir + } elseif {[winfo class $w] ne "TkChooseDir"} { + destroy $w + ::tk::dialog::file::Create $w TkChooseDir + } else { + set data(dirMenuBtn) $w.contents.f1.menu + set data(dirMenu) $w.contents.f1.menu.menu + set data(upBtn) $w.contents.f1.up + set data(icons) $w.contents.icons + set data(ent) $w.contents.f2.ent + set data(okBtn) $w.contents.f2.ok + set data(cancelBtn) $w.contents.f2.cancel + set data(hiddenBtn) $w.contents.f2.hidden + } + if {$::tk::dialog::file::showHiddenBtn} { + $data(hiddenBtn) configure -state normal + grid $data(hiddenBtn) + } else { + $data(hiddenBtn) configure -state disabled + grid remove $data(hiddenBtn) + } + + # When using -mustexist, manage the OK button state for validity + $data(okBtn) configure -state normal + if {$data(-mustexist)} { + $data(ent) configure -validate key \ + -validatecommand [list ::tk::dialog::file::chooseDir::IsOK? $w %P] + } else { + $data(ent) configure -validate none + } + + # Dialog boxes should be transient with respect to their parent, + # so that they will always stay on top of their parent window. However, + # some window managers will create the window as withdrawn if the parent + # window is withdrawn or iconified. Combined with the grab we put on the + # window, this can hang the entire application. Therefore we only make + # the dialog transient if the parent is viewable. + + if {[winfo viewable [winfo toplevel $data(-parent)]] } { + wm transient $w $data(-parent) + } + + trace add variable data(selectPath) write \ + [list ::tk::dialog::file::SetPath $w] + $data(dirMenuBtn) configure \ + -textvariable ::tk::dialog::file::${dataName}(selectPath) + + set data(filter) "*" + set data(previousEntryText) "" + ::tk::dialog::file::UpdateWhenIdle $w + + # Withdraw the window, then update all the geometry information + # so we know how big it wants to be, then center the window in the + # display (Motif style) and de-iconify it. + + ::tk::PlaceWindow $w widget $data(-parent) + wm title $w $data(-title) + + # Set a grab and claim the focus too. + + ::tk::SetFocusGrab $w $data(ent) + $data(ent) delete 0 end + $data(ent) insert 0 $data(selectPath) + $data(ent) selection range 0 end + $data(ent) icursor end + + # Wait for the user to respond, then restore the focus and + # return the index of the selected button. Restore the focus + # before deleting the window, since otherwise the window manager + # may take the focus away so we can't redirect it. Finally, + # restore any grab that was in effect. + + vwait ::tk::Priv(selectFilePath) + + ::tk::RestoreFocusGrab $w $data(ent) withdraw + + # Cleanup traces on selectPath variable + # + + foreach trace [trace info variable data(selectPath)] { + trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1] + } + if {[winfo exists $data(dirMenuBtn)]} { + $data(dirMenuBtn) configure -textvariable {} + } + + # Return value to user + # + + return $Priv(selectFilePath) +} + +# ::tk::dialog::file::chooseDir::Config -- +# +# Configures the Tk choosedir dialog according to the argument list +# +proc ::tk::dialog::file::chooseDir::Config {dataName argList} { + upvar ::tk::dialog::file::$dataName data + + # 0: Delete all variable that were set on data(selectPath) the + # last time the file dialog is used. The traces may cause troubles + # if the dialog is now used with a different -parent option. + # + foreach trace [trace info variable data(selectPath)] { + trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1] + } + + # 1: the configuration specs + # + set specs { + {-mustexist "" "" 0} + {-initialdir "" "" ""} + {-parent "" "" "."} + {-title "" "" ""} + } + + # 2: default values depending on the type of the dialog + # + if {![info exists data(selectPath)]} { + # first time the dialog has been popped up + set data(selectPath) [pwd] + } + + # 3: parse the arguments + # + tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList + + if {$data(-title) eq ""} { + set data(-title) "[mc "Choose Directory"]" + } + + # Stub out the -multiple value for the dialog; it doesn't make sense for + # choose directory dialogs, but we have to have something there because we + # share so much code with the file dialogs. + set data(-multiple) 0 + + # 4: set the default directory and selection according to the -initial + # settings + # + if {$data(-initialdir) ne ""} { + # Ensure that initialdir is an absolute path name. + if {[file isdirectory $data(-initialdir)]} { + set old [pwd] + cd $data(-initialdir) + set data(selectPath) [pwd] + cd $old + } else { + set data(selectPath) [pwd] + } + } + + if {![winfo exists $data(-parent)]} { + return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \ + "bad window path name \"$data(-parent)\"" + } +} + +# Gets called when user presses Return in the "Selection" entry or presses OK. +# +proc ::tk::dialog::file::chooseDir::OkCmd {w} { + upvar ::tk::dialog::file::[winfo name $w] data + + # This is the brains behind selecting non-existant directories. Here's + # the flowchart: + # 1. If the icon list has a selection, join it with the current dir, + # and return that value. + # 1a. If the icon list does not have a selection ... + # 2. If the entry is empty, do nothing. + # 3. If the entry contains an invalid directory, then... + # 3a. If the value is the same as last time through here, end dialog. + # 3b. If the value is different than last time, save it and return. + # 4. If entry contains a valid directory, then... + # 4a. If the value is the same as the current directory, end dialog. + # 4b. If the value is different from the current directory, change to + # that directory. + + set selection [$data(icons) selection get] + if {[llength $selection] != 0} { + set iconText [$data(icons) get [lindex $selection 0]] + set iconText [file join $data(selectPath) $iconText] + Done $w $iconText + } else { + set text [$data(ent) get] + if {$text eq ""} { + return + } + set text [file join {*}[file split [string trim $text]]] + if {![file exists $text] || ![file isdirectory $text]} { + # Entry contains an invalid directory. If it's the same as the + # last time they came through here, reset the saved value and end + # the dialog. Otherwise, save the value (so we can do this test + # next time). + if {$text eq $data(previousEntryText)} { + set data(previousEntryText) "" + Done $w $text + } else { + set data(previousEntryText) $text + } + } else { + # Entry contains a valid directory. If it is the same as the + # current directory, end the dialog. Otherwise, change to that + # directory. + if {$text eq $data(selectPath)} { + Done $w $text + } else { + set data(selectPath) $text + } + } + } + return +} + +# Change state of OK button to match -mustexist correctness of entry +# +proc ::tk::dialog::file::chooseDir::IsOK? {w text} { + upvar ::tk::dialog::file::[winfo name $w] data + + set ok [file isdirectory $text] + $data(okBtn) configure -state [expr {$ok ? "normal" : "disabled"}] + + # always return 1 + return 1 +} + +proc ::tk::dialog::file::chooseDir::DblClick {w} { + upvar ::tk::dialog::file::[winfo name $w] data + set selection [$data(icons) selection get] + if {[llength $selection] != 0} { + set filenameFragment [$data(icons) get [lindex $selection 0]] + set file $data(selectPath) + if {[file isdirectory $file]} { + ::tk::dialog::file::ListInvoke $w [list $filenameFragment] + return + } + } +} + +# Gets called when user browses the IconList widget (dragging mouse, arrow +# keys, etc) +# +proc ::tk::dialog::file::chooseDir::ListBrowse {w text} { + upvar ::tk::dialog::file::[winfo name $w] data + + if {$text eq ""} { + return + } + + set file [::tk::dialog::file::JoinFile $data(selectPath) $text] + $data(ent) delete 0 end + $data(ent) insert 0 $file +} + +# ::tk::dialog::file::chooseDir::Done -- +# +# Gets called when user has input a valid filename. Pops up a +# dialog box to confirm selection when necessary. Sets the +# Priv(selectFilePath) variable, which will break the "vwait" +# loop in tk_chooseDirectory and return the selected filename to the +# script that calls tk_getOpenFile or tk_getSaveFile +# +proc ::tk::dialog::file::chooseDir::Done {w {selectFilePath ""}} { + upvar ::tk::dialog::file::[winfo name $w] data + variable ::tk::Priv + + if {$selectFilePath eq ""} { + set selectFilePath $data(selectPath) + } + if {$data(-mustexist) && ![file isdirectory $selectFilePath]} { + return + } + set Priv(selectFilePath) $selectFilePath +} diff --git a/evalkit_llava/lib/tk8.6/console.tcl b/evalkit_llava/lib/tk8.6/console.tcl new file mode 100644 index 0000000000000000000000000000000000000000..d73b2f5c81b883d391367d8c4059ad9d04e4541a --- /dev/null +++ b/evalkit_llava/lib/tk8.6/console.tcl @@ -0,0 +1,1154 @@ +# console.tcl -- +# +# This code constructs the console window for an application. It +# can be used by non-unix systems that do not have built-in support +# for shells. +# +# Copyright (c) 1995-1997 Sun Microsystems, Inc. +# Copyright (c) 1998-2000 Ajuba Solutions. +# Copyright (c) 2007-2008 Daniel A. Steffen +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +# TODO: history - remember partially written command + +namespace eval ::tk::console { + variable blinkTime 500 ; # msecs to blink braced range for + variable blinkRange 1 ; # enable blinking of the entire braced range + variable magicKeys 1 ; # enable brace matching and proc/var recognition + variable maxLines 600 ; # maximum # of lines buffered in console + variable showMatches 1 ; # show multiple expand matches + variable useFontchooser [llength [info command ::tk::fontchooser]] + variable inPlugin [info exists embed_args] + variable defaultPrompt ; # default prompt if tcl_prompt1 isn't used + + if {$inPlugin} { + set defaultPrompt {subst {[history nextid] % }} + } else { + set defaultPrompt {subst {([file tail [pwd]]) [history nextid] % }} + } +} + +# simple compat function for tkcon code added for this console +interp alias {} EvalAttached {} consoleinterp eval + +# ::tk::ConsoleInit -- +# This procedure constructs and configures the console windows. +# +# Arguments: +# None. + +proc ::tk::ConsoleInit {} { + if {![consoleinterp eval {set tcl_interactive}]} { + wm withdraw . + } + + if {[tk windowingsystem] eq "aqua"} { + set mod "Cmd" + } else { + set mod "Ctrl" + } + + if {[catch {menu .menubar} err]} { + bgerror "INIT: $err" + } + AmpMenuArgs .menubar add cascade -label [mc &File] -menu .menubar.file + AmpMenuArgs .menubar add cascade -label [mc &Edit] -menu .menubar.edit + + menu .menubar.file -tearoff 0 + AmpMenuArgs .menubar.file add command -label [mc "&Source..."] \ + -command {tk::ConsoleSource} + AmpMenuArgs .menubar.file add command -label [mc "&Hide Console"] \ + -command {wm withdraw .} + AmpMenuArgs .menubar.file add command -label [mc "&Clear Console"] \ + -command {.console delete 1.0 "promptEnd linestart"} + if {[tk windowingsystem] ne "aqua"} { + AmpMenuArgs .menubar.file add command -label [mc E&xit] -command {exit} + } + + menu .menubar.edit -tearoff 0 + AmpMenuArgs .menubar.edit add command -label [mc Cu&t] -accel "$mod+X"\ + -command {event generate .console <>} + AmpMenuArgs .menubar.edit add command -label [mc &Copy] -accel "$mod+C"\ + -command {event generate .console <>} + AmpMenuArgs .menubar.edit add command -label [mc P&aste] -accel "$mod+V"\ + -command {event generate .console <>} + + if {[tk windowingsystem] ne "win32"} { + AmpMenuArgs .menubar.edit add command -label [mc Cl&ear] \ + -command {event generate .console <>} + } else { + AmpMenuArgs .menubar.edit add command -label [mc &Delete] \ + -command {event generate .console <>} -accel "Del" + + AmpMenuArgs .menubar add cascade -label [mc &Help] -menu .menubar.help + menu .menubar.help -tearoff 0 + AmpMenuArgs .menubar.help add command -label [mc &About...] \ + -command tk::ConsoleAbout + } + + AmpMenuArgs .menubar.edit add separator + if {$::tk::console::useFontchooser} { + if {[tk windowingsystem] eq "aqua"} { + .menubar.edit add command -label tk_choose_font_marker + set index [.menubar.edit index tk_choose_font_marker] + .menubar.edit entryconfigure $index \ + -label [mc "Show Fonts"]\ + -accelerator "$mod-T"\ + -command [list ::tk::console::FontchooserToggle] + bind Console <> \ + [list ::tk::console::FontchooserVisibility $index] + ::tk::console::FontchooserVisibility $index + } else { + AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \ + -command [list ::tk::console::FontchooserToggle] + } + bind Console [list ::tk::console::FontchooserFocus %W 1] + bind Console [list ::tk::console::FontchooserFocus %W 0] + } + AmpMenuArgs .menubar.edit add command -label [mc "&Increase Font Size"] \ + -accel "$mod++" -command {event generate .console <>} + AmpMenuArgs .menubar.edit add command -label [mc "&Decrease Font Size"] \ + -accel "$mod+-" -command {event generate .console <>} + AmpMenuArgs .menubar.edit add command -label [mc "Fit To Screen Width"] \ + -command {event generate .console <>} + + if {[tk windowingsystem] eq "aqua"} { + .menubar add cascade -label [mc Window] -menu [menu .menubar.window] + .menubar add cascade -label [mc Help] -menu [menu .menubar.help] + } + + . configure -menu .menubar + + # See if we can find a better font than the TkFixedFont + catch {font create TkConsoleFont {*}[font configure TkFixedFont]} + set families [font families] + switch -exact -- [tk windowingsystem] { + aqua { set preferred {Monaco 10} } + win32 { set preferred {ProFontWindows 8 Consolas 8} } + default { set preferred {} } + } + foreach {family size} $preferred { + if {$family in $families} { + font configure TkConsoleFont -family $family -size $size + break + } + } + + # Provide the right border for the text widget (platform dependent). + ::ttk::style layout ConsoleFrame { + Entry.field -sticky news -border 1 -children { + ConsoleFrame.padding -sticky news + } + } + ::ttk::frame .consoleframe -style ConsoleFrame + + set con [text .console -yscrollcommand [list .sb set] -setgrid true \ + -borderwidth 0 -highlightthickness 0 -font TkConsoleFont] + if {[tk windowingsystem] eq "aqua"} { + scrollbar .sb -command [list $con yview] + } else { + ::ttk::scrollbar .sb -command [list $con yview] + } + pack .sb -in .consoleframe -fill both -side right -padx 1 -pady 1 + pack $con -in .consoleframe -fill both -expand 1 -side left -padx 1 -pady 1 + pack .consoleframe -fill both -expand 1 -side left + + ConsoleBind $con + + $con tag configure stderr -foreground red + $con tag configure stdin -foreground blue + $con tag configure prompt -foreground \#8F4433 + $con tag configure proc -foreground \#008800 + $con tag configure var -background \#FFC0D0 + $con tag raise sel + $con tag configure blink -background \#FFFF00 + $con tag configure find -background \#FFFF00 + + focus $con + + # Avoid listing this console in [winfo interps] + if {[info command ::send] eq "::send"} {rename ::send {}} + + wm protocol . WM_DELETE_WINDOW { wm withdraw . } + wm title . [mc "Console"] + flush stdout + $con mark set output [$con index "end - 1 char"] + tk::TextSetCursor $con end + $con mark set promptEnd insert + $con mark gravity promptEnd left + + # A variant of ConsolePrompt to avoid a 'puts' call + set w $con + set temp [$w index "end - 1 char"] + $w mark set output end + if {![consoleinterp eval "info exists tcl_prompt1"]} { + set string [EvalAttached $::tk::console::defaultPrompt] + $w insert output $string stdout + } + $w mark set output $temp + ::tk::TextSetCursor $w end + $w mark set promptEnd insert + $w mark gravity promptEnd left + + if {[tk windowingsystem] ne "aqua"} { + # Subtle work-around to erase the '% ' that tclMain.c prints out + after idle [subst -nocommand { + if {[$con get 1.0 output] eq "% "} { $con delete 1.0 output } + }] + } +} + +# ::tk::ConsoleSource -- +# +# Prompts the user for a file to source in the main interpreter. +# +# Arguments: +# None. + +proc ::tk::ConsoleSource {} { + set filename [tk_getOpenFile -defaultextension .tcl -parent . \ + -title [mc "Select a file to source"] \ + -filetypes [list \ + [list [mc "Tcl Scripts"] .tcl] \ + [list [mc "All Files"] *]]] + if {$filename ne ""} { + set cmd [list source $filename] + if {[catch {consoleinterp eval $cmd} result]} { + ConsoleOutput stderr "$result\n" + } + } +} + +# ::tk::ConsoleInvoke -- +# Processes the command line input. If the command is complete it +# is evaled in the main interpreter. Otherwise, the continuation +# prompt is added and more input may be added. +# +# Arguments: +# None. + +proc ::tk::ConsoleInvoke {args} { + set ranges [.console tag ranges input] + set cmd "" + if {[llength $ranges]} { + set pos 0 + while {[lindex $ranges $pos] ne ""} { + set start [lindex $ranges $pos] + set end [lindex $ranges [incr pos]] + append cmd [.console get $start $end] + incr pos + } + } + if {$cmd eq ""} { + ConsolePrompt + } elseif {[info complete $cmd]} { + .console mark set output end + .console tag delete input + set result [consoleinterp record $cmd] + if {$result ne ""} { + puts $result + } + ConsoleHistory reset + ConsolePrompt + } else { + ConsolePrompt partial + } + .console yview -pickplace insert +} + +# ::tk::ConsoleHistory -- +# This procedure implements command line history for the +# console. In general is evals the history command in the +# main interpreter to obtain the history. The variable +# ::tk::HistNum is used to store the current location in the history. +# +# Arguments: +# cmd - Which action to take: prev, next, reset. + +set ::tk::HistNum 1 +proc ::tk::ConsoleHistory {cmd} { + variable HistNum + + switch $cmd { + prev { + incr HistNum -1 + if {$HistNum == 0} { + set cmd {history event [expr {[history nextid] -1}]} + } else { + set cmd "history event $HistNum" + } + if {[catch {consoleinterp eval $cmd} cmd]} { + incr HistNum + return + } + .console delete promptEnd end + .console insert promptEnd $cmd {input stdin} + .console see end + } + next { + incr HistNum + if {$HistNum == 0} { + set cmd {history event [expr {[history nextid] -1}]} + } elseif {$HistNum > 0} { + set cmd "" + set HistNum 1 + } else { + set cmd "history event $HistNum" + } + if {$cmd ne ""} { + catch {consoleinterp eval $cmd} cmd + } + .console delete promptEnd end + .console insert promptEnd $cmd {input stdin} + .console see end + } + reset { + set HistNum 1 + } + } +} + +# ::tk::ConsolePrompt -- +# This procedure draws the prompt. If tcl_prompt1 or tcl_prompt2 +# exists in the main interpreter it will be called to generate the +# prompt. Otherwise, a hard coded default prompt is printed. +# +# Arguments: +# partial - Flag to specify which prompt to print. + +proc ::tk::ConsolePrompt {{partial normal}} { + set w .console + if {$partial eq "normal"} { + set temp [$w index "end - 1 char"] + $w mark set output end + if {[consoleinterp eval "info exists tcl_prompt1"]} { + consoleinterp eval "eval \[set tcl_prompt1\]" + } else { + puts -nonewline [EvalAttached $::tk::console::defaultPrompt] + } + } else { + set temp [$w index output] + $w mark set output end + if {[consoleinterp eval "info exists tcl_prompt2"]} { + consoleinterp eval "eval \[set tcl_prompt2\]" + } else { + puts -nonewline "> " + } + } + flush stdout + $w mark set output $temp + ::tk::TextSetCursor $w end + $w mark set promptEnd insert + $w mark gravity promptEnd left + ::tk::console::ConstrainBuffer $w $::tk::console::maxLines + $w see end +} + +# Copy selected text from the console +proc ::tk::console::Copy {w} { + if {![catch {set data [$w get sel.first sel.last]}]} { + clipboard clear -displayof $w + clipboard append -displayof $w $data + } +} +# Copies selected text. If the selection is within the current active edit +# region then it will be cut, if not it is only copied. +proc ::tk::console::Cut {w} { + if {![catch {set data [$w get sel.first sel.last]}]} { + clipboard clear -displayof $w + clipboard append -displayof $w $data + if {[$w compare sel.first >= output]} { + $w delete sel.first sel.last + } + } +} +# Paste text from the clipboard +proc ::tk::console::Paste {w} { + catch { + set clip [::tk::GetSelection $w CLIPBOARD] + set list [split $clip \n\r] + tk::ConsoleInsert $w [lindex $list 0] + foreach x [lrange $list 1 end] { + $w mark set insert {end - 1c} + tk::ConsoleInsert $w "\n" + tk::ConsoleInvoke + tk::ConsoleInsert $w $x + } + } +} + +# Fit TkConsoleFont to window width +proc ::tk::console::FitScreenWidth {w} { + set width [winfo screenwidth $w] + set cwidth [$w cget -width] + set s -50 + set fit 0 + array set fi [font configure TkConsoleFont] + while {$s < 0} { + set fi(-size) $s + set f [font create {*}[array get fi]] + set c [font measure $f "eM"] + font delete $f + if {$c * $cwidth < 1.667 * $width} { + font configure TkConsoleFont -size $s + break + } + incr s 2 + } +} + +# ::tk::ConsoleBind -- +# This procedure first ensures that the default bindings for the Text +# class have been defined. Then certain bindings are overridden for +# the class. +# +# Arguments: +# None. + +proc ::tk::ConsoleBind {w} { + bindtags $w [list $w Console PostConsole [winfo toplevel $w] all] + + ## Get all Text bindings into Console + foreach ev [bind Text] { + bind Console $ev [bind Text $ev] + } + ## We really didn't want the newline insertion... + bind Console {} + ## ...or any Control-v binding (would block <>) + bind Console {} + + # For the moment, transpose isn't enabled until the console + # gets and overhaul of how it handles input -- hobbs + bind Console {} + + # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. + # Otherwise, if a widget binding for one of these is defined, the + # class binding will also fire and insert the character + # which is wrong. + + bind Console {# nothing } + bind Console {# nothing} + bind Console {# nothing} + if {[tk windowingsystem] eq "aqua"} { + bind Console {# nothing} + bind Console {# nothing} + } + + foreach {ev key} { + <> + <> + <> + <> + + <> + <> + <> + <> + <> + <> + <> + <> + <> + + <> + <> + <> + <> + <> + <> + <> + } { + event add $ev $key + bind Console $key {} + } + if {[tk windowingsystem] eq "aqua"} { + foreach {ev key} { + <> + <> + } { + event add $ev $key + bind Console $key {} + } + if {$::tk::console::useFontchooser} { + bind Console [list ::tk::console::FontchooserToggle] + } + } + bind Console <> { + if {[%W compare insert > promptEnd]} { + ::tk::console::Expand %W + } + } + bind Console <> { + if {[%W compare insert > promptEnd]} { + ::tk::console::Expand %W path + } + } + bind Console <> { + if {[%W compare insert > promptEnd]} { + ::tk::console::Expand %W proc + } + } + bind Console <> { + if {[%W compare insert > promptEnd]} { + ::tk::console::Expand %W var + } + } + bind Console <> { + %W mark set insert {end - 1c} + tk::ConsoleInsert %W "\n" + tk::ConsoleInvoke + break + } + bind Console { + if {{} ne [%W tag nextrange sel 1.0 end] \ + && [%W compare sel.first >= promptEnd]} { + %W delete sel.first sel.last + } elseif {[%W compare insert >= promptEnd]} { + %W delete insert + %W see insert + } + } + bind Console { + if {{} ne [%W tag nextrange sel 1.0 end] \ + && [%W compare sel.first >= promptEnd]} { + %W delete sel.first sel.last + } elseif {[%W compare insert != 1.0] && \ + [%W compare insert > promptEnd]} { + %W delete insert-1c + %W see insert + } + } + bind Console [bind Console ] + + bind Console <> { + if {[%W compare insert < promptEnd]} { + tk::TextSetCursor %W {insert linestart} + } else { + tk::TextSetCursor %W promptEnd + } + } + bind Console <> { + tk::TextSetCursor %W {insert lineend} + } + bind Console { + if {[%W compare insert < promptEnd]} { + break + } + %W delete insert + } + bind Console <> { + if {[%W compare insert < promptEnd]} { + break + } + if {[%W compare insert == {insert lineend}]} { + %W delete insert + } else { + %W delete insert {insert lineend} + } + } + bind Console <> { + ## Clear console display + %W delete 1.0 "promptEnd linestart" + } + bind Console <> { + ## Clear command line (Unix shell staple) + %W delete promptEnd end + } + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} + } + } + bind Console { + if {[%W compare {insert -1c wordstart} >= promptEnd]} { + %W delete {insert -1c wordstart} insert + } + } + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} + } + } + bind Console { + if {[%W compare {insert -1c wordstart} >= promptEnd]} { + %W delete {insert -1c wordstart} insert + } + } + bind Console { + if {[%W compare insert >= promptEnd]} { + %W delete insert {insert wordend} + } + } + bind Console <> { + tk::ConsoleHistory prev + } + bind Console <> { + tk::ConsoleHistory next + } + bind Console { + catch {tk::ConsoleInsert %W [::tk::GetSelection %W PRIMARY]} + } + bind Console { + tk::ConsoleInsert %W %A + } + bind Console { + destroy {*}[winfo children .] + source -encoding utf-8 [file join $tk_library console.tcl] + } + if {[tk windowingsystem] eq "aqua"} { + bind Console { + exit + } + } + bind Console <> { ::tk::console::Cut %W } + bind Console <> { ::tk::console::Copy %W } + bind Console <> { ::tk::console::Paste %W } + + bind Console <> { + set size [font configure TkConsoleFont -size] + if {$size < 0} {set sign -1} else {set sign 1} + set size [expr {(abs($size) + 1) * $sign}] + font configure TkConsoleFont -size $size + if {$::tk::console::useFontchooser} { + tk fontchooser configure -font TkConsoleFont + } + } + bind Console <> { + set size [font configure TkConsoleFont -size] + if {abs($size) < 2} { return } + if {$size < 0} {set sign -1} else {set sign 1} + set size [expr {(abs($size) - 1) * $sign}] + font configure TkConsoleFont -size $size + if {$::tk::console::useFontchooser} { + tk fontchooser configure -font TkConsoleFont + } + } + bind Console <> { + ::tk::console::FitScreenWidth %W + } + + ## + ## Bindings for doing special things based on certain keys + ## + bind PostConsole { + if {"\\" ne [%W get insert-2c]} { + ::tk::console::MatchPair %W \( \) promptEnd + } + } + bind PostConsole { + if {"\\" ne [%W get insert-2c]} { + ::tk::console::MatchPair %W \[ \] promptEnd + } + } + bind PostConsole { + if {"\\" ne [%W get insert-2c]} { + ::tk::console::MatchPair %W \{ \} promptEnd + } + } + bind PostConsole { + if {"\\" ne [%W get insert-2c]} { + ::tk::console::MatchQuote %W promptEnd + } + } + + bind PostConsole { + if {"%A" ne ""} { + ::tk::console::TagProc %W + } + } +} + +# ::tk::ConsoleInsert -- +# Insert a string into a text at the point of the insertion cursor. +# If there is a selection in the text, and it covers the point of the +# insertion cursor, then delete the selection before inserting. Insertion +# is restricted to the prompt area. +# +# Arguments: +# w - The text window in which to insert the string +# s - The string to insert (usually just a single character) + +proc ::tk::ConsoleInsert {w s} { + if {$s eq ""} { + return + } + catch { + if {[$w compare sel.first <= insert] \ + && [$w compare sel.last >= insert]} { + $w tag remove sel sel.first promptEnd + $w delete sel.first sel.last + } + } + if {[$w compare insert < promptEnd]} { + $w mark set insert end + } + $w insert insert $s {input stdin} + $w see insert +} + +# ::tk::ConsoleOutput -- +# +# This routine is called directly by ConsolePutsCmd to cause a string +# to be displayed in the console. +# +# Arguments: +# dest - The output tag to be used: either "stderr" or "stdout". +# string - The string to be displayed. + +proc ::tk::ConsoleOutput {dest string} { + set w .console + $w insert output $string $dest + ::tk::console::ConstrainBuffer $w $::tk::console::maxLines + $w see insert +} + +# ::tk::ConsoleExit -- +# +# This routine is called by ConsoleEventProc when the main window of +# the application is destroyed. Don't call exit - that probably already +# happened. Just delete our window. +# +# Arguments: +# None. + +proc ::tk::ConsoleExit {} { + destroy . +} + +# ::tk::ConsoleAbout -- +# +# This routine displays an About box to show Tcl/Tk version info. +# +# Arguments: +# None. + +proc ::tk::ConsoleAbout {} { + tk_messageBox -type ok -message "[mc {Tcl for Windows}] + +Tcl $::tcl_patchLevel +Tk $::tk_patchLevel" +} + +# ::tk::console::Fontchooser* -- +# Let the user select the console font (TIP 324). + +proc ::tk::console::FontchooserToggle {} { + if {[tk fontchooser configure -visible]} { + tk fontchooser hide + } else { + tk fontchooser show + } +} +proc ::tk::console::FontchooserVisibility {index} { + if {[tk fontchooser configure -visible]} { + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"] + } else { + .menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"] + } +} +proc ::tk::console::FontchooserFocus {w isFocusIn} { + if {$isFocusIn} { + tk fontchooser configure -parent $w -font TkConsoleFont \ + -command [namespace code [list FontchooserApply]] + } else { + tk fontchooser configure -parent $w -font {} -command {} + } +} +proc ::tk::console::FontchooserApply {font args} { + catch {font configure TkConsoleFont {*}[font actual $font]} +} + +# ::tk::console::TagProc -- +# +# Tags a procedure in the console if it's recognized +# This procedure is not perfect. However, making it perfect wastes +# too much CPU time... +# +# Arguments: +# w - console text widget + +proc ::tk::console::TagProc w { + if {!$::tk::console::magicKeys} { + return + } + set exp "\[^\\\\\]\[\[ \t\n\r\;{}\"\$\]" + set i [$w search -backwards -regexp $exp insert-1c promptEnd-1c] + if {$i eq ""} { + set i promptEnd + } else { + append i +2c + } + regsub -all "\[\[\\\\\\?\\*\]" [$w get $i "insert-1c wordend"] {\\\0} c + if {[llength [EvalAttached [list info commands $c]]]} { + $w tag add proc $i "insert-1c wordend" + } else { + $w tag remove proc $i "insert-1c wordend" + } + if {[llength [EvalAttached [list info vars $c]]]} { + $w tag add var $i "insert-1c wordend" + } else { + $w tag remove var $i "insert-1c wordend" + } +} + +# ::tk::console::MatchPair -- +# +# Blinks a matching pair of characters +# c2 is assumed to be at the text index 'insert'. +# This proc is really loopy and took me an hour to figure out given +# all possible combinations with escaping except for escaped \'s. +# It doesn't take into account possible commenting... Oh well. If +# anyone has something better, I'd like to see/use it. This is really +# only efficient for small contexts. +# +# Arguments: +# w - console text widget +# c1 - first char of pair +# c2 - second char of pair +# +# Calls: ::tk::console::Blink + +proc ::tk::console::MatchPair {w c1 c2 {lim 1.0}} { + if {!$::tk::console::magicKeys} { + return + } + if {{} ne [set ix [$w search -back $c1 insert $lim]]} { + while { + [string match {\\} [$w get $ix-1c]] && + [set ix [$w search -back $c1 $ix-1c $lim]] ne {} + } {} + set i1 insert-1c + while {$ix ne {}} { + set i0 $ix + set j 0 + while {[set i0 [$w search $c2 $i0 $i1]] ne {}} { + append i0 +1c + if {[string match {\\} [$w get $i0-2c]]} { + continue + } + incr j + } + if {!$j} { + break + } + set i1 $ix + while {$j && [set ix [$w search -back $c1 $ix $lim]] ne {}} { + if {[string match {\\} [$w get $ix-1c]]} { + continue + } + incr j -1 + } + } + if {[string match {} $ix]} { + set ix [$w index $lim] + } + } else { + set ix [$w index $lim] + } + if {$::tk::console::blinkRange} { + Blink $w $ix [$w index insert] + } else { + Blink $w $ix $ix+1c [$w index insert-1c] [$w index insert] + } +} + +# ::tk::console::MatchQuote -- +# +# Blinks between matching quotes. +# Blinks just the quote if it's unmatched, otherwise blinks quoted string +# The quote to match is assumed to be at the text index 'insert'. +# +# Arguments: +# w - console text widget +# +# Calls: ::tk::console::Blink + +proc ::tk::console::MatchQuote {w {lim 1.0}} { + if {!$::tk::console::magicKeys} { + return + } + set i insert-1c + set j 0 + while {[set i [$w search -back \" $i $lim]] ne {}} { + if {[string match {\\} [$w get $i-1c]]} { + continue + } + if {!$j} { + set i0 $i + } + incr j + } + if {$j&1} { + if {$::tk::console::blinkRange} { + Blink $w $i0 [$w index insert] + } else { + Blink $w $i0 $i0+1c [$w index insert-1c] [$w index insert] + } + } else { + Blink $w [$w index insert-1c] [$w index insert] + } +} + +# ::tk::console::Blink -- +# +# Blinks between n index pairs for a specified duration. +# +# Arguments: +# w - console text widget +# i1 - start index to blink region +# i2 - end index of blink region +# dur - duration in usecs to blink for +# +# Outputs: +# blinks selected characters in $w + +proc ::tk::console::Blink {w args} { + eval [list $w tag add blink] $args + after $::tk::console::blinkTime [list $w] tag remove blink $args +} + +# ::tk::console::ConstrainBuffer -- +# +# This limits the amount of data in the text widget +# Called by Prompt and ConsoleOutput +# +# Arguments: +# w - console text widget +# size - # of lines to constrain to +# +# Outputs: +# may delete data in console widget + +proc ::tk::console::ConstrainBuffer {w size} { + if {[$w index end] > $size} { + $w delete 1.0 [expr {int([$w index end])-$size}].0 + } +} + +# ::tk::console::Expand -- +# +# Arguments: +# ARGS: w - text widget in which to expand str +# type - type of expansion (path / proc / variable) +# +# Calls: ::tk::console::Expand(Pathname|Procname|Variable) +# +# Outputs: The string to match is expanded to the longest possible match. +# If ::tk::console::showMatches is non-zero and the longest match +# equaled the string to expand, then all possible matches are +# output to stdout. Triggers bell if no matches are found. +# +# Returns: number of matches found + +proc ::tk::console::Expand {w {type ""}} { + set exp "\[^\\\\\]\[\[ \t\n\r\\\{\"\\\\\$\]" + set tmp [$w search -backwards -regexp $exp insert-1c promptEnd-1c] + if {$tmp eq ""} { + set tmp promptEnd + } else { + append tmp +2c + } + if {[$w compare $tmp >= insert]} { + return + } + set str [$w get $tmp insert] + switch -glob $type { + path* { + set res [ExpandPathname $str] + } + proc* { + set res [ExpandProcname $str] + } + var* { + set res [ExpandVariable $str] + } + default { + set res {} + foreach t {Pathname Procname Variable} { + if {![catch {Expand$t $str} res] && ($res ne "")} { + break + } + } + } + } + set len [llength $res] + if {$len} { + set repl [lindex $res 0] + $w delete $tmp insert + $w insert $tmp $repl {input stdin} + if {($len > 1) && ($::tk::console::showMatches) && ($repl eq $str)} { + puts stdout [lsort [lreplace $res 0 0]] + } + } else { + bell + } + return [incr len -1] +} + +# ::tk::console::ExpandPathname -- +# +# Expand a file pathname based on $str +# This is based on UNIX file name conventions +# +# Arguments: +# str - partial file pathname to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandPathname str { + set pwd [EvalAttached pwd] + if {[catch {EvalAttached [list cd [file dirname $str]]} err opt]} { + return -options $opt $err + } + set dir [file tail $str] + ## Check to see if it was known to be a directory and keep the trailing + ## slash if so (file tail cuts it off) + if {[string match */ $str]} { + append dir / + } + if {[catch {lsort [EvalAttached [list glob $dir*]]} m]} { + set match {} + } else { + if {[llength $m] > 1} { + if { $::tcl_platform(platform) eq "windows" } { + ## Windows is screwy because it's case insensitive + set tmp [ExpandBestMatch [string tolower $m] \ + [string tolower $dir]] + ## Don't change case if we haven't changed the word + if {[string length $dir]==[string length $tmp]} { + set tmp $dir + } + } else { + set tmp [ExpandBestMatch $m $dir] + } + if {[string match ?*/* $str]} { + set tmp [file dirname $str]/$tmp + } elseif {[string match /* $str]} { + set tmp /$tmp + } + regsub -all { } $tmp {\\ } tmp + set match [linsert $m 0 $tmp] + } else { + ## This may look goofy, but it handles spaces in path names + eval append match $m + if {[file isdir $match]} { + append match / + } + if {[string match ?*/* $str]} { + set match [file dirname $str]/$match + } elseif {[string match /* $str]} { + set match /$match + } + regsub -all { } $match {\\ } match + ## Why is this one needed and the ones below aren't!! + set match [list $match] + } + } + EvalAttached [list cd $pwd] + return $match +} + +# ::tk::console::ExpandProcname -- +# +# Expand a tcl proc name based on $str +# +# Arguments: +# str - partial proc name to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandProcname str { + set match [EvalAttached [list info commands $str*]] + if {[llength $match] == 0} { + set ns [EvalAttached \ + "namespace children \[namespace current\] [list $str*]"] + if {[llength $ns]==1} { + set match [EvalAttached [list info commands ${ns}::*]] + } else { + set match $ns + } + } + if {[llength $match] > 1} { + regsub -all { } [ExpandBestMatch $match $str] {\\ } str + set match [linsert $match 0 $str] + } else { + regsub -all { } $match {\\ } match + } + return $match +} + +# ::tk::console::ExpandVariable -- +# +# Expand a tcl variable name based on $str +# +# Arguments: +# str - partial tcl var name to expand +# +# Calls: ::tk::console::ExpandBestMatch +# +# Returns: list containing longest unique match followed by all the +# possible further matches + +proc ::tk::console::ExpandVariable str { + if {[regexp {([^\(]*)\((.*)} $str -> ary str]} { + ## Looks like they're trying to expand an array. + set match [EvalAttached [list array names $ary $str*]] + if {[llength $match] > 1} { + set vars $ary\([ExpandBestMatch $match $str] + foreach var $match { + lappend vars $ary\($var\) + } + return $vars + } elseif {[llength $match] == 1} { + set match $ary\($match\) + } + ## Space transformation avoided for array names. + } else { + set match [EvalAttached [list info vars $str*]] + if {[llength $match] > 1} { + regsub -all { } [ExpandBestMatch $match $str] {\\ } str + set match [linsert $match 0 $str] + } else { + regsub -all { } $match {\\ } match + } + } + return $match +} + +# ::tk::console::ExpandBestMatch -- +# +# Finds the best unique match in a list of names. +# The extra $e in this argument allows us to limit the innermost loop a little +# further. This improves speed as $l becomes large or $e becomes long. +# +# Arguments: +# l - list to find best unique match in +# e - currently best known unique match +# +# Returns: longest unique match in the list + +proc ::tk::console::ExpandBestMatch {l {e {}}} { + set ec [lindex $l 0] + if {[llength $l]>1} { + set e [expr {[string length $e] - 1}] + set ei [expr {[string length $ec] - 1}] + foreach l $l { + while {$ei>=$e && [string first $ec $l]} { + set ec [string range $ec 0 [incr ei -1]] + } + } + } + return $ec +} + +# now initialize the console +::tk::ConsoleInit diff --git a/evalkit_llava/lib/tk8.6/demos/README b/evalkit_llava/lib/tk8.6/demos/README new file mode 100644 index 0000000000000000000000000000000000000000..7285a93894418f41d21ab0c8d67a16d157a46ec4 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/README @@ -0,0 +1,44 @@ +This directory contains a collection of programs to demonstrate +the features of the Tk toolkit. The programs are all scripts for +"wish", a windowing shell. If wish has been installed on your path +then you can invoke any of the programs in this directory just +by typing its file name to your command shell under Unix. Otherwise +invoke wish with the file as its first argument, e.g., "wish hello". +The rest of this file contains a brief description of each program. +Files with names ending in ".tcl" are procedure packages used by one +or more of the demo programs; they can't be used as programs by +themselves so they aren't described below. + +hello - Creates a single button; if you click on it, a message + is typed and the application terminates. + +widget - Contains a collection of demonstrations of the widgets + currently available in the Tk library. Most of the .tcl + files are scripts for individual demos available through + the "widget" program. + +ixset - A simple Tk-based wrapper for the "xset" program, which + allows you to interactively query and set various X options + such as mouse acceleration and bell volume. Thanks to + Pierre David for contributing this example. + +rolodex - A mock-up of a simple rolodex application. It has much of + the user interface for such an application but no back-end + database. This program was written in response to Tom + LaStrange's toolkit benchmark challenge. + +tcolor - A color editor. Allows you to edit colors in several + different ways, and will also perform automatic updates + using "send". + +rmt - Allows you to "hook-up" remotely to any Tk application + on the display. Select an application with the menu, + then just type commands: they'll go to that application. + +timer - Displays a seconds timer with start and stop buttons. + Control-c and control-q cause it to exit. + +browse - A simple directory browser. Invoke it with and argument + giving the name of the directory you'd like to browse. + Double-click on files or subdirectories to browse them. + Control-c and control-q cause the program to exit. diff --git a/evalkit_llava/lib/tk8.6/demos/anilabel.tcl b/evalkit_llava/lib/tk8.6/demos/anilabel.tcl new file mode 100644 index 0000000000000000000000000000000000000000..61e6315787ea384e226eb8bf28d10dc710a1d686 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/anilabel.tcl @@ -0,0 +1,160 @@ +# anilabel.tcl -- +# +# This demonstration script creates a toplevel window containing +# several animated label widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .anilabel +catch {destroy $w} +toplevel $w +wm title $w "Animated Label Demonstration" +wm iconname $w "anilabel" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "Four animated labels are displayed below; each of the labels on the left is animated by making the text message inside it appear to scroll, and the label on the right is animated by animating the image that it displays." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +# Ensure that this this is an array +array set animationCallbacks {} + +## This callback is the core of how to do animation in Tcl/Tk; all +## animations work in basically the same way, with a procedure that +## uses the [after] command to reschedule itself at some point in the +## future. Of course, the details of how to update the state will vary +## according to what is being animated. +proc RotateLabelText {w interval} { + global animationCallbacks + + # Schedule the calling of this procedure again in the future + set animationCallbacks($w) [after $interval RotateLabelText $w $interval] + + # We do marquee-like scrolling text by chopping characters off the + # front of the text and sticking them on the end. + set text [$w cget -text] + set newText [string range $text 1 end][string index $text 0] + $w configure -text $newText +} + +## A helper procedure to start the animation happening. +proc animateLabelText {w text interval} { + global animationCallbacks + + # Install the text into the widget + $w configure -text $text + + # Schedule the start of the animation loop + set animationCallbacks($w) [after $interval RotateLabelText $w $interval] + + # Make sure that the animation stops and is cleaned up after itself + # when the animated label is destroyed. Note that at this point we + # cannot manipulate the widget itself, as that has already died. + bind $w { + after cancel $animationCallbacks(%W) + unset animationCallbacks(%W) + } +} + +## Next, a similar pair of procedures to animate a GIF loaded into a +## photo image. +proc SelectNextImageFrame {w interval} { + global animationCallbacks + set animationCallbacks($w) \ + [after $interval SelectNextImageFrame $w $interval] + set image [$w cget -image] + + # The easy way to animate a GIF! + set idx -1 + scan [$image cget -format] "GIF -index %d" idx + if {[catch { + # Note that we get an error if the index is out of range + $image configure -format "GIF -index [incr idx]" + }]} then { + $image configure -format "GIF -index 0" + } +} +proc animateLabelImage {w imageData interval} { + global animationCallbacks + + # Create a multi-frame GIF from base-64-encoded data + set image [image create photo -format GIF -data $imageData] + + # Install the image into the widget + $w configure -image $image + + # Schedule the start of the animation loop + set animationCallbacks($w) \ + [after $interval SelectNextImageFrame $w $interval] + + # Make sure that the animation stops and is cleaned up after itself + # when the animated label is destroyed. Note that at this point we + # cannot manipulate the widget itself, as that has already died. + # Also note that this script is in double-quotes; this is always OK + # because image names are chosen automatically to be simple words. + bind $w " + after cancel \$animationCallbacks(%W) + unset animationCallbacks(%W) + rename $image {} + " +} + +# Make some widgets to contain the animations +labelframe $w.left -text "Scrolling Texts" +labelframe $w.right -text "GIF Image" +pack $w.left $w.right -side left -padx 10 -pady 10 -expand yes + +# This method of scrolling text looks far better with a fixed-width font +label $w.left.l1 -bd 4 -relief ridge -font fixedFont +label $w.left.l2 -bd 4 -relief groove -font fixedFont +label $w.left.l3 -bd 4 -relief flat -font fixedFont -width 18 +pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 10 -pady 10 -anchor w +# Don't need to do very much with this label except turn off the border +label $w.right.l -bd 0 +pack $w.right.l -side top -expand yes -padx 10 -pady 10 + +# This is a base-64-encoded animated GIF file. +set tclPoweredData { + R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM + zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm + mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt + YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP + dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM + ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC + DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0 + qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6 + NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT + 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk + UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY + 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC + Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4 + AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn + wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo + IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY + 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a + N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2 + KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA + LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK + z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA + eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+ + r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc + WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF + CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A + NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR + oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j + Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7 + ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw== +} + +# Finally, set up the text scrolling animation +animateLabelText $w.left.l1 "* Slow Animation *" 300 +animateLabelText $w.left.l2 "* Fast Animation *" 80 +animateLabelText $w.left.l3 "This is a longer scrolling text in a widget that will not show the whole message at once. " 150 +animateLabelImage $w.right.l $tclPoweredData 100 diff --git a/evalkit_llava/lib/tk8.6/demos/bind.tcl b/evalkit_llava/lib/tk8.6/demos/bind.tcl new file mode 100644 index 0000000000000000000000000000000000000000..8b56639f80fb3fc3355ae268f4ad3c917ec25155 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/bind.tcl @@ -0,0 +1,78 @@ +# bind.tcl -- +# +# This demonstration script creates a text widget with bindings set +# up for hypertext-like effects. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .bind +catch {destroy $w} +toplevel $w +wm title $w "Text Demonstration - Tag Bindings" +wm iconname $w "bind" +positionWindow $w + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +text $w.text -yscrollcommand "$w.scroll set" -setgrid true \ + -width 60 -height 24 -font $font -wrap word +ttk::scrollbar $w.scroll -command "$w.text yview" +pack $w.scroll -side right -fill y +pack $w.text -expand yes -fill both + +# Set up display styles. + +if {[winfo depth $w] > 1} { + set bold "-background #43ce80 -relief raised -borderwidth 1" + set normal "-background {} -relief flat" +} else { + set bold "-foreground white -background black" + set normal "-foreground {} -background {}" +} + +# Add text to widget. + +$w.text insert 0.0 {\ +The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked. + +} +$w.text insert end \ +{1. Samples of all the different types of items that can be created in canvas widgets.} d1 +$w.text insert end \n\n +$w.text insert end \ +{2. A simple two-dimensional plot that allows you to adjust the positions of the data points.} d2 +$w.text insert end \n\n +$w.text insert end \ +{3. Anchoring and justification modes for text items.} d3 +$w.text insert end \n\n +$w.text insert end \ +{4. An editor for arrow-head shapes for line items.} d4 +$w.text insert end \n\n +$w.text insert end \ +{5. A ruler with facilities for editing tab stops.} d5 +$w.text insert end \n\n +$w.text insert end \ +{6. A grid that demonstrates how canvases can be scrolled.} d6 + +# Create bindings for tags. + +foreach tag {d1 d2 d3 d4 d5 d6} { + $w.text tag bind $tag "$w.text tag configure $tag $bold" + $w.text tag bind $tag "$w.text tag configure $tag $normal" +} +# Main widget program sets variable tk_demoDirectory +$w.text tag bind d1 {source -encoding utf-8 [file join $tk_demoDirectory items.tcl]} +$w.text tag bind d2 {source -encoding utf-8 [file join $tk_demoDirectory plot.tcl]} +$w.text tag bind d3 {source -encoding utf-8 [file join $tk_demoDirectory ctext.tcl]} +$w.text tag bind d4 {source -encoding utf-8 [file join $tk_demoDirectory arrow.tcl]} +$w.text tag bind d5 {source -encoding utf-8 [file join $tk_demoDirectory ruler.tcl]} +$w.text tag bind d6 {source -encoding utf-8 [file join $tk_demoDirectory cscroll.tcl]} + +$w.text mark set insert 0.0 +$w.text configure -state disabled diff --git a/evalkit_llava/lib/tk8.6/demos/browse b/evalkit_llava/lib/tk8.6/demos/browse new file mode 100644 index 0000000000000000000000000000000000000000..15e9fce8347f0905d37f523318fb329a2b1333d6 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/browse @@ -0,0 +1,66 @@ +#!/bin/sh +# the next line restarts using wish \ +exec wish8.6 "$0" ${1+"$@"} + +# browse -- +# This script generates a directory browser, which lists the working +# directory and allows you to open files or subdirectories by +# double-clicking. + +package require Tk + +# Create a scrollbar on the right side of the main window and a listbox +# on the left side. + +scrollbar .scroll -command ".list yview" +pack .scroll -side right -fill y +listbox .list -yscroll ".scroll set" -relief sunken -width 20 -height 20 \ + -setgrid yes +pack .list -side left -fill both -expand yes +wm minsize . 1 1 + +# The procedure below is invoked to open a browser on a given file; if the +# file is a directory then another instance of this program is invoked; if +# the file is a regular file then the Mx editor is invoked to display +# the file. + +set browseScript [file join [pwd] $argv0] +proc browse {dir file} { + global env browseScript + if {[string compare $dir "."] != 0} {set file $dir/$file} + switch [file type $file] { + directory { + exec [info nameofexecutable] $browseScript $file & + } + file { + if {[info exists env(EDITOR)]} { + eval exec $env(EDITOR) $file & + } else { + exec xedit $file & + } + } + default { + puts stdout "\"$file\" isn't a directory or regular file" + } + } +} + +# Fill the listbox with a list of all the files in the directory. + +if {$argc>0} {set dir [lindex $argv 0]} else {set dir "."} +foreach i [lsort [glob * .* *.*]] { + if {[file type $i] eq "directory"} { + # Safe to do since it is still a directory. + append i / + } + .list insert end $i +} + +# Set up bindings for the browser. + +bind all {destroy .} +bind .list {foreach i [selection get] {browse $dir $i}} + +# Local Variables: +# mode: tcl +# End: diff --git a/evalkit_llava/lib/tk8.6/demos/button.tcl b/evalkit_llava/lib/tk8.6/demos/button.tcl new file mode 100644 index 0000000000000000000000000000000000000000..bb943e625c4b8d90cc696303424b510d835ea800 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/button.tcl @@ -0,0 +1,47 @@ +# button.tcl -- +# +# This demonstration script creates a toplevel window containing +# several button widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .button +catch {destroy $w} +toplevel $w +wm title $w "Button Demonstration" +wm iconname $w "button" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button. You can press Tab to move among the buttons, then press Space to invoke the current button." +pack $w.msg -side top + +## See Code / Dismiss buttons +pack [addSeeDismiss $w.buttons $w] -side bottom -fill x + +proc colorrefresh {w col} { + $w configure -bg $col + if {[tk windowingsystem] eq "aqua"} { + # set highlightbackground of all buttons in $w + set l [list $w] + while {[llength $l]} { + set l [concat [lassign $l b] [winfo children $b]] + if {[winfo class $b] eq "Button"} { + $b configure -highlightbackground $col + } + } + } +} + +button $w.b1 -text "Peach Puff" -width 10 \ + -command [list colorrefresh $w PeachPuff1] +button $w.b2 -text "Light Blue" -width 10 \ + -command [list colorrefresh $w LightBlue1] +button $w.b3 -text "Sea Green" -width 10 \ + -command [list colorrefresh $w SeaGreen2] +button $w.b4 -text "Yellow" -width 10 \ + -command [list colorrefresh $w Yellow1] +pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2 diff --git a/evalkit_llava/lib/tk8.6/demos/check.tcl b/evalkit_llava/lib/tk8.6/demos/check.tcl new file mode 100644 index 0000000000000000000000000000000000000000..cf21761839c5b0d7429c981af8e3e751e83d64b5 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/check.tcl @@ -0,0 +1,71 @@ +# check.tcl -- +# +# This demonstration script creates a toplevel window containing +# several checkbuttons. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .check +catch {destroy $w} +toplevel $w +wm title $w "Checkbutton Demonstration" +wm iconname $w "check" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "Four checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. The first button also follows the state of the other three. If only some of the three are checked, the first button will display the tri-state mode. Click the \"See Variables\" button to see the current values of the variables." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w [list safety wipers brakes sober]] +pack $btns -side bottom -fill x + +checkbutton $w.b0 -text "Safety Check" -variable safety -relief flat \ + -onvalue "all" \ + -offvalue "none" \ + -tristatevalue "partial" +checkbutton $w.b1 -text "Wipers OK" -variable wipers -relief flat +checkbutton $w.b2 -text "Brakes OK" -variable brakes -relief flat +checkbutton $w.b3 -text "Driver Sober" -variable sober -relief flat +pack $w.b0 -side top -pady 2 -anchor w +pack $w.b1 $w.b2 $w.b3 -side top -pady 2 -anchor w -padx 15 + +## This code makes $w.b0 function as a tri-state button; it's not +## needed at all for just straight yes/no buttons. + +set in_check 0 +proc tristate_check {n1 n2 op} { + global safety wipers brakes sober in_check + if {$in_check} { + return + } + set in_check 1 + if {$n1 eq "safety"} { + if {$safety eq "none"} { + set wipers 0 + set brakes 0 + set sober 0 + } elseif {$safety eq "all"} { + set wipers 1 + set brakes 1 + set sober 1 + } + } else { + if {$wipers == 1 && $brakes == 1 && $sober == 1} { + set safety all + } elseif {$wipers == 1 || $brakes == 1 || $sober == 1} { + set safety partial + } else { + set safety none + } + } + set in_check 0 +} + +trace add variable wipers write tristate_check +trace add variable brakes write tristate_check +trace add variable sober write tristate_check +trace add variable safety write tristate_check diff --git a/evalkit_llava/lib/tk8.6/demos/clrpick.tcl b/evalkit_llava/lib/tk8.6/demos/clrpick.tcl new file mode 100644 index 0000000000000000000000000000000000000000..ba50b7560f341f5e5aa47ac96f49f125ce871110 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/clrpick.tcl @@ -0,0 +1,54 @@ +# clrpick.tcl -- +# +# This demonstration script prompts the user to select a color. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .clrpick +catch {destroy $w} +toplevel $w +wm title $w "Color Selection Dialog" +wm iconname $w "colors" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "Press the buttons below to choose the foreground and background colors for the widgets in this window." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +button $w.back -text "Set background color ..." \ + -command \ + "setColor $w $w.back background {-background -highlightbackground}" +button $w.fore -text "Set foreground color ..." \ + -command \ + "setColor $w $w.back foreground -foreground" + +pack $w.back $w.fore -side top -anchor c -pady 2m + +proc setColor {w button name options} { + grab $w + set initialColor [$button cget -$name] + set color [tk_chooseColor -title "Choose a $name color" -parent $w \ + -initialcolor $initialColor] + if {[string compare $color ""]} { + setColor_helper $w $options $color + } + grab release $w +} + +proc setColor_helper {w options color} { + foreach option $options { + catch { + $w config $option $color + } + } + foreach child [winfo children $w] { + setColor_helper $child $options $color + } +} diff --git a/evalkit_llava/lib/tk8.6/demos/dialog2.tcl b/evalkit_llava/lib/tk8.6/demos/dialog2.tcl new file mode 100644 index 0000000000000000000000000000000000000000..6ae27a883791a6872811c21d3c4e962caef5473a --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/dialog2.tcl @@ -0,0 +1,18 @@ +# dialog2.tcl -- +# +# This demonstration script creates a dialog box with a global grab. + +after idle { + .dialog2.msg configure -wraplength 4i +} +after 100 { + grab -global .dialog2 +} +set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\ +warning 0 OK Cancel {Show Code}] + +switch $i { + 0 {puts "You pressed OK"} + 1 {puts "You pressed Cancel"} + 2 {showCode .dialog2} +} diff --git a/evalkit_llava/lib/tk8.6/demos/en.msg b/evalkit_llava/lib/tk8.6/demos/en.msg new file mode 100644 index 0000000000000000000000000000000000000000..05d4a64a4e789bbe09b14f19f5999184747d4cf7 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/en.msg @@ -0,0 +1,97 @@ +::msgcat::mcset en "Widget Demonstration" +::msgcat::mcset en "tkWidgetDemo" +::msgcat::mcset en "&File" +::msgcat::mcset en "About..." +::msgcat::mcset en "&About..." +::msgcat::mcset en "" +::msgcat::mcset en "&Quit" +::msgcat::mcset en "Meta+Q" ;# Displayed hotkey +::msgcat::mcset en "Meta-q" ;# Actual binding sequence +::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey +::msgcat::mcset en "Control-q" ;# Actual binding sequence +::msgcat::mcset en "Variable values" +::msgcat::mcset en "Variable values:" +::msgcat::mcset en "OK" +::msgcat::mcset en "Run the \"%s\" sample program" +::msgcat::mcset en "Dismiss" +::msgcat::mcset en "Rerun Demo" +::msgcat::mcset en "Demo code: %s" +::msgcat::mcset en "About Widget Demo" +::msgcat::mcset en "Tk widget demonstration application" +::msgcat::mcset en "Copyright © %s" +::msgcat::mcset en " + @@title + Tk Widget Demonstrations + @@newline + @@normal + @@newline + + 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 + @@bold + See Code + @@normal + button to see the Tcl/Tk code that created the demonstration. If + you wish, you can edit the code and click the + @@bold + Rerun Demo + @@normal + button in the code window to reinvoke the demonstration with the + modified code. + @@newline +" +::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons" +::msgcat::mcset en "Labels (text and bitmaps)" +::msgcat::mcset en "Labels and UNICODE text" +::msgcat::mcset en "Buttons" +::msgcat::mcset en "Check-buttons (select any of a group)" +::msgcat::mcset en "Radio-buttons (select one of a group)" +::msgcat::mcset en "A 15-puzzle game made out of buttons" +::msgcat::mcset en "Iconic buttons that use bitmaps" +::msgcat::mcset en "Two labels displaying images" +::msgcat::mcset en "A simple user interface for viewing images" +::msgcat::mcset en "Labelled frames" +::msgcat::mcset en "Listboxes" +::msgcat::mcset en "The 50 states" +::msgcat::mcset en "Colors: change the color scheme for the application" +::msgcat::mcset en "A collection of famous and infamous sayings" +::msgcat::mcset en "Entries and Spin-boxes" +::msgcat::mcset en "Entries without scrollbars" +::msgcat::mcset en "Entries with scrollbars" +::msgcat::mcset en "Validated entries and password fields" +::msgcat::mcset en "Spin-boxes" +::msgcat::mcset en "Simple Rolodex-like form" +::msgcat::mcset en "Text" +::msgcat::mcset en "Basic editable text" +::msgcat::mcset en "Text display styles" +::msgcat::mcset en "Hypertext (tag bindings)" +::msgcat::mcset en "A text widget with embedded windows" +::msgcat::mcset en "A search tool built with a text widget" +::msgcat::mcset en "Canvases" +::msgcat::mcset en "The canvas item types" +::msgcat::mcset en "A simple 2-D plot" +::msgcat::mcset en "Text items in canvases" +::msgcat::mcset en "An editor for arrowheads on canvas lines" +::msgcat::mcset en "A ruler with adjustable tab stops" +::msgcat::mcset en "A building floor plan" +::msgcat::mcset en "A simple scrollable canvas" +::msgcat::mcset en "Scales" +::msgcat::mcset en "Horizontal scale" +::msgcat::mcset en "Vertical scale" +::msgcat::mcset en "Paned Windows" +::msgcat::mcset en "Horizontal paned window" +::msgcat::mcset en "Vertical paned window" +::msgcat::mcset en "Menus" +::msgcat::mcset en "Menus and cascades (sub-menus)" +::msgcat::mcset en "Menu-buttons" +::msgcat::mcset en "Common Dialogs" +::msgcat::mcset en "Message boxes" +::msgcat::mcset en "File selection dialog" +::msgcat::mcset en "Color picker" +::msgcat::mcset en "Miscellaneous" +::msgcat::mcset en "The built-in bitmaps" +::msgcat::mcset en "A dialog box with a local grab" +::msgcat::mcset en "A dialog box with a global grab" diff --git a/evalkit_llava/lib/tk8.6/demos/entry1.tcl b/evalkit_llava/lib/tk8.6/demos/entry1.tcl new file mode 100644 index 0000000000000000000000000000000000000000..7365fc7279a7d3c37a8c7774d5084ae040412b55 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/entry1.tcl @@ -0,0 +1,34 @@ +# entry1.tcl -- +# +# This demonstration script creates several entry widgets without +# scrollbars. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .entry1 +catch {destroy $w} +toplevel $w +wm title $w "Entry Demonstration (no scrollbars)" +wm iconname $w "entry1" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse the middle mouse button pressed." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +entry $w.e1 +entry $w.e2 +entry $w.e3 +pack $w.e1 $w.e2 $w.e3 -side top -pady 5 -padx 10 -fill x + +$w.e1 insert 0 "Initial value" +$w.e2 insert end "This entry contains a long value, much too long " +$w.e2 insert end "to fit in the window at one time, so long in fact " +$w.e2 insert end "that you'll have to scan or scroll to see the end." diff --git a/evalkit_llava/lib/tk8.6/demos/entry2.tcl b/evalkit_llava/lib/tk8.6/demos/entry2.tcl new file mode 100644 index 0000000000000000000000000000000000000000..a4009a745d31f92a41de93132ceda33f9b108e1e --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/entry2.tcl @@ -0,0 +1,46 @@ +# entry2.tcl -- +# +# This demonstration script is the same as the entry1.tcl script +# except that it creates scrollbars for the entries. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .entry2 +catch {destroy $w} +toplevel $w +wm title $w "Entry Demonstration (with scrollbars)" +wm iconname $w "entry2" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +frame $w.frame -borderwidth 10 +pack $w.frame -side top -fill x -expand 1 + +entry $w.frame.e1 -xscrollcommand "$w.frame.s1 set" +ttk::scrollbar $w.frame.s1 -orient horizontal -command \ + "$w.frame.e1 xview" +frame $w.frame.spacer1 -width 20 -height 10 +entry $w.frame.e2 -xscrollcommand "$w.frame.s2 set" +ttk::scrollbar $w.frame.s2 -orient horizontal -command \ + "$w.frame.e2 xview" +frame $w.frame.spacer2 -width 20 -height 10 +entry $w.frame.e3 -xscrollcommand "$w.frame.s3 set" +ttk::scrollbar $w.frame.s3 -orient horizontal -command \ + "$w.frame.e3 xview" +pack $w.frame.e1 $w.frame.s1 $w.frame.spacer1 $w.frame.e2 $w.frame.s2 \ + $w.frame.spacer2 $w.frame.e3 $w.frame.s3 -side top -fill x + +$w.frame.e1 insert 0 "Initial value" +$w.frame.e2 insert end "This entry contains a long value, much too long " +$w.frame.e2 insert end "to fit in the window at one time, so long in fact " +$w.frame.e2 insert end "that you'll have to scan or scroll to see the end." diff --git a/evalkit_llava/lib/tk8.6/demos/filebox.tcl b/evalkit_llava/lib/tk8.6/demos/filebox.tcl new file mode 100644 index 0000000000000000000000000000000000000000..e06ebba56ff383c2e5a24de8347252bee3a2b1e2 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/filebox.tcl @@ -0,0 +1,81 @@ +# filebox.tcl -- +# +# This demonstration script prompts the user to select a file. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .filebox +catch {destroy $w} +toplevel $w +wm title $w "File Selection Dialogs" +wm iconname $w "filebox" +positionWindow $w + +ttk::frame $w._bg +place $w._bg -x 0 -y 0 -relwidth 1 -relheight 1 + +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +foreach i {open save} { + set f [ttk::frame $w.$i] + ttk::label $f.lab -text "Select a file to $i: " -anchor e + ttk::entry $f.ent -width 20 + ttk::button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i" + pack $f.lab -side left + pack $f.ent -side left -expand yes -fill x + pack $f.but -side left + pack $f -fill x -padx 1c -pady 3 +} + +if {[tk windowingsystem] eq "x11"} { + ttk::checkbutton $w.strict -text "Use Motif Style Dialog" \ + -variable tk_strictMotif -onvalue 1 -offvalue 0 + pack $w.strict -anchor c + + # This binding ensures that we don't run the rest of the demos + # with motif style interactions + bind $w.strict {set tk_strictMotif 0} +} + +proc fileDialog {w ent operation} { + # Type names Extension(s) Mac File Type(s) + # + #--------------------------------------------------------- + set types { + {"Text files" {.txt .doc} } + {"Text files" {} TEXT} + {"Tcl Scripts" {.tcl} TEXT} + {"C Source Files" {.c .h} } + {"All Source Files" {.tcl .c .h} } + {"Image Files" {.gif} } + {"Image Files" {.jpeg .jpg} } + {"Image Files" "" {GIFF JPEG}} + {"All files" *} + } + if {$operation == "open"} { + global selected_type + if {![info exists selected_type]} { + set selected_type "Tcl Scripts" + } + set file [tk_getOpenFile -filetypes $types -parent $w \ + -typevariable selected_type] + puts "You selected filetype \"$selected_type\"" + } else { + set file [tk_getSaveFile -filetypes $types -parent $w \ + -initialfile Untitled -defaultextension .txt] + } + if {[string compare $file ""]} { + $ent delete 0 end + $ent insert 0 $file + $ent xview end + } +} diff --git a/evalkit_llava/lib/tk8.6/demos/floor.tcl b/evalkit_llava/lib/tk8.6/demos/floor.tcl new file mode 100644 index 0000000000000000000000000000000000000000..4831ccf90dbcafaabf5e275be79f19d5ca38bc7e --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/floor.tcl @@ -0,0 +1,1372 @@ +# floor.tcl -- +# +# This demonstration script creates a canvas widet that displays the +# floorplan for DEC's Western Research Laboratory. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +# floorDisplay -- +# Recreate the floorplan display in the canvas given by "w". The +# floor given by "active" is displayed on top with its office structure +# visible. +# +# Arguments: +# w - Name of the canvas window. +# active - Number of active floor (1, 2, or 3). + +proc floorDisplay {w active} { + global floorLabels floorItems colors activeFloor + + if {$activeFloor == $active} { + return + } + + $w delete all + set activeFloor $active + + # First go through the three floors, displaying the backgrounds for + # each floor. + + bg1 $w $colors(bg1) $colors(outline1) + bg2 $w $colors(bg2) $colors(outline2) + bg3 $w $colors(bg3) $colors(outline3) + + # Raise the background for the active floor so that it's on top. + + $w raise floor$active + + # Create a dummy item just to mark this point in the display list, + # so we can insert highlights here. + + $w create rect 0 100 1 101 -fill {} -outline {} -tags marker + + # Add the walls and labels for the active floor, along with + # transparent polygons that define the rooms on the floor. + # Make sure that the room polygons are on top. + + catch {unset floorLabels} + catch {unset floorItems} + fg$active $w $colors(offices) + $w raise room + + # Offset the floors diagonally from each other. + + $w move floor1 2c 2c + $w move floor2 1c 1c + + # Create items for the room entry and its label. + + $w create window 600 100 -anchor w -window $w.entry + $w create text 600 100 -anchor e -text "Room: " + + $w config -scrollregion [$w bbox all] +} + +# newRoom -- +# This procedure is invoked whenever the mouse enters a room +# in the floorplan. It changes tags so that the current room is +# highlighted. +# +# Arguments: +# w - The name of the canvas window. + +proc newRoom w { + global currentRoom floorLabels + + set id [$w find withtag current] + if {$id != ""} { + set currentRoom $floorLabels($id) + } + update idletasks +} + +# roomChanged -- +# This procedure is invoked whenever the currentRoom variable changes. +# It highlights the current room and unhighlights any previous room. +# +# Arguments: +# w - The canvas window displaying the floorplan. +# args - Not used. + +proc roomChanged {w args} { + global currentRoom floorItems colors + $w delete highlight + if {[catch {set item $floorItems($currentRoom)}]} { + return + } + set new [eval \ + "$w create polygon [$w coords $item] -fill $colors(active) \ + -outline {} -tags highlight"] + $w raise $new marker +} + +# bg1 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the background information for the first +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +proc bg1 {w fill outline} { + $w create polygon 347 80 349 82 351 84 353 85 363 92 375 99 386 104 \ + 386 129 398 129 398 162 484 162 484 129 559 129 559 133 725 \ + 133 725 129 802 129 802 389 644 389 644 391 559 391 559 327 \ + 508 327 508 311 484 311 484 278 395 278 395 288 400 288 404 \ + 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 \ + 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 \ + 342 331 347 332 351 334 354 336 357 341 359 340 360 335 363 \ + 331 365 326 366 304 366 304 355 258 355 258 387 60 387 60 391 \ + 0 391 0 337 3 337 3 114 8 114 8 25 30 25 30 5 93 5 98 5 104 7 \ + 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 34 221 \ + 22 223 17 227 13 231 8 236 4 242 2 246 0 260 0 283 1 300 5 \ + 321 14 335 22 348 25 365 29 363 39 358 48 352 56 337 70 \ + 344 76 347 80 \ + -tags {floor1 bg} -fill $fill -outline {} + $w create line 386 129 398 129 -fill $outline -tags {floor1 bg} + $w create line 258 355 258 387 -fill $outline -tags {floor1 bg} + $w create line 60 387 60 391 -fill $outline -tags {floor1 bg} + $w create line 0 337 0 391 -fill $outline -tags {floor1 bg} + $w create line 60 391 0 391 -fill $outline -tags {floor1 bg} + $w create line 3 114 3 337 -fill $outline -tags {floor1 bg} + $w create line 258 387 60 387 -fill $outline -tags {floor1 bg} + $w create line 484 162 398 162 -fill $outline -tags {floor1 bg} + $w create line 398 162 398 129 -fill $outline -tags {floor1 bg} + $w create line 484 278 484 311 -fill $outline -tags {floor1 bg} + $w create line 484 311 508 311 -fill $outline -tags {floor1 bg} + $w create line 508 327 508 311 -fill $outline -tags {floor1 bg} + $w create line 559 327 508 327 -fill $outline -tags {floor1 bg} + $w create line 644 391 559 391 -fill $outline -tags {floor1 bg} + $w create line 644 389 644 391 -fill $outline -tags {floor1 bg} + $w create line 559 129 484 129 -fill $outline -tags {floor1 bg} + $w create line 484 162 484 129 -fill $outline -tags {floor1 bg} + $w create line 725 133 559 133 -fill $outline -tags {floor1 bg} + $w create line 559 129 559 133 -fill $outline -tags {floor1 bg} + $w create line 725 129 802 129 -fill $outline -tags {floor1 bg} + $w create line 802 389 802 129 -fill $outline -tags {floor1 bg} + $w create line 3 337 0 337 -fill $outline -tags {floor1 bg} + $w create line 559 391 559 327 -fill $outline -tags {floor1 bg} + $w create line 802 389 644 389 -fill $outline -tags {floor1 bg} + $w create line 725 133 725 129 -fill $outline -tags {floor1 bg} + $w create line 8 25 8 114 -fill $outline -tags {floor1 bg} + $w create line 8 114 3 114 -fill $outline -tags {floor1 bg} + $w create line 30 25 8 25 -fill $outline -tags {floor1 bg} + $w create line 484 278 395 278 -fill $outline -tags {floor1 bg} + $w create line 30 25 30 5 -fill $outline -tags {floor1 bg} + $w create line 93 5 30 5 -fill $outline -tags {floor1 bg} + $w create line 98 5 93 5 -fill $outline -tags {floor1 bg} + $w create line 104 7 98 5 -fill $outline -tags {floor1 bg} + $w create line 110 10 104 7 -fill $outline -tags {floor1 bg} + $w create line 116 16 110 10 -fill $outline -tags {floor1 bg} + $w create line 119 20 116 16 -fill $outline -tags {floor1 bg} + $w create line 122 28 119 20 -fill $outline -tags {floor1 bg} + $w create line 123 32 122 28 -fill $outline -tags {floor1 bg} + $w create line 123 68 123 32 -fill $outline -tags {floor1 bg} + $w create line 220 68 123 68 -fill $outline -tags {floor1 bg} + $w create line 386 129 386 104 -fill $outline -tags {floor1 bg} + $w create line 386 104 375 99 -fill $outline -tags {floor1 bg} + $w create line 375 99 363 92 -fill $outline -tags {floor1 bg} + $w create line 353 85 363 92 -fill $outline -tags {floor1 bg} + $w create line 220 68 220 34 -fill $outline -tags {floor1 bg} + $w create line 337 70 352 56 -fill $outline -tags {floor1 bg} + $w create line 352 56 358 48 -fill $outline -tags {floor1 bg} + $w create line 358 48 363 39 -fill $outline -tags {floor1 bg} + $w create line 363 39 365 29 -fill $outline -tags {floor1 bg} + $w create line 365 29 348 25 -fill $outline -tags {floor1 bg} + $w create line 348 25 335 22 -fill $outline -tags {floor1 bg} + $w create line 335 22 321 14 -fill $outline -tags {floor1 bg} + $w create line 321 14 300 5 -fill $outline -tags {floor1 bg} + $w create line 300 5 283 1 -fill $outline -tags {floor1 bg} + $w create line 283 1 260 0 -fill $outline -tags {floor1 bg} + $w create line 260 0 246 0 -fill $outline -tags {floor1 bg} + $w create line 246 0 242 2 -fill $outline -tags {floor1 bg} + $w create line 242 2 236 4 -fill $outline -tags {floor1 bg} + $w create line 236 4 231 8 -fill $outline -tags {floor1 bg} + $w create line 231 8 227 13 -fill $outline -tags {floor1 bg} + $w create line 223 17 227 13 -fill $outline -tags {floor1 bg} + $w create line 221 22 223 17 -fill $outline -tags {floor1 bg} + $w create line 220 34 221 22 -fill $outline -tags {floor1 bg} + $w create line 340 360 335 363 -fill $outline -tags {floor1 bg} + $w create line 335 363 331 365 -fill $outline -tags {floor1 bg} + $w create line 331 365 326 366 -fill $outline -tags {floor1 bg} + $w create line 326 366 304 366 -fill $outline -tags {floor1 bg} + $w create line 304 355 304 366 -fill $outline -tags {floor1 bg} + $w create line 395 288 400 288 -fill $outline -tags {floor1 bg} + $w create line 404 288 400 288 -fill $outline -tags {floor1 bg} + $w create line 409 290 404 288 -fill $outline -tags {floor1 bg} + $w create line 413 292 409 290 -fill $outline -tags {floor1 bg} + $w create line 418 297 413 292 -fill $outline -tags {floor1 bg} + $w create line 421 302 418 297 -fill $outline -tags {floor1 bg} + $w create line 422 309 421 302 -fill $outline -tags {floor1 bg} + $w create line 421 318 422 309 -fill $outline -tags {floor1 bg} + $w create line 421 318 417 325 -fill $outline -tags {floor1 bg} + $w create line 417 325 411 330 -fill $outline -tags {floor1 bg} + $w create line 411 330 405 332 -fill $outline -tags {floor1 bg} + $w create line 405 332 397 333 -fill $outline -tags {floor1 bg} + $w create line 397 333 344 333 -fill $outline -tags {floor1 bg} + $w create line 344 333 340 334 -fill $outline -tags {floor1 bg} + $w create line 340 334 336 336 -fill $outline -tags {floor1 bg} + $w create line 336 336 335 338 -fill $outline -tags {floor1 bg} + $w create line 335 338 332 342 -fill $outline -tags {floor1 bg} + $w create line 331 347 332 342 -fill $outline -tags {floor1 bg} + $w create line 332 351 331 347 -fill $outline -tags {floor1 bg} + $w create line 334 354 332 351 -fill $outline -tags {floor1 bg} + $w create line 336 357 334 354 -fill $outline -tags {floor1 bg} + $w create line 341 359 336 357 -fill $outline -tags {floor1 bg} + $w create line 341 359 340 360 -fill $outline -tags {floor1 bg} + $w create line 395 288 395 278 -fill $outline -tags {floor1 bg} + $w create line 304 355 258 355 -fill $outline -tags {floor1 bg} + $w create line 347 80 344 76 -fill $outline -tags {floor1 bg} + $w create line 344 76 337 70 -fill $outline -tags {floor1 bg} + $w create line 349 82 347 80 -fill $outline -tags {floor1 bg} + $w create line 351 84 349 82 -fill $outline -tags {floor1 bg} + $w create line 353 85 351 84 -fill $outline -tags {floor1 bg} +} + +# bg2 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the background information for the second +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +proc bg2 {w fill outline} { + $w create polygon 559 129 484 129 484 162 398 162 398 129 315 129 \ + 315 133 176 133 176 129 96 129 96 133 3 133 3 339 0 339 0 391 \ + 60 391 60 387 258 387 258 329 350 329 350 311 395 311 395 280 \ + 484 280 484 311 508 311 508 327 558 327 558 391 644 391 644 \ + 367 802 367 802 129 725 129 725 133 559 133 559 129 \ + -tags {floor2 bg} -fill $fill -outline {} + $w create line 350 311 350 329 -fill $outline -tags {floor2 bg} + $w create line 398 129 398 162 -fill $outline -tags {floor2 bg} + $w create line 802 367 802 129 -fill $outline -tags {floor2 bg} + $w create line 802 129 725 129 -fill $outline -tags {floor2 bg} + $w create line 725 133 725 129 -fill $outline -tags {floor2 bg} + $w create line 559 129 559 133 -fill $outline -tags {floor2 bg} + $w create line 559 133 725 133 -fill $outline -tags {floor2 bg} + $w create line 484 162 484 129 -fill $outline -tags {floor2 bg} + $w create line 559 129 484 129 -fill $outline -tags {floor2 bg} + $w create line 802 367 644 367 -fill $outline -tags {floor2 bg} + $w create line 644 367 644 391 -fill $outline -tags {floor2 bg} + $w create line 644 391 558 391 -fill $outline -tags {floor2 bg} + $w create line 558 327 558 391 -fill $outline -tags {floor2 bg} + $w create line 558 327 508 327 -fill $outline -tags {floor2 bg} + $w create line 508 327 508 311 -fill $outline -tags {floor2 bg} + $w create line 484 311 508 311 -fill $outline -tags {floor2 bg} + $w create line 484 280 484 311 -fill $outline -tags {floor2 bg} + $w create line 398 162 484 162 -fill $outline -tags {floor2 bg} + $w create line 484 280 395 280 -fill $outline -tags {floor2 bg} + $w create line 395 280 395 311 -fill $outline -tags {floor2 bg} + $w create line 258 387 60 387 -fill $outline -tags {floor2 bg} + $w create line 3 133 3 339 -fill $outline -tags {floor2 bg} + $w create line 3 339 0 339 -fill $outline -tags {floor2 bg} + $w create line 60 391 0 391 -fill $outline -tags {floor2 bg} + $w create line 0 339 0 391 -fill $outline -tags {floor2 bg} + $w create line 60 387 60 391 -fill $outline -tags {floor2 bg} + $w create line 258 329 258 387 -fill $outline -tags {floor2 bg} + $w create line 350 329 258 329 -fill $outline -tags {floor2 bg} + $w create line 395 311 350 311 -fill $outline -tags {floor2 bg} + $w create line 398 129 315 129 -fill $outline -tags {floor2 bg} + $w create line 176 133 315 133 -fill $outline -tags {floor2 bg} + $w create line 176 129 96 129 -fill $outline -tags {floor2 bg} + $w create line 3 133 96 133 -fill $outline -tags {floor2 bg} + $w create line 315 133 315 129 -fill $outline -tags {floor2 bg} + $w create line 176 133 176 129 -fill $outline -tags {floor2 bg} + $w create line 96 133 96 129 -fill $outline -tags {floor2 bg} +} + +# bg3 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the background information for the third +# floor. +# +# Arguments: +# w - The canvas window. +# fill - Fill color to use for the floor's background. +# outline - Color to use for the floor's outline. + +proc bg3 {w fill outline} { + $w create polygon 159 300 107 300 107 248 159 248 159 129 96 129 96 \ + 133 21 133 21 331 0 331 0 391 60 391 60 370 159 370 159 300 \ + -tags {floor3 bg} -fill $fill -outline {} + $w create polygon 258 370 258 329 350 329 350 311 399 311 399 129 \ + 315 129 315 133 176 133 176 129 159 129 159 370 258 370 \ + -tags {floor3 bg} -fill $fill -outline {} + $w create line 96 133 96 129 -fill $outline -tags {floor3 bg} + $w create line 176 129 96 129 -fill $outline -tags {floor3 bg} + $w create line 176 129 176 133 -fill $outline -tags {floor3 bg} + $w create line 315 133 176 133 -fill $outline -tags {floor3 bg} + $w create line 315 133 315 129 -fill $outline -tags {floor3 bg} + $w create line 399 129 315 129 -fill $outline -tags {floor3 bg} + $w create line 399 311 399 129 -fill $outline -tags {floor3 bg} + $w create line 399 311 350 311 -fill $outline -tags {floor3 bg} + $w create line 350 329 350 311 -fill $outline -tags {floor3 bg} + $w create line 350 329 258 329 -fill $outline -tags {floor3 bg} + $w create line 258 370 258 329 -fill $outline -tags {floor3 bg} + $w create line 60 370 258 370 -fill $outline -tags {floor3 bg} + $w create line 60 370 60 391 -fill $outline -tags {floor3 bg} + $w create line 60 391 0 391 -fill $outline -tags {floor3 bg} + $w create line 0 391 0 331 -fill $outline -tags {floor3 bg} + $w create line 21 331 0 331 -fill $outline -tags {floor3 bg} + $w create line 21 331 21 133 -fill $outline -tags {floor3 bg} + $w create line 96 133 21 133 -fill $outline -tags {floor3 bg} + $w create line 107 300 159 300 159 248 107 248 107 300 \ + -fill $outline -tags {floor3 bg} +} + +# fg1 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the first +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +proc fg1 {w color} { + global floorLabels floorItems + set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 101 + set {floorItems(101)} $i + $w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {Pub Lift1} + set {floorItems(Pub Lift1)} $i + $w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {Priv Lift1} + set {floorItems(Priv Lift1)} $i + $w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 110 + set {floorItems(110)} $i + $w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 109 + set {floorItems(109)} $i + $w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 111 + set {floorItems(111)} $i + $w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 117B + set {floorItems(117B)} $i + $w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 112 + set {floorItems(112)} $i + $w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 113 + set {floorItems(113)} $i + $w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 117A + set {floorItems(117A)} $i + $w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 117 + set {floorItems(117)} $i + $w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 114 + set {floorItems(114)} $i + $w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 115 + set {floorItems(115)} $i + $w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 116 + set {floorItems(116)} $i + $w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 118 + set {floorItems(118)} $i + $w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 120 + set {floorItems(120)} $i + $w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 122 + set {floorItems(122)} $i + $w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 121 + set {floorItems(121)} $i + $w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 106A + set {floorItems(106A)} $i + $w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 105 + set {floorItems(105)} $i + $w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 106B + set {floorItems(106B)} $i + $w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 104 + set {floorItems(104)} $i + $w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 108 + set {floorItems(108)} $i + $w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 107 + set {floorItems(107)} $i + $w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) Smoking + set {floorItems(Smoking)} $i + $w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 123 + set {floorItems(123)} $i + $w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 103 + set {floorItems(103)} $i + $w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 124 + set {floorItems(124)} $i + $w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 125 + set {floorItems(125)} $i + $w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 126 + set {floorItems(126)} $i + $w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 127 + set {floorItems(127)} $i + $w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) MShower + set {floorItems(MShower)} $i + $w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) Closet + set {floorItems(Closet)} $i + $w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) WShower + set {floorItems(WShower)} $i + $w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 130 + set {floorItems(130)} $i + $w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 102 + set {floorItems(102)} $i + $w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 128 + set {floorItems(128)} $i + $w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 129 + set {floorItems(129)} $i + $w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 133 + set {floorItems(133)} $i + $w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 132 + set {floorItems(132)} $i + $w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 134 + set {floorItems(134)} $i + $w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 135 + set {floorItems(135)} $i + $w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {Ramona Stair} + set {floorItems(Ramona Stair)} $i + $w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {University Stair} + set {floorItems(University Stair)} $i + $w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {Plaza Stair} + set {floorItems(Plaza Stair)} $i + $w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) {Plaza Deck} + set {floorItems(Plaza Deck)} $i + $w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 106 + set {floorItems(106)} $i + $w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label} + set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -outline {} -tags {floor1 room}] + set floorLabels($i) 119 + set {floorItems(119)} $i + $w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label} + $w create line 155 191 155 189 -fill $color -tags {floor1 wall} + $w create line 155 177 155 169 -fill $color -tags {floor1 wall} + $w create line 96 129 96 169 -fill $color -tags {floor1 wall} + $w create line 78 169 176 169 -fill $color -tags {floor1 wall} + $w create line 176 247 176 129 -fill $color -tags {floor1 wall} + $w create line 340 206 307 206 -fill $color -tags {floor1 wall} + $w create line 340 187 340 170 -fill $color -tags {floor1 wall} + $w create line 340 210 340 201 -fill $color -tags {floor1 wall} + $w create line 340 247 340 224 -fill $color -tags {floor1 wall} + $w create line 340 241 307 241 -fill $color -tags {floor1 wall} + $w create line 376 246 376 170 -fill $color -tags {floor1 wall} + $w create line 307 247 307 170 -fill $color -tags {floor1 wall} + $w create line 376 170 307 170 -fill $color -tags {floor1 wall} + $w create line 315 129 315 170 -fill $color -tags {floor1 wall} + $w create line 147 129 176 129 -fill $color -tags {floor1 wall} + $w create line 202 133 176 133 -fill $color -tags {floor1 wall} + $w create line 398 129 315 129 -fill $color -tags {floor1 wall} + $w create line 258 352 258 387 -fill $color -tags {floor1 wall} + $w create line 60 387 60 391 -fill $color -tags {floor1 wall} + $w create line 0 337 0 391 -fill $color -tags {floor1 wall} + $w create line 60 391 0 391 -fill $color -tags {floor1 wall} + $w create line 3 114 3 337 -fill $color -tags {floor1 wall} + $w create line 258 387 60 387 -fill $color -tags {floor1 wall} + $w create line 52 237 52 273 -fill $color -tags {floor1 wall} + $w create line 52 189 52 225 -fill $color -tags {floor1 wall} + $w create line 52 140 52 177 -fill $color -tags {floor1 wall} + $w create line 395 306 395 311 -fill $color -tags {floor1 wall} + $w create line 531 254 398 254 -fill $color -tags {floor1 wall} + $w create line 475 178 475 238 -fill $color -tags {floor1 wall} + $w create line 502 162 398 162 -fill $color -tags {floor1 wall} + $w create line 398 129 398 188 -fill $color -tags {floor1 wall} + $w create line 383 188 376 188 -fill $color -tags {floor1 wall} + $w create line 408 188 408 194 -fill $color -tags {floor1 wall} + $w create line 398 227 398 254 -fill $color -tags {floor1 wall} + $w create line 408 227 398 227 -fill $color -tags {floor1 wall} + $w create line 408 222 408 227 -fill $color -tags {floor1 wall} + $w create line 408 206 408 210 -fill $color -tags {floor1 wall} + $w create line 408 208 475 208 -fill $color -tags {floor1 wall} + $w create line 484 278 484 311 -fill $color -tags {floor1 wall} + $w create line 484 311 508 311 -fill $color -tags {floor1 wall} + $w create line 508 327 508 311 -fill $color -tags {floor1 wall} + $w create line 559 327 508 327 -fill $color -tags {floor1 wall} + $w create line 644 391 559 391 -fill $color -tags {floor1 wall} + $w create line 644 389 644 391 -fill $color -tags {floor1 wall} + $w create line 514 205 475 205 -fill $color -tags {floor1 wall} + $w create line 496 189 496 187 -fill $color -tags {floor1 wall} + $w create line 559 129 484 129 -fill $color -tags {floor1 wall} + $w create line 484 162 484 129 -fill $color -tags {floor1 wall} + $w create line 725 133 559 133 -fill $color -tags {floor1 wall} + $w create line 559 129 559 133 -fill $color -tags {floor1 wall} + $w create line 725 149 725 167 -fill $color -tags {floor1 wall} + $w create line 725 129 802 129 -fill $color -tags {floor1 wall} + $w create line 802 389 802 129 -fill $color -tags {floor1 wall} + $w create line 739 167 802 167 -fill $color -tags {floor1 wall} + $w create line 396 188 408 188 -fill $color -tags {floor1 wall} + $w create line 0 337 9 337 -fill $color -tags {floor1 wall} + $w create line 58 337 21 337 -fill $color -tags {floor1 wall} + $w create line 43 391 43 337 -fill $color -tags {floor1 wall} + $w create line 105 337 75 337 -fill $color -tags {floor1 wall} + $w create line 91 387 91 337 -fill $color -tags {floor1 wall} + $w create line 154 337 117 337 -fill $color -tags {floor1 wall} + $w create line 139 387 139 337 -fill $color -tags {floor1 wall} + $w create line 227 337 166 337 -fill $color -tags {floor1 wall} + $w create line 258 337 251 337 -fill $color -tags {floor1 wall} + $w create line 258 328 302 328 -fill $color -tags {floor1 wall} + $w create line 302 355 302 311 -fill $color -tags {floor1 wall} + $w create line 395 311 302 311 -fill $color -tags {floor1 wall} + $w create line 484 278 395 278 -fill $color -tags {floor1 wall} + $w create line 395 294 395 278 -fill $color -tags {floor1 wall} + $w create line 473 278 473 275 -fill $color -tags {floor1 wall} + $w create line 473 256 473 254 -fill $color -tags {floor1 wall} + $w create line 533 257 531 254 -fill $color -tags {floor1 wall} + $w create line 553 276 551 274 -fill $color -tags {floor1 wall} + $w create line 698 276 553 276 -fill $color -tags {floor1 wall} + $w create line 559 391 559 327 -fill $color -tags {floor1 wall} + $w create line 802 389 644 389 -fill $color -tags {floor1 wall} + $w create line 741 314 741 389 -fill $color -tags {floor1 wall} + $w create line 698 280 698 167 -fill $color -tags {floor1 wall} + $w create line 707 280 698 280 -fill $color -tags {floor1 wall} + $w create line 802 280 731 280 -fill $color -tags {floor1 wall} + $w create line 741 280 741 302 -fill $color -tags {floor1 wall} + $w create line 698 167 727 167 -fill $color -tags {floor1 wall} + $w create line 725 137 725 129 -fill $color -tags {floor1 wall} + $w create line 514 254 514 175 -fill $color -tags {floor1 wall} + $w create line 496 175 514 175 -fill $color -tags {floor1 wall} + $w create line 502 175 502 162 -fill $color -tags {floor1 wall} + $w create line 475 166 475 162 -fill $color -tags {floor1 wall} + $w create line 496 176 496 175 -fill $color -tags {floor1 wall} + $w create line 491 189 496 189 -fill $color -tags {floor1 wall} + $w create line 491 205 491 189 -fill $color -tags {floor1 wall} + $w create line 487 238 475 238 -fill $color -tags {floor1 wall} + $w create line 487 240 487 238 -fill $color -tags {floor1 wall} + $w create line 487 252 487 254 -fill $color -tags {floor1 wall} + $w create line 315 133 304 133 -fill $color -tags {floor1 wall} + $w create line 256 133 280 133 -fill $color -tags {floor1 wall} + $w create line 78 247 270 247 -fill $color -tags {floor1 wall} + $w create line 307 247 294 247 -fill $color -tags {floor1 wall} + $w create line 214 133 232 133 -fill $color -tags {floor1 wall} + $w create line 217 247 217 266 -fill $color -tags {floor1 wall} + $w create line 217 309 217 291 -fill $color -tags {floor1 wall} + $w create line 217 309 172 309 -fill $color -tags {floor1 wall} + $w create line 154 309 148 309 -fill $color -tags {floor1 wall} + $w create line 175 300 175 309 -fill $color -tags {floor1 wall} + $w create line 151 300 175 300 -fill $color -tags {floor1 wall} + $w create line 151 247 151 309 -fill $color -tags {floor1 wall} + $w create line 78 237 78 265 -fill $color -tags {floor1 wall} + $w create line 78 286 78 309 -fill $color -tags {floor1 wall} + $w create line 106 309 78 309 -fill $color -tags {floor1 wall} + $w create line 130 309 125 309 -fill $color -tags {floor1 wall} + $w create line 99 309 99 247 -fill $color -tags {floor1 wall} + $w create line 127 299 99 299 -fill $color -tags {floor1 wall} + $w create line 127 309 127 299 -fill $color -tags {floor1 wall} + $w create line 155 191 137 191 -fill $color -tags {floor1 wall} + $w create line 137 169 137 191 -fill $color -tags {floor1 wall} + $w create line 78 171 78 169 -fill $color -tags {floor1 wall} + $w create line 78 190 78 218 -fill $color -tags {floor1 wall} + $w create line 86 192 86 169 -fill $color -tags {floor1 wall} + $w create line 86 192 78 192 -fill $color -tags {floor1 wall} + $w create line 52 301 3 301 -fill $color -tags {floor1 wall} + $w create line 52 286 52 301 -fill $color -tags {floor1 wall} + $w create line 52 252 3 252 -fill $color -tags {floor1 wall} + $w create line 52 203 3 203 -fill $color -tags {floor1 wall} + $w create line 3 156 52 156 -fill $color -tags {floor1 wall} + $w create line 8 25 8 114 -fill $color -tags {floor1 wall} + $w create line 63 114 3 114 -fill $color -tags {floor1 wall} + $w create line 75 114 97 114 -fill $color -tags {floor1 wall} + $w create line 108 114 129 114 -fill $color -tags {floor1 wall} + $w create line 129 114 129 89 -fill $color -tags {floor1 wall} + $w create line 52 114 52 128 -fill $color -tags {floor1 wall} + $w create line 132 89 88 89 -fill $color -tags {floor1 wall} + $w create line 88 25 88 89 -fill $color -tags {floor1 wall} + $w create line 88 114 88 89 -fill $color -tags {floor1 wall} + $w create line 218 89 144 89 -fill $color -tags {floor1 wall} + $w create line 147 111 147 129 -fill $color -tags {floor1 wall} + $w create line 162 111 147 111 -fill $color -tags {floor1 wall} + $w create line 162 109 162 111 -fill $color -tags {floor1 wall} + $w create line 162 96 162 89 -fill $color -tags {floor1 wall} + $w create line 218 89 218 94 -fill $color -tags {floor1 wall} + $w create line 218 89 218 119 -fill $color -tags {floor1 wall} + $w create line 8 25 88 25 -fill $color -tags {floor1 wall} + $w create line 258 337 258 328 -fill $color -tags {floor1 wall} + $w create line 113 129 96 129 -fill $color -tags {floor1 wall} + $w create line 302 355 258 355 -fill $color -tags {floor1 wall} + $w create line 386 104 386 129 -fill $color -tags {floor1 wall} + $w create line 377 100 386 104 -fill $color -tags {floor1 wall} + $w create line 365 94 377 100 -fill $color -tags {floor1 wall} + $w create line 350 83 365 94 -fill $color -tags {floor1 wall} + $w create line 337 70 350 83 -fill $color -tags {floor1 wall} + $w create line 337 70 323 56 -fill $color -tags {floor1 wall} + $w create line 312 49 323 56 -fill $color -tags {floor1 wall} + $w create line 295 40 312 49 -fill $color -tags {floor1 wall} + $w create line 282 37 295 40 -fill $color -tags {floor1 wall} + $w create line 260 34 282 37 -fill $color -tags {floor1 wall} + $w create line 253 34 260 34 -fill $color -tags {floor1 wall} + $w create line 386 128 386 104 -fill $color -tags {floor1 wall} + $w create line 113 152 156 152 -fill $color -tags {floor1 wall} + $w create line 113 152 156 152 -fill $color -tags {floor1 wall} + $w create line 113 152 113 129 -fill $color -tags {floor1 wall} +} + +# fg2 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the second +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +proc fg2 {w color} { + global floorLabels floorItems + set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 238 + set {floorItems(238)} $i + $w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 237 + set {floorItems(237)} $i + $w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 246 + set {floorItems(246)} $i + $w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 247 + set {floorItems(247)} $i + $w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 202 + set {floorItems(202)} $i + $w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 206 + set {floorItems(206)} $i + $w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 212 + set {floorItems(212)} $i + $w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 245 + set {floorItems(245)} $i + $w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 244 + set {floorItems(244)} $i + $w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 243 + set {floorItems(243)} $i + $w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 242 + set {floorItems(242)} $i + $w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) {Barbecue Deck} + set {floorItems(Barbecue Deck)} $i + $w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 240 + set {floorItems(240)} $i + $w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 241 + set {floorItems(241)} $i + $w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 239 + set {floorItems(239)} $i + $w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 248 + set {floorItems(248)} $i + $w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 236 + set {floorItems(236)} $i + $w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 235 + set {floorItems(235)} $i + $w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 234 + set {floorItems(234)} $i + $w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 233 + set {floorItems(233)} $i + $w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 230 + set {floorItems(230)} $i + $w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 232 + set {floorItems(232)} $i + $w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 229 + set {floorItems(229)} $i + $w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 227 + set {floorItems(227)} $i + $w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 228 + set {floorItems(228)} $i + $w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 226 + set {floorItems(226)} $i + $w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 225 + set {floorItems(225)} $i + $w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 224 + set {floorItems(224)} $i + $w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 223 + set {floorItems(223)} $i + $w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 222 + set {floorItems(222)} $i + $w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 221 + set {floorItems(221)} $i + $w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 204 + set {floorItems(204)} $i + $w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 205 + set {floorItems(205)} $i + $w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 207 + set {floorItems(207)} $i + $w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 208 + set {floorItems(208)} $i + $w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 209 + set {floorItems(209)} $i + $w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 217 + set {floorItems(217)} $i + $w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 217A + set {floorItems(217A)} $i + $w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 216 + set {floorItems(216)} $i + $w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 215 + set {floorItems(215)} $i + $w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 214 + set {floorItems(214)} $i + $w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 213 + set {floorItems(213)} $i + $w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 210 + set {floorItems(210)} $i + $w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 211 + set {floorItems(211)} $i + $w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 203 + set {floorItems(203)} $i + $w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 220 + set {floorItems(220)} $i + $w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) {Priv Lift2} + set {floorItems(Priv Lift2)} $i + $w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) {Pub Lift 2} + set {floorItems(Pub Lift 2)} $i + $w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 218 + set {floorItems(218)} $i + $w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 219 + set {floorItems(219)} $i + $w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label} + set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor2 room}] + set floorLabels($i) 201 + set {floorItems(201)} $i + $w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label} + $w create line 641 186 678 186 -fill $color -tags {floor2 wall} + $w create line 757 350 757 367 -fill $color -tags {floor2 wall} + $w create line 634 133 634 144 -fill $color -tags {floor2 wall} + $w create line 634 144 627 144 -fill $color -tags {floor2 wall} + $w create line 572 133 572 144 -fill $color -tags {floor2 wall} + $w create line 572 144 579 144 -fill $color -tags {floor2 wall} + $w create line 398 129 398 162 -fill $color -tags {floor2 wall} + $w create line 174 197 175 197 -fill $color -tags {floor2 wall} + $w create line 175 197 175 227 -fill $color -tags {floor2 wall} + $w create line 757 206 757 221 -fill $color -tags {floor2 wall} + $w create line 396 188 408 188 -fill $color -tags {floor2 wall} + $w create line 727 189 725 189 -fill $color -tags {floor2 wall} + $w create line 747 167 802 167 -fill $color -tags {floor2 wall} + $w create line 747 167 747 189 -fill $color -tags {floor2 wall} + $w create line 755 189 739 189 -fill $color -tags {floor2 wall} + $w create line 769 224 757 224 -fill $color -tags {floor2 wall} + $w create line 802 224 802 129 -fill $color -tags {floor2 wall} + $w create line 802 129 725 129 -fill $color -tags {floor2 wall} + $w create line 725 189 725 129 -fill $color -tags {floor2 wall} + $w create line 725 186 690 186 -fill $color -tags {floor2 wall} + $w create line 676 133 676 186 -fill $color -tags {floor2 wall} + $w create line 627 144 627 186 -fill $color -tags {floor2 wall} + $w create line 629 186 593 186 -fill $color -tags {floor2 wall} + $w create line 579 144 579 186 -fill $color -tags {floor2 wall} + $w create line 559 129 559 133 -fill $color -tags {floor2 wall} + $w create line 725 133 559 133 -fill $color -tags {floor2 wall} + $w create line 484 162 484 129 -fill $color -tags {floor2 wall} + $w create line 559 129 484 129 -fill $color -tags {floor2 wall} + $w create line 526 129 526 186 -fill $color -tags {floor2 wall} + $w create line 540 186 581 186 -fill $color -tags {floor2 wall} + $w create line 528 186 523 186 -fill $color -tags {floor2 wall} + $w create line 511 186 475 186 -fill $color -tags {floor2 wall} + $w create line 496 190 496 186 -fill $color -tags {floor2 wall} + $w create line 496 205 496 202 -fill $color -tags {floor2 wall} + $w create line 475 205 527 205 -fill $color -tags {floor2 wall} + $w create line 558 205 539 205 -fill $color -tags {floor2 wall} + $w create line 558 205 558 249 -fill $color -tags {floor2 wall} + $w create line 558 249 475 249 -fill $color -tags {floor2 wall} + $w create line 662 206 642 206 -fill $color -tags {floor2 wall} + $w create line 695 206 675 206 -fill $color -tags {floor2 wall} + $w create line 695 278 642 278 -fill $color -tags {floor2 wall} + $w create line 642 291 642 206 -fill $color -tags {floor2 wall} + $w create line 695 291 695 206 -fill $color -tags {floor2 wall} + $w create line 716 208 716 206 -fill $color -tags {floor2 wall} + $w create line 757 206 716 206 -fill $color -tags {floor2 wall} + $w create line 757 221 757 224 -fill $color -tags {floor2 wall} + $w create line 793 224 802 224 -fill $color -tags {floor2 wall} + $w create line 757 262 716 262 -fill $color -tags {floor2 wall} + $w create line 716 220 716 264 -fill $color -tags {floor2 wall} + $w create line 716 315 716 276 -fill $color -tags {floor2 wall} + $w create line 757 315 703 315 -fill $color -tags {floor2 wall} + $w create line 757 325 757 224 -fill $color -tags {floor2 wall} + $w create line 757 367 644 367 -fill $color -tags {floor2 wall} + $w create line 689 367 689 315 -fill $color -tags {floor2 wall} + $w create line 647 315 644 315 -fill $color -tags {floor2 wall} + $w create line 659 315 691 315 -fill $color -tags {floor2 wall} + $w create line 600 325 600 391 -fill $color -tags {floor2 wall} + $w create line 627 325 644 325 -fill $color -tags {floor2 wall} + $w create line 644 391 644 315 -fill $color -tags {floor2 wall} + $w create line 615 325 575 325 -fill $color -tags {floor2 wall} + $w create line 644 391 558 391 -fill $color -tags {floor2 wall} + $w create line 563 325 558 325 -fill $color -tags {floor2 wall} + $w create line 558 391 558 314 -fill $color -tags {floor2 wall} + $w create line 558 327 508 327 -fill $color -tags {floor2 wall} + $w create line 558 275 484 275 -fill $color -tags {floor2 wall} + $w create line 558 302 558 275 -fill $color -tags {floor2 wall} + $w create line 508 327 508 311 -fill $color -tags {floor2 wall} + $w create line 484 311 508 311 -fill $color -tags {floor2 wall} + $w create line 484 275 484 311 -fill $color -tags {floor2 wall} + $w create line 475 208 408 208 -fill $color -tags {floor2 wall} + $w create line 408 206 408 210 -fill $color -tags {floor2 wall} + $w create line 408 222 408 227 -fill $color -tags {floor2 wall} + $w create line 408 227 398 227 -fill $color -tags {floor2 wall} + $w create line 398 227 398 254 -fill $color -tags {floor2 wall} + $w create line 408 188 408 194 -fill $color -tags {floor2 wall} + $w create line 383 188 376 188 -fill $color -tags {floor2 wall} + $w create line 398 188 398 162 -fill $color -tags {floor2 wall} + $w create line 398 162 484 162 -fill $color -tags {floor2 wall} + $w create line 475 162 475 254 -fill $color -tags {floor2 wall} + $w create line 398 254 475 254 -fill $color -tags {floor2 wall} + $w create line 484 280 395 280 -fill $color -tags {floor2 wall} + $w create line 395 311 395 275 -fill $color -tags {floor2 wall} + $w create line 307 197 293 197 -fill $color -tags {floor2 wall} + $w create line 278 197 233 197 -fill $color -tags {floor2 wall} + $w create line 233 197 233 249 -fill $color -tags {floor2 wall} + $w create line 307 179 284 179 -fill $color -tags {floor2 wall} + $w create line 233 249 278 249 -fill $color -tags {floor2 wall} + $w create line 269 179 269 133 -fill $color -tags {floor2 wall} + $w create line 220 179 220 133 -fill $color -tags {floor2 wall} + $w create line 155 191 110 191 -fill $color -tags {floor2 wall} + $w create line 90 190 98 190 -fill $color -tags {floor2 wall} + $w create line 98 169 98 190 -fill $color -tags {floor2 wall} + $w create line 52 133 52 165 -fill $color -tags {floor2 wall} + $w create line 52 214 52 177 -fill $color -tags {floor2 wall} + $w create line 52 226 52 262 -fill $color -tags {floor2 wall} + $w create line 52 274 52 276 -fill $color -tags {floor2 wall} + $w create line 234 275 234 339 -fill $color -tags {floor2 wall} + $w create line 226 339 258 339 -fill $color -tags {floor2 wall} + $w create line 211 387 211 339 -fill $color -tags {floor2 wall} + $w create line 214 339 177 339 -fill $color -tags {floor2 wall} + $w create line 258 387 60 387 -fill $color -tags {floor2 wall} + $w create line 3 133 3 339 -fill $color -tags {floor2 wall} + $w create line 165 339 129 339 -fill $color -tags {floor2 wall} + $w create line 117 339 80 339 -fill $color -tags {floor2 wall} + $w create line 68 339 59 339 -fill $color -tags {floor2 wall} + $w create line 0 339 46 339 -fill $color -tags {floor2 wall} + $w create line 60 391 0 391 -fill $color -tags {floor2 wall} + $w create line 0 339 0 391 -fill $color -tags {floor2 wall} + $w create line 60 387 60 391 -fill $color -tags {floor2 wall} + $w create line 258 329 258 387 -fill $color -tags {floor2 wall} + $w create line 350 329 258 329 -fill $color -tags {floor2 wall} + $w create line 395 311 350 311 -fill $color -tags {floor2 wall} + $w create line 398 129 315 129 -fill $color -tags {floor2 wall} + $w create line 176 133 315 133 -fill $color -tags {floor2 wall} + $w create line 176 129 96 129 -fill $color -tags {floor2 wall} + $w create line 3 133 96 133 -fill $color -tags {floor2 wall} + $w create line 66 387 66 339 -fill $color -tags {floor2 wall} + $w create line 115 387 115 339 -fill $color -tags {floor2 wall} + $w create line 163 387 163 339 -fill $color -tags {floor2 wall} + $w create line 234 275 276 275 -fill $color -tags {floor2 wall} + $w create line 288 275 309 275 -fill $color -tags {floor2 wall} + $w create line 298 275 298 329 -fill $color -tags {floor2 wall} + $w create line 341 283 350 283 -fill $color -tags {floor2 wall} + $w create line 321 275 341 275 -fill $color -tags {floor2 wall} + $w create line 375 275 395 275 -fill $color -tags {floor2 wall} + $w create line 315 129 315 170 -fill $color -tags {floor2 wall} + $w create line 376 170 307 170 -fill $color -tags {floor2 wall} + $w create line 307 250 307 170 -fill $color -tags {floor2 wall} + $w create line 376 245 376 170 -fill $color -tags {floor2 wall} + $w create line 340 241 307 241 -fill $color -tags {floor2 wall} + $w create line 340 245 340 224 -fill $color -tags {floor2 wall} + $w create line 340 210 340 201 -fill $color -tags {floor2 wall} + $w create line 340 187 340 170 -fill $color -tags {floor2 wall} + $w create line 340 206 307 206 -fill $color -tags {floor2 wall} + $w create line 293 250 307 250 -fill $color -tags {floor2 wall} + $w create line 271 179 238 179 -fill $color -tags {floor2 wall} + $w create line 226 179 195 179 -fill $color -tags {floor2 wall} + $w create line 176 129 176 179 -fill $color -tags {floor2 wall} + $w create line 182 179 176 179 -fill $color -tags {floor2 wall} + $w create line 174 169 176 169 -fill $color -tags {floor2 wall} + $w create line 162 169 90 169 -fill $color -tags {floor2 wall} + $w create line 96 169 96 129 -fill $color -tags {floor2 wall} + $w create line 175 227 90 227 -fill $color -tags {floor2 wall} + $w create line 90 190 90 227 -fill $color -tags {floor2 wall} + $w create line 52 179 3 179 -fill $color -tags {floor2 wall} + $w create line 52 228 3 228 -fill $color -tags {floor2 wall} + $w create line 52 276 3 276 -fill $color -tags {floor2 wall} + $w create line 155 177 155 169 -fill $color -tags {floor2 wall} + $w create line 110 191 110 169 -fill $color -tags {floor2 wall} + $w create line 155 189 155 197 -fill $color -tags {floor2 wall} + $w create line 350 283 350 329 -fill $color -tags {floor2 wall} + $w create line 162 197 155 197 -fill $color -tags {floor2 wall} + $w create line 341 275 341 283 -fill $color -tags {floor2 wall} +} + +# fg3 -- +# This procedure represents part of the floorplan database. When +# invoked, it instantiates the foreground information for the third +# floor (office outlines and numbers). +# +# Arguments: +# w - The canvas window. +# color - Color to use for drawing foreground information. + +proc fg3 {w color} { + global floorLabels floorItems + set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 316 + set {floorItems(316)} $i + $w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 309 + set {floorItems(309)} $i + $w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 308 + set {floorItems(308)} $i + $w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 307 + set {floorItems(307)} $i + $w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 305 + set {floorItems(305)} $i + $w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 324B + set {floorItems(324B)} $i + $w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 324A + set {floorItems(324A)} $i + $w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 320 + set {floorItems(320)} $i + $w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 310 + set {floorItems(310)} $i + $w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 312 + set {floorItems(312)} $i + $w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 313 + set {floorItems(313)} $i + $w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 314 + set {floorItems(314)} $i + $w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 315 + set {floorItems(315)} $i + $w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 316B + set {floorItems(316B)} $i + $w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 316A + set {floorItems(316A)} $i + $w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 319 + set {floorItems(319)} $i + $w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 311 + set {floorItems(311)} $i + $w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 318 + set {floorItems(318)} $i + $w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 317 + set {floorItems(317)} $i + $w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 323 + set {floorItems(323)} $i + $w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 325 + set {floorItems(325)} $i + $w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 321 + set {floorItems(321)} $i + $w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 322 + set {floorItems(322)} $i + $w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) {Pub Lift3} + set {floorItems(Pub Lift3)} $i + $w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) {Priv Lift3} + set {floorItems(Priv Lift3)} $i + $w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 303 + set {floorItems(303)} $i + $w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 324 + set {floorItems(324)} $i + $w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 304 + set {floorItems(304)} $i + $w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 301 + set {floorItems(301)} $i + $w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 327 + set {floorItems(327)} $i + $w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 326 + set {floorItems(326)} $i + $w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 302 + set {floorItems(302)} $i + $w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label} + set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -outline {} -tags {floor3 room}] + set floorLabels($i) 306 + set {floorItems(306)} $i + $w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label} + $w create line 341 275 341 283 -fill $color -tags {floor3 wall} + $w create line 162 197 155 197 -fill $color -tags {floor3 wall} + $w create line 396 247 399 247 -fill $color -tags {floor3 wall} + $w create line 399 129 399 311 -fill $color -tags {floor3 wall} + $w create line 258 202 243 202 -fill $color -tags {floor3 wall} + $w create line 350 283 350 329 -fill $color -tags {floor3 wall} + $w create line 251 231 243 231 -fill $color -tags {floor3 wall} + $w create line 243 220 251 220 -fill $color -tags {floor3 wall} + $w create line 243 250 243 202 -fill $color -tags {floor3 wall} + $w create line 155 197 155 190 -fill $color -tags {floor3 wall} + $w create line 110 192 110 169 -fill $color -tags {floor3 wall} + $w create line 155 192 110 192 -fill $color -tags {floor3 wall} + $w create line 155 177 155 169 -fill $color -tags {floor3 wall} + $w create line 176 197 176 227 -fill $color -tags {floor3 wall} + $w create line 69 280 69 274 -fill $color -tags {floor3 wall} + $w create line 21 276 69 276 -fill $color -tags {floor3 wall} + $w create line 69 262 69 226 -fill $color -tags {floor3 wall} + $w create line 21 228 69 228 -fill $color -tags {floor3 wall} + $w create line 21 179 75 179 -fill $color -tags {floor3 wall} + $w create line 69 179 69 214 -fill $color -tags {floor3 wall} + $w create line 90 220 90 227 -fill $color -tags {floor3 wall} + $w create line 90 204 90 202 -fill $color -tags {floor3 wall} + $w create line 90 203 100 203 -fill $color -tags {floor3 wall} + $w create line 90 187 90 179 -fill $color -tags {floor3 wall} + $w create line 90 227 176 227 -fill $color -tags {floor3 wall} + $w create line 100 179 100 227 -fill $color -tags {floor3 wall} + $w create line 100 179 87 179 -fill $color -tags {floor3 wall} + $w create line 96 179 96 129 -fill $color -tags {floor3 wall} + $w create line 162 169 96 169 -fill $color -tags {floor3 wall} + $w create line 173 169 176 169 -fill $color -tags {floor3 wall} + $w create line 182 179 176 179 -fill $color -tags {floor3 wall} + $w create line 176 129 176 179 -fill $color -tags {floor3 wall} + $w create line 195 179 226 179 -fill $color -tags {floor3 wall} + $w create line 224 133 224 179 -fill $color -tags {floor3 wall} + $w create line 264 179 264 133 -fill $color -tags {floor3 wall} + $w create line 238 179 264 179 -fill $color -tags {floor3 wall} + $w create line 273 207 273 193 -fill $color -tags {floor3 wall} + $w create line 273 235 273 250 -fill $color -tags {floor3 wall} + $w create line 273 224 273 219 -fill $color -tags {floor3 wall} + $w create line 273 193 307 193 -fill $color -tags {floor3 wall} + $w create line 273 222 307 222 -fill $color -tags {floor3 wall} + $w create line 273 250 307 250 -fill $color -tags {floor3 wall} + $w create line 384 247 376 247 -fill $color -tags {floor3 wall} + $w create line 340 206 307 206 -fill $color -tags {floor3 wall} + $w create line 340 187 340 170 -fill $color -tags {floor3 wall} + $w create line 340 210 340 201 -fill $color -tags {floor3 wall} + $w create line 340 247 340 224 -fill $color -tags {floor3 wall} + $w create line 340 241 307 241 -fill $color -tags {floor3 wall} + $w create line 376 247 376 170 -fill $color -tags {floor3 wall} + $w create line 307 250 307 170 -fill $color -tags {floor3 wall} + $w create line 376 170 307 170 -fill $color -tags {floor3 wall} + $w create line 315 129 315 170 -fill $color -tags {floor3 wall} + $w create line 376 283 366 283 -fill $color -tags {floor3 wall} + $w create line 376 283 376 275 -fill $color -tags {floor3 wall} + $w create line 399 275 376 275 -fill $color -tags {floor3 wall} + $w create line 341 275 320 275 -fill $color -tags {floor3 wall} + $w create line 341 283 350 283 -fill $color -tags {floor3 wall} + $w create line 298 275 298 329 -fill $color -tags {floor3 wall} + $w create line 308 275 298 275 -fill $color -tags {floor3 wall} + $w create line 243 322 243 275 -fill $color -tags {floor3 wall} + $w create line 243 275 284 275 -fill $color -tags {floor3 wall} + $w create line 258 322 226 322 -fill $color -tags {floor3 wall} + $w create line 212 370 212 322 -fill $color -tags {floor3 wall} + $w create line 214 322 177 322 -fill $color -tags {floor3 wall} + $w create line 163 370 163 322 -fill $color -tags {floor3 wall} + $w create line 165 322 129 322 -fill $color -tags {floor3 wall} + $w create line 84 322 117 322 -fill $color -tags {floor3 wall} + $w create line 71 322 64 322 -fill $color -tags {floor3 wall} + $w create line 115 322 115 370 -fill $color -tags {floor3 wall} + $w create line 66 322 66 370 -fill $color -tags {floor3 wall} + $w create line 52 322 21 322 -fill $color -tags {floor3 wall} + $w create line 21 331 0 331 -fill $color -tags {floor3 wall} + $w create line 21 331 21 133 -fill $color -tags {floor3 wall} + $w create line 96 133 21 133 -fill $color -tags {floor3 wall} + $w create line 176 129 96 129 -fill $color -tags {floor3 wall} + $w create line 315 133 176 133 -fill $color -tags {floor3 wall} + $w create line 315 129 399 129 -fill $color -tags {floor3 wall} + $w create line 399 311 350 311 -fill $color -tags {floor3 wall} + $w create line 350 329 258 329 -fill $color -tags {floor3 wall} + $w create line 258 322 258 370 -fill $color -tags {floor3 wall} + $w create line 60 370 258 370 -fill $color -tags {floor3 wall} + $w create line 60 370 60 391 -fill $color -tags {floor3 wall} + $w create line 0 391 0 331 -fill $color -tags {floor3 wall} + $w create line 60 391 0 391 -fill $color -tags {floor3 wall} + $w create line 307 250 307 242 -fill $color -tags {floor3 wall} + $w create line 273 250 307 250 -fill $color -tags {floor3 wall} + $w create line 258 250 243 250 -fill $color -tags {floor3 wall} +} + +# Below is the "main program" that creates the floorplan demonstration. + +set w .floor +global c currentRoom colors activeFloor +catch {destroy $w} +toplevel $w +wm title $w "Floorplan Canvas Demonstration" +wm iconname $w "Floorplan" +wm geometry $w +20+20 +wm minsize $w 100 100 + +label $w.msg -font $font -wraplength 8i -justify left -text "This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +set f [frame $w.frame] +pack $f -side top -fill both -expand yes +set h [ttk::scrollbar $f.hscroll -orient horizontal] +set v [ttk::scrollbar $f.vscroll -orient vertical] +set f1 [frame $f.f1 -borderwidth 2 -relief sunken] +set c [canvas $f1.c -width 900 -height 500 -highlightthickness 0 \ + -xscrollcommand [list $h set] \ + -yscrollcommand [list $v set]] +pack $c -expand yes -fill both +grid $f1 -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news +grid $v -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news +grid $h -padx 1 -pady 1 -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news +grid rowconfig $f 0 -weight 1 -minsize 0 +grid columnconfig $f 0 -weight 1 -minsize 0 +pack $f -expand yes -fill both -padx 1 -pady 1 + +$v configure -command [list $c yview] +$h configure -command [list $c xview] + +# Create an entry for displaying and typing in current room. + +entry $c.entry -width 10 -textvariable currentRoom + +# Choose colors, then fill in the floorplan. + +if {[winfo depth $c] > 1} { + set colors(bg1) #a9c1da + set colors(outline1) #77889a + set colors(bg2) #9ab0c6 + set colors(outline2) #687786 + set colors(bg3) #8ba0b3 + set colors(outline3) #596673 + set colors(offices) Black + set colors(active) #c4d1df +} else { + set colors(bg1) white + set colors(outline1) black + set colors(bg2) white + set colors(outline2) black + set colors(bg3) white + set colors(outline3) black + set colors(offices) Black + set colors(active) black +} +set activeFloor "" +floorDisplay $c 3 + +# Set up event bindings for canvas: + +$c bind floor1 "floorDisplay $c 1" +$c bind floor2 "floorDisplay $c 2" +$c bind floor3 "floorDisplay $c 3" +$c bind room "newRoom $c" +$c bind room {set currentRoom ""} +if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" +} else { + bind $c "$c scan mark %x %y" + bind $c "$c scan dragto %x %y" +} +bind $c "unset currentRoom" +set currentRoom "" +trace add variable currentRoom write "roomChanged $c" diff --git a/evalkit_llava/lib/tk8.6/demos/form.tcl b/evalkit_llava/lib/tk8.6/demos/form.tcl new file mode 100644 index 0000000000000000000000000000000000000000..4d804370a55392deaaf721ffb9205e5e8fc70435 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/form.tcl @@ -0,0 +1,38 @@ +# form.tcl -- +# +# This demonstration script creates a simple form with a bunch +# of entry widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .form +catch {destroy $w} +toplevel $w +wm title $w "Form Demonstration" +wm iconname $w "form" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +foreach i {f1 f2 f3 f4 f5} { + frame $w.$i -bd 2 + entry $w.$i.entry -relief sunken -width 40 + label $w.$i.label + pack $w.$i.entry -side right + pack $w.$i.label -side left +} +$w.f1.label config -text Name: +$w.f2.label config -text Address: +$w.f5.label config -text Phone: +pack $w.msg $w.f1 $w.f2 $w.f3 $w.f4 $w.f5 -side top -fill x +bind $w "destroy $w" +focus $w.f1.entry diff --git a/evalkit_llava/lib/tk8.6/demos/goldberg.tcl b/evalkit_llava/lib/tk8.6/demos/goldberg.tcl new file mode 100644 index 0000000000000000000000000000000000000000..e71b9d23c58f3de6c6d2bb09fd487ec4fe3d8801 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/goldberg.tcl @@ -0,0 +1,1834 @@ +##+################################################################# +# +# TkGoldberg.tcl +# by Keith Vetter, March 13, 2003 +# +# "Man will always find a difficult means to perform a simple task" +# Rube Goldberg +# +# Reproduced here with permission. +# +##+################################################################# +# +# Keith Vetter 2003-03-21: this started out as a simple little program +# but was so much fun that it grew and grew. So I apologize about the +# size but I just couldn't resist sharing it. +# +# This is a whizzlet that does a Rube Goldberg type animation, the +# design of which comes from an New Years e-card from IncrediMail. +# That version had nice sound effects which I eschewed. On the other +# hand, that version was in black and white (actually dark blue and +# light blue) and this one is fully colorized. +# +# One thing I learned from this project is that drawing filled complex +# objects on a canvas is really hard. More often than not I had to +# draw each item twice--once with the desired fill color but no +# outline, and once with no fill but with the outline. Another trick +# is erasing by drawing with the background color. Having a flood fill +# command would have been extremely helpful. +# +# Two wiki pages were extremely helpful: Drawing rounded rectangles +# which I generalized into Drawing rounded polygons, and regular +# polygons which allowed me to convert ovals and arcs into polygons +# which could then be rotated (see Canvas Rotation). I also wrote +# Named Colors to aid in the color selection. +# +# I could comment on the code, but it's just 26 state machines with +# lots of canvas create and move calls. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .goldberg +catch {destroy $w} +toplevel $w +wm title $w "Tk Goldberg (demonstration)" +wm iconname $w "goldberg" +wm resizable $w 0 0 +#positionWindow $w + +label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\ + demonstration of just how complex you can make your animations\ + become. Click the ball to start things moving!\n\n\"Man will always\ + find a difficult means to perform a simple task\"\n - Rube Goldberg" +pack $w.msg -side top + +###--- End of Boilerplate ---### + +# Ensure that this this is an array +array set animationCallbacks {} +bind $w { + if {"%W" eq [winfo toplevel %W]} { + unset S C speed + } +} + +set S(title) "Tk Goldberg" +set S(speed) 5 +set S(cnt) 0 +set S(message) "\\nWelcome\\nto\\nTcl/Tk" +array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500} + +set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5 +set S(mode) $::MSTART + +# Colors for everything +set C(fg) black +set C(bg) cornflowerblue + +set C(0) white; set C(1a) darkgreen; set C(1b) yellow +set C(2) red; set C(3a) green; set C(3b) darkblue +set C(4) $C(fg); set C(5a) brown; set C(5b) white +set C(6) magenta; set C(7) green; set C(8) $C(fg) +set C(9) blue4; set C(10a) white; set C(10b) cyan +set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2 +set C(13a) yellow; set C(13b) red; set C(14) white +set C(15a) green; set C(15b) yellow; set C(16) gray65 +set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50 +set C(20) cyan; set C(21) gray65; set C(22) $C(20) +set C(23a) blue; set C(23b) red; set C(23c) yellow +set C(24a) red; set C(24b) white; +set C(24c) black; set C(26) $C(0); + +proc DoDisplay {w} { + global S C + + ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5 + pack [frame $w.screen -bd 2 -relief raised] \ + -side left -fill both -expand 1 + + canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0 + $w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up + $w.c yview moveto .05 + pack $w.c -in $w.screen -side top -fill both -expand 1 + + bind $w.c [list $w.pause invoke] + bind $w.c { + after cancel $animationCallbacks(goldberg) + unset animationCallbacks(goldberg) + } + DoCtrlFrame $w + DoDetailFrame $w + if {[tk windowingsystem] ne "aqua"} { + ttk::button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2 + } else { + button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg) + } + place $w.show -in $w.c -relx 1 -rely 0 -anchor ne + update +} + +proc DoCtrlFrame {w} { + global S + ttk::button $w.start -text "Start" -command [list DoButton $w 0] + ttk::checkbutton $w.pause -text "Pause" -command [list DoButton $w 1] \ + -variable S(pause) + ttk::button $w.step -text "Single Step" -command [list DoButton $w 2] + ttk::button $w.bstep -text "Big Step" -command [list DoButton $w 4] + ttk::button $w.reset -text "Reset" -command [list DoButton $w 3] + ttk::labelframe $w.details + raise $w.details + set S(details) 0 + ttk::checkbutton $w.details.cb -text "Details" -variable S(details) + ttk::labelframe $w.message -text "Message" + ttk::entry $w.message.e -textvariable S(message) -justify center + ttk::labelframe $w.speed -text "Speed: 0" + ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 -variable S(speed) + ttk::button $w.about -text About -command [list About $w] + + grid $w.start -in $w.ctrl -row 0 -sticky ew + grid rowconfigure $w.ctrl 1 -minsize 10 + grid $w.pause -in $w.ctrl -row 2 -sticky ew + grid $w.step -in $w.ctrl -sticky ew -pady 2 + grid $w.bstep -in $w.ctrl -sticky ew + grid $w.reset -in $w.ctrl -sticky ew -pady 2 + grid rowconfigure $w.ctrl 10 -minsize 18 + grid $w.details -in $w.ctrl -row 11 -sticky ew + grid rowconfigure $w.ctrl 11 -minsize 20 + $w.details configure -labelwidget $w.details.cb + grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug + raise $w.details + raise $w.details.cb + grid rowconfigure $w.ctrl 50 -weight 1 + trace add variable ::S(mode) write [list ActiveGUI $w] + trace add variable ::S(details) write [list ActiveGUI $w] + trace add variable ::S(speed) write [list ActiveGUI $w] + + grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5 + grid $w.message.e -sticky nsew + grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5} + pack $w.speed.scale -fill both -expand 1 + grid $w.about -in $w.ctrl -row 100 -sticky ew + bind $w.reset {set S(mode) -1} ;# Debugging + + ## See Code / Dismiss buttons hack! + set btns [addSeeDismiss $w.ctrl.buttons $w] + grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4 + set i 0 + foreach b [winfo children $btns] { + if {[winfo class $b] eq "TButton"} { + grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew + foreach b3 [$b configure] { + set b3 [lindex $b3 0] + # Some options are read-only; ignore those errors + catch {$b2 configure $b3 [$b cget $b3]} + } + } + } + destroy $btns +} + +proc DoDetailFrame {w} { + set w2 $w.details.f + ttk::frame $w2 + + ttk::label $w2.l -textvariable S(cnt) -background white + grid $w2.l - - - -sticky ew -row 0 + for {set i 1} {1} {incr i} { + if {[info procs "Move$i"] eq ""} break + ttk::label $w2.l$i -text $i -anchor e -width 2 -background white + ttk::label $w2.ll$i -textvariable STEP($i) -width 5 -background white + set row [expr {($i + 1) / 2}] + set col [expr {(($i + 1) & 1) * 2}] + grid $w2.l$i -sticky ew -row $row -column $col + grid $w2.ll$i -sticky ew -row $row -column [incr col] + } + grid columnconfigure $w2 1 -weight 1 +} + +# Map or unmap the ctrl window +proc ShowCtrl {w} { + if {[winfo ismapped $w.ctrl]} { + pack forget $w.ctrl + $w.show config -text "\xbb" + } else { + pack $w.ctrl -side right -fill both -ipady 5 + $w.show config -text "\xab" + } +} + +proc DrawAll {w} { + ResetStep + $w.c delete all + for {set i 0} {1} {incr i} { + set p "Draw$i" + if {[info procs $p] eq ""} break + $p $w + } +} + +proc ActiveGUI {w var1 var2 op} { + global S MGO MSTART MDONE + array set z {0 disabled 1 normal} + + set m $S(mode) + set S(pause) [expr {$m == 2}] + $w.start config -state $z([expr {$m != $MGO}]) + $w.pause config -state $z([expr {$m != $MSTART && $m != $MDONE}]) + $w.step config -state $z([expr {$m != $MGO && $m != $MDONE}]) + $w.bstep config -state $z([expr {$m != $MGO && $m != $MDONE}]) + $w.reset config -state $z([expr {$m != $MSTART}]) + + if {$S(details)} { + grid $w.details.f -sticky ew + } else { + grid forget $w.details.f + } + set S(speed) [expr {round($S(speed))}] + $w.speed config -text "Speed: $S(speed)" +} + +proc Start {} { + global S MGO + set S(mode) $MGO +} + +proc DoButton {w what} { + global S MDONE MGO MSSTEP MBSTEP MPAUSE + + if {$what == 0} { ;# Start + if {$S(mode) == $MDONE} { + Reset $w + } + set S(mode) $MGO + } elseif {$what == 1} { ;# Pause + set S(mode) [expr {$S(pause) ? $MPAUSE : $MGO}] + } elseif {$what == 2} { ;# Step + set S(mode) $MSSTEP + } elseif {$what == 3} { ;# Reset + Reset $w + } elseif {$what == 4} { ;# Big step + set S(mode) $MBSTEP + } +} + +proc Go {w {who {}}} { + global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP + + set now [clock clicks -milliseconds] + catch {after cancel $animationCallbacks(goldberg)} + if {$who ne ""} { ;# Start here for debugging + set S(active) $who + set S(mode) $MGO + } + if {$S(mode) == -1} return ;# Debugging + set n 0 + if {$S(mode) != $MPAUSE} { ;# Not paused + set n [NextStep $w] ;# Do the next move + } + if {$S(mode) == $MSSTEP} { ;# Single step + set S(mode) $MPAUSE + } + if {$S(mode) == $MBSTEP && $n} { ;# Big step + set S(mode) $MSSTEP + } + + set elapsed [expr {[clock click -milliseconds] - $now}] + set delay [expr {$speed($S(speed)) - $elapsed}] + if {$delay <= 0} { + set delay 1 + } + set animationCallbacks(goldberg) [after $delay [list Go $w]] +} + +# NextStep: drives the next step of the animation +proc NextStep {w} { + global S MSTART MDONE + set rval 0 ;# Return value + + if {$S(mode) != $MSTART && $S(mode) != $MDONE} { + incr S(cnt) + } + set alive {} + foreach {who} $S(active) { + set n ["Move$who" $w] + if {$n & 1} { ;# This guy still alive + lappend alive $who + } + if {$n & 2} { ;# Next guy is active + lappend alive [expr {$who + 1}] + set rval 1 + } + if {$n & 4} { ;# End of puzzle flag + set S(mode) $MDONE ;# Done mode + set S(active) {} ;# No more animation + return 1 + } + } + set S(active) $alive + return $rval +} +proc About {w} { + set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\ + permission of the author)\n\n\"Man will always find a difficult\ + means to perform a simple task.\"\nRube Goldberg" + tk_messageBox -parent $w -message $msg -title About +} +################################################################ +# +# All the drawing and moving routines +# + +# START HERE! banner +proc Draw0 {w} { + set color $::C(0) + set xy {579 119} + $w.c create text $xy -text "START HERE!" -fill $color -anchor w \ + -tag I0 -font {{Times Roman} 12 italic bold} + set xy {719 119 763 119} + $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \ + -arrowshape {18 18 5} + $w.c bind I0 Start +} +proc Move0 {w {step {}}} { + set step [GetStep 0 $step] + + if {$::S(mode) > $::MSTART} { ;# Start the ball rolling + MoveAbs $w I0 {-100 -100} ;# Hide the banner + return 2 + } + + set pos { + {673 119} {678 119} {683 119} {688 119} + {693 119} {688 119} {683 119} {678 119} + } + set step [expr {$step % [llength $pos]}] + MoveAbs $w I0 [lindex $pos $step] + return 1 +} + +# Dropping ball +proc Draw1 {w} { + set color $::C(1a) + set color2 $::C(1b) + set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133} + $w.c create poly $xy -width 3 -fill $color -outline {} + set xy {771 133 685 133 685 168 751 168 751 346 771 346 771 133} + $w.c create poly $xy -width 3 -fill $color -outline {} + + set xy [box 812 122 9] + $w.c create oval $xy -tag I1 -fill $color2 -outline {} + $w.c bind I1 Start +} +proc Move1 {w {step {}}} { + set step [GetStep 1 $step] + set pos { + {807 122} {802 122} {797 123} {793 124} {789 129} {785 153} + {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503} + {824 585 y} {838 587} {848 593} {857 601} {-100 -100} + } + if {$step >= [llength $pos]} { + return 0 + } + set where [lindex $pos $step] + MoveAbs $w I1 $where + + if {[lindex $where 2] eq "y"} { + Move15a $w + } + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Lighting the match +proc Draw2 {w} { + set color red + set color $::C(2) + set xy {750 369 740 392 760 392} ;# Fulcrum + $w.c create poly $xy -fill $::C(fg) -outline $::C(fg) + set xy {628 335 660 383} ;# Strike box + $w.c create rect $xy -fill {} -outline $::C(fg) + for {set y 0} {$y < 3} {incr y} { + set yy [expr {335+$y*16}] + $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \ + -foreground $::C(fg) + $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \ + -foreground $::C(fg) + } + + set xy {702 366 798 366} ;# Lever + $w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0 + set xy {712 363 712 355} ;# R strap + $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1 + set xy {705 363 705 355} ;# L strap + $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2 + set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick + $w.c create line $xy -fill $::C(fg) -tag I2_3 + + #set xy {662 352 680 365} ;# Match head + set xy { + 671 352 677.4 353.9 680 358.5 677.4 363.1 671 365 664.6 363.1 + 662 358.5 664.6 353.9 + } + $w.c create poly $xy -fill $color -outline $color -tag I2_4 +} +proc Move2 {w {step {}}} { + set step [GetStep 2 $step] + + set stages {0 0 1 2 0 2 1 0 1 2 0 2 1} + set xy(0) { + 686 333 692 323 682 316 674 309 671 295 668 307 662 318 662 328 + 671 336 + } + set xy(1) {687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335} + set xy(2) { + 686 331 704 322 688 300 678 283 678 283 674 298 666 309 660 324 + 672 336 + } + + if {$step >= [llength $stages]} { + $w.c delete I2 + return 0 + } + + if {$step == 0} { ;# Rotate the match + set beta 20 + lassign [Anchor $w I2_0 s] Ox Oy ;# Where to pivot + for {set i 0} {[$w.c find withtag I2_$i] ne ""} {incr i} { + RotateItem $w I2_$i $Ox $Oy $beta + } + $w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame + return 1 + } + $w.c coords I2 $xy([lindex $stages $step]) + return [expr {$step == 7 ? 3 : 1}] +} + +# Weight and pulleys +proc Draw3 {w} { + set color $::C(3a) + set color2 $::C(3b) + + set xy {602 296 577 174 518 174} + foreach {x y} $xy { ;# 3 Pulleys + $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \ + -width 3 + $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg) + } + + set xy {750 309 670 309} ;# Wall to flame + $w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1 + set xy {670 309 650 309} ;# Flame to pulley 1 + $w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg) + set xy {650 309 600 309} ;# Flame to pulley 1 + $w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg) + set xy {589 296 589 235} ;# Pulley 1 half way to 2 + $w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg) + set xy {589 235 589 174} ;# Pulley 1 other half to 2 + $w.c create line $xy -width 3 -fill $::C(fg) + set xy {577 161 518 161} ;# Across the top + $w.c create line $xy -width 3 -fill $::C(fg) + set xy {505 174 505 205} ;# Down to weight + $w.c create line $xy -tag I3_w -width 3 -fill $::C(fg) + + # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle + set xy {515 207 495 207} + foreach {x1 y1 x2 y2} $xy { + $w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 \ + -outline $color2 + $w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 \ + -outline $color2 + incr y1 -6; incr y2 6 + $w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 \ + -outline $color2 + } + set xy {492 220 518 263} + set xy [RoundRect $w $xy 15] + $w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2 + set xy {500 217 511 217} + $w.c create line $xy -tag I3_ -fill $color2 -width 10 + + set xy {502 393 522 393 522 465} ;# Bottom weight target + $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10 +} +proc Move3 {w {step {}}} { + set step [GetStep 3 $step] + + set pos {{505 247} {505 297} {505 386.5} {505 386.5}} + set rope(0) {750 309 729 301 711 324 690 300} + set rope(1) {750 309 737 292 736 335 717 315 712 320} + set rope(2) {750 309 737 309 740 343 736 351 725 340} + set rope(3) {750 309 738 321 746 345 742 356} + + if {$step >= [llength $pos]} { + return 0 + } + + $w.c delete "I3_$step" ;# Delete part of the rope + MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down + $w.c coords I3_s $rope($step) ;# Flapping rope end + $w.c coords I3_w [concat 505 174 [lindex $pos $step]] + if {$step == 2} { + $w.c move I3__ 0 30 + return 2 + } + return 1 +} + +# Cage and door +proc Draw4 {w} { + set color $::C(4) + lassign {527 356 611 464} x0 y0 x1 y1 + + for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars + $w.c create line $x0 $y $x1 $y -fill $color -width 1 + } + for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars + $w.c create line $x $y0 $x $y1 -fill $color -width 1 + } + + set xy {518 464 518 428} ;# Swing gate + $w.c create line $xy -tag I4 -fill $color -width 3 +} +proc Move4 {w {step {}}} { + set step [GetStep 4 $step] + + set angles {-10 -20 -30 -30} + if {$step >= [llength $angles]} { + return 0 + } + RotateItem $w I4 518 464 [lindex $angles $step] + $w.c raise I4 + return [expr {$step == 3 ? 3 : 1}] +} + +# Mouse +proc Draw5 {w} { + set color $::C(5a) + set color2 $::C(5b) + set xy {377 248 410 248 410 465 518 465} ;# Mouse course + lappend xy 518 428 451 428 451 212 377 212 + $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3 + + set xy { + 534.5 445.5 541 440 552 436 560 436 569 440 574 446 575 452 574 454 + 566 456 554 456 545 456 537 454 530 452 + } + $w.c create poly $xy -tag {I5 I5_0} -fill $color + set xy {573 452 592 458 601 460 613 456} ;# Tail + $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3 + set xy [box 540 446 2] ;# Eye + set xy {540 444 541 445 541 447 540 448 538 447 538 445} + #.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} + $w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1 + set xy {538 454 535 461} ;# Front leg + $w.c create line $xy -tag {I5 I5_3} -fill $color -width 2 + set xy {566 455 569 462} ;# Back leg + $w.c create line $xy -tag {I5 I5_4} -fill $color -width 2 + set xy {544 455 545 460} ;# 2nd front leg + $w.c create line $xy -tag {I5 I5_5} -fill $color -width 2 + set xy {560 455 558 460} ;# 2nd back leg + $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2 +} +proc Move5 {w {step {}}} { + set step [GetStep 5 $step] + + set pos { + {553 452} {533 452} {513 452} {493 452} {473 452} + {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394} + {422 374} {422 354} {422 334} {422 314} {422 294} + {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237} + } + if {$step >= [llength $pos]} { + return 0 + } + + lassign [lindex $pos $step] x y beta next + MoveAbs $w I5 [list $x $y] + if {$beta ne ""} { + lassign [Centroid $w I5_0] Ox Oy + foreach id {0 1 2 3 4 5 6} { + RotateItem $w I5_$id $Ox $Oy $beta + } + } + if {$next eq "x"} { + return 3 + } + return 1 +} + +# Dropping gumballs +array set XY6 { + -1 {366 207} -2 {349 204} -3 {359 193} -4 {375 192} -5 {340 190} + -6 {349 177} -7 {366 177} -8 {380 176} -9 {332 172} -10 {342 161} + -11 {357 164} -12 {372 163} -13 {381 149} -14 {364 151} -15 {349 146} + -16 {333 148} 0 {357 219} + 1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334} + 7 {367 340} 8 {366 346} 9 {364 350} 10 {361 355} 11 {359 370} 12 {359 391} + 13,0 {360 456} 13,1 {376 456} 13,2 {346 456} 13,3 {330 456} + 13,4 {353 444} 13,5 {368 443} 13,6 {339 442} 13,7 {359 431} + 13,8 {380 437} 13,9 {345 428} 13,10 {328 434} 13,11 {373 424} + 13,12 {331 420} 13,13 {360 417} 13,14 {345 412} 13,15 {376 410} + 13,16 {360 403} +} +proc Draw6 {w} { + set color $::C(6) + set xy {324 130 391 204} ;# Ball holder + set xy [RoundRect $w $xy 10] + $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color + set xy {339 204 376 253} ;# Below the ball holder + $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \ + -tag I6c + set xy [box 346 339 28] + $w.c create oval $xy -fill $color -outline {} ;# Rotor + $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ + -start 80 -extent 205 + $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \ + -start -41 -extent 85 + + set xy [box 346 339 15] ;# Center of rotor + $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m + set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor + $w.c create poly $xy -fill $color -outline {} + $w.c create line $xy -fill $::C(fg) -width 2 + + set xy {353 240 367 300} ;# Poke bottom hole + $w.c create rect $xy -fill $color -outline {} + set xy {341 190 375 210} ;# Poke another hole + $w.c create rect $xy -fill $color -outline {} + + set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366} + $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor + $w.c create line $xy -fill $::C(fg) -width 2 + set xy [box 275 342 7] ;# On/off rotor + $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) + set xy {276 334 342 325} ;# Fan belt top + $w.c create line $xy -fill $::C(fg) -width 3 + set xy {276 349 342 353} ;# Fan belt bottom + $w.c create line $xy -fill $::C(fg) -width 3 + + set xy {337 212 337 247} ;# What the mouse pushes + $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ + set xy {392 212 392 247} + $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_ + set xy {337 230 392 230} + $w.c create line $xy -fill $::C(fg) -width 7 -tag I6_ + + set who -1 ;# All the balls + set colors {red cyan orange green blue darkblue} + lappend colors {*}$colors {*}$colors + + for {set i 0} {$i < 17} {incr i} { + set loc [expr {-1 * $i}] + set color [lindex $colors $i] + $w.c create oval [box {*}$::XY6($loc) 5] -fill $color \ + -outline $color -tag I6_b$i + } + Draw6a $w 12 ;# The wheel +} +proc Draw6a {w beta} { + $w.c delete I6_0 + lassign {346 339} Ox Oy + for {set i 0} {$i < 4} {incr i} { + set b [expr {$beta + $i * 45}] + lassign [RotateC 28 0 0 0 $b] x y + set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \ + [expr {$Ox-$x}] [expr {$Oy-$y}]] + $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2 + } +} +proc Move6 {w {step {}}} { + set step [GetStep 6 $step] + if {$step > 62} { + return 0 + } + + if {$step < 2} { ;# Open gate for balls to drop + $w.c move I6_ -7 0 + if {$step == 1} { ;# Poke a hole + set xy {348 226 365 240} + $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {} + } + return 1 + } + + set s [expr {$step - 1}] ;# Do the gumball drop dance + for {set i 0} {$i <= int(($s-1) / 3)} {incr i} { + set tag "I6_b$i" + if {[$w.c find withtag $tag] eq ""} break + set loc [expr {$s - 3 * $i}] + + if {[info exists ::XY6($loc,$i)]} { + MoveAbs $w $tag $::XY6($loc,$i) + } elseif {[info exists ::XY6($loc)]} { + MoveAbs $w $tag $::XY6($loc) + } + } + if {($s % 3) == 1} { + set first [expr {($s + 2) / 3}] + for {set i $first} {1} {incr i} { + set tag "I6_b$i" + if {[$w.c find withtag $tag] eq ""} break + set loc [expr {$first - $i}] + MoveAbs $w $tag $::XY6($loc) + } + } + if {$s >= 3} { ;# Rotate the motor + set idx [expr {$s % 3}] + #Draw6a $w [lindex {12 35 64} $idx] + Draw6a $w [expr {12 + $s * 15}] + } + return [expr {$s == 3 ? 3 : 1}] +} + +# On/off switch +proc Draw7 {w} { + set color $::C(7) + set xy {198 306 277 374} ;# Box + $w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z + $w.c lower I7z + set xy {275 343 230 349} + $w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \ + -arrowshape {23 23 8} -width 6 + set xy {225 324} ;# On button + $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) + set xy {218 323} ;# On text + set font {{Times Roman} 8} + $w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font + set xy {225 350} ;# Off button + $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg) + set xy {218 349} ;# Off button + $w.c create text $xy -text "off" -anchor e -fill $::C(fg) -font $font +} +proc Move7 {w {step {}}} { + set step [GetStep 7 $step] + set numsteps 30 + if {$step > $numsteps} { + return 0 + } + set beta [expr {30.0 / $numsteps}] + RotateItem $w I7 275 343 $beta + + return [expr {$step == $numsteps ? 3 : 1}] +} + +# Electricity to the fan +proc Draw8 {w} { + Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3 +} +proc Move8 {w {step {}}} { + set step [GetStep 8 $step] + + if {$step > 3} { + return 0 + } + if {$step == 0} { + Sparkle $w [Anchor $w I8_s s] I8 + return 1 + + } elseif {$step == 1} { + MoveAbs $w I8 [Anchor $w I8_s c] + } elseif {$step == 2} { + MoveAbs $w I8 [Anchor $w I8_s n] + } else { + $w.c delete I8 + } + return [expr {$step == 2 ? 3 : 1}] +} + +# Fan +proc Draw9 {w} { + set color $::C(9) + set xy {266 194 310 220} + $w.c create oval $xy -outline $color -fill $color + set xy {280 209 296 248} + $w.c create oval $xy -outline $color -fill $color + set xy {288 249 252 249 260 240 280 234 296 234 316 240 324 249 288 249} + $w.c create poly $xy -fill $color -smooth 1 + + set xy {248 205 265 214 264 205 265 196} ;# Spinner + $w.c create poly $xy -fill $color + + set xy {255 206 265 234} ;# Fan blades + $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 + set xy {255 176 265 204} + $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0 + set xy {255 206 265 220} + $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1 + set xy {255 190 265 204} + $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1 +} +proc Move9 {w {step {}}} { + set step [GetStep 9 $step] + + if {$step & 1} { + $w.c itemconfig I9_0 -width 4 + $w.c itemconfig I9_1 -width 1 + $w.c lower I9_1 I9_0 + } else { + $w.c itemconfig I9_0 -width 1 + $w.c itemconfig I9_1 -width 4 + $w.c lower I9_0 I9_1 + } + if {$step == 0} { + return 3 + } + return 1 +} + +# Boat +proc Draw10 {w} { + set color $::C(10a) + set color2 $::C(10b) + set xy {191 230 233 230 233 178 191 178} ;# Sail + $w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10 + set xy [box 209 204 31] ;# Front + $w.c create arc $xy -outline {} -fill $color -style pie \ + -start 120 -extent 120 -tag I10 + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + -start 120 -extent 120 -tag I10 + set xy [box 249 204 31] ;# Back + $w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \ + -start 120 -extent 120 -tag I10 + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + -start 120 -extent 120 -tag I10 + + set xy {200 171 200 249} ;# Mast + $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 + set xy {159 234 182 234} ;# Bow sprit + $w.c create line $xy -fill $::C(fg) -width 3 -tag I10 + set xy {180 234 180 251 220 251} ;# Hull + $w.c create line $xy -fill $::C(fg) -width 6 -tag I10 + + set xy {92 255 221 255} ;# Waves + Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w + + set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water + set xy [concat $xy 222 266 222 277 99 277] + $w.c create poly $xy -fill $color2 -outline $color2 + set xy {222 266 222 277 97 277 97 266} ;# Water bottom + $w.c create line $xy -fill $::C(fg) -width 3 + + set xy [box 239 262 17] + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + -start 95 -extent 103 + set xy [box 76 266 21] + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190 +} +proc Move10 {w {step {}}} { + set step [GetStep 10 $step] + set pos { + {195 212} {193 212} {190 212} {186 212} {181 212} {176 212} + {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212} + {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212} + } + + if {$step >= [llength $pos]} { + return 0 + } + set where [lindex $pos $step] + MoveAbs $w I10 $where + + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# 2nd ball drop +proc Draw11 {w} { + set color $::C(11a) + set color2 $::C(11b) + set xy {23 264 55 591} ;# Color the down tube + $w.c create rect $xy -fill $color -outline {} + set xy [box 71 460 48] ;# Color the outer loop + $w.c create oval $xy -fill $color -outline {} + + set xy {55 264 55 458} ;# Top right side + $w.c create line $xy -fill $::C(fg) -width 3 + set xy {55 504 55 591} ;# Bottom right side + $w.c create line $xy -fill $::C(fg) -width 3 + set xy [box 71 460 48] ;# Outer loop + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + -start 110 -extent -290 -tag I11i + set xy [box 71 460 16] ;# Inner loop + $w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i + $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3 + + set xy {23 264 23 591} ;# Left side + $w.c create line $xy -fill $::C(fg) -width 3 + set xy [box 1 266 23] ;# Top left curve + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90 + + set xy [box 75 235 9] ;# The ball + $w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11 +} +proc Move11 {w {step {}}} { + set step [GetStep 11 $step] + set pos { + {75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296} + {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423} + {-100 -100} {38 505} {38 527 x} {38 591} + } + + if {$step >= [llength $pos]} { + return 0 + } + set where [lindex $pos $step] + MoveAbs $w I11 $where + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Hand +proc Draw12 {w} { + set xy {20 637 20 617 20 610 20 590 40 590 40 590 60 590 60 610 60 610} + lappend xy 60 610 65 620 60 631 ;# Thumb + lappend xy 60 631 60 637 60 662 60 669 52 669 56 669 50 669 50 662 50 637 + + set y0 637 ;# Bumps for fingers + set y1 645 + for {set x 50} {$x > 20} {incr x -10} { + set x1 [expr {$x - 5}] + set x2 [expr {$x - 10}] + lappend xy $x $y0 $x1 $y1 $x2 $y0 + } + $w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \ + -width 3 +} +proc Move12 {w {step {}}} { + set step [GetStep 12 $step] + set pos {{42.5 641 x}} + if {$step >= [llength $pos]} { + return 0 + } + + set where [lindex $pos $step] + MoveAbs $w I12 $where + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Fax +proc Draw13 {w} { + set color $::C(13a) + set xy {86 663 149 663 149 704 50 704 50 681 64 681 86 671} + set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671} + set radii {2 9 9 8 5 5 2} + + RoundPoly $w.c $xy $radii -width 3 -outline $::C(fg) -fill $color + RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color + + set xy {56 677} + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + -tag I13 + set xy {809 677} + $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \ + -tag I13R + + set xy {112 687} ;# Label + $w.c create text $xy -text "FAX" -fill $::C(fg) \ + -font {{Times Roman} 12 bold} + set xy {762 687} + $w.c create text $xy -text "FAX" -fill $::C(fg) \ + -font {{Times Roman} 12 bold} + + set xy {138 663 148 636 178 636} ;# Paper guide + $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 + set xy {732 663 722 636 692 636} + $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3 + + Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3 +} +proc Move13 {w {step {}}} { + set step [GetStep 13 $step] + set numsteps 7 + + if {$step == $numsteps+2} { + MoveAbs $w I13_star {-100 -100} + $w.c itemconfig I13R -fill $::C(13b) -width 2 + return 2 + } + if {$step == 0} { ;# Button down + $w.c delete I13 + Sparkle $w {-100 -100} I13_star ;# Create off screen + return 1 + } + lassign [Anchor $w I13_s w] x0 y0 + lassign [Anchor $w I13_s e] x1 y1 + set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}] + MoveAbs $w I13_star [list $x $y0] + return 1 +} + +# Paper in fax +proc Draw14 {w} { + set color $::C(14) + set xy {102 661 113 632 130 618} ;# Left paper edge + $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0 + set xy {148 629 125 640 124 662} ;# Right paper edge + $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1 + Draw14a $w L + + set xy { + 768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171 + } + $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_0 + $w.c lower I14R_0 + # NB. these numbers are VERY sensitive, you must start with final size + # and shrink down to get the values + set xy { + 745.947897349 662.428358855 745.997829056 662.452239237 746.0 662.5 + } + $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1 + $w.c lower I14R_1 +} +proc Draw14a {w side} { + set color $::C(14) + set xy [$w.c coords I14${side}_0] + set xy2 [$w.c coords I14${side}_1] + lassign $xy x0 y0 x1 y1 x2 y2 + lassign $xy2 x3 y3 x4 y4 x5 y5 + set zz [concat \ + $x0 $y0 $x0 $y0 $xy $x2 $y2 $x2 $y2 \ + $x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5] + $w.c delete I14$side + $w.c create poly $zz -tag I14$side -smooth 1 -fill $color -outline $color \ + -width 3 + $w.c lower I14$side +} +proc Move14 {w {step {}}} { + set step [GetStep 14 $step] + + # Paper going down + set sc [expr {.9 - .05*$step}] + if {$sc < .3} { + $w.c delete I14L + return 0 + } + + lassign [$w.c coords I14L_0] Ox Oy + $w.c scale I14L_0 $Ox $Oy $sc $sc + lassign [lrange [$w.c coords I14L_1] end-1 end] Ox Oy + $w.c scale I14L_1 $Ox $Oy $sc $sc + Draw14a $w L + + # Paper going up + set sc [expr {.35 + .05*$step}] + set sc [expr {1 / $sc}] + + lassign [$w.c coords I14R_0] Ox Oy + $w.c scale I14R_0 $Ox $Oy $sc $sc + lassign [lrange [$w.c coords I14R_1] end-1 end] Ox Oy + $w.c scale I14R_1 $Ox $Oy $sc $sc + Draw14a $w R + + return [expr {$step == 10 ? 3 : 1}] +} + +# Light beam +proc Draw15 {w} { + set color $::C(15a) + set xy {824 599 824 585 820 585 829 585} + $w.c create line $xy -fill $::C(fg) -width 3 -tag I15a + set xy {789 599 836 643} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + set xy {778 610 788 632} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + set xy {766 617 776 625} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + + set xy {633 600 681 640} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 3 + set xy {635 567 657 599} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2 + set xy {765 557 784 583} + $w.c create rect $xy -fill $color -outline $::C(fg) -width 2 + + Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3 +} +proc Move15a {w} { + set color $::C(15b) + $w.c scale I15a 824 599 1 .3 ;# Button down + set xy {765 621 681 621} + $w.c create line $xy -dash "-" -width 3 -fill $color -tag I15 +} +proc Move15 {w {step {}}} { + set step [GetStep 15 $step] + set numsteps 6 + + if {$step == $numsteps+2} { + MoveAbs $w I15_star {-100 -100} + return 2 + } + if {$step == 0} { ;# Break the light beam + Sparkle $w {-100 -100} I15_star + set xy {765 621 745 621} + $w.c coords I15 $xy + return 1 + } + lassign [Anchor $w I15_s w] x0 y0 + lassign [Anchor $w I15_s e] x1 y1 + set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}] + MoveAbs $w I15_star [list $x $y0] + return 1 +} + +# Bell +proc Draw16 {w} { + set color $::C(16) + set xy {722 485 791 556} + $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 + set xy [box 752 515 25] ;# Bell + $w.c create oval $xy -fill $color -outline black -tag I16b -width 2 + set xy [box 752 515 5] ;# Bell button + $w.c create oval $xy -fill black -outline black -tag I16b + + set xy {784 523 764 549} ;# Clapper + $w.c create line $xy -width 3 -tag I16c -fill $::C(fg) + set xy [box 784 523 4] + $w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d +} +proc Move16 {w {step {}}} { + set step [GetStep 16 $step] + + # Note: we never stop + lassign {760 553} Ox Oy + if {$step & 1} { + set beta 12 + $w.c move I16b 3 0 + } else { + set beta -12 + $w.c move I16b -3 0 + } + RotateItem $w I16c $Ox $Oy $beta + RotateItem $w I16d $Ox $Oy $beta + + return [expr {$step == 1 ? 3 : 1}] +} + +# Cat +proc Draw17 {w} { + set color $::C(17) + + set xy {584 556 722 556} + $w.c create line $xy -fill $::C(fg) -width 3 + set xy {584 485 722 485} + $w.c create line $xy -fill $::C(fg) -width 3 + + set xy {664 523 717 549} ;# Body + $w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \ + -style chord -start 128 -extent -260 -tag I17 + + set xy {709 554 690 543} ;# Paw + $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 + set xy {657 544 676 555} + $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17 + + set xy [box 660 535 15] ;# Lower face + $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \ + -start 150 -extent 240 -tag I17_ + $w.c create arc $xy -outline {} -fill $color -width 1 -style chord \ + -start 150 -extent 240 -tag I17_ + set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + $w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c} + set xy {652 542 628 539} ;# Whiskers + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {652 543 632 545} + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {652 546 632 552} + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + + set xy {668 543 687 538} + $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + set xy {668 544 688 546} + $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + set xy {668 547 688 553} + $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w} + + set xy {649 530 654 538 659 530} ;# Left eye + $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 + set xy {671 530 666 538 661 530} ;# Right eye + $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 + set xy {655 543 660 551 665 543} ;# Mouth + $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17 +} +proc Move17 {w {step {}}} { + set step [GetStep 17 $step] + + if {$step == 0} { + $w.c delete I17 ;# Delete most of the cat + set xy {655 543 660 535 665 543} ;# Mouth + $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ + set xy [box 654 530 4] ;# Left eye + $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ + set xy [box 666 530 4] ;# Right eye + $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_ + + $w.c move I17_ 0 -20 ;# Move face up + set xy {652 528 652 554} ;# Front leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {670 528 670 554} ;# 2nd front leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + + set xy { + 675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525 + 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517 + 677 512 + } ;# Body + $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \ + -outline $::C(fg) -width 3 -smooth 1 -tag I17_ + set xy {716 514 716 554} ;# Back leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {694 532 694 554} ;# 2nd back leg + $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_ + set xy {715 514 718 506 719 495 716 488};# Tail + $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_ + + $w.c raise I17w ;# Make whiskers visible + $w.c move I17_ -5 0 ;# Move away from wall a bit + return 2 + } + return 0 +} + +# Sling shot +proc Draw18 {w} { + set color $::C(18) + set xy {721 506 627 506} ;# Sling hold + $w.c create line $xy -width 4 -fill $::C(fg) -tag I18 + + set xy {607 500 628 513} ;# Sling rock + $w.c create oval $xy -fill $color -outline {} -tag I18a + + set xy {526 513 606 507 494 502} ;# Sling band + $w.c create line $xy -fill $::C(fg) -width 4 -tag I18b + set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling + $w.c create line $xy -fill $::C(fg) -width 6 +} +proc Move18 {w {step {}}} { + set step [GetStep 18 $step] + + set pos { + {587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506} + {16 506} {-100 -100} + } + + set b(0) {490 502 719 507 524 512} ;# Band collapsing + set b(1) { + 491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534 + 532 519 529 499 + } + set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500} + set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501} + + if {$step >= [llength $pos]} { + return 0 + } + + if {$step == 0} { + $w.c delete I18 + $w.c itemconfig I18b -smooth 1 + } + if {[info exists b($step)]} { + $w.c coords I18b $b($step) + } + + set where [lindex $pos $step] + MoveAbs $w I18a $where + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Water pipe +proc Draw19 {w} { + set color $::C(19) + set xx {249 181 155 118 86 55 22 0} + foreach {x1 x2} $xx { + $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19 + $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top + $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom + } + $w.c raise I11i + + set xy [box 168 460 16] ;# Bulge by the joint + $w.c create oval $xy -fill $color -outline {} + $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ + -start 21 -extent 136 + $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \ + -start -21 -extent -130 + + set xy {249 447 255 473} ;# First joint 26x6 + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + + set xy [box 257 433 34] ;# Bend up + $w.c create arc $xy -outline {} -fill $color -width 1 \ + -style pie -start 0 -extent -91 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 0 -extent -90 + set xy [box 257 433 20] + $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ + -style pie -start 0 -extent -92 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 0 -extent -90 + set xy [box 257 421 34] ;# Bend left + $w.c create arc $xy -outline {} -fill $color -width 1 \ + -style pie -start 1 -extent 91 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 0 -extent 90 + set xy [box 257 421 20] + $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ + -style pie -start 0 -extent 90 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 0 -extent 90 + set xy [box 243 421 34] ;# Bend down + $w.c create arc $xy -outline {} -fill $color -width 1 \ + -style pie -start 90 -extent 90 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 90 -extent 90 + set xy [box 243 421 20] + $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \ + -style pie -start 90 -extent 90 + $w.c create arc $xy -outline $::C(fg) -width 1 \ + -style arc -start 90 -extent 90 + + set xy {270 427 296 433} ;# 2nd joint bottom + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + set xy {270 421 296 427} ;# 2nd joint top + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + set xy {249 382 255 408} ;# Third joint right + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + set xy {243 382 249 408} ;# Third joint left + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + set xy {203 420 229 426} ;# Last joint + $w.c create rect $xy -fill $color -outline $::C(fg) -width 1 + + set xy [box 168 460 6] ;# Handle joint + $w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a + set xy {168 460 168 512} ;# Handle bar + $w.c create line $xy -fill $::C(fg) -width 5 -tag I19b +} +proc Move19 {w {step {}}} { + set step [GetStep 19 $step] + + set angles {30 30 30} + if {$step == [llength $angles]} { + return 2 + } + + RotateItem $w I19b {*}[Centroid $w I19a] [lindex $angles $step] + return 1 +} + +# Water pouring +proc Draw20 {w} { +} +proc Move20 {w {step {}}} { + set step [GetStep 20 $step] + + set pos {451 462 473 484 496 504 513 523 532} + set freq {20 40 40 40 40 40 40 40 40} + set pos { + {451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40} + {523 40} {532 40 x} + } + if {$step >= [llength $pos]} { + return 0 + } + + $w.c delete I20 + set where [lindex $pos $step] + lassign $where y f + H2O $w $y $f + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} +proc H2O {w y f} { + set color $::C(20) + $w.c delete I20 + + Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \ + -smooth 1 + $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + -tag {I20 I20a} + $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \ + -tag {I20 I20b} + $w.c move I20a 8 0 + $w.c move I20b 16 0 +} + +# Bucket +proc Draw21 {w} { + set color $::C(21) + set xy {217 451 244 490} ;# Right handle + $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a + set xy {201 467 182 490} ;# Left handle + $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a + + set xy {245 490 237 535} ;# Right side + set xy2 {189 535 181 490} ;# Left side + $w.c create poly [concat $xy $xy2] -fill $color -outline {} \ + -tag {I21 I21f} + $w.c create line $xy -fill $::C(fg) -width 2 -tag I21 + $w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21 + + set xy {182 486 244 498} ;# Top + $w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f} + $w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t} + set xy {189 532 237 540} ;# Bottom + $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \ + -tag {I21 I21b} +} +proc Move21 {w {step {}}} { + set step [GetStep 21 $step] + + set numsteps 30 + if {$step >= $numsteps} { + return 0 + } + + lassign [$w.c coords I21b] x1 y1 x2 y2 + #lassign [$w.c coords I21t] X1 Y1 X2 Y2 + lassign {183 492 243 504} X1 Y1 X2 Y2 + + set f [expr {$step / double($numsteps)}] + set y2 [expr {$y2 - 3}] + set xx1 [expr {$x1 + ($X1 - $x1) * $f}] + set yy1 [expr {$y1 + ($Y1 - $y1) * $f}] + set xx2 [expr {$x2 + ($X2 - $x2) * $f}] + set yy2 [expr {$y2 + ($Y2 - $y2) * $f}] + #H2O $w $yy1 40 + + $w.c itemconfig I21b -fill $::C(20) + $w.c delete I21w + $w.c create poly $x2 $y2 $x1 $y1 $xx1 $yy1 $xx2 $yy1 -tag {I21 I21w} \ + -outline {} -fill $::C(20) + $w.c lower I21w I21 + $w.c raise I21b + $w.c lower I21f + + return [expr {$step == $numsteps-1 ? 3 : 1}] +} + +# Bucket drop +proc Draw22 {w} { +} +proc Move22 {w {step {}}} { + set step [GetStep 22 $step] + set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}} + + if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)} + if {$step >= [llength $pos]} { + return 0 + } + set where [lindex $pos $step] + MoveAbs $w I21 $where + H2O $w [lindex $where 1] 40 + $w.c delete I21_a ;# Delete handles + + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Blow dart +proc Draw23 {w} { + set color $::C(23a) + set color2 $::C(23b) + set color3 $::C(23c) + + set xy {185 623 253 650} ;# Block + $w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a + set xy {187 592 241 623} ;# Balloon + $w.c create oval $xy -outline {} -fill $color -tag I23b + $w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \ + -style arc -start 12 -extent 336 + set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle + $w.c create poly $xy -outline {} -fill $color -tag I23b + $w.c create line $xy -fill $::C(fg) -width 3 -tag I23b + + set xy {285 611 250 603} ;# Dart body + $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d + set xy {249 596 249 618 264 607 249 596} ;# Dart tail + $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d + set xy {249 607 268 607} ;# Dart detail + $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d + set xy {285 607 305 607} ;# Dart needle + $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d +} +proc Move23 {w {step {}}} { + set step [GetStep 23 $step] + + set pos { + {277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607} + {587 607} {687 607} {787 607} {-100 -100} + } + + if {$step >= [llength $pos]} { + return 0 + } + if {$step <= 1} { + $w.c scale I23b {*}[Anchor $w I23a n] .9 .5 + } + set where [lindex $pos $step] + MoveAbs $w I23d $where + + if {[lindex $where 2] eq "x"} { + return 3 + } + return 1 +} + +# Balloon +proc Draw24 {w} { + set color $::C(24a) + set xy {366 518 462 665} ;# Balloon + $w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24 + set xy {414 666 414 729} ;# String + $w.c create line $xy -fill $::C(fg) -width 3 -tag I24 + set xy {410 666 404 673 422 673 418 666} ;# Nozzle + $w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24 + + set xy {387 567 390 549 404 542} ;# Reflections + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + set xy {395 568 399 554 413 547} + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + set xy {403 570 396 555 381 553} + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 + set xy {408 564 402 547 386 545} + $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24 +} +proc Move24 {w {step {}}} { + global S + set step [GetStep 24 $step] + + if {$step > 4} { + return 0 + } elseif {$step == 4} { + return 2 + } + + if {$step == 0} { + $w.c delete I24 ;# Exploding balloon + set xy { + 347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626 + 320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702 + 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508 + 431 441 431 440 400 502 347 465 347 465 + } + $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ + -width 10 -smooth 1 + set msg [subst $S(message)] + $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \ + -fill $::C(24c) \ + -justify center -font {{Times Roman} 18 bold} + return 1 + } + + $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold] + $w.c move I24 0 -60 + $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25 + return 1 +} + +# Displaying the message +proc Move25 {w {step {}}} { + global S + set step [GetStep 25 $step] + if {$step == 0} { + set ::XY(25) [clock clicks -milliseconds] + return 1 + } + set elapsed [expr {[clock clicks -milliseconds] - $::XY(25)}] + if {$elapsed < 5000} { + return 1 + } + return 2 +} + +# Collapsing balloon +proc Move26 {w {step {}}} { + global S + set step [GetStep 26 $step] + + if {$step >= 3} { + $w.c delete I24 I26 + $w.c create text 430 755 -anchor s -tag I26 \ + -fill $::C(26) \ + -text "click to continue" -font {{Times Roman} 24 bold} + bind $w.c [list Reset $w] + return 4 + } + + $w.c scale I24 {*}[Centroid $w I24] .8 .8 + $w.c move I24 0 60 + $w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold] + return 1 +} + +################################################################ +# +# Helper functions +# + +proc box {x y r} { + return [list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]] +} + +proc MoveAbs {w item xy} { + lassign $xy x y + lassign [Centroid $w $item] Ox Oy + set dx [expr {$x - $Ox}] + set dy [expr {$y - $Oy}] + $w.c move $item $dx $dy +} + +proc RotateItem {w item Ox Oy beta} { + set xy [$w.c coords $item] + set xy2 {} + foreach {x y} $xy { + lappend xy2 {*}[RotateC $x $y $Ox $Oy $beta] + } + $w.c coords $item $xy2 +} + +proc RotateC {x y Ox Oy beta} { + # rotates vector (Ox,Oy)->(x,y) by beta degrees clockwise + + set x [expr {$x - $Ox}] ;# Shift to origin + set y [expr {$y - $Oy}] + + set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians + set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate + set yy [expr {$x * sin($beta) + $y * cos($beta)}] + + set xx [expr {$xx + $Ox}] ;# Shift back + set yy [expr {$yy + $Oy}] + + return [list $xx $yy] +} + +proc Reset {w} { + global S + DrawAll $w + bind $w.c {} + set S(mode) $::MSTART + set S(active) 0 +} + +# Each Move## keeps its state info in STEP, this retrieves and increments it +proc GetStep {who step} { + global STEP + if {$step ne ""} { + set STEP($who) $step + } elseif {![info exists STEP($who)] || $STEP($who) eq ""} { + set STEP($who) 0 + } else { + incr STEP($who) + } + return $STEP($who) +} + +proc ResetStep {} { + global STEP + set ::S(cnt) 0 + foreach a [array names STEP] { + set STEP($a) "" + } +} + +proc Sine {w x0 y0 x1 y1 amp freq args} { + set PI [expr {4 * atan(1)}] + set step 2 + set xy {} + if {$y0 == $y1} { ;# Horizontal + for {set x $x0} {$x <= $x1} {incr x $step} { + set beta [expr {($x - $x0) * 2 * $PI / $freq}] + set y [expr {$y0 + $amp * sin($beta)}] + lappend xy $x $y + } + } else { + for {set y $y0} {$y <= $y1} {incr y $step} { + set beta [expr {($y - $y0) * 2 * $PI / $freq}] + set x [expr {$x0 + $amp * sin($beta)}] + lappend xy $x $y + } + } + return [$w.c create line $xy {*}$args] +} + +proc RoundRect {w xy radius args} { + lassign $xy x0 y0 x3 y3 + set r [winfo pixels $w.c $radius] + set d [expr {2 * $r}] + + # Make sure that the radius of the curve is less than 3/8 size of the box! + set maxr 0.75 + if {$d > $maxr * ($x3 - $x0)} { + set d [expr {$maxr * ($x3 - $x0)}] + } + if {$d > $maxr * ($y3 - $y0)} { + set d [expr {$maxr * ($y3 - $y0)}] + } + + set x1 [expr { $x0 + $d }] + set x2 [expr { $x3 - $d }] + set y1 [expr { $y0 + $d }] + set y2 [expr { $y3 - $d }] + + set xy [list $x0 $y0 $x1 $y0 $x2 $y0 $x3 $y0 $x3 $y1 $x3 $y2] + lappend xy $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1 + return $xy +} + +proc RoundPoly {canv xy radii args} { + set lenXY [llength $xy] + set lenR [llength $radii] + if {$lenXY != 2*$lenR} { + error "wrong number of vertices and radii" + } + + set knots {} + lassign [lrange $xy end-1 end] x0 y0 + lassign $xy x1 y1 + lappend xy {*}[lrange $xy 0 1] + + for {set i 0} {$i < $lenXY} {incr i 2} { + set radius [lindex $radii [expr {$i/2}]] + set r [winfo pixels $canv $radius] + + lassign [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] x2 y2 + set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r] + lappend knots {*}$z + + lassign [list $x1 $y1] x0 y0 + lassign [list $x2 $y2] x1 y1 + } + set n [$canv create polygon $knots -smooth 1 {*}$args] + return $n +} + +proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} { + set d [expr {2 * $radius}] + set maxr 0.75 + + set v1x [expr {$x0 - $x1}] + set v1y [expr {$y0 - $y1}] + set v2x [expr {$x2 - $x1}] + set v2y [expr {$y2 - $y1}] + + set vlen1 [expr {sqrt($v1x*$v1x + $v1y*$v1y)}] + set vlen2 [expr {sqrt($v2x*$v2x + $v2y*$v2y)}] + if {$d > $maxr * $vlen1} { + set d [expr {$maxr * $vlen1}] + } + if {$d > $maxr * $vlen2} { + set d [expr {$maxr * $vlen2}] + } + + lappend xy [expr {$x1 + $d * $v1x/$vlen1}] [expr {$y1 + $d * $v1y/$vlen1}] + lappend xy $x1 $y1 + lappend xy [expr {$x1 + $d * $v2x/$vlen2}] [expr {$y1 + $d * $v2y/$vlen2}] + + return $xy +} + +proc Sparkle {w Oxy tag} { + set xy {299 283 298 302 295 314 271 331 239 310 242 292 256 274 281 273} + foreach {x y} $xy { + $w.c create line 271 304 $x $y -fill white -width 3 -tag $tag + } + MoveAbs $w $tag $Oxy +} + +proc Centroid {w item} { + return [Anchor $w $item c] +} + +proc Anchor {w item where} { + lassign [$w.c bbox $item] x1 y1 x2 y2 + if {[string match *n* $where]} { + set y $y1 + } elseif {[string match *s* $where]} { + set y $y2 + } else { + set y [expr {($y1 + $y2) / 2.0}] + } + if {[string match *w* $where]} { + set x $x1 + } elseif {[string match *e* $where]} { + set x $x2 + } else { + set x [expr {($x1 + $x2) / 2.0}] + } + return [list $x $y] +} + +DoDisplay $w +Reset $w +Go $w ;# Start everything going diff --git a/evalkit_llava/lib/tk8.6/demos/icon.tcl b/evalkit_llava/lib/tk8.6/demos/icon.tcl new file mode 100644 index 0000000000000000000000000000000000000000..224d8f95a30a3dd1c5e3edd997fe140307948651 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/icon.tcl @@ -0,0 +1,51 @@ +# icon.tcl -- +# +# This demonstration script creates a toplevel window containing +# buttons that display bitmaps instead of text. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .icon +catch {destroy $w} +toplevel $w +wm title $w "Iconic Button Demonstration" +wm iconname $w "icon" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +# Main widget program sets variable tk_demoDirectory +image create bitmap flagup \ + -file [file join $tk_demoDirectory images flagup.xbm] \ + -maskfile [file join $tk_demoDirectory images flagup.xbm] +image create bitmap flagdown \ + -file [file join $tk_demoDirectory images flagdown.xbm] \ + -maskfile [file join $tk_demoDirectory images flagdown.xbm] +frame $w.frame -borderwidth 10 +pack $w.frame -side top + +checkbutton $w.frame.b1 -image flagdown -selectimage flagup \ + -indicatoron 0 +$w.frame.b1 configure -selectcolor [$w.frame.b1 cget -background] +checkbutton $w.frame.b2 \ + -bitmap @[file join $tk_demoDirectory images letters.xbm] \ + -indicatoron 0 -selectcolor SeaGreen1 +frame $w.frame.left +pack $w.frame.left $w.frame.b1 $w.frame.b2 -side left -expand yes -padx 5m + +radiobutton $w.frame.left.b3 \ + -bitmap @[file join $tk_demoDirectory images letters.xbm] \ + -variable letters -value full +radiobutton $w.frame.left.b4 \ + -bitmap @[file join $tk_demoDirectory images noletter.xbm] \ + -variable letters -value empty +pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes diff --git a/evalkit_llava/lib/tk8.6/demos/image1.tcl b/evalkit_llava/lib/tk8.6/demos/image1.tcl new file mode 100644 index 0000000000000000000000000000000000000000..0bd2f490be61c98f06f4d5446f14b0a913aebdb6 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/image1.tcl @@ -0,0 +1,35 @@ +# image1.tcl -- +# +# This demonstration script displays two image widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .image1 +catch {destroy $w} +toplevel $w +wm title $w "Image Demonstration #1" +wm iconname $w "Image1" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration displays two images, each in a separate label widget." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +# Main widget program sets variable tk_demoDirectory +catch {image delete image1a} +image create photo image1a -file [file join $tk_demoDirectory images earth.gif] +label $w.l1 -image image1a -bd 1 -relief sunken + +catch {image delete image1b} +image create photo image1b \ + -file [file join $tk_demoDirectory images earthris.gif] +label $w.l2 -image image1b -bd 1 -relief sunken + +pack $w.l1 $w.l2 -side top -padx .5m -pady .5m diff --git a/evalkit_llava/lib/tk8.6/demos/knightstour.tcl b/evalkit_llava/lib/tk8.6/demos/knightstour.tcl new file mode 100644 index 0000000000000000000000000000000000000000..11b3b5cffd2020f178c885510d445cb3b197ba08 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/knightstour.tcl @@ -0,0 +1,268 @@ +# Copyright (C) 2008 Pat Thoyts +# +# Calculate a Knight's tour of a chessboard. +# +# This uses Warnsdorff's rule to calculate the next square each +# time. This specifies that the next square should be the one that +# has the least number of available moves. +# +# Using this rule it is possible to get to a position where +# there are no squares available to move into. In this implementation +# this occurs when the starting square is d6. +# +# To solve this fault an enhancement to the rule is that if we +# have a choice of squares with an equal score, we should choose +# the one nearest the edge of the board. +# +# If the call to the Edgemost function is commented out you can see +# this occur. +# +# You can drag the knight to a specific square to start if you wish. +# If you let it repeat then it will choose random start positions +# for each new tour. + +package require Tk + +# Return a list of accessible squares from a given square +proc ValidMoves {square} { + set moves {} + foreach pair {{-1 -2} {-2 -1} {-2 1} {-1 2} {1 2} {2 1} {2 -1} {1 -2}} { + set col [expr {($square % 8) + [lindex $pair 0]}] + set row [expr {($square / 8) + [lindex $pair 1]}] + if {$row >= 0 && $row < 8 && $col >= 0 && $col < 8} { + lappend moves [expr {$row * 8 + $col}] + } + } + return $moves +} + +# Return the number of available moves for this square +proc CheckSquare {square} { + variable visited + set moves 0 + foreach test [ValidMoves $square] { + if {[lsearch -exact -integer $visited $test] < 0} { + incr moves + } + } + return $moves +} + +# Select the next square to move to. Returns -1 if there are no available +# squares remaining that we can move to. +proc Next {square} { + variable visited + set minimum 9 + set nextSquare -1 + foreach testSquare [ValidMoves $square] { + if {[lsearch -exact -integer $visited $testSquare] < 0} { + set count [CheckSquare $testSquare] + if {$count < $minimum} { + set minimum $count + set nextSquare $testSquare + } elseif {$count == $minimum} { + # to remove the enhancement to Warnsdorff's rule + # remove the next line: + set nextSquare [Edgemost $nextSquare $testSquare] + } + } + } + return $nextSquare +} + +# Select the square nearest the edge of the board +proc Edgemost {a b} { + set colA [expr {3-int(abs(3.5-($a%8)))}] + set colB [expr {3-int(abs(3.5-($b%8)))}] + set rowA [expr {3-int(abs(3.5-($a/8)))}] + set rowB [expr {3-int(abs(3.5-($b/8)))}] + return [expr {($colA * $rowA) < ($colB * $rowB) ? $a : $b}] +} + +# Display a square number as a standard chess square notation. +proc N {square} { + return [format %c%d [expr {97 + $square % 8}] \ + [expr {$square / 8 + 1}]] +} + +# Perform a Knight's move and schedule the next move. +proc MovePiece {dlg last square} { + variable visited + variable delay + variable continuous + $dlg.f.txt insert end "[llength $visited]. [N $last] .. [N $square]\n" {} + $dlg.f.txt see end + $dlg.f.c itemconfigure [expr {1+$last}] -state normal -outline black + $dlg.f.c itemconfigure [expr {1+$square}] -state normal -outline red + $dlg.f.c moveto knight {*}[lrange [$dlg.f.c coords [expr {1+$square}]] 0 1] + lappend visited $square + set next [Next $square] + if {$next ne -1} { + variable aid [after $delay [list MovePiece $dlg $square $next]] + } else { + $dlg.tf.b1 configure -state normal + if {[llength $visited] == 64} { + variable initial + if {$initial == $square} { + $dlg.f.txt insert end "Closed tour!" + } else { + $dlg.f.txt insert end "Success\n" {} + if {$continuous} { + after [expr {$delay * 2}] [namespace code \ + [list Tour $dlg [expr {int(rand() * 64)}]]] + } + } + } else { + $dlg.f.txt insert end "FAILED!\n" {} + } + } +} + +# Begin a new tour of the board given a random start position +proc Tour {dlg {square {}}} { + variable visited {} + $dlg.f.txt delete 1.0 end + $dlg.tf.b1 configure -state disabled + for {set n 0} {$n < 64} {incr n} { + $dlg.f.c itemconfigure $n -state disabled -outline black + } + if {$square eq {}} { + set coords [lrange [$dlg.f.c coords knight] 0 1] + set square [expr {[$dlg.f.c find closest {*}$coords 0 65]-1}] + } + variable initial $square + after idle [list MovePiece $dlg $initial $initial] +} + +proc Stop {} { + variable aid + catch {after cancel $aid} +} + +proc Exit {dlg} { + Stop + destroy $dlg +} + +proc SetDelay {new} { + variable delay [expr {int($new)}] +} + +proc DragStart {w x y} { + $w dtag selected + $w addtag selected withtag current + variable dragging [list $x $y] +} +proc DragMotion {w x y} { + variable dragging + if {[info exists dragging]} { + $w move selected [expr {$x - [lindex $dragging 0]}] \ + [expr {$y - [lindex $dragging 1]}] + variable dragging [list $x $y] + } +} +proc DragEnd {w x y} { + set square [$w find closest $x $y 0 65] + $w moveto selected {*}[lrange [$w coords $square] 0 1] + $w dtag selected + variable dragging ; unset dragging +} + +proc CreateGUI {} { + catch {destroy .knightstour} + set dlg [toplevel .knightstour] + wm title $dlg "Knights tour" + wm withdraw $dlg + set f [ttk::frame $dlg.f] + set c [canvas $f.c -width 240 -height 240] + text $f.txt -width 10 -height 1 \ + -yscrollcommand [list $f.vs set] -font {Arial 8} + ttk::scrollbar $f.vs -command [list $f.txt yview] + + variable delay 600 + variable continuous 0 + ttk::frame $dlg.tf + ttk::label $dlg.tf.ls -text Speed + ttk::scale $dlg.tf.sc -from 8 -to 2000 -command [list SetDelay] \ + -variable [namespace which -variable delay] + ttk::checkbutton $dlg.tf.cc -text Repeat \ + -variable [namespace which -variable continuous] + ttk::button $dlg.tf.b1 -text Start -command [list Tour $dlg] + ttk::button $dlg.tf.b2 -text Exit -command [list Exit $dlg] + set square 0 + for {set row 7} {$row >= 0} {incr row -1} { + for {set col 0} {$col < 8} {incr col} { + if {(($col & 1) ^ ($row & 1))} { + set fill tan3 ; set dfill tan4 + } else { + set fill bisque ; set dfill bisque3 + } + set coords [list [expr {$col * 30 + 4}] [expr {$row * 30 + 4}] \ + [expr {$col * 30 + 30}] [expr {$row * 30 + 30}]] + $c create rectangle $coords -fill $fill -disabledfill $dfill \ + -width 2 -state disabled -outline black + } + } + if {[tk windowingsystem] ne "x11"} { + catch {eval font create KnightFont -size -24} + $c create text 0 0 -font KnightFont -text "\u265e" \ + -anchor nw -tags knight -fill black -activefill "#600000" + } else { + # On X11 we cannot reliably tell if the \u265e glyph is available + # so just use a polygon + set pts { + 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16 + 2 17 4 14 5 15 3 17 5 17 9 14 10 15 5 21 + } + $c create polygon $pts -tag knight -offset 8 \ + -fill black -activefill "#600000" + } + $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1] + $c bind knight [namespace code [list DragStart %W %x %y]] + $c bind knight [namespace code [list DragMotion %W %x %y]] + $c bind knight [namespace code [list DragEnd %W %x %y]] + + grid $c $f.txt $f.vs -sticky news + grid rowconfigure $f 0 -weight 1 + grid columnconfigure $f 1 -weight 1 + + grid $f - - - - - -sticky news + set things [list $dlg.tf.ls $dlg.tf.sc $dlg.tf.cc $dlg.tf.b1] + if {![info exists ::widgetDemo]} { + lappend things $dlg.tf.b2 + if {[tk windowingsystem] ne "aqua"} { + set things [linsert $things 0 [ttk::sizegrip $dlg.tf.sg]] + } + } + pack {*}$things -side right + if {[tk windowingsystem] eq "aqua"} { + pack configure {*}$things -padx {4 4} -pady {12 12} + pack configure [lindex $things 0] -padx {4 24} + pack configure [lindex $things end] -padx {16 4} + } + grid $dlg.tf - - - - - -sticky ew + if {[info exists ::widgetDemo]} { + grid [addSeeDismiss $dlg.buttons $dlg] - - - - - -sticky ew + } + + grid rowconfigure $dlg 0 -weight 1 + grid columnconfigure $dlg 0 -weight 1 + + bind $dlg {console show} + bind $dlg [list $dlg.tf.b1 invoke] + bind $dlg [list $dlg.tf.b2 invoke] + bind $dlg [namespace code [list Stop]] + wm protocol $dlg WM_DELETE_WINDOW [namespace code [list Exit $dlg]] + + wm deiconify $dlg + tkwait window $dlg +} + +if {![winfo exists .knightstour]} { + if {![info exists widgetDemo]} { wm withdraw . } + set r [catch [linsert $argv 0 CreateGUI] err] + if {$r} { + tk_messageBox -icon error -title "Error" -message $err + } + if {![info exists widgetDemo]} { exit $r } +} diff --git a/evalkit_llava/lib/tk8.6/demos/license.terms b/evalkit_llava/lib/tk8.6/demos/license.terms new file mode 100644 index 0000000000000000000000000000000000000000..01264352c87ca7e34771bd1ee18bed5201ef139f --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/license.terms @@ -0,0 +1,40 @@ +This software is copyrighted by the Regents of the University of +California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState +Corporation, Apple Inc. and other parties. The following terms apply to +all files associated with the software unless explicitly disclaimed in +individual files. + +The authors hereby grant permission to use, copy, modify, distribute, +and license this software and its documentation for any purpose, provided +that existing copyright notices are retained in all copies and that this +notice is included verbatim in any distributions. No written agreement, +license, or royalty fee is required for any of the authorized uses. +Modifications to this software may be copyrighted by their authors +and need not follow the licensing terms described here, provided that +the new terms are clearly indicated on the first page of each file where +they apply. + +IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY +FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY +DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE +IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE +NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR +MODIFICATIONS. + +GOVERNMENT USE: If you are acquiring this software on behalf of the +U.S. government, the Government shall have only "Restricted Rights" +in the software and related documentation as defined in the Federal +Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you +are acquiring the software on behalf of the Department of Defense, the +software shall be classified as "Commercial Computer Software" and the +Government shall have only "Restricted Rights" as defined in Clause +252.227-7013 (b) (3) of DFARs. Notwithstanding the foregoing, the +authors grant the U.S. Government and others acting in its behalf +permission to use and distribute the software in accordance with the +terms specified in this license. diff --git a/evalkit_llava/lib/tk8.6/demos/menu.tcl b/evalkit_llava/lib/tk8.6/demos/menu.tcl new file mode 100644 index 0000000000000000000000000000000000000000..4f5d703fbb266eefa5009ac394cdb803f9672dcb --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/menu.tcl @@ -0,0 +1,177 @@ +# menu.tcl -- +# +# This demonstration script creates a window with a bunch of menus +# and cascaded menus using menubars. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .menu +catch {destroy $w} +toplevel $w +wm title $w "Menu Demonstration" +wm iconname $w "menu" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left +if {[tk windowingsystem] eq "aqua"} { + $w.msg configure -text "This window has a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by selecting the first item in the menu." +} else { + $w.msg configure -text "This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu." +} +pack $w.msg -side top + +set menustatus " " +frame $w.statusBar +label $w.statusBar.label -textvariable menustatus -relief sunken -bd 1 -font "Helvetica 10" -anchor w +pack $w.statusBar.label -side left -padx 2 -expand yes -fill both +pack $w.statusBar -side bottom -fill x -pady 2 + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +menu $w.menu -tearoff 0 + +set m $w.menu.file +menu $m -tearoff 0 +$w.menu add cascade -label "File" -menu $m -underline 0 +$m add command -label "Open..." -command {error "this is just a demo: no action has been defined for the \"Open...\" entry"} +$m add command -label "New" -command {error "this is just a demo: no action has been defined for the \"New\" entry"} +$m add command -label "Save" -command {error "this is just a demo: no action has been defined for the \"Save\" entry"} +$m add command -label "Save As..." -command {error "this is just a demo: no action has been defined for the \"Save As...\" entry"} +$m add separator +$m add command -label "Print Setup..." -command {error "this is just a demo: no action has been defined for the \"Print Setup...\" entry"} +$m add command -label "Print..." -command {error "this is just a demo: no action has been defined for the \"Print...\" entry"} +$m add separator +$m add command -label "Dismiss Menus Demo" -command "destroy $w" + +set m $w.menu.basic +$w.menu add cascade -label "Basic" -menu $m -underline 0 +menu $m -tearoff 0 +$m add command -label "Long entry that does nothing" +if {[tk windowingsystem] eq "aqua"} { + set modifier Command +} elseif {[tk windowingsystem] eq "win32"} { + set modifier Control +} else { + set modifier Meta +} +foreach i {A B C D E F} { + $m add command -label "Print letter \"$i\"" -underline 14 \ + -accelerator $modifier+$i -command "puts $i" + bind $w <$modifier-[string tolower $i]> "puts $i" +} + +set m $w.menu.cascade +$w.menu add cascade -label "Cascades" -menu $m -underline 0 +menu $m -tearoff 0 +$m add command -label "Print hello" \ + -command {puts stdout "Hello"} -accelerator $modifier+H -underline 6 +bind $w <$modifier-h> {puts stdout "Hello"} +$m add command -label "Print goodbye" -command {\ + puts stdout "Goodbye"} -accelerator $modifier+G -underline 6 +bind $w <$modifier-g> {puts stdout "Goodbye"} +$m add cascade -label "Check buttons" \ + -menu $w.menu.cascade.check -underline 0 +$m add cascade -label "Radio buttons" \ + -menu $w.menu.cascade.radio -underline 0 + +set m $w.menu.cascade.check +menu $m -tearoff 0 +$m add check -label "Oil checked" -variable oil +$m add check -label "Transmission checked" -variable trans +$m add check -label "Brakes checked" -variable brakes +$m add check -label "Lights checked" -variable lights +$m add separator +$m add command -label "Show current values" \ + -command "showVars $w.menu.cascade.dialog oil trans brakes lights" +$m invoke 1 +$m invoke 3 + +set m $w.menu.cascade.radio +menu $m -tearoff 0 +$m add radio -label "10 point" -variable pointSize -value 10 +$m add radio -label "14 point" -variable pointSize -value 14 +$m add radio -label "18 point" -variable pointSize -value 18 +$m add radio -label "24 point" -variable pointSize -value 24 +$m add radio -label "32 point" -variable pointSize -value 32 +$m add sep +$m add radio -label "Roman" -variable style -value roman +$m add radio -label "Bold" -variable style -value bold +$m add radio -label "Italic" -variable style -value italic +$m add sep +$m add command -label "Show current values" \ + -command "showVars $w.menu.cascade.dialog pointSize style" +$m invoke 1 +$m invoke 7 + +set m $w.menu.icon +$w.menu add cascade -label "Icons" -menu $m -underline 0 +menu $m -tearoff 0 +# Main widget program sets variable tk_demoDirectory +image create photo lilearth -file [file join $tk_demoDirectory \ +images earthmenu.png] +$m add command -image lilearth \ + -hidemargin 1 -command [list \ + tk_dialog $w.pattern {Bitmap Menu Entry} \ + "The menu entry you invoked displays a photoimage rather than\ + a text string. Other than this, it is just like any other\ + menu entry." {} 0 OK ] +foreach i {info questhead error} { + $m add command -bitmap $i -hidemargin 1 -command [list \ + puts "You invoked the $i bitmap" ] +} +$m entryconfigure 2 -columnbreak 1 + +set m $w.menu.more +$w.menu add cascade -label "More" -menu $m -underline 0 +menu $m -tearoff 0 +foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Make life meaningful}} { + $m add command -label $i -command [list puts "You invoked \"$i\""] +} +set emojiLabel [encoding convertfrom utf-8 "\xF0\x9F\x98\x8D Make friends"] +$m add command -label $emojiLabel -command [list puts "Menu labels can include non-BMP characters."] +$m entryconfigure "Does almost nothing" -bitmap questhead -compound left \ + -command [list \ + tk_dialog $w.compound {Compound Menu Entry} \ + "The menu entry you invoked displays both a bitmap and a\ + text string. Other than this, it is just like any other\ + menu entry." {} 0 OK ] + +set m $w.menu.colors +$w.menu add cascade -label "Colors" -menu $m -underline 1 +menu $m -tearoff 1 +if {[tk windowingsystem] eq "aqua"} { + # Aqua ignores the -background and -foreground options, but a compound + # button can be used for selecting colors. + foreach i {red orange yellow green blue} { + image create photo image_$i -height 16 -width 16 + image_$i put black -to 0 0 16 1 + image_$i put black -to 0 1 1 16 + image_$i put black -to 0 15 16 16 + image_$i put black -to 15 1 16 16 + image_$i put $i -to 1 1 15 15 + $m add command -label $i -image image_$i -compound left -command [list \ + puts "You invoked \"$i\"" ] + } +} else { + foreach i {red orange yellow green blue} { + $m add command -label $i -background $i -command [list \ + puts "You invoked \"$i\"" ] + } +} + +$w configure -menu $w.menu + +bind Menu <> { + global $menustatus + if {[catch {%W entrycget active -label} label]} { + set label " " + } + set menustatus $label + update idletasks +} diff --git a/evalkit_llava/lib/tk8.6/demos/menubu.tcl b/evalkit_llava/lib/tk8.6/demos/menubu.tcl new file mode 100644 index 0000000000000000000000000000000000000000..453b05c421c7ff7f026b84934b9fba9090b36c18 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/menubu.tcl @@ -0,0 +1,87 @@ +# menubu.tcl -- +# +# This demonstration script creates a window with a bunch of menus +# and cascaded menus using menubuttons. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .menubu +catch {destroy $w} +toplevel $w +wm title $w "Menu Button Demonstration" +wm iconname $w "menubutton" +positionWindow $w + +frame $w.body +pack $w.body -expand 1 -fill both + +menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised +menu $w.body.below.m -tearoff 0 +$w.body.below.m add command -label "Below menu: first item" -command "puts \"You have selected the first item from the Below menu.\"" +$w.body.below.m add command -label "Below menu: second item" -command "puts \"You have selected the second item from the Below menu.\"" +grid $w.body.below -row 0 -column 1 -sticky n +menubutton $w.body.right -text "Right" -underline 0 -direction right -menu $w.body.right.m -relief raised +menu $w.body.right.m -tearoff 0 +$w.body.right.m add command -label "Right menu: first item" -command "puts \"You have selected the first item from the Right menu.\"" +$w.body.right.m add command -label "Right menu: second item" -command "puts \"You have selected the second item from the Right menu.\"" +frame $w.body.center +menubutton $w.body.left -text "Left" -underline 0 -direction left -menu $w.body.left.m -relief raised +menu $w.body.left.m -tearoff 0 +$w.body.left.m add command -label "Left menu: first item" -command "puts \"You have selected the first item from the Left menu.\"" +$w.body.left.m add command -label "Left menu: second item" -command "puts \"You have selected the second item from the Left menu.\"" +grid $w.body.right -row 1 -column 0 -sticky w +grid $w.body.center -row 1 -column 1 -sticky news +grid $w.body.left -row 1 -column 2 -sticky e +menubutton $w.body.above -text "Above" -underline 0 -direction above -menu $w.body.above.m -relief raised +menu $w.body.above.m -tearoff 0 +$w.body.above.m add command -label "Above menu: first item" -command "puts \"You have selected the first item from the Above menu.\"" +$w.body.above.m add command -label "Above menu: second item" -command "puts \"You have selected the second item from the Above menu.\"" +grid $w.body.above -row 2 -column 1 -sticky s + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +set body $w.body.center +label $body.label -wraplength 300 -font "Helvetica 14" -justify left -text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette." +pack $body.label -side top -padx 25 -pady 25 +frame $body.buttons +pack $body.buttons -padx 25 -pady 25 +tk_optionMenu $body.buttons.options menubuttonoptions one two three +pack $body.buttons.options -side left -padx 25 -pady 25 +set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet] +if {[tk windowingsystem] eq "aqua"} { + set topBorderColor Black + set bottomBorderColor Black +} else { + set topBorderColor gray50 + set bottomBorderColor gray75 +} +for {set i 0} {$i <= [$m index last]} {incr i} { + set name [$m entrycget $i -label] + image create photo image_$name -height 16 -width 16 + image_$name put $topBorderColor -to 0 0 16 1 + image_$name put $topBorderColor -to 0 1 1 16 + image_$name put $bottomBorderColor -to 0 15 16 16 + image_$name put $bottomBorderColor -to 15 1 16 16 + image_$name put $name -to 1 1 15 15 + + image create photo image_${name}_s -height 16 -width 16 + image_${name}_s put Black -to 0 0 16 2 + image_${name}_s put Black -to 0 2 2 16 + image_${name}_s put Black -to 2 14 16 16 + image_${name}_s put Black -to 14 2 16 14 + image_${name}_s put $name -to 2 2 14 14 + + $m entryconfigure $i -image image_$name -selectimage image_${name}_s -hidemargin 1 +} +$m configure -tearoff 1 +foreach i {Black gray75 gray50 White} { + $m entryconfigure $i -columnbreak 1 +} + +pack $body.buttons.colors -side left -padx 25 -pady 25 diff --git a/evalkit_llava/lib/tk8.6/demos/paned1.tcl b/evalkit_llava/lib/tk8.6/demos/paned1.tcl new file mode 100644 index 0000000000000000000000000000000000000000..6b21d3519766333dd61424319689d2a4cb43cb53 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/paned1.tcl @@ -0,0 +1,32 @@ +# paned1.tcl -- +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows horizontally. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .paned1 +catch {destroy $w} +toplevel $w +wm title $w "Horizontal Paned Window Demonstration" +wm iconname $w "paned1" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)" +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +panedwindow $w.pane +pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m + +label $w.pane.left -text "This is the\nleft side" -fg black -bg yellow +label $w.pane.right -text "This is the\nright side" -fg black -bg cyan + +$w.pane add $w.pane.left $w.pane.right diff --git a/evalkit_llava/lib/tk8.6/demos/paned2.tcl b/evalkit_llava/lib/tk8.6/demos/paned2.tcl new file mode 100644 index 0000000000000000000000000000000000000000..c5492493e3e7575b68d78542af6cd353dd84c406 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/paned2.tcl @@ -0,0 +1,74 @@ +# paned2.tcl -- +# +# This demonstration script creates a toplevel window containing +# a paned window that separates two windows vertically. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .paned2 +catch {destroy $w} +toplevel $w +wm title $w "Vertical Paned Window Demonstration" +wm iconname $w "paned2" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)" +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +# Create the pane itself +panedwindow $w.pane -orient vertical +pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m + +# The top window is a listbox with scrollbar +set paneList { + {List of Tk Widgets} + button + canvas + checkbutton + entry + frame + label + labelframe + listbox + menu + menubutton + message + panedwindow + radiobutton + scale + scrollbar + spinbox + text + toplevel +} +set f [frame $w.pane.top] +listbox $f.list -listvariable paneList -yscrollcommand "$f.scr set" +# Invert the first item to highlight it +$f.list itemconfigure 0 \ + -background [$f.list cget -fg] -foreground [$f.list cget -bg] +ttk::scrollbar $f.scr -orient vertical -command "$f.list yview" +pack $f.scr -side right -fill y +pack $f.list -fill both -expand 1 + +# The bottom window is a text widget with scrollbar +set f [frame $w.pane.bottom] +text $f.text -xscrollcommand "$f.xscr set" -yscrollcommand "$f.yscr set" \ + -width 30 -height 8 -wrap none +ttk::scrollbar $f.xscr -orient horizontal -command "$f.text xview" +ttk::scrollbar $f.yscr -orient vertical -command "$f.text yview" +grid $f.text $f.yscr -sticky nsew +grid $f.xscr -sticky nsew +grid columnconfigure $f 0 -weight 1 +grid rowconfigure $f 0 -weight 1 +$f.text insert 1.0 "This is just a normal text widget" + +# Now add our contents to the paned window +$w.pane add $w.pane.top $w.pane.bottom diff --git a/evalkit_llava/lib/tk8.6/demos/radio.tcl b/evalkit_llava/lib/tk8.6/demos/radio.tcl new file mode 100644 index 0000000000000000000000000000000000000000..5c737033e62ace2815254f926fd3ec8ff63041c1 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/radio.tcl @@ -0,0 +1,66 @@ +# radio.tcl -- +# +# This demonstration script creates a toplevel window containing +# several radiobutton widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .radio +catch {destroy $w} +toplevel $w +wm title $w "Radiobutton Demonstration" +wm iconname $w "radio" +positionWindow $w +label $w.msg -font $font -wraplength 5i -justify left -text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. When the 'Tristate' button is pressed, the radio buttons will display the tri-state mode. Selecting any radio button will return the buttons to their respective on/off state. Click the \"See Variables\" button to see the current values of the variables." +grid $w.msg -row 0 -column 0 -columnspan 3 -sticky nsew + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w [list size color align]] +grid $btns -row 3 -column 0 -columnspan 3 -sticky ew + +labelframe $w.left -pady 2 -text "Point Size" -padx 2 +labelframe $w.mid -pady 2 -text "Color" -padx 2 +labelframe $w.right -pady 2 -text "Alignment" -padx 2 +button $w.tristate -text Tristate -command "set size multi; set color multi" \ + -pady 2 -padx 2 +if {[tk windowingsystem] eq "aqua"} { + $w.tristate configure -padx 10 +} +grid $w.left -column 0 -row 1 -pady .5c -padx .5c -rowspan 2 +grid $w.mid -column 1 -row 1 -pady .5c -padx .5c -rowspan 2 +grid $w.right -column 2 -row 1 -pady .5c -padx .5c +grid $w.tristate -column 2 -row 2 -pady .5c -padx .5c + +foreach i {10 12 14 18 24} { + radiobutton $w.left.b$i -text "Point Size $i" -variable size \ + -relief flat -value $i -tristatevalue "multi" + pack $w.left.b$i -side top -pady 2 -anchor w -fill x +} + +foreach c {Red Green Blue Yellow Orange Purple} { + set lower [string tolower $c] + radiobutton $w.mid.$lower -text $c -variable color \ + -relief flat -value $lower -anchor w \ + -command "$w.mid configure -fg \$color" \ + -tristatevalue "multi" + pack $w.mid.$lower -side top -pady 2 -fill x +} + + +label $w.right.l -text "Label" -bitmap questhead -compound left +$w.right.l configure -width [winfo reqwidth $w.right.l] -compound top +$w.right.l configure -height [winfo reqheight $w.right.l] +foreach a {Top Left Right Bottom} { + set lower [string tolower $a] + radiobutton $w.right.$lower -text $a -variable align \ + -relief flat -value $lower -indicatoron 0 -width 7 \ + -command "$w.right.l configure -compound \$align" +} + +grid x $w.right.top +grid $w.right.left $w.right.l $w.right.right +grid x $w.right.bottom diff --git a/evalkit_llava/lib/tk8.6/demos/ruler.tcl b/evalkit_llava/lib/tk8.6/demos/ruler.tcl new file mode 100644 index 0000000000000000000000000000000000000000..0b78370708893e608e9b06c235926f78f7290b89 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/ruler.tcl @@ -0,0 +1,175 @@ +# ruler.tcl -- +# +# This demonstration script creates a canvas widget that displays a ruler +# with tab stops that can be set, moved, and deleted. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +# rulerMkTab -- +# This procedure creates a new triangular polygon in a canvas to +# represent a tab stop. +# +# Arguments: +# c - The canvas window. +# x, y - Coordinates at which to create the tab stop. + +proc rulerMkTab {c x y} { + upvar #0 demo_rulerInfo v + set newTab [$c create polygon $x $y \ + [expr {$x+$v(size)}] [expr {$y+$v(size)}] \ + [expr {$x-$v(size)}] [expr {$y+$v(size)}]] + set fill [$c itemcget $newTab -outline] + $c itemconfigure $newTab -fill $fill -outline {} + set v(normalStyle) "-fill $fill" + return $newTab +} + +set w .ruler +catch {destroy $w} +toplevel $w +wm title $w "Ruler Demonstration" +wm iconname $w "ruler" +positionWindow $w +set c $w.c + +label $w.msg -font $font -wraplength 5i -justify left -text "This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +canvas $c -width 14.8c -height 2.5c +pack $w.c -side top -fill x + +set demo_rulerInfo(grid) .25c +set demo_rulerInfo(left) [winfo fpixels $c 1c] +set demo_rulerInfo(right) [winfo fpixels $c 13c] +set demo_rulerInfo(top) [winfo fpixels $c 1c] +set demo_rulerInfo(bottom) [winfo fpixels $c 1.5c] +set demo_rulerInfo(size) [winfo fpixels $c .2c] +# Main widget program sets variable tk_demoDirectory +if {[winfo depth $c] > 1} { + set demo_rulerInfo(activeStyle) "-fill red -stipple {}" + set demo_rulerInfo(deleteStyle) [list -fill red \ + -stipple @[file join $tk_demoDirectory images gray25.xbm]] +} else { + set demo_rulerInfo(activeStyle) "-fill black -stipple {}" + set demo_rulerInfo(deleteStyle) [list -fill black \ + -stipple @[file join $tk_demoDirectory images gray25.xbm]] +} + +$c create line 1c 0.5c 1c 1c 13c 1c 13c 0.5c -width 1 +for {set i 0} {$i < 12} {incr i} { + set x [expr {$i+1}] + $c create line ${x}c 1c ${x}c 0.6c -width 1 + $c create line $x.25c 1c $x.25c 0.8c -width 1 + $c create line $x.5c 1c $x.5c 0.7c -width 1 + $c create line $x.75c 1c $x.75c 0.8c -width 1 + $c create text $x.15c .75c -text $i -anchor sw +} +$c addtag well withtag [$c create rect 13.2c 1c 13.8c 0.5c \ + -fill [lindex [$c config -bg] 4]] +$c addtag well withtag [rulerMkTab $c [winfo pixels $c 13.5c] \ + [winfo pixels $c .65c]] + +$c bind well "rulerNewTab $c %x %y" +$c bind tab "rulerSelectTab $c %x %y" +bind $c "rulerMoveTab $c %x %y" +bind $c "rulerReleaseTab $c" + +# rulerNewTab -- +# Does all the work of creating a tab stop, including creating the +# triangle object and adding tags to it to give it tab behavior. +# +# Arguments: +# c - The canvas window. +# x, y - The coordinates of the tab stop. + +proc rulerNewTab {c x y} { + upvar #0 demo_rulerInfo v + $c addtag active withtag [rulerMkTab $c $x $y] + $c addtag tab withtag active + set v(x) $x + set v(y) $y + rulerMoveTab $c $x $y +} + +# rulerSelectTab -- +# This procedure is invoked when mouse button 1 is pressed over +# a tab. It remembers information about the tab so that it can +# be dragged interactively. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse (identifies the point by +# which the tab was picked up for dragging). + +proc rulerSelectTab {c x y} { + upvar #0 demo_rulerInfo v + set v(x) [$c canvasx $x $v(grid)] + set v(y) [expr {$v(top)+2}] + $c addtag active withtag current + eval "$c itemconf active $v(activeStyle)" + $c raise active +} + +# rulerMoveTab -- +# This procedure is invoked during mouse motion events to drag a tab. +# It adjusts the position of the tab, and changes its appearance if +# it is about to be dragged out of the ruler. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse. + +proc rulerMoveTab {c x y} { + upvar #0 demo_rulerInfo v + if {[$c find withtag active] == ""} { + return + } + set cx [$c canvasx $x $v(grid)] + set cy [$c canvasy $y] + if {$cx < $v(left)} { + set cx $v(left) + } + if {$cx > $v(right)} { + set cx $v(right) + } + if {($cy >= $v(top)) && ($cy <= $v(bottom))} { + set cy [expr {$v(top)+2}] + eval "$c itemconf active $v(activeStyle)" + } else { + set cy [expr {$cy-$v(size)-2}] + eval "$c itemconf active $v(deleteStyle)" + } + $c move active [expr {$cx-$v(x)}] [expr {$cy-$v(y)}] + set v(x) $cx + set v(y) $cy +} + +# rulerReleaseTab -- +# This procedure is invoked during button release events that end +# a tab drag operation. It deselects the tab and deletes the tab if +# it was dragged out of the ruler. +# +# Arguments: +# c - The canvas widget. +# x, y - The coordinates of the mouse. + +proc rulerReleaseTab c { + upvar #0 demo_rulerInfo v + if {[$c find withtag active] == {}} { + return + } + if {$v(y) != $v(top)+2} { + $c delete active + } else { + eval "$c itemconf active $v(normalStyle)" + $c dtag active + } +} diff --git a/evalkit_llava/lib/tk8.6/demos/sayings.tcl b/evalkit_llava/lib/tk8.6/demos/sayings.tcl new file mode 100644 index 0000000000000000000000000000000000000000..aa3479c648e373069470fdd3cc6a7c4bfff17ea3 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/sayings.tcl @@ -0,0 +1,44 @@ +# sayings.tcl -- +# +# This demonstration script creates a listbox that can be scrolled +# both horizontally and vertically. It displays a collection of +# well-known sayings. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .sayings +catch {destroy $w} +toplevel $w +wm title $w "Listbox Demonstration (well-known sayings)" +wm iconname $w "sayings" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "The listbox below contains a collection of well-known sayings. You can scan the list using either of the scrollbars or by dragging in the listbox window with button 2 pressed." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +frame $w.frame -borderwidth 10 +pack $w.frame -side top -expand yes -fill both -padx 1c + + +ttk::scrollbar $w.frame.yscroll -command "$w.frame.list yview" +ttk::scrollbar $w.frame.xscroll -orient horizontal \ + -command "$w.frame.list xview" +listbox $w.frame.list -width 20 -height 10 -setgrid 1 \ + -yscroll "$w.frame.yscroll set" -xscroll "$w.frame.xscroll set" + +grid $w.frame.list -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news +grid $w.frame.yscroll -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news +grid $w.frame.xscroll -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news +grid rowconfig $w.frame 0 -weight 1 -minsize 0 +grid columnconfig $w.frame 0 -weight 1 -minsize 0 + + +$w.frame.list insert 0 "Don't speculate, measure" "Waste not, want not" "Early to bed and early to rise makes a man healthy, wealthy, and wise" "Ask not what your country can do for you, ask what you can do for your country" "I shall return" "NOT" "A picture is worth a thousand words" "User interfaces are hard to build" "Thou shalt not steal" "A penny for your thoughts" "Fool me once, shame on you; fool me twice, shame on me" "Every cloud has a silver lining" "Where there's smoke there's fire" "It takes one to know one" "Curiosity killed the cat" "Take this job and shove it" "Up a creek without a paddle" "I'm mad as hell and I'm not going to take it any more" "An apple a day keeps the doctor away" "Don't look a gift horse in the mouth" "Measure twice, cut once" diff --git a/evalkit_llava/lib/tk8.6/demos/spin.tcl b/evalkit_llava/lib/tk8.6/demos/spin.tcl new file mode 100644 index 0000000000000000000000000000000000000000..d897e6d8f317ed7cd453ea941ea84bd939f0431b --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/spin.tcl @@ -0,0 +1,53 @@ +# spin.tcl -- +# +# This demonstration script creates several spinbox widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .spin +catch {destroy $w} +toplevel $w +wm title $w "Spinbox Demonstration" +wm iconname $w "spin" +positionWindow $w + +label $w.msg -font $font -wraplength 5i -justify left -text "Three different\ + spin-boxes are displayed below. You can add characters by pointing,\ + clicking and typing. The normal Motif editing characters are\ + supported, along with many Emacs bindings. For example, Backspace\ + and Control-h delete the character to the left of the insertion\ + cursor and Delete and Control-d delete the chararacter to the right\ + of the insertion cursor. For values that are too large to fit in the\ + window all at once, you can scan through the value by dragging with\ + mouse button2 pressed. Note that the first spin-box will only permit\ + you to type in integers, and the third selects from a list of\ + Australian cities." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +set australianCities { + Canberra Sydney Melbourne Perth Adelaide Brisbane + Hobart Darwin "Alice Springs" +} + +spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ + -vcmd {string is integer %P} +spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10 +spinbox $w.s3 -values $australianCities -width 10 + +#entry $w.e1 +#entry $w.e2 +#entry $w.e3 +pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x + +#$w.e1 insert 0 "Initial value" +#$w.e2 insert end "This entry contains a long value, much too long " +#$w.e2 insert end "to fit in the window at one time, so long in fact " +#$w.e2 insert end "that you'll have to scan or scroll to see the end." diff --git a/evalkit_llava/lib/tk8.6/demos/states.tcl b/evalkit_llava/lib/tk8.6/demos/states.tcl new file mode 100644 index 0000000000000000000000000000000000000000..aeb3d5bb06d8bc07c6e9b5f2d11d16f064497ac7 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/states.tcl @@ -0,0 +1,54 @@ +# states.tcl -- +# +# This demonstration script creates a listbox widget that displays +# the names of the 50 states in the United States of America. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .states +catch {destroy $w} +toplevel $w +wm title $w "Listbox Demonstration (50 states)" +wm iconname $w "states" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down." +pack $w.msg -side top + +labelframe $w.justif -text Justification +foreach c {Left Center Right} { + set lower [string tolower $c] + radiobutton $w.justif.$lower -text $c -variable just \ + -relief flat -value $lower -anchor w \ + -command "$w.frame.list configure -justify \$just" \ + -tristatevalue "multi" + pack $w.justif.$lower -side left -pady 2 -fill x +} +pack $w.justif + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +frame $w.frame -borderwidth .5c +pack $w.frame -side top -expand yes -fill y + +ttk::scrollbar $w.frame.scroll -command "$w.frame.list yview" +listbox $w.frame.list -yscroll "$w.frame.scroll set" -setgrid 1 -height 12 +pack $w.frame.scroll -side right -fill y +pack $w.frame.list -side left -expand 1 -fill both + +$w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \ + Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \ + Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \ + Massachusetts Michigan Minnesota Mississippi Missouri \ + Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \ + "New York" "North Carolina" "North Dakota" \ + Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \ + "South Carolina" "South Dakota" \ + Tennessee Texas Utah Vermont Virginia Washington \ + "West Virginia" Wisconsin Wyoming diff --git a/evalkit_llava/lib/tk8.6/demos/textpeer.tcl b/evalkit_llava/lib/tk8.6/demos/textpeer.tcl new file mode 100644 index 0000000000000000000000000000000000000000..83e8e14fec7bff773cf0f3fefe2eac302ce5f237 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/textpeer.tcl @@ -0,0 +1,62 @@ +# textpeer.tcl -- +# +# This demonstration script creates a pair of text widgets that can edit a +# single logical buffer. This is particularly useful when editing related text +# in two (or more) parts of the same file. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .textpeer +catch {destroy $w} +toplevel $w +wm title $w "Text Widget Peering Demonstration" +wm iconname $w "textpeer" +positionWindow $w + +set count 0 + +## Define a widget that we peer from; it won't ever actually be shown though +set first [text $w.text[incr count]] +$first insert end "This is a coupled pair of text widgets; they are peers to " +$first insert end "each other. They have the same underlying data model, but " +$first insert end "can show different locations, have different current edit " +$first insert end "locations, and have different selections. You can also " +$first insert end "create additional peers of any of these text widgets using " +$first insert end "the Make Peer button beside the text widget to clone, and " +$first insert end "delete a particular peer widget using the Delete Peer " +$first insert end "button." + +## Procedures to make and kill clones; most of this is just so that the demo +## looks nice... +proc makeClone {w parent} { + global count + set t [$parent peer create $w.text[incr count] -yscroll "$w.sb$count set"\ + -height 10 -wrap word] + set sb [ttk::scrollbar $w.sb$count -command "$t yview" -orient vertical] + set b1 [button $w.clone$count -command "makeClone $w $t" \ + -text "Make Peer"] + set b2 [button $w.kill$count -command "killClone $w $count" \ + -text "Delete Peer"] + set row [expr {$count * 2}] + grid $t $sb $b1 -sticky nsew -row $row + grid ^ ^ $b2 -row [incr row] + grid configure $b1 $b2 -sticky new + grid rowconfigure $w $b2 -weight 1 +} +proc killClone {w count} { + destroy $w.text$count $w.sb$count + destroy $w.clone$count $w.kill$count +} + +## Now set up the GUI +makeClone $w $first +makeClone $w $first +destroy $first + +## See Code / Dismiss buttons +grid [addSeeDismiss $w.buttons $w] - - -sticky ew -row 5000 +grid columnconfigure $w 0 -weight 1 diff --git a/evalkit_llava/lib/tk8.6/demos/tree.tcl b/evalkit_llava/lib/tk8.6/demos/tree.tcl new file mode 100644 index 0000000000000000000000000000000000000000..1cc70f877fa96cbc546adc964f6fbbff73ab3363 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/tree.tcl @@ -0,0 +1,89 @@ +# tree.tcl -- +# +# This demonstration script creates a toplevel window containing a Ttk +# tree widget. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .tree +catch {destroy $w} +toplevel $w +wm title $w "Directory Browser" +wm iconname $w "tree" +positionWindow $w + +## Explanatory text +ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which allows the user to browse a hierarchical data-set such as a filesystem. The tree widget not only allows for the tree part itself, but it also supports an arbitrary number of additional columns which can show additional data (in this case, the size of the files found in your filesystem). You can also change the width of the columns by dragging the boundary between them." +pack $w.msg -fill x + +## See Code / Dismiss +pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x + +## Code to populate the roots of the tree (can be more than one on Windows) +proc populateRoots {tree} { + foreach dir [lsort -dictionary [file volumes]] { + populateTree $tree [$tree insert {} end -text $dir \ + -values [list $dir directory]] + } +} + +## Code to populate a node of the tree +proc populateTree {tree node} { + if {[$tree set $node type] ne "directory"} { + return + } + set path [$tree set $node fullpath] + $tree delete [$tree children $node] + foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] { + set f [file normalize $f] + set type [file type $f] + set id [$tree insert $node end -text [file tail $f] \ + -values [list $f $type]] + + if {$type eq "directory"} { + ## Make it so that this node is openable + $tree insert $id 0 -text dummy ;# a dummy + $tree item $id -text [file tail $f]/ + + } elseif {$type eq "file"} { + set size [file size $f] + ## Format the file size nicely + if {$size >= 1024*1024*1024} { + set size [format %.1f\ GB [expr {$size/1024/1024/1024.}]] + } elseif {$size >= 1024*1024} { + set size [format %.1f\ MB [expr {$size/1024/1024.}]] + } elseif {$size >= 1024} { + set size [format %.1f\ kB [expr {$size/1024.}]] + } else { + append size " bytes" + } + $tree set $id size $size + } + } + + # Stop this code from rerunning on the current node + $tree set $node type processedDirectory +} + +## Create the tree and set it up +ttk::treeview $w.tree -columns {fullpath type size} -displaycolumns {size} \ + -yscroll "$w.vsb set" -xscroll "$w.hsb set" +ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview" +ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview" +$w.tree heading \#0 -text "Directory Structure" +$w.tree heading size -text "File Size" +$w.tree column size -width 70 +populateRoots $w.tree +bind $w.tree <> {populateTree %W [%W focus]} + +## Arrange the tree and its scrollbars in the toplevel +lower [ttk::frame $w.dummy] +pack $w.dummy -fill both -expand 1 +grid $w.tree $w.vsb -sticky nsew -in $w.dummy +grid $w.hsb -sticky nsew -in $w.dummy +grid columnconfigure $w.dummy 0 -weight 1 +grid rowconfigure $w.dummy 0 -weight 1 diff --git a/evalkit_llava/lib/tk8.6/demos/ttknote.tcl b/evalkit_llava/lib/tk8.6/demos/ttknote.tcl new file mode 100644 index 0000000000000000000000000000000000000000..50a925822fc53924e387d0b6475066173aaae2d2 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/ttknote.tcl @@ -0,0 +1,57 @@ +# ttknote.tcl -- +# +# This demonstration script creates a toplevel window containing a Ttk +# notebook widget. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .ttknote +catch {destroy $w} +toplevel $w +wm title $w "Ttk Notebook Widget" +wm iconname $w "ttknote" +positionWindow $w + +## See Code / Dismiss +pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x + +ttk::frame $w.f +pack $w.f -fill both -expand 1 +set w $w.f + +## Make the notebook and set up Ctrl+Tab traversal +ttk::notebook $w.note +pack $w.note -fill both -expand 1 -padx 2 -pady 3 +ttk::notebook::enableTraversal $w.note + +## Popuplate the first pane +ttk::frame $w.note.msg +ttk::label $w.note.msg.m -font $font -wraplength 4i -justify left -anchor n -text "Ttk is the new Tk themed widget set. One of the widgets it includes is the notebook widget, which provides a set of tabs that allow the selection of a group of panels, each with distinct content. They are a feature of many modern user interfaces. Not only can the tabs be selected with the mouse, but they can also be switched between using Ctrl+Tab when the notebook page heading itself is selected. Note that the second tab is disabled, and cannot be selected." +ttk::button $w.note.msg.b -text "Neat!" -underline 0 -command { + set neat "Yeah, I know..." + after 500 {set neat {}} +} +bind $w "focus $w.note.msg.b; $w.note.msg.b invoke" +ttk::label $w.note.msg.l -textvariable neat +$w.note add $w.note.msg -text "Description" -underline 0 -padding 2 +grid $w.note.msg.m - -sticky new -pady 2 +grid $w.note.msg.b $w.note.msg.l -pady {2 4} +grid rowconfigure $w.note.msg 1 -weight 1 +grid columnconfigure $w.note.msg {0 1} -weight 1 -uniform 1 + +## Populate the second pane. Note that the content doesn't really matter +ttk::frame $w.note.disabled +$w.note add $w.note.disabled -text "Disabled" -state disabled + +## Popuplate the third pane +ttk::frame $w.note.editor +$w.note add $w.note.editor -text "Text Editor" -underline 0 +text $w.note.editor.t -width 40 -height 10 -wrap char \ + -yscroll "$w.note.editor.s set" +ttk::scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview" +pack $w.note.editor.s -side right -fill y -padx {0 2} -pady 2 +pack $w.note.editor.t -fill both -expand 1 -pady 2 -padx {2 0} diff --git a/evalkit_llava/lib/tk8.6/demos/ttkpane.tcl b/evalkit_llava/lib/tk8.6/demos/ttkpane.tcl new file mode 100644 index 0000000000000000000000000000000000000000..3f8898725d4a1f9b2d7ddd697e562b75e06ad56b --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/ttkpane.tcl @@ -0,0 +1,112 @@ +# ttkpane.tcl -- +# +# This demonstration script creates a Ttk pane with some content. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .ttkpane +catch {destroy $w} +toplevel $w +wm title $w "Themed Nested Panes" +wm iconname $w "ttkpane" +positionWindow $w + +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows off a nested set of themed paned windows. Their sizes can be changed by grabbing the area between each contained pane and dragging the divider." +pack $w.msg [ttk::separator $w.msgSep] -side top -fill x + +## See Code / Dismiss +pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x + +ttk::frame $w.f +pack $w.f -fill both -expand 1 +set w $w.f +ttk::panedwindow $w.outer -orient horizontal +$w.outer add [ttk::panedwindow $w.outer.inLeft -orient vertical] +$w.outer add [ttk::panedwindow $w.outer.inRight -orient vertical] +$w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.top -text Button] +$w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.bot -text Clocks] +$w.outer.inRight add [ttk::labelframe $w.outer.inRight.top -text Progress] +$w.outer.inRight add [ttk::labelframe $w.outer.inRight.bot -text Text] +if {[tk windowingsystem] eq "aqua"} { + foreach i [list inLeft.top inLeft.bot inRight.top inRight.bot] { + $w.outer.$i configure -padding 3 + } +} + +# Fill the button pane +ttk::button $w.outer.inLeft.top.b -text "Press Me" -command { + tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \ + -parent .ttkpane -title "Button Pressed" +} +pack $w.outer.inLeft.top.b -padx 2 -pady 5 + +# Fill the clocks pane +set i 0 +proc every {delay script} { + uplevel #0 $script + after $delay [list every $delay $script] +} +set testzones { + :Europe/Berlin + :America/Argentina/Buenos_Aires + :Africa/Johannesburg + :Europe/London + :America/Los_Angeles + :Europe/Moscow + :America/New_York + :Asia/Singapore + :Australia/Sydney + :Asia/Tokyo +} +# Force a pre-load of all the timezones needed; otherwise can end up +# poor-looking synch problems! +set zones {} +foreach zone $testzones { + if {![catch {clock format 0 -timezone $zone}]} { + lappend zones $zone + } +} +if {[llength $zones] < 2} { lappend zones -0200 :GMT :UTC +0200 } +foreach zone $zones { + set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]] + if {$i} { + pack [ttk::separator $w.outer.inLeft.bot.s$i] -fill x + } + ttk::label $w.outer.inLeft.bot.l$i -text $city -anchor w + ttk::label $w.outer.inLeft.bot.t$i -textvariable time($zone) -anchor w + pack $w.outer.inLeft.bot.l$i $w.outer.inLeft.bot.t$i -fill x + every 1000 "set time($zone) \[clock format \[clock seconds\] -timezone $zone -format %T\]" + incr i +} + +# Fill the progress pane +ttk::progressbar $w.outer.inRight.top.progress -mode indeterminate +pack $w.outer.inRight.top.progress -fill both -expand 1 +$w.outer.inRight.top.progress start + +# Fill the text pane +if {[tk windowingsystem] ne "aqua"} { + # The trick with the ttk::frame makes the text widget look like it fits with + # the current Ttk theme despite not being a themed widget itself. It is done + # by styling the frame like an entry, turning off the border in the text + # widget, and putting the text widget in the frame with enough space to allow + # the surrounding border to show through (2 pixels seems to be enough). + ttk::frame $w.outer.inRight.bot.f -style TEntry + text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0 + pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 2 -padx 2 + ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview" + pack $w.sb -side right -fill y -in $w.outer.inRight.bot + pack $w.outer.inRight.bot.f -fill both -expand 1 + pack $w.outer -fill both -expand 1 +} else { + text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0 + ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview" + pack $w.sb -side right -fill y -in $w.outer.inRight.bot + pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot + pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10} +} + diff --git a/evalkit_llava/lib/tk8.6/demos/ttkprogress.tcl b/evalkit_llava/lib/tk8.6/demos/ttkprogress.tcl new file mode 100644 index 0000000000000000000000000000000000000000..8a72cf969573a36210008439d63c8e529631daea --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/ttkprogress.tcl @@ -0,0 +1,46 @@ +# ttkprogress.tcl -- +# +# This demonstration script creates several progress bar widgets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .ttkprogress +catch {destroy $w} +toplevel $w +wm title $w "Progress Bar Demonstration" +wm iconname $w "ttkprogress" +positionWindow $w + +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Below are two progress bars. The top one is a \u201Cdeterminate\u201D progress bar, which is used for showing how far through a defined task the program has got. The bottom one is an \u201Cindeterminate\u201D progress bar, which is used to show that the program is busy but does not know how long for. Both are run here in self-animated mode, which can be turned on and off using the buttons underneath." +pack $w.msg -side top -fill x + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +ttk::frame $w.f +pack $w.f -fill both -expand 1 +set w $w.f + +proc doBars {op args} { + foreach w $args { + $w $op + } +} +ttk::progressbar $w.p1 -mode determinate +ttk::progressbar $w.p2 -mode indeterminate +ttk::button $w.start -text "Start Progress" -command [list \ + doBars start $w.p1 $w.p2] +ttk::button $w.stop -text "Stop Progress" -command [list \ + doBars stop $w.p1 $w.p2] + +grid $w.p1 - -pady 5 -padx 10 +grid $w.p2 - -pady 5 -padx 10 +grid $w.start $w.stop -padx 10 -pady 5 +grid configure $w.start -sticky e +grid configure $w.stop -sticky w +grid columnconfigure $w all -weight 1 diff --git a/evalkit_llava/lib/tk8.6/demos/unicodeout.tcl b/evalkit_llava/lib/tk8.6/demos/unicodeout.tcl new file mode 100644 index 0000000000000000000000000000000000000000..759dc0006b7b5a965dc1f61bb03e7e98d73f38e5 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/unicodeout.tcl @@ -0,0 +1,145 @@ +# unicodeout.tcl -- +# +# This demonstration script shows how you can produce output (in label +# widgets) using many different alphabets. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .unicodeout +catch {destroy $w} +toplevel $w +wm title $w "Unicode Label Demonstration" +wm iconname $w "unicodeout" +positionWindow $w + +label $w.msg -font $font -wraplength 4i -anchor w -justify left \ + -text "This is a sample of Tk's support for languages that use\ + non-Western character sets. However, what you will actually see\ + below depends largely on what character sets you have installed,\ + and what you see for characters that are not present varies greatly\ + between platforms as well. The strings are written in Tcl using\ + UNICODE characters using the \\uXXXX escape so as to do so in a\ + portable fashion." +pack $w.msg -side top + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +## The frame that will contain the sample texts. +pack [frame $w.f] -side bottom -expand 1 -fill both -padx 2m -pady 1m +grid columnconfigure $w.f 1 -weight 1 +set i 0 +proc addSample {w language args} { + global font i + set sample [join $args ""] + set j [incr i] + label $w.f.l$j -font $font -text "${language}:" -anchor nw -pady 0 + label $w.f.s$j -font $font -text $sample -anchor nw -width 30 -pady 0 + grid $w.f.l$j $w.f.s$j -sticky ew -pady 0 + grid configure $w.f.l$j -padx 1m +} + +## A helper procedure that determines what form to use to express languages +## that have complex rendering rules... +proc usePresentationFormsFor {language} { + switch [tk windowingsystem] { + aqua { + # OSX wants natural character order; the renderer knows how to + # compose things for display for all languages. + return false + } + x11 { + # The X11 font renderers that Tk supports all know nothing about + # composing characters, so we need to use presentation forms. + return true + } + win32 { + # On Windows, we need to determine whether the font system will + # render right-to-left text. This varies by language! + try { + package require registry + set rkey [join { + HKEY_LOCAL_MACHINE + SOFTWARE + Microsoft + {Windows NT} + CurrentVersion + LanguagePack + } \\] + return [expr { + [string toupper $language] ni [registry values $rkey] + }] + } trap error {} { + # Cannot work it out, so use presentation forms. + return true + } + } + default { + # Default to using presentation forms. + return true + } + } +} + +## Processing when some characters are not currently cached by the display +## engine might take a while, so make sure we're displaying something in the +## meantime... +pack [label $w.wait -text "Please wait while loading fonts..." \ + -font {Helvetica 12 italic}] +set oldCursor [$w cget -cursor] +$w conf -cursor watch +update + +## Add the samples... +if {[usePresentationFormsFor Arabic]} { + # Using presentation forms (pre-layouted) + addSample $w Arabic \ + "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \ + "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D" +} else { + # Using standard text characters + addSample $w Arabic \ + "\u0627\u0644\u0643\u0644\u0645\u0629 " \ + "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" +} +addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57" +addSample $w "Simpl. Chinese" "\u6C49\u8BED" +addSample $w French "Langue fran\xE7aise" +addSample $w Greek \ + "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \ + "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1" +if {[usePresentationFormsFor Hebrew]} { + # Visual order (pre-layouted) + addSample $w Hebrew \ + "\u05EA\u05D9\u05E8\u05D1\u05E2 \u05D1\u05EA\u05DB" +} else { + # Standard logical order + addSample $w Hebrew \ + "\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA" +} +addSample $w Hindi \ + "\u0939\u093F\u0928\u094D\u0926\u0940 \u092D\u093E\u0937\u093E" +addSample $w Icelandic "\xCDslenska" +addSample $w Japanese \ + "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \ + "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA" +addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" +addSample $w Russian \ + "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" +if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} { + if {[package vsatisfies [package provide Tcl] 8.7-]} { + addSample $w Emoji "😀💩👍🇳🇱" + } else { + addSample $w Emoji \ + "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1" + } +} + +## We're done processing, so change things back to normal running... +destroy $w.wait +$w conf -cursor $oldCursor diff --git a/evalkit_llava/lib/tk8.6/demos/vscale.tcl b/evalkit_llava/lib/tk8.6/demos/vscale.tcl new file mode 100644 index 0000000000000000000000000000000000000000..2c7ea769699aaa805adf1d3cad176e4aa223b6a1 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/vscale.tcl @@ -0,0 +1,46 @@ +# vscale.tcl -- +# +# This demonstration script shows an example with a vertical scale. + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .vscale +catch {destroy $w} +toplevel $w +wm title $w "Vertical Scale Demonstration" +wm iconname $w "vscale" +positionWindow $w + +label $w.msg -font $font -wraplength 3.5i -justify left -text "An arrow and a vertical scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the size of the arrow." +pack $w.msg -side top -padx .5c + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] +pack $btns -side bottom -fill x + +frame $w.frame -borderwidth 10 +pack $w.frame + +scale $w.frame.scale -orient vertical -length 284 -from 0 -to 250 \ + -command "setHeight $w.frame.canvas" -tickinterval 50 +canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0 +$w.frame.canvas create polygon 0 0 1 1 2 2 -fill SeaGreen3 -tags poly +$w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line +frame $w.frame.right -borderwidth 15 +pack $w.frame.scale -side left -anchor ne +pack $w.frame.canvas -side left -anchor nw -fill y +$w.frame.scale set 75 + +proc setHeight {w height} { + incr height 21 + set y2 [expr {$height - 30}] + if {$y2 < 21} { + set y2 21 + } + $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 + $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20 +} diff --git a/evalkit_llava/lib/tk8.6/demos/widget b/evalkit_llava/lib/tk8.6/demos/widget new file mode 100644 index 0000000000000000000000000000000000000000..4f3d876b7a786419b910349c8b50c9e2b81b9abb --- /dev/null +++ b/evalkit_llava/lib/tk8.6/demos/widget @@ -0,0 +1,734 @@ +#!/bin/sh +# the next line restarts using wish \ +exec wish8.6 "$0" ${1+"$@"} + +# widget -- +# This script demonstrates the various widgets provided by Tk, along with many +# of the features of the Tk toolkit. This file only contains code to generate +# the main window for the application, which invokes individual +# demonstrations. The code for the actual demonstrations is contained in +# separate ".tcl" files is this directory, which are sourced by this script as +# needed. + +package require Tk 8.5 +package require msgcat + +destroy {*}[winfo children .] +set tk_demoDirectory [file join [pwd] [file dirname [info script]]] +::msgcat::mcload $tk_demoDirectory +namespace import ::msgcat::mc +wm title . [mc "Widget Demonstration"] +if {[tk windowingsystem] eq "x11"} { + # This won't work everywhere, but there's no other way in core Tk at the + # moment to display a coloured icon. + image create photo TclPowered \ + -file [file join $tk_library images logo64.gif] + wm iconwindow . [toplevel ._iconWindow] + pack [label ._iconWindow.i -image TclPowered] + wm iconname . [mc "tkWidgetDemo"] +} + +if {"defaultFont" ni [font names]} { + # TIP #145 defines some standard named fonts + if {"TkDefaultFont" in [font names] && "TkFixedFont" in [font names]} { + # FIX ME: the following technique of cloning the font to copy it works + # fine but means that if the system font is changed by Tk + # cannot update the copied font. font alias might be useful + # here -- or fix the app to use TkDefaultFont etc. + font create mainFont {*}[font configure TkDefaultFont] + font create fixedFont {*}[font configure TkFixedFont] + font create boldFont {*}[font configure TkDefaultFont] -weight bold + font create titleFont {*}[font configure TkDefaultFont] -weight bold + font create statusFont {*}[font configure TkDefaultFont] + font create varsFont {*}[font configure TkDefaultFont] + if {[tk windowingsystem] eq "aqua"} { + font configure titleFont -size 17 + } + } else { + font create mainFont -family Helvetica -size 12 + font create fixedFont -family Courier -size 10 + font create boldFont -family Helvetica -size 12 -weight bold + font create titleFont -family Helvetica -size 18 -weight bold + font create statusFont -family Helvetica -size 10 + font create varsFont -family Helvetica -size 14 + } +} + +set widgetDemo 1 +set font mainFont + +image create photo ::img::refresh -format GIF -data { + R0lGODlhEAAQAJEDAP///wAAACpnKv///yH5BAEAAAMALAAAAAAQABAAAAI63IKp + xgcPH2ouwgBCw1HIxHCQ4F3hSJKmwZXqWrmWxj7lKJ2dndcon9EBUq+gz3brVXAR + 2tICU0gXBQA7 +} + +image create photo ::img::view -format GIF -data { + R0lGODlhEAAQAKIHAP///wwMDAAAAMDAwNnZ2SYmJmZmZv///yH5BAEAAAcALAAA + AAAQABAAAANMKLos90+ASamDRxJCgw9YVnlDOXiQBgRDBRgHKE6sW8QR3doPKK27 + yg33q/GIOhdg6OsEJzeZykiBSUcs06e56Xx6np8ScIkFGuhQAgA7 +} + +image create photo ::img::delete -format GIF -data { + R0lGODlhEAAQAIABAIQAAP///yH5BAEAAAEALAAAAAAQABAAAAIjjI+pmwAc3HGy + PUSvqYpuvWQg40FfSVacBa5nN6JYDI3mzRQAOw== +} + +image create photo ::img::print -format GIF -data { + R0lGODlhEAAQALMKAAAAAP///52VunNkl8C82Yl+qldBgq+pyrOzs1fYAP///wAA + AAAAAAAAAAAAAAAAACH5BAEAAAoALAAAAAAQABAAAARGUMlJKwU4AztB+ODGeUiJ + fGLlgeEYmGWQXmx7aXgmAUTv/74N4EAsGhOJg1DAbDqbwoJ0Sp0KB9isNis0eL/g + ryhH5pgnEQA7 +} + +# Note that this is run through the message catalog! This is because this is +# actually an image of a word. +image create photo ::img::new -format PNG -data [mc { + iVBORw0KGgoAAAANSUhEUgAAAB4AAAAOCAYAAAA45qw5AAACMElEQVR4AeVTAwxd + QRCc2tZHGtQ2w9q2bdsOa9u2bUW1bdt2Z372JZe6DapJLqtb3h7+T8yKi5j4CsYD + EUQXxETclT7kWOlH2VV+tFkdQHPSwksSISF+BauCqL0qgOcMWgGfgEkaMsHxqUBk + 3plE/sOnh/qDPAPJH/CKFBivGHWzFwBRnHhlqbu1Mh6CoFNnC/JshQ9p4YC2lrKt + DCAV+THiVejyhMjAbrNSrroiEfKR9g7ZfCgOog8QfnUQV62wAk68ndQ9ZbyoWO1H + Y6eDY1LCQL6a9ApOp9Hi1T0+gQq2JKMlky/oTKQliKWxEZvyG575kpW4pl1aZnQK + CLOVt45Lkp8uXp2SL8KO6uitNTZLdpK6s+I/eZbhpmsmWeOGOVQNKYLITzpKPAO3 + tY7LSNZ7ccSLxX9y3uuOxRkg3dKESMoCHvL+GRVCutXsB3guLgDCeXOv4iWWkvwG + BaS+PmlpK6SI9ApI2oC2UtrwZQEkhkH+NtolVlQXJl1I+QltuU3XEc721bIRFpa8 + IA5iqTo6vNNWmkNBLQbPeXwF2g17Q94nTQAfY3YzeY+WSu8MDzQ2kpELUhSGJUHE + 0zeR3rY1L+Xl5G/re+jbiK6KhThwwInsts1fbMUUcpZszKeVtggZEiGdZDe5AtHh + 7vL4CGiRvvKPS8FAvq9Nr4ZkFadR2y6kggu1z4vlyIbBp6BugQ8JLEg4bTkD9eMZ + QZ8hpJ3VvTtuvbWrY/ElvP/9R+Aj3603+iE3fkEAAAAASUVORK5CYII= +}] + +#---------------------------------------------------------------- +# The code below creates the main window, consisting of a menu bar and a text +# widget that explains how to use the program, plus lists all of the demos as +# hypertext items. +#---------------------------------------------------------------- + +menu .menuBar -tearoff 0 + +# On Aqua, just use the default menu. +if {[tk windowingsystem] ne "aqua"} { + # This is a tk-internal procedure to make i18n easier + ::tk::AmpMenuArgs .menuBar add cascade -label [mc "&File"] \ + -menu .menuBar.file + menu .menuBar.file -tearoff 0 + ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&About..."] \ + -command {tkAboutDialog} -accelerator [mc ""] + bind . {tkAboutDialog} + .menuBar.file add sep + if {[string match win* [tk windowingsystem]]} { + # Windows doesn't usually have a Meta key + ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&Quit"] \ + -command {exit} -accelerator [mc "Ctrl+Q"] + bind . <[mc "Control-q"]> {exit} + } else { + ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&Quit"] \ + -command {exit} -accelerator [mc "Meta-Q"] + bind . <[mc "Meta-q"]> {exit} + } + . configure -menu .menuBar +} + +ttk::frame .statusBar +ttk::label .statusBar.lab -text " " -anchor w +if {[tk windowingsystem] eq "aqua"} { + ttk::separator .statusBar.sep + pack .statusBar.sep -side top -expand yes -fill x -pady 0 +} +pack .statusBar.lab -side left -padx 2 -expand yes -fill both +if {[tk windowingsystem] ne "aqua"} { + ttk::sizegrip .statusBar.foo + pack .statusBar.foo -side left -padx 2 +} +pack .statusBar -side bottom -fill x -pady 2 + +set textheight 30 +catch { + set textheight [expr { + ([winfo screenheight .] * 0.7) / + [font metrics mainFont -displayof . -linespace] + }] +} + +ttk::frame .textFrame +ttk::scrollbar .s -orient vertical -command {.t yview} -takefocus 1 +pack .s -in .textFrame -side right -fill y +text .t -yscrollcommand {.s set} -wrap word -width 70 -height $textheight \ + -font mainFont -setgrid 1 -highlightthickness 0 \ + -padx 4 -pady 2 -takefocus 0 +pack .t -in .textFrame -expand y -fill both -padx 1 +pack .textFrame -expand yes -fill both +if {[tk windowingsystem] eq "aqua"} { + pack configure .statusBar.lab -padx {10 18} -pady {4 6} + pack configure .statusBar -pady 0 + .t configure -padx 10 -pady 0 +} + +# Create a bunch of tags to use in the text widget, such as those for section +# titles and demo descriptions. Also define the bindings for tags. + +.t tag configure title -font titleFont +.t tag configure subtitle -font titleFont +.t tag configure bold -font boldFont +if {[tk windowingsystem] eq "aqua"} { + .t tag configure title -spacing1 8 + .t tag configure subtitle -spacing3 3 +} + +# We put some "space" characters to the left and right of each demo +# description so that the descriptions are highlighted only when the mouse +# cursor is right over them (but not when the cursor is to their left or +# right). +# +.t tag configure demospace -lmargin1 1c -lmargin2 1c + +if {[winfo depth .] == 1} { + .t tag configure demo -lmargin1 1c -lmargin2 1c \ + -underline 1 + .t tag configure visited -lmargin1 1c -lmargin2 1c \ + -underline 1 + .t tag configure hot -background black -foreground white +} else { + .t tag configure demo -lmargin1 1c -lmargin2 1c \ + -foreground blue -underline 1 + .t tag configure visited -lmargin1 1c -lmargin2 1c \ + -foreground #303080 -underline 1 + if {[tk windowingsystem] eq "aqua"} { + .t tag configure demo -foreground systemLinkColor + .t tag configure visited -foreground purple + } + .t tag configure hot -foreground red -underline 1 +} +.t tag bind demo { + invoke [.t index {@%x,%y}] +} +set lastLine "" +.t tag bind demo { + set lastLine [.t index {@%x,%y linestart}] + .t tag add hot "$lastLine +1 chars" "$lastLine lineend -1 chars" + .t config -cursor [::ttk::cursor link] + showStatus [.t index {@%x,%y}] +} +.t tag bind demo { + .t tag remove hot 1.0 end + .t config -cursor [::ttk::cursor text] + .statusBar.lab config -text "" +} +.t tag bind demo { + set newLine [.t index {@%x,%y linestart}] + if {$newLine ne $lastLine} { + .t tag remove hot 1.0 end + set lastLine $newLine + + set tags [.t tag names {@%x,%y}] + set i [lsearch -glob $tags demo-*] + if {$i >= 0} { + .t tag add hot "$lastLine +1 chars" "$lastLine lineend -1 chars" + } + } + showStatus [.t index {@%x,%y}] +} + +############################################################################## +# Create the text for the text widget. + +# addFormattedText -- +# +# Add formatted text (but not hypertext) to the text widget after first +# passing it through the message catalog to allow for localization. +# Lines starting with @@ are formatting directives (insert title, insert +# demo hyperlink, begin newline, or change style) and all other lines +# are literal strings to be inserted. Substitutions are performed, +# allowing processing pieces through the message catalog. Blank lines +# are ignored. +# +proc addFormattedText {formattedText} { + set style normal + set isNL 1 + set demoCount 0 + set new 0 + foreach line [split $formattedText \n] { + set line [string trim $line] + if {$line eq ""} { + continue + } + if {[string match @@* $line]} { + set data [string range $line 2 end] + set key [lindex $data 0] + set values [lrange $data 1 end] + switch -exact -- $key { + title { + .t insert end [mc $values]\n title \n normal + } + newline { + .t insert end \n $style + set isNL 1 + } + subtitle { + .t insert end "\n" {} [mc $values] subtitle \ + " \n " demospace + set demoCount 0 + } + demo { + set description [lassign $values name] + .t insert end "[incr demoCount]. [mc $description]" \ + [list demo demo-$name] + if {$new} { + .t image create end -image ::img::new -padx 5 + set new 0 + } + .t insert end " \n " demospace + } + new { + set new 1 + } + default { + set style $key + } + } + continue + } + if {!$isNL} { + .t insert end " " $style + } + set isNL 0 + .t insert end [mc $line] $style + } +} + +addFormattedText { + @@title Tk Widget Demonstrations + + 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 + @@bold + See Code + @@normal + button to see the Tcl/Tk code that created the demonstration. If + you wish, you can edit the code and click the + @@bold + Rerun Demo + @@normal + button in the code window to reinvoke the demonstration with the + modified code. + @@newline + + @@subtitle Labels, buttons, checkbuttons, and radiobuttons + @@demo label Labels (text and bitmaps) + @@demo unicodeout Labels and UNICODE text + @@demo button Buttons + @@demo check Check-buttons (select any of a group) + @@demo radio Radio-buttons (select one of a group) + @@demo puzzle A 15-puzzle game made out of buttons + @@demo icon Iconic buttons that use bitmaps + @@demo image1 Two labels displaying images + @@demo image2 A simple user interface for viewing images + @@demo labelframe Labelled frames + @@demo ttkbut The simple Themed Tk widgets + + @@subtitle Listboxes and Trees + @@demo states The 50 states + @@demo colors Colors: change the color scheme for the application + @@demo sayings A collection of famous and infamous sayings + @@demo mclist A multi-column list of countries + @@demo tree A directory browser tree + + @@subtitle Entries, Spin-boxes and Combo-boxes + @@demo entry1 Entries without scrollbars + @@demo entry2 Entries with scrollbars + @@demo entry3 Validated entries and password fields + @@demo spin Spin-boxes + @@demo combo Combo-boxes + @@demo form Simple Rolodex-like form + + @@subtitle Text + @@demo text Basic editable text + @@demo style Text display styles + @@demo bind Hypertext (tag bindings) + @@demo twind A text widget with embedded windows and other features + @@demo search A search tool built with a text widget + @@demo textpeer Peering text widgets + + @@subtitle Canvases + @@demo items The canvas item types + @@demo plot A simple 2-D plot + @@demo ctext Text items in canvases + @@demo arrow An editor for arrowheads on canvas lines + @@demo ruler A ruler with adjustable tab stops + @@demo floor A building floor plan + @@demo cscroll A simple scrollable canvas + @@demo knightstour A Knight's tour of the chess board + + @@subtitle Scales and Progress Bars + @@demo hscale Horizontal scale + @@demo vscale Vertical scale + @@new + @@demo ttkscale Themed scale linked to a label with traces + @@demo ttkprogress Progress bar + + @@subtitle Paned Windows and Notebooks + @@demo paned1 Horizontal paned window + @@demo paned2 Vertical paned window + @@demo ttkpane Themed nested panes + @@demo ttknote Notebook widget + + @@subtitle Menus and Toolbars + @@demo menu Menus and cascades (sub-menus) + @@demo menubu Menu-buttons + @@demo ttkmenu Themed menu buttons + @@demo toolbar Themed toolbar + + @@subtitle Common Dialogs + @@demo msgbox Message boxes + @@demo filebox File selection dialog + @@demo clrpick Color picker + @@demo fontchoose Font selection dialog + + @@subtitle Animation + @@demo anilabel Animated labels + @@demo aniwave Animated wave + @@demo pendulum Pendulum simulation + @@demo goldberg A celebration of Rube Goldberg + + @@subtitle Miscellaneous + @@demo bitmap The built-in bitmaps + @@demo dialog1 A dialog box with a local grab + @@demo dialog2 A dialog box with a global grab +} + +############################################################################## + +.t configure -state disabled +focus .s + +# addSeeDismiss -- +# Add "See Code" and "Dismiss" button frame, with optional "See Vars" +# +# Arguments: +# w - The name of the frame to use. + +proc addSeeDismiss {w show {vars {}} {extra {}}} { + ## See Code / Dismiss buttons + ttk::frame $w + ttk::separator $w.sep + #ttk::frame $w.sep -height 2 -relief sunken + grid $w.sep -columnspan 4 -row 0 -sticky ew -pady 2 + ttk::button $w.dismiss -text [mc "Dismiss"] \ + -image ::img::delete -compound left \ + -command [list destroy [winfo toplevel $w]] + ttk::button $w.code -text [mc "See Code"] \ + -image ::img::view -compound left \ + -command [list showCode $show] + set buttons [list x $w.code $w.dismiss] + if {[llength $vars]} { + ttk::button $w.vars -text [mc "See Variables"] \ + -image ::img::view -compound left \ + -command [concat [list showVars $w.dialog] $vars] + set buttons [linsert $buttons 1 $w.vars] + } + if {$extra ne ""} { + set buttons [linsert $buttons 1 [uplevel 1 $extra]] + } + grid {*}$buttons -padx 4 -pady 4 + grid columnconfigure $w 0 -weight 1 + if {[tk windowingsystem] eq "aqua"} { + foreach b [lrange $buttons 1 end] {$b configure -takefocus 0} + grid configure $w.sep -pady 0 + grid configure {*}$buttons -pady {10 12} + grid configure [lindex $buttons 1] -padx {16 4} + grid configure [lindex $buttons end] -padx {4 18} + } + return $w +} + +# positionWindow -- +# This procedure is invoked by most of the demos to position a new demo +# window. +# +# Arguments: +# w - The name of the window to position. + +proc positionWindow w { + wm geometry $w +300+300 +} + +# showVars -- +# Displays the values of one or more variables in a window, and updates the +# display whenever any of the variables changes. +# +# Arguments: +# w - Name of new window to create for display. +# args - Any number of names of variables. + +proc showVars {w args} { + catch {destroy $w} + toplevel $w + if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog} + wm title $w [mc "Variable values"] + + set b [ttk::frame $w.frame] + grid $b -sticky news + set f [ttk::labelframe $b.title -text [mc "Variable values:"]] + foreach var $args { + ttk::label $f.n$var -text "$var:" -anchor w + ttk::label $f.v$var -textvariable $var -anchor w + grid $f.n$var $f.v$var -padx 2 -pady 2 -sticky w + } + ttk::button $b.ok -text [mc "OK"] \ + -command [list destroy $w] -default active + bind $w [list $b.ok invoke] + bind $w [list $b.ok invoke] + + grid $f -sticky news -padx 4 + grid $b.ok -sticky e -padx 4 -pady {6 4} + if {[tk windowingsystem] eq "aqua"} { + $b.ok configure -takefocus 0 + grid configure $b.ok -pady {10 12} -padx {16 18} + grid configure $f -padx 10 -pady {10 0} + } + grid columnconfig $f 1 -weight 1 + grid rowconfigure $f 100 -weight 1 + grid columnconfig $b 0 -weight 1 + grid rowconfigure $b 0 -weight 1 + grid columnconfig $w 0 -weight 1 + grid rowconfigure $w 0 -weight 1 +} + +# invoke -- +# This procedure is called when the user clicks on a demo description. It is +# responsible for invoking the demonstration. +# +# Arguments: +# index - The index of the character that the user clicked on. + +proc invoke index { + global tk_demoDirectory + set tags [.t tag names $index] + set i [lsearch -glob $tags demo-*] + if {$i < 0} { + return + } + set cursor [.t cget -cursor] + .t configure -cursor [::ttk::cursor busy] + update + set demo [string range [lindex $tags $i] 5 end] + uplevel 1 [list source -encoding utf-8 [file join $tk_demoDirectory $demo.tcl]] + update + .t configure -cursor $cursor + + .t tag add visited "$index linestart +1 chars" "$index lineend -1 chars" +} + +# showStatus -- +# +# Show the name of the demo program in the status bar. This procedure is +# called when the user moves the cursor over a demo description. +# +proc showStatus index { + set tags [.t tag names $index] + set i [lsearch -glob $tags demo-*] + set cursor [.t cget -cursor] + if {$i < 0} { + .statusBar.lab config -text " " + set newcursor [::ttk::cursor text] + } else { + set demo [string range [lindex $tags $i] 5 end] + .statusBar.lab config -text [mc "Run the \"%s\" sample program" $demo] + set newcursor [::ttk::cursor link] + } + if {$cursor ne $newcursor} { + .t config -cursor $newcursor + } +} + +# evalShowCode -- +# +# Arguments: +# w - Name of text widget containing code to eval + +proc evalShowCode {w} { + set code [$w get 1.0 end-1c] + uplevel #0 $code +} + +# showCode -- +# This procedure creates a toplevel window that displays the code for a +# demonstration and allows it to be edited and reinvoked. +# +# Arguments: +# w - The name of the demonstration's window, which can be used to +# derive the name of the file containing its code. + +proc showCode w { + global tk_demoDirectory + set file [string range $w 1 end].tcl + set top .code + if {![winfo exists $top]} { + toplevel $top + if {[tk windowingsystem] eq "x11"} {wm attributes $top -type dialog} + + set t [frame $top.f] + set text [text $t.text -font fixedFont -height 24 -wrap word \ + -xscrollcommand [list $t.xscroll set] \ + -yscrollcommand [list $t.yscroll set] \ + -setgrid 1 -highlightthickness 0 -pady 2 -padx 3] + ttk::scrollbar $t.xscroll -command [list $t.text xview] \ + -orient horizontal + ttk::scrollbar $t.yscroll -command [list $t.text yview] \ + -orient vertical + + grid $t.text $t.yscroll -sticky news + #grid $t.xscroll + grid rowconfigure $t 0 -weight 1 + grid columnconfig $t 0 -weight 1 + + set btns [ttk::frame $top.btns] + ttk::separator $btns.sep + grid $btns.sep -columnspan 4 -row 0 -sticky ew -pady 2 + ttk::button $btns.dismiss -text [mc "Dismiss"] \ + -default active -command [list destroy $top] \ + -image ::img::delete -compound left + ttk::button $btns.print -text [mc "Print Code"] \ + -command [list printCode $text $file] \ + -image ::img::print -compound left + ttk::button $btns.rerun -text [mc "Rerun Demo"] \ + -command [list evalShowCode $text] \ + -image ::img::refresh -compound left + set buttons [list x $btns.rerun $btns.print $btns.dismiss] + grid {*}$buttons -padx 4 -pady 4 + grid columnconfigure $btns 0 -weight 1 + if {[tk windowingsystem] eq "aqua"} { + foreach b [lrange $buttons 1 end] {$b configure -takefocus 0} + grid configure $btns.sep -pady 0 + grid configure {*}$buttons -pady {10 12} + grid configure [lindex $buttons 1] -padx {16 4} + grid configure [lindex $buttons end] -padx {4 18} + } + grid $t -sticky news + grid $btns -sticky ew + grid rowconfigure $top 0 -weight 1 + grid columnconfig $top 0 -weight 1 + + bind $top { + if {[winfo class %W] ne "Text"} { .code.btns.dismiss invoke } + } + bind $top [bind $top ] + } else { + wm deiconify $top + raise $top + } + wm title $top [mc "Demo code: %s" [file join $tk_demoDirectory $file]] + wm iconname $top $file + set id [open [file join $tk_demoDirectory $file]] + fconfigure $id -encoding utf-8 -eofchar "\032 {}" + $top.f.text delete 1.0 end + $top.f.text insert 1.0 [read $id] + $top.f.text mark set insert 1.0 + close $id +} + +# printCode -- +# Prints the source code currently displayed in the See Code dialog. Much +# thanks to Arjen Markus for this. +# +# Arguments: +# w - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) + +proc printCode {w file} { + set code [$w get 1.0 end-1c] + + set dir "." + if {[info exists ::env(HOME)]} { + set dir "$::env(HOME)" + } + if {[info exists ::env(TMP)]} { + set dir $::env(TMP) + } + if {[info exists ::env(TEMP)]} { + set dir $::env(TEMP) + } + + set filename [file join $dir "tkdemo-$file"] + set outfile [open $filename "w"] + puts $outfile $code + close $outfile + + switch -- $::tcl_platform(platform) { + unix { + if {[catch {exec lp -c $filename} msg]} { + tk_messageBox -title "Print spooling failure" \ + -message "Print spooling probably failed: $msg" + } + } + windows { + if {[catch {PrintTextWin32 $filename} msg]} { + tk_messageBox -title "Print spooling failure" \ + -message "Print spooling probably failed: $msg" + } + } + default { + tk_messageBox -title "Operation not Implemented" \ + -message "Wow! Unknown platform: $::tcl_platform(platform)" + } + } + + # + # Be careful to throw away the temporary file in a gentle manner ... + # + if {[file exists $filename]} { + catch {file delete $filename} + } +} + +# PrintTextWin32 -- +# Print a file under Windows using all the "intelligence" necessary +# +# Arguments: +# filename - Name of the file +# +# Note: +# Taken from the Wiki page by Keith Vetter, "Printing text files under +# Windows". +# Note: +# Do not execute the command in the background: that way we can dispose of the +# file smoothly. +# +proc PrintTextWin32 {filename} { + package require registry + set app [auto_execok notepad.exe] + set pcmd "$app /p %1" + catch { + set app [registry get {HKEY_CLASSES_ROOT\.txt} {}] + set pcmd [registry get \ + {HKEY_CLASSES_ROOT\\$app\\shell\\print\\command} {}] + } + + regsub -all {%1} $pcmd $filename pcmd + puts $pcmd + + regsub -all {\\} $pcmd {\\\\} pcmd + set command "[auto_execok start] /min $pcmd" + eval exec $command +} + +# tkAboutDialog -- +# +# Pops up a message box with an "about" message +# +proc tkAboutDialog {} { + tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ + -message [mc "Tk widget demonstration application"] -detail \ +"[mc "Copyright \xA9 %s" {1996-1997 Sun Microsystems, Inc.}] +[mc "Copyright \xA9 %s" {1997-2000 Ajuba Solutions, Inc.}] +[mc "Copyright \xA9 %s" {2001-2009 Donal K. Fellows}] +[mc "Copyright \xA9 %s" {2002-2007 Daniel A. Steffen}]" +} + +# Local Variables: +# mode: tcl +# End: diff --git a/evalkit_llava/lib/tk8.6/dialog.tcl b/evalkit_llava/lib/tk8.6/dialog.tcl new file mode 100644 index 0000000000000000000000000000000000000000..a099d90036028ddee2782e505b728c3a7aea7a12 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/dialog.tcl @@ -0,0 +1,175 @@ +# dialog.tcl -- +# +# This file defines the procedure tk_dialog, which creates a dialog +# box containing a bitmap, a message, and one or more buttons. +# +# Copyright (c) 1992-1993 The Regents of the University of California. +# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +# +# ::tk_dialog: +# +# This procedure displays a dialog box, waits for a button in the dialog +# to be invoked, then returns the index of the selected button. If the +# dialog somehow gets destroyed, -1 is returned. +# +# Arguments: +# w - Window to use for dialog top-level. +# title - Title to display in dialog's decorative frame. +# text - Message to display in dialog. +# bitmap - Bitmap to display in dialog (empty string means none). +# default - Index of button that is to display the default ring +# (-1 means none). +# args - One or more strings to display in buttons across the +# bottom of the dialog box. + +proc ::tk_dialog {w title text bitmap default args} { + variable ::tk::Priv + + # Check that $default was properly given + if {[string is integer -strict $default]} { + if {$default >= [llength $args]} { + return -code error -errorcode {TK DIALOG BAD_DEFAULT} \ + "default button index greater than number of buttons\ + specified for tk_dialog" + } + } elseif {"" eq $default} { + set default -1 + } else { + set default [lsearch -exact $args $default] + } + + set windowingsystem [tk windowingsystem] + + # 1. Create the top-level window and divide it into top + # and bottom parts. + + destroy $w + toplevel $w -class Dialog + wm title $w $title + wm iconname $w Dialog + wm protocol $w WM_DELETE_WINDOW { } + + # Dialog boxes should be transient with respect to their parent, + # so that they will always stay on top of their parent window. However, + # some window managers will create the window as withdrawn if the parent + # window is withdrawn or iconified. Combined with the grab we put on the + # window, this can hang the entire application. Therefore we only make + # the dialog transient if the parent is viewable. + # + if {[winfo viewable [winfo toplevel [winfo parent $w]]] } { + wm transient $w [winfo toplevel [winfo parent $w]] + } + + if {$windowingsystem eq "aqua"} { + ::tk::unsupported::MacWindowStyle style $w moveableModal {} + } elseif {$windowingsystem eq "x11"} { + wm attributes $w -type dialog + } + + frame $w.bot + frame $w.top + if {$windowingsystem eq "x11"} { + $w.bot configure -relief raised -bd 1 + $w.top configure -relief raised -bd 1 + } + pack $w.bot -side bottom -fill both + pack $w.top -side top -fill both -expand 1 + grid anchor $w.bot center + + # 2. Fill the top part with bitmap and message (use the option + # database for -wraplength and -font so that they can be + # overridden by the caller). + + option add *Dialog.msg.wrapLength 3i widgetDefault + option add *Dialog.msg.font TkCaptionFont widgetDefault + + label $w.msg -justify left -text $text + pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m + if {$bitmap ne ""} { + if {$windowingsystem eq "aqua" && $bitmap eq "error"} { + set bitmap "stop" + } + label $w.bitmap -bitmap $bitmap + pack $w.bitmap -in $w.top -side left -padx 3m -pady 3m + } + + # 3. Create a row of buttons at the bottom of the dialog. + + set i 0 + foreach but $args { + button $w.button$i -text $but -command [list set ::tk::Priv(button) $i] + if {$i == $default} { + $w.button$i configure -default active + } else { + $w.button$i configure -default normal + } + grid $w.button$i -in $w.bot -column $i -row 0 -sticky ew \ + -padx 10 -pady 4 + grid columnconfigure $w.bot $i + # We boost the size of some Mac buttons for l&f + if {$windowingsystem eq "aqua"} { + set tmp [string tolower $but] + if {$tmp eq "ok" || $tmp eq "cancel"} { + grid columnconfigure $w.bot $i -minsize 90 + } + grid configure $w.button$i -pady 7 + } + incr i + } + + # 4. Create a binding for on the dialog if there is a + # default button. + # Convention also dictates that if the keyboard focus moves among the + # the buttons that the binding affects the button with the focus. + + if {$default >= 0} { + bind $w [list $w.button$default invoke] + } + bind $w <> [list bind $w {[tk_focusPrev %W] invoke}] + bind $w <> [list bind $w {[tk_focusNext %W] invoke}] + + # 5. Create a binding for the window that sets the + # button variable to -1; this is needed in case something happens + # that destroys the window, such as its parent window being destroyed. + + bind $w {set ::tk::Priv(button) -1} + + # 6. Withdraw the window, then update all the geometry information + # so we know how big it wants to be, then center the window in the + # display (Motif style) and de-iconify it. + + ::tk::PlaceWindow $w + tkwait visibility $w + + # 7. Set a grab and claim the focus too. + + if {$default >= 0} { + set focus $w.button$default + } else { + set focus $w + } + tk::SetFocusGrab $w $focus + + # 8. Wait for the user to respond, then restore the focus and + # return the index of the selected button. Restore the focus + # before deleting the window, since otherwise the window manager + # may take the focus away so we can't redirect it. Finally, + # restore any grab that was in effect. + + vwait ::tk::Priv(button) + + catch { + # It's possible that the window has already been destroyed, + # hence this "catch". Delete the Destroy handler so that + # Priv(button) doesn't get reset by it. + + bind $w {} + } + tk::RestoreFocusGrab $w $focus + return $Priv(button) +} diff --git a/evalkit_llava/lib/tk8.6/entry.tcl b/evalkit_llava/lib/tk8.6/entry.tcl new file mode 100644 index 0000000000000000000000000000000000000000..5cb5ab912d75742d697f877dda44bdf016265f17 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/entry.tcl @@ -0,0 +1,699 @@ +# entry.tcl -- +# +# This file defines the default bindings for Tk entry widgets and provides +# procedures that help in implementing those bindings. +# +# Copyright (c) 1992-1994 The Regents of the University of California. +# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +#------------------------------------------------------------------------- +# Elements of tk::Priv that are used in this file: +# +# afterId - If non-null, it means that auto-scanning is underway +# and it gives the "after" id for the next auto-scan +# command to be executed. +# mouseMoved - Non-zero means the mouse has moved a significant +# amount since the button went down (so, for example, +# start dragging out a selection). +# pressX - X-coordinate at which the mouse button was pressed. +# selectMode - The style of selection currently underway: +# char, word, or line. +# x, y - Last known mouse coordinates for scanning +# and auto-scanning. +# data - Used for Cut and Copy +#------------------------------------------------------------------------- + +#------------------------------------------------------------------------- +# The code below creates the default class bindings for entries. +#------------------------------------------------------------------------- +bind Entry <> { + if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} { + clipboard clear -displayof %W + clipboard append -displayof %W $tk::Priv(data) + %W delete sel.first sel.last + unset tk::Priv(data) + } +} +bind Entry <> { + if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} { + clipboard clear -displayof %W + clipboard append -displayof %W $tk::Priv(data) + unset tk::Priv(data) + } +} +bind Entry <> { + catch { + if {[tk windowingsystem] ne "x11"} { + catch { + %W delete sel.first sel.last + } + } + %W insert insert [::tk::GetSelection %W CLIPBOARD] + tk::EntrySeeInsert %W + } +} +bind Entry <> { + # ignore if there is no selection + catch {%W delete sel.first sel.last} +} +bind Entry <> { + if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] + || !$tk::Priv(mouseMoved)} { + tk::EntryPaste %W %x + } +} + +bind Entry <> { + %W selection range 0 end + %W icursor end +} + +# Standard Motif bindings: + +bind Entry { + tk::EntryButton1 %W %x + %W selection clear +} +bind Entry { + set tk::Priv(x) %x + tk::EntryMouseSelect %W %x +} +bind Entry { + set tk::Priv(selectMode) word + tk::EntryMouseSelect %W %x + catch {%W icursor sel.last} +} +bind Entry { + set tk::Priv(selectMode) line + tk::EntryMouseSelect %W %x + catch {%W icursor sel.last} +} +bind Entry { + set tk::Priv(selectMode) char + %W selection adjust @%x +} +bind Entry { + set tk::Priv(selectMode) word + tk::EntryMouseSelect %W %x +} +bind Entry { + set tk::Priv(selectMode) line + tk::EntryMouseSelect %W %x +} +bind Entry { + set tk::Priv(x) %x + tk::EntryAutoScan %W +} +bind Entry { + tk::CancelRepeat +} +bind Entry { + tk::CancelRepeat +} +bind Entry { + %W icursor @%x +} + +bind Entry <> { + tk::EntrySetCursor %W [expr {[%W index insert]-1}] +} +bind Entry <> { + tk::EntrySetCursor %W [expr {[%W index insert]+1}] +} +bind Entry <> { + tk::EntryKeySelect %W [expr {[%W index insert]-1}] + tk::EntrySeeInsert %W +} +bind Entry <> { + tk::EntryKeySelect %W [expr {[%W index insert]+1}] + tk::EntrySeeInsert %W +} +bind Entry <> { + tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert] +} +bind Entry <> { + tk::EntrySetCursor %W [tk::EntryNextWord %W insert] +} +bind Entry <> { + tk::EntryKeySelect %W [tk::EntryPreviousWord %W insert] + tk::EntrySeeInsert %W +} +bind Entry <> { + tk::EntryKeySelect %W [tk::EntryNextWord %W insert] + tk::EntrySeeInsert %W +} +bind Entry <> { + tk::EntrySetCursor %W 0 +} +bind Entry <> { + tk::EntryKeySelect %W 0 + tk::EntrySeeInsert %W +} +bind Entry <> { + tk::EntrySetCursor %W end +} +bind Entry <> { + tk::EntryKeySelect %W end + tk::EntrySeeInsert %W +} + +bind Entry { + if {[%W selection present]} { + %W delete sel.first sel.last + } else { + %W delete insert + } +} +bind Entry { + tk::EntryBackspace %W +} + +bind Entry { + %W selection from insert +} +bind Entry { + %W selection from insert +} +bind Spinbox { + %W selection adjust insert +} +bind Spinbox { + %W selection adjust insert +} +bind Spinbox <> { + %W selection range 0 end +} +bind Spinbox <> { + %W selection clear +} +bind Spinbox { + ::tk::EntryInsert %W %A +} + +# Ignore all Alt, Meta, Control, and Mod4 keypresses unless explicitly bound. +# Otherwise, if a widget binding for one of these is defined, the +# class binding will also fire and insert the character, +# which is wrong. Ditto for Escape, Return, and Tab. + +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +bind Spinbox {# nothing} +if {[tk windowingsystem] eq "aqua"} { + bind Spinbox {# nothing} + bind Spinbox {# nothing} +} + +# On Windows, paste is done using Shift-Insert. Shift-Insert already +# generates the <> event, so we don't need to do anything here. +if {[tk windowingsystem] ne "win32"} { + bind Spinbox { + catch {::tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]} + } +} + +# Additional emacs-like bindings: + +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryBackspace %W + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert end + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryTranspose %W + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete insert [::tk::EntryNextWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert] + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete [::tk::EntryPreviousWord %W insert] insert + } +} +bind Spinbox { + if {!$tk_strictMotif} { + %W delete [::tk::EntryPreviousWord %W insert] insert + } +} + +# A few additional bindings of my own. + +if {[tk windowingsystem] ne "aqua"} { + bind Spinbox <2> { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x + } + } + bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x + } + } +} else { + bind Spinbox <3> { + if {!$tk_strictMotif} { + ::tk::EntryScanMark %W %x + } + } + bind Spinbox { + if {!$tk_strictMotif} { + ::tk::EntryScanDrag %W %x + } + } +} + +# ::tk::spinbox::Invoke -- +# Invoke an element of the spinbox +# +# Arguments: +# w - The spinbox window. +# elem - Element to invoke + +proc ::tk::spinbox::Invoke {w elem} { + variable ::tk::Priv + + if {![winfo exists $w]} { + return + } + + if {![info exists Priv(outsideElement)]} { + $w invoke $elem + incr Priv(repeated) + } + set delay [$w cget -repeatinterval] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $elem]] + } +} + +# ::tk::spinbox::ClosestGap -- +# Given x and y coordinates, this procedure finds the closest boundary +# between characters to the given coordinates and returns the index +# of the character just after the boundary. +# +# Arguments: +# w - The spinbox window. +# x - X-coordinate within the window. + +proc ::tk::spinbox::ClosestGap {w x} { + set pos [$w index @$x] + set bbox [$w bbox $pos] + if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} { + return $pos + } + incr pos +} + +# ::tk::spinbox::ArrowPress -- +# This procedure is invoked to handle button-1 presses in buttonup +# or buttondown elements of spinbox widgets. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. + +proc ::tk::spinbox::ArrowPress {w x y} { + variable ::tk::Priv + + if {[$w cget -state] ne "disabled" && \ + [string match "button*" $Priv(element)]} { + $w selection element $Priv(element) + set Priv(repeated) 0 + set Priv(relief) [$w cget -$Priv(element)relief] + catch {after cancel $Priv(afterId)} + set delay [$w cget -repeatdelay] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $Priv(element)]] + } + if {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + } + } +} + +# ::tk::spinbox::ButtonDown -- +# This procedure is invoked to handle button-1 presses in spinbox +# widgets. It moves the insertion cursor, sets the selection anchor, +# and claims the input focus. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. + +proc ::tk::spinbox::ButtonDown {w x y} { + variable ::tk::Priv + + # Get the element that was clicked in. If we are not directly over + # the spinbox, default to entry. This is necessary for spinbox grabs. + # + set Priv(element) [$w identify $x $y] + if {$Priv(element) eq ""} { + set Priv(element) "entry" + } + + switch -exact $Priv(element) { + "buttonup" - "buttondown" { + ::tk::spinbox::ArrowPress $w $x $y + } + "entry" { + set Priv(selectMode) char + set Priv(mouseMoved) 0 + set Priv(pressX) $x + $w icursor [::tk::spinbox::ClosestGap $w $x] + $w selection from insert + if {"disabled" ne [$w cget -state]} {focus $w} + $w selection clear + } + default { + return -code error -errorcode {TK SPINBOX UNKNOWN_ELEMENT} \ + "unknown spinbox element \"$Priv(element)\"" + } + } +} + +# ::tk::spinbox::ButtonUp -- +# This procedure is invoked to handle button-1 releases in spinbox +# widgets. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. + +proc ::tk::spinbox::ButtonUp {w x y} { + variable ::tk::Priv + + ::tk::CancelRepeat + + # Priv(relief) may not exist if the ButtonUp is not paired with + # a preceding ButtonDown + if {[info exists Priv(element)] && [info exists Priv(relief)] && \ + [string match "button*" $Priv(element)]} { + if {[info exists Priv(repeated)] && !$Priv(repeated)} { + $w invoke $Priv(element) + } + $w configure -$Priv(element)relief $Priv(relief) + $w selection element none + } +} + +# ::tk::spinbox::MouseSelect -- +# This procedure is invoked when dragging out a selection with +# the mouse. Depending on the selection mode (character, word, +# line) it selects in different-sized units. This procedure +# ignores mouse motions initially until the mouse has moved from +# one character to another or until there have been multiple clicks. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the mouse. +# cursor - optional place to set cursor. + +proc ::tk::spinbox::MouseSelect {w x {cursor {}}} { + variable ::tk::Priv + + if {$Priv(element) ne "entry"} { + # The ButtonUp command triggered by ButtonRelease-1 handles + # invoking one of the spinbuttons. + return + } + set cur [::tk::spinbox::ClosestGap $w $x] + set anchor [$w index anchor] + if {($cur ne $anchor) || (abs($Priv(pressX) - $x) >= 3)} { + set Priv(mouseMoved) 1 + } + switch $Priv(selectMode) { + char { + if {$Priv(mouseMoved)} { + if {$cur < $anchor} { + $w selection range $cur $anchor + } elseif {$cur > $anchor} { + $w selection range $anchor $cur + } else { + $w selection clear + } + } + } + word { + if {$cur < [$w index anchor]} { + set before [tcl_wordBreakBefore [$w get] $cur] + set after [tcl_wordBreakAfter [$w get] $anchor-1] + } else { + set before [tcl_wordBreakBefore [$w get] $anchor] + set after [tcl_wordBreakAfter [$w get] $cur-1] + } + if {$before < 0} { + set before 0 + } + if {$after < 0} { + set after end + } + $w selection range $before $after + } + line { + $w selection range 0 end + } + } + if {$cursor ne {} && $cursor ne "ignore"} { + catch {$w icursor $cursor} + } + update idletasks +} + +# ::tk::spinbox::Paste -- +# This procedure sets the insertion cursor to the current mouse position, +# pastes the selection there, and sets the focus to the window. +# +# Arguments: +# w - The spinbox window. +# x - X position of the mouse. + +proc ::tk::spinbox::Paste {w x} { + $w icursor [::tk::spinbox::ClosestGap $w $x] + catch {$w insert insert [::tk::GetSelection $w PRIMARY]} + if {"disabled" eq [$w cget -state]} { + focus $w + } +} + +# ::tk::spinbox::Motion -- +# This procedure is invoked when the mouse moves in a spinbox window +# with button 1 down. +# +# Arguments: +# w - The spinbox window. +# x - The x-coordinate of the mouse. +# y - The y-coordinate of the mouse. + +proc ::tk::spinbox::Motion {w x y} { + variable ::tk::Priv + + if {![info exists Priv(element)]} { + set Priv(element) [$w identify $x $y] + } + + set Priv(x) $x + if {"entry" eq $Priv(element)} { + ::tk::spinbox::MouseSelect $w $x ignore + } elseif {[$w identify $x $y] ne $Priv(element)} { + if {![info exists Priv(outsideElement)]} { + # We've wandered out of the spin button + # setting outside element will cause ::tk::spinbox::Invoke to + # loop without doing anything + set Priv(outsideElement) "" + $w selection element none + } + } elseif {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + $w selection element $Priv(element) + } +} + +# ::tk::spinbox::AutoScan -- +# This procedure is invoked when the mouse leaves an spinbox window +# with button 1 down. It scrolls the window left or right, +# depending on where the mouse is, and reschedules itself as an +# "after" command so that the window continues to scroll until the +# mouse moves back into the window or the mouse button is released. +# +# Arguments: +# w - The spinbox window. + +proc ::tk::spinbox::AutoScan {w} { + variable ::tk::Priv + + set x $Priv(x) + if {$x >= [winfo width $w]} { + $w xview scroll 2 units + ::tk::spinbox::MouseSelect $w $x ignore + } elseif {$x < 0} { + $w xview scroll -2 units + ::tk::spinbox::MouseSelect $w $x ignore + } + set Priv(afterId) [after 50 [list ::tk::spinbox::AutoScan $w]] +} + +# ::tk::spinbox::GetSelection -- +# +# Returns the selected text of the spinbox. Differs from entry in that +# a spinbox has no -show option to obscure contents. +# +# Arguments: +# w - The spinbox window from which the text to get + +proc ::tk::spinbox::GetSelection {w} { + return [string range [$w get] [$w index sel.first] \ + [expr {[$w index sel.last] - 1}]] +} diff --git a/evalkit_llava/lib/tk8.6/text.tcl b/evalkit_llava/lib/tk8.6/text.tcl new file mode 100644 index 0000000000000000000000000000000000000000..60eab4178e6f7fcfa5a1cd3e00bc4329138ced0c --- /dev/null +++ b/evalkit_llava/lib/tk8.6/text.tcl @@ -0,0 +1,1242 @@ +# text.tcl -- +# +# This file defines the default bindings for Tk text widgets and provides +# procedures that help in implementing the bindings. +# +# Copyright (c) 1992-1994 The Regents of the University of California. +# Copyright (c) 1994-1997 Sun Microsystems, Inc. +# Copyright (c) 1998 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +#------------------------------------------------------------------------- +# Elements of ::tk::Priv that are used in this file: +# +# afterId - If non-null, it means that auto-scanning is underway +# and it gives the "after" id for the next auto-scan +# command to be executed. +# char - Character position on the line; kept in order +# to allow moving up or down past short lines while +# still remembering the desired position. +# mouseMoved - Non-zero means the mouse has moved a significant +# amount since the button went down (so, for example, +# start dragging out a selection). +# prevPos - Used when moving up or down lines via the keyboard. +# Keeps track of the previous insert position, so +# we can distinguish a series of ups and downs, all +# in a row, from a new up or down. +# selectMode - The style of selection currently underway: +# char, word, or line. +# x, y - Last known mouse coordinates for scanning +# and auto-scanning. +# +#------------------------------------------------------------------------- + +#------------------------------------------------------------------------- +# The code below creates the default class bindings for text widgets. +#------------------------------------------------------------------------- + + + +# Standard Motif bindings: + +bind Text <1> { + tk::TextButton1 %W %x %y + %W tag remove sel 0.0 end +} +bind Text { + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::TextSelectTo %W %x %y +} +bind Text { + set tk::Priv(selectMode) word + tk::TextSelectTo %W %x %y + catch {%W mark set insert sel.first} +} +bind Text { + set tk::Priv(selectMode) line + tk::TextSelectTo %W %x %y + catch {%W mark set insert sel.first} +} +bind Text { + tk::TextResetAnchor %W @%x,%y + set tk::Priv(selectMode) char + tk::TextSelectTo %W %x %y +} +bind Text { + set tk::Priv(selectMode) word + tk::TextSelectTo %W %x %y 1 +} +bind Text { + set tk::Priv(selectMode) line + tk::TextSelectTo %W %x %y +} +bind Text { + set tk::Priv(x) %x + set tk::Priv(y) %y + tk::TextAutoScan %W +} +bind Text { + tk::CancelRepeat +} +bind Text { + tk::CancelRepeat +} + +bind Text { + %W mark set insert @%x,%y + # An operation that moves the insert mark without making it + # one end of the selection must insert an autoseparator + if {[%W cget -autoseparators]} { + %W edit separator + } +} +# stop an accidental double click triggering +bind Text { # nothing } +# stop an accidental movement triggering +bind Text { # nothing } +bind Text <> { + tk::TextSetCursor %W insert-1displayindices +} +bind Text <> { + tk::TextSetCursor %W insert+1displayindices +} +bind Text <> { + tk::TextSetCursor %W [tk::TextUpDownLine %W -1] +} +bind Text <> { + tk::TextSetCursor %W [tk::TextUpDownLine %W 1] +} +bind Text <> { + tk::TextKeySelect %W [%W index {insert - 1displayindices}] +} +bind Text <> { + tk::TextKeySelect %W [%W index {insert + 1displayindices}] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextUpDownLine %W -1] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextUpDownLine %W 1] +} +bind Text <> { + tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] +} +bind Text <> { + tk::TextSetCursor %W [tk::TextNextWord %W insert] +} +bind Text <> { + tk::TextSetCursor %W [tk::TextPrevPara %W insert] +} +bind Text <> { + tk::TextSetCursor %W [tk::TextNextPara %W insert] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextNextWord %W insert] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextPrevPara %W insert] +} +bind Text <> { + tk::TextKeySelect %W [tk::TextNextPara %W insert] +} +bind Text { + tk::TextSetCursor %W [tk::TextScrollPages %W -1] +} +bind Text { + tk::TextKeySelect %W [tk::TextScrollPages %W -1] +} +bind Text { + tk::TextSetCursor %W [tk::TextScrollPages %W 1] +} +bind Text { + tk::TextKeySelect %W [tk::TextScrollPages %W 1] +} +bind Text { + %W xview scroll -1 page +} +bind Text { + %W xview scroll 1 page +} + +bind Text <> { + tk::TextSetCursor %W {insert display linestart} +} +bind Text <> { + tk::TextKeySelect %W {insert display linestart} +} +bind Text <> { + tk::TextSetCursor %W {insert display lineend} +} +bind Text <> { + tk::TextKeySelect %W {insert display lineend} +} +bind Text { + tk::TextSetCursor %W 1.0 +} +bind Text { + tk::TextKeySelect %W 1.0 +} +bind Text { + tk::TextSetCursor %W {end - 1 indices} +} +bind Text { + tk::TextKeySelect %W {end - 1 indices} +} + +bind Text { + if {[%W cget -state] eq "normal"} { + tk::TextInsert %W \t + focus %W + break + } +} +bind Text { + # Needed only to keep binding from triggering; doesn't + # have to actually do anything. + break +} +bind Text { + focus [tk_focusNext %W] +} +bind Text { + focus [tk_focusPrev %W] +} +bind Text { + tk::TextInsert %W \t +} +bind Text { + tk::TextInsert %W \n + if {[%W cget -autoseparators]} { + %W edit separator + } +} +bind Text { + if {[tk::TextCursorInSelection %W]} { + %W delete sel.first sel.last + } else { + if {[%W compare end != insert+1c]} { + %W delete insert + } + %W see insert + } +} +bind Text { + if {[tk::TextCursorInSelection %W]} { + %W delete sel.first sel.last + } else { + if {[%W compare insert != 1.0]} { + %W delete insert-1c + } + %W see insert + } +} + +bind Text { + %W mark set [tk::TextAnchor %W] insert +} +bind Text , : +# Ttk entry widget doesn't use selection anchor. +# : +# Inserts PRIMARY selection (on non-Windows platforms). +# This is inconsistent with typical platform bindings. +# , : +# These don't do the right thing to start with. +# , , , +# , : +# Judgment call. If happens to be assigned to the Alt key, +# these could conflict with application accelerators. +# (Plus, who has a Meta key these days?) +# : +# Another judgment call. If anyone misses this, let me know +# and I'll put it back. +# + +## Clipboard events: +# +bind TEntry <> { ttk::entry::Cut %W } +bind TEntry <> { ttk::entry::Copy %W } +bind TEntry <> { ttk::entry::Paste %W } +bind TEntry <> { ttk::entry::Clear %W } + +## Button1 bindings: +# Used for selection and navigation. +# +bind TEntry { ttk::entry::Press %W %x } +bind TEntry { ttk::entry::Shift-Press %W %x } +bind TEntry { ttk::entry::Select %W %x word } +bind TEntry { ttk::entry::Select %W %x line } +bind TEntry { ttk::entry::Drag %W %x } + +bind TEntry { ttk::entry::DragOut %W %m } +bind TEntry { ttk::entry::DragIn %W } +bind TEntry { ttk::entry::Release %W } + +bind TEntry <> { + %W instate {!readonly !disabled} { %W icursor @%x ; focus %W } +} + +## Button2 (Button3 on Aqua) bindings: +# Used for scanning and primary transfer. +# Note: ButtonRelease-2 (ButtonRelease-3 on Aqua) +# is mapped to <> in tk.tcl. +# +if {[tk windowingsystem] ne "aqua"} { + bind TEntry { ttk::entry::ScanMark %W %x } + bind TEntry { ttk::entry::ScanDrag %W %x } + bind TEntry { ttk::entry::ScanRelease %W %x } +} else { + bind TEntry { ttk::entry::ScanMark %W %x } + bind TEntry { ttk::entry::ScanDrag %W %x } + bind TEntry { ttk::entry::ScanRelease %W %x } +} +bind TEntry <> { ttk::entry::ScanRelease %W %x } + +## Keyboard navigation bindings: +# +bind TEntry <> { ttk::entry::Move %W prevchar } +bind TEntry <> { ttk::entry::Move %W nextchar } +bind TEntry <> { ttk::entry::Move %W prevword } +bind TEntry <> { ttk::entry::Move %W nextword } +bind TEntry <> { ttk::entry::Move %W home } +bind TEntry <> { ttk::entry::Move %W end } + +bind TEntry <> { ttk::entry::Extend %W prevchar } +bind TEntry <> { ttk::entry::Extend %W nextchar } +bind TEntry <> { ttk::entry::Extend %W prevword } +bind TEntry <> { ttk::entry::Extend %W nextword } +bind TEntry <> { ttk::entry::Extend %W home } +bind TEntry <> { ttk::entry::Extend %W end } + +bind TEntry <> { %W selection range 0 end } +bind TEntry <> { %W selection clear } + +bind TEntry <> { %W selection range 0 end; %W icursor end } + +## Edit bindings: +# +bind TEntry { ttk::entry::Insert %W %A } +bind TEntry { ttk::entry::Delete %W } +bind TEntry { ttk::entry::Backspace %W } + +# Ignore all Alt, Meta, and Control keypresses unless explicitly bound. +# Otherwise, the class binding will fire and insert the character. +# Ditto for Escape, Return, and Tab. +# +bind TEntry {# nothing} +bind TEntry {# nothing} +bind TEntry {# nothing} +bind TEntry {# nothing} +bind TEntry {# nothing} +bind TEntry {# nothing} +bind TEntry {# nothing} + +# Argh. Apparently on Windows, the NumLock modifier is interpreted +# as a Command modifier. +if {[tk windowingsystem] eq "aqua"} { + bind TEntry {# nothing} + bind TEntry {# nothing} +} +# Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] +bind TEntry <> {# nothing} +bind TEntry <> {# nothing} + +## Additional emacs-like bindings: +# +bind TEntry { ttk::entry::Delete %W } +bind TEntry { ttk::entry::Backspace %W } +bind TEntry { %W delete insert end } + +# Bindings for IME text input. + +bind TEntry <> { + dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] +} +bind TEntry <> { + if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + bell + } else { + %W selection range $mark insert + } +} +bind TEntry <> { + %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] +} +bind TEntry <> { + ttk::entry::Backspace %W +} + +### Clipboard procedures. +# + +## EntrySelection -- Return the selected text of the entry. +# Raises an error if there is no selection. +# +proc ttk::entry::EntrySelection {w} { + set entryString [string range [$w get] [$w index sel.first] \ + [expr {[$w index sel.last] - 1}]] + if {[$w cget -show] ne ""} { + return [string repeat [string index [$w cget -show] 0] \ + [string length $entryString]] + } + return $entryString +} + +## Paste -- Insert clipboard contents at current insert point. +# +proc ttk::entry::Paste {w} { + catch { + set clipboard [::tk::GetSelection $w CLIPBOARD] + PendingDelete $w + $w insert insert $clipboard + See $w insert + } +} + +## Copy -- Copy selection to clipboard. +# +proc ttk::entry::Copy {w} { + if {![catch {EntrySelection $w} selection]} { + clipboard clear -displayof $w + clipboard append -displayof $w $selection + } +} + +## Clear -- Delete the selection. +# +proc ttk::entry::Clear {w} { + catch { $w delete sel.first sel.last } +} + +## Cut -- Copy selection to clipboard then delete it. +# +proc ttk::entry::Cut {w} { + Copy $w; Clear $w +} + +### Navigation procedures. +# + +## ClosestGap -- Find closest boundary between characters. +# Returns the index of the character just after the boundary. +# +proc ttk::entry::ClosestGap {w x} { + set pos [$w index @$x] + set bbox [$w bbox $pos] + if {$x - [lindex $bbox 0] > [lindex $bbox 2]/2} { + incr pos + } + return $pos +} + +## See $index -- Make sure that the character at $index is visible. +# +proc ttk::entry::See {w {index insert}} { + set c [$w index $index] + # @@@ OR: check [$w index left] / [$w index right] + if {$c < [$w index @0] || $c >= [$w index @[winfo width $w]]} { + $w xview $c + } +} + +## NextWord -- Find the next word position. +# Note: The "next word position" follows platform conventions: +# either the next end-of-word position, or the start-of-word +# position following the next end-of-word position. +# +set ::ttk::entry::State(startNext) \ + [string equal [tk windowingsystem] "win32"] + +proc ttk::entry::NextWord {w start} { + # the check on [winfo class] is because the spinbox and combobox also use this proc + if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} { + return end + } + variable State + set pos [tcl_endOfWord [$w get] [$w index $start]] + if {$pos >= 0 && $State(startNext)} { + set pos [tcl_startOfNextWord [$w get] $pos] + } + if {$pos < 0} { + return end + } + return $pos +} + +## PrevWord -- Find the previous word position. +# +proc ttk::entry::PrevWord {w start} { + # the check on [winfo class] is because the spinbox and combobox also use this proc + if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} { + return 0 + } + set pos [tcl_startOfPreviousWord [$w get] [$w index $start]] + if {$pos < 0} { + return 0 + } + return $pos +} + +## RelIndex -- Compute character/word/line-relative index. +# +proc ttk::entry::RelIndex {w where {index insert}} { + switch -- $where { + prevchar { expr {[$w index $index] - 1} } + nextchar { expr {[$w index $index] + 1} } + prevword { PrevWord $w $index } + nextword { NextWord $w $index } + home { return 0 } + end { $w index end } + default { error "Bad relative index $index" } + } +} + +## Move -- Move insert cursor to relative location. +# Also clears the selection, if any, and makes sure +# that the insert cursor is visible. +# +proc ttk::entry::Move {w where} { + $w icursor [RelIndex $w $where] + $w selection clear + See $w insert +} + +### Selection procedures. +# + +## ExtendTo -- Extend the selection to the specified index. +# +# The other end of the selection (the anchor) is determined as follows: +# +# (1) if there is no selection, the anchor is the insert cursor; +# (2) if the index is outside the selection, grow the selection; +# (3) if the insert cursor is at one end of the selection, anchor the other end +# (4) otherwise anchor the start of the selection +# +# The insert cursor is placed at the new end of the selection. +# +# Returns: selection anchor. +# +proc ttk::entry::ExtendTo {w index} { + set index [$w index $index] + set insert [$w index insert] + + # Figure out selection anchor: + if {![$w selection present]} { + set anchor $insert + } else { + set selfirst [$w index sel.first] + set sellast [$w index sel.last] + + if { ($index < $selfirst) + || ($insert == $selfirst && $index <= $sellast) + } { + set anchor $sellast + } else { + set anchor $selfirst + } + } + + # Extend selection: + if {$anchor < $index} { + $w selection range $anchor $index + } else { + $w selection range $index $anchor + } + + $w icursor $index + return $anchor +} + +## Extend -- Extend the selection to a relative position, show insert cursor +# +proc ttk::entry::Extend {w where} { + ExtendTo $w [RelIndex $w $where] + See $w +} + +### Button 1 binding procedures. +# +# Double-clicking followed by a drag enters "word-select" mode. +# Triple-clicking enters "line-select" mode. +# + +## Press -- Button-1 binding. +# Set the insertion cursor, claim the input focus, set up for +# future drag operations. +# +proc ttk::entry::Press {w x} { + variable State + + $w icursor [ClosestGap $w $x] + $w selection clear + $w instate !disabled { focus $w } + + # Set up for future drag, double-click, or triple-click. + set State(x) $x + set State(selectMode) char + set State(anchor) [$w index insert] +} + +## Shift-Press -- Shift-Button-1 binding. +# Extends the selection, sets anchor for future drag operations. +# +proc ttk::entry::Shift-Press {w x} { + variable State + + focus $w + set anchor [ExtendTo $w @$x] + + set State(x) $x + set State(selectMode) char + set State(anchor) $anchor +} + +## Select $w $x $mode -- Binding for double- and triple- clicks. +# Selects a word or line (according to mode), +# and sets the selection mode for subsequent drag operations. +# +proc ttk::entry::Select {w x mode} { + variable State + set cur [ClosestGap $w $x] + + switch -- $mode { + word { WordSelect $w $cur $cur } + line { LineSelect $w $cur $cur } + char { # no-op } + } + + set State(anchor) $cur + set State(selectMode) $mode +} + +## Drag -- Button1 motion binding. +# +proc ttk::entry::Drag {w x} { + variable State + set State(x) $x + DragTo $w $x +} + +## DragTo $w $x -- Extend selection to $x based on current selection mode. +# +proc ttk::entry::DragTo {w x} { + variable State + + set cur [ClosestGap $w $x] + switch $State(selectMode) { + char { CharSelect $w $State(anchor) $cur } + word { WordSelect $w $State(anchor) $cur } + line { LineSelect $w $State(anchor) $cur } + none { # no-op } + } +} + +## binding: +# Begin autoscroll. +# +proc ttk::entry::DragOut {w mode} { + variable State + if {$State(selectMode) ne "none" && $mode eq "NotifyNormal"} { + ttk::Repeatedly ttk::entry::AutoScroll $w + } +} + +## binding +# Suspend autoscroll. +# +proc ttk::entry::DragIn {w} { + ttk::CancelRepeat +} + +## binding +# +proc ttk::entry::Release {w} { + variable State + set State(selectMode) none + ttk::CancelRepeat ;# suspend autoscroll +} + +## AutoScroll +# Called repeatedly when the mouse is outside an entry window +# with Button 1 down. Scroll the window left or right, +# depending on where the mouse left the window, and extend +# the selection according to the current selection mode. +# +# TODO: AutoScroll should repeat faster (50ms) than normal autorepeat. +# TODO: Need a way for Repeat scripts to cancel themselves. +# +proc ttk::entry::AutoScroll {w} { + variable State + if {![winfo exists $w]} return + set x $State(x) + if {$x > [winfo width $w]} { + $w xview scroll 2 units + DragTo $w $x + } elseif {$x < 0} { + $w xview scroll -2 units + DragTo $w $x + } +} + +## CharSelect -- select characters between index $from and $to +# +proc ttk::entry::CharSelect {w from to} { + if {$to <= $from} { + $w selection range $to $from + } else { + $w selection range $from $to + } + $w icursor $to +} + +## WordSelect -- Select whole words between index $from and $to +# +proc ttk::entry::WordSelect {w from to} { + if {$to < $from} { + set first [WordBack [$w get] $to] + set last [WordForward [$w get] $from] + $w icursor $first + } else { + set first [WordBack [$w get] $from] + set last [WordForward [$w get] $to] + $w icursor $last + } + $w selection range $first $last +} + +## WordBack, WordForward -- helper routines for WordSelect. +# +proc ttk::entry::WordBack {text index} { + if {[set pos [tcl_wordBreakBefore $text $index]] < 0} { return 0 } + return $pos +} +proc ttk::entry::WordForward {text index} { + if {[set pos [tcl_wordBreakAfter $text $index]] < 0} { return end } + return $pos +} + +## LineSelect -- Select the entire line. +# +proc ttk::entry::LineSelect {w _ _} { + variable State + $w selection range 0 end + $w icursor end +} + +### Button 2 binding procedures. +# + +## ScanMark -- Button-2 binding. +# Marks the start of a scan or primary transfer operation. +# +proc ttk::entry::ScanMark {w x} { + variable State + set State(scanX) $x + set State(scanIndex) [$w index @0] + set State(scanMoved) 0 +} + +## ScanDrag -- Button2 motion binding. +# +proc ttk::entry::ScanDrag {w x} { + variable State + + set dx [expr {$State(scanX) - $x}] + if {abs($dx) > $State(deadband)} { + set State(scanMoved) 1 + } + set left [expr {$State(scanIndex) + ($dx*$State(scanNum))/$State(scanDen)}] + $w xview $left + + if {$left != [set newLeft [$w index @0]]} { + # We've scanned past one end of the entry; + # reset the mark so that the text will start dragging again + # as soon as the mouse reverses direction. + # + set State(scanX) $x + set State(scanIndex) $newLeft + } +} + +## ScanRelease -- Button2 release binding. +# Do a primary transfer if the mouse has not moved since the button press. +# +proc ttk::entry::ScanRelease {w x} { + variable State + if {!$State(scanMoved)} { + $w instate {!disabled !readonly} { + $w icursor [ClosestGap $w $x] + catch {$w insert insert [::tk::GetSelection $w PRIMARY]} + } + } +} + +### Insertion and deletion procedures. +# + +## PendingDelete -- Delete selection prior to insert. +# If the entry currently has a selection, delete it and +# set the insert position to where the selection was. +# Returns: 1 if pending delete occurred, 0 if nothing was selected. +# +proc ttk::entry::PendingDelete {w} { + if {[$w selection present]} { + $w icursor sel.first + $w delete sel.first sel.last + return 1 + } + return 0 +} + +## Insert -- Insert text into the entry widget. +# If a selection is present, the new text replaces it. +# Otherwise, the new text is inserted at the insert cursor. +# +proc ttk::entry::Insert {w s} { + if {$s eq ""} { return } + PendingDelete $w + $w insert insert $s + See $w insert +} + +## Backspace -- Backspace over the character just before the insert cursor. +# If there is a selection, delete that instead. +# If the new insert position is offscreen to the left, +# scroll to place the cursor at about the middle of the window. +# +proc ttk::entry::Backspace {w} { + if {[PendingDelete $w]} { + See $w + return + } + set x [expr {[$w index insert] - 1}] + if {$x < 0} { return } + + $w delete $x + + if {[$w index @0] >= [$w index insert]} { + set range [$w xview] + set left [lindex $range 0] + set right [lindex $range 1] + $w xview moveto [expr {$left - ($right - $left)/2.0}] + } +} + +## Delete -- Delete the character after the insert cursor. +# If there is a selection, delete that instead. +# +proc ttk::entry::Delete {w} { + if {![PendingDelete $w]} { + $w delete insert + } +} + +#*EOF* diff --git a/evalkit_llava/lib/tk8.6/ttk/fonts.tcl b/evalkit_llava/lib/tk8.6/ttk/fonts.tcl new file mode 100644 index 0000000000000000000000000000000000000000..4f735a8beb059d00d095b33f425b938d1f89a780 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/ttk/fonts.tcl @@ -0,0 +1,154 @@ +# +# Font specifications. +# +# This file, [source]d at initialization time, sets up the following +# symbolic fonts based on the current platform: +# +# TkDefaultFont -- default for GUI items not otherwise specified +# TkTextFont -- font for user text (entry, listbox, others) +# TkFixedFont -- standard fixed width font +# TkHeadingFont -- headings (column headings, etc) +# TkCaptionFont -- dialog captions (primary text in alert dialogs, etc.) +# TkTooltipFont -- font to use for tooltip windows +# TkIconFont -- font to use for icon captions +# TkMenuFont -- used to use for menu items +# +# In Tk 8.5, some of these fonts may be provided by the TIP#145 implementation +# (On Windows and Mac OS X as of Oct 2007). +# +# +++ Platform notes: +# +# Windows: +# The default system font changed from "MS Sans Serif" to "Tahoma" +# in Windows XP/Windows 2000. +# +# MS documentation says to use "Tahoma 8" in Windows 2000/XP, +# although many MS programs still use "MS Sans Serif 8" +# +# Should use SystemParametersInfo() instead. +# +# Mac OSX / Aqua: +# Quoth the Apple HIG: +# The _system font_ (Lucida Grande Regular 13 pt) is used for text +# in menus, dialogs, and full-size controls. +# [...] Use the _view font_ (Lucida Grande Regular 12pt) as the default +# font of text in lists and tables. +# [...] Use the _emphasized system font_ (Lucida Grande Bold 13 pt) +# sparingly. It is used for the message text in alerts. +# [...] The _small system font_ (Lucida Grande Regular 11 pt) [...] +# is also the default font for column headings in lists, for help tags, +# and for small controls. +# +# Note that the font for column headings (TkHeadingFont) is +# _smaller_ than the default font. +# +# There does not appear to be any recommendations for fixed-width fonts. +# +# X11: +# "Classic" look used Helvetica bold for everything except +# for entry widgets, which use Helvetica medium. +# Most other toolkits use medium weight for all UI elements, +# which is what we do now. +# +# Font size specified in pixels on X11, not points. +# This is Theoretically Wrong, but in practice works better; using +# points leads to huge inconsistencies across different servers. +# + +namespace eval ttk { + +variable tip145 [catch {font create TkDefaultFont}] +catch {font create TkTextFont} +catch {font create TkHeadingFont} +catch {font create TkCaptionFont} +catch {font create TkTooltipFont} +catch {font create TkFixedFont} +catch {font create TkIconFont} +catch {font create TkMenuFont} +catch {font create TkSmallCaptionFont} + +if {!$tip145} { +variable F ;# miscellaneous platform-specific font parameters +switch -- [tk windowingsystem] { + win32 { + # In safe interps there is no osVersion element. + if {[info exists tcl_platform(osVersion)]} { + if {$tcl_platform(osVersion) >= 5.0} { + set F(family) "Tahoma" + } else { + set F(family) "MS Sans Serif" + } + } else { + if {[lsearch -exact [font families] Tahoma] >= 0} { + set F(family) "Tahoma" + } else { + set F(family) "MS Sans Serif" + } + } + set F(size) 8 + + font configure TkDefaultFont -family $F(family) -size $F(size) + font configure TkTextFont -family $F(family) -size $F(size) + font configure TkHeadingFont -family $F(family) -size $F(size) + font configure TkCaptionFont -family $F(family) -size $F(size) \ + -weight bold + font configure TkTooltipFont -family $F(family) -size $F(size) + font configure TkFixedFont -family Courier -size 10 + font configure TkIconFont -family $F(family) -size $F(size) + font configure TkMenuFont -family $F(family) -size $F(size) + font configure TkSmallCaptionFont -family $F(family) -size $F(size) + } + aqua { + set F(family) "Lucida Grande" + set F(fixed) "Monaco" + set F(menusize) 14 + set F(size) 13 + set F(viewsize) 12 + set F(smallsize) 11 + set F(labelsize) 10 + set F(fixedsize) 11 + + font configure TkDefaultFont -family $F(family) -size $F(size) + font configure TkTextFont -family $F(family) -size $F(size) + font configure TkHeadingFont -family $F(family) -size $F(smallsize) + font configure TkCaptionFont -family $F(family) -size $F(size) \ + -weight bold + font configure TkTooltipFont -family $F(family) -size $F(smallsize) + font configure TkFixedFont -family $F(fixed) -size $F(fixedsize) + font configure TkIconFont -family $F(family) -size $F(size) + font configure TkMenuFont -family $F(family) -size $F(menusize) + font configure TkSmallCaptionFont -family $F(family) -size $F(labelsize) + } + default - + x11 { + if {![catch {tk::pkgconfig get fontsystem} F(fs)] && $F(fs) eq "xft"} { + set F(family) "sans-serif" + set F(fixed) "monospace" + } else { + set F(family) "Helvetica" + set F(fixed) "courier" + } + set F(size) -12 + set F(ttsize) -10 + set F(capsize) -14 + set F(fixedsize) -12 + + font configure TkDefaultFont -family $F(family) -size $F(size) + font configure TkTextFont -family $F(family) -size $F(size) + font configure TkHeadingFont -family $F(family) -size $F(size) \ + -weight bold + font configure TkCaptionFont -family $F(family) -size $F(capsize) \ + -weight bold + font configure TkTooltipFont -family $F(family) -size $F(ttsize) + font configure TkFixedFont -family $F(fixed) -size $F(fixedsize) + font configure TkIconFont -family $F(family) -size $F(size) + font configure TkMenuFont -family $F(family) -size $F(size) + font configure TkSmallCaptionFont -family $F(family) -size $F(ttsize) + } +} +unset -nocomplain F +} + +} + +#*EOF* diff --git a/evalkit_llava/lib/tk8.6/ttk/menubutton.tcl b/evalkit_llava/lib/tk8.6/ttk/menubutton.tcl new file mode 100644 index 0000000000000000000000000000000000000000..f98a5daa93ee5529097a7953da94b4666251cb95 --- /dev/null +++ b/evalkit_llava/lib/tk8.6/ttk/menubutton.tcl @@ -0,0 +1,233 @@ +# +# Bindings for Menubuttons. +# +# Menubuttons have three interaction modes: +# +# Pulldown: Press menubutton, drag over menu, release to activate menu entry +# Popdown: Click menubutton to post menu +# Keyboard: or accelerator key to post menu +# +# (In addition, when menu system is active, "dropdown" -- menu posts +# on mouse-over. Ttk menubuttons don't implement this). +# +# For keyboard and popdown mode, we hand off to tk_popup and let +# the built-in Tk bindings handle the rest of the interaction. +# +# ON X11: +# +# Standard Tk menubuttons use a global grab on the menubutton. +# This won't work for Ttk menubuttons in pulldown mode, +# since we need to process the final event, +# and this might be delivered to the menu. So instead we +# rely on the passive grab that occurs on