#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"

# 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.
#
# RCS: @(#) $Id: widget,v 1.9.2.3 2007/11/09 06:48:32 das Exp $

eval destroy [winfo child .]
wm title . "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 . "tkWidgetDemo"
}

array set widgetFont {
    main   {Helvetica 12}
    bold   {Helvetica 12 bold}
    title  {Helvetica 18 bold}
    status {Helvetica 10}
    vars   {Helvetica 14}
}

set widgetDemo 1
set font $widgetFont(main)

#----------------------------------------------------------------
# The code below create 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

if {[tk windowingsystem] ne "classic" && [tk windowingsystem] ne "aqua"} {
    .menuBar add cascade -menu .menuBar.file -label "File" -underline 0
    menu .menuBar.file -tearoff 0
    .menuBar.file add command -label "About..." -command "tkAboutDialog" \
	-underline 0 -accelerator "<F1>"
    .menuBar.file add sep
    .menuBar.file add command -label "Quit" -command "exit" -underline 0 \
	-accelerator "Meta-Q"
    bind . <F1> tkAboutDialog
}

. configure -menu .menuBar

frame .statusBar
label .statusBar.lab -text "   " -relief sunken -bd 1 \
	-font $widgetFont(status) -anchor w
label .statusBar.foo -width 8 -relief sunken -bd 1 \
	-font $widgetFont(status) -anchor w
pack .statusBar.lab -side left -padx 2 -expand yes -fill both
pack .statusBar.foo -side left -padx 2
pack .statusBar -side bottom -fill x -pady 2

set textheight 30
catch {
    set textheight [expr {
	([winfo screenheight .] - 200) /
	[font metrics $widgetFont(main) -displayof . -linespace]
    }]
}

frame .textFrame
scrollbar .s -orient vertical -command {.t yview} -highlightthickness 0 \
    -takefocus 1
pack .s -in .textFrame -side right -fill y
text .t -yscrollcommand {.s set}  -wrap word  -width 70  -height $textheight \
	-font $widgetFont(main)  -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

# 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 $widgetFont(title)
.t tag configure bold  -font $widgetFont(bold)

# 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
    .t tag configure hot -foreground red -underline 1
}
.t tag bind demo <ButtonRelease-1> {
    invoke [.t index {@%x,%y}]
}
set lastLine ""
.t tag bind demo <Enter> {
    set lastLine [.t index {@%x,%y linestart}]
    .t tag add hot "$lastLine +1 chars" "$lastLine lineend -1 chars"
    .t config -cursor hand2
    showStatus [.t index {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}]
}
.t tag bind demo <Leave> {
    .t tag remove hot 1.x {@%x,%y}