#!/bin/sh
# the next line restarts using wish \
exec wish8.0jp "$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.4 1999/04/08 01:24:53 m-hirano Exp $

eval destroy [winfo child .]
wm title . "Widget Demonstration"
set widgetDemo 1

# setup fonts, kinsoku
if {[info commands kanji] != {}} {
    if {$tcl_platform(platform) == "windows"} {
	foreach p {10 12 14 18 24} {
	    font create @kanji${p} -copy [list {$B#M#S(B $B#P%4%7%C%/(B} $p]
	    font create @kanji${p}b -copy [list {$B#M#S(B $B#P%4%7%C%/(B} $p bold]
	    font create @kanji${p}bi -copy [list {$B#M#S(B $B#P%4%7%C%/(B} $p bold italic]
	}
    } else {
	set aSize(10) 10
	set aSize(12) 13
	set aSize(14) 13
	set aSize(18) 15
	set aSize(24) 23
	foreach p {10 12 14 18 24} {
	    font create @kanji$p -charset jisx0208.1983 -size $aSize($p)
	    font create @kanji${p}b -charset jisx0208.1983 -size $aSize($p) -weight bold
	    font create @kanji${p}bi -charset jisx0208.1983 -size $aSize($p) -weight bold -slant italic
	}
    }
    font create Helvetica10 -compound {{Helvetica 10} @kanji10}
    font create Courier12bolditalic -compound {{Courier 12 bold italic} @kanji12bi}
    font create Helvetica12 -compound {{Helvetica 12} @kanji12}
    font create Courier14bold -compound {{Courier 14 bold} @kanji14b}
    font create Helvetica14 -compound {{Helvetica 14} @kanji14}
    font create Helvetica18 -compound {{Helvetica 18} @kanji18}
    font create Helvetica18bold -compound {{Helvetica 18 bold} @kanji18b}
    font create Helvetica24 -compound {{Helvetica 24} @kanji24}
    font create Helvetica24bold -compound {{Helvetica 24 bold} @kanji24b}

    kinsoku add begin \
	"$B$!(B" "$B$#(B" "$B$%(B" "$B$'(B" "$B$)(B" "$B$c(B" "$B$e(B" "$B$g(B" "$B$C(B" \
	"$B%!(B" "$B%#(B" "$B%%(B" "$B%'(B" "$B%)(B" "$B%c(B" "$B%e(B" "$B%g(B" "$B%C(B" \
	"$B!<(B"
    kinsoku add end \
	"\""
} else {
    font create Helvetica10 -family Helvetica -size 10
    font create Courier12bolditalic -family Courier -size 12 -weight bold -slant italic
    font create Helvetica12 -family Helvetica -size 12
    font create Courier14bold -family Courier -size 14 -weight bold
    font create Helvetica14 -family Helvetica -size 14
    font create Helvetica18 -family Helvetica -size 18
    font create Helvetica18bold -family Helvetica -size 18 -weight bold
    font create Helvetica24 -family Helvetica -size 24
    font create Helvetica24bold -family Helvetica -size 24 -weight bold
}
#----------------------------------------------------------------
# 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.
#----------------------------------------------------------------

set font {Helvetica14}
menu .menuBar -tearoff 0
.menuBar add cascade -menu .menuBar.file -label "File" -underline 0
menu .menuBar.file -tearoff 0

# On the Mac use the specia .apple menu for the about item
if {$tcl_platform(platform) == "macintosh"} {
    .menuBar add cascade -menu .menuBar.apple
    menu .menuBar.apple -tearoff 0
    .menuBar.apple add command -label "About..." -command "aboutBox"
} else {
    .menuBar.file add command -label "About..." -command "aboutBox" \
	-underline 0 -accelerator "<F1>"
    .menuBar.file add sep
}

.menuBar.file add command -label "Quit" -command "exit" -underline 0 \
    -accelerator "Meta-Q"
. configure -menu .menuBar
bind . <F1> aboutBox

# Create Lang Menu
.menuBar add cascade -menu .menuBar.lang -label "Lang" -underline 0
menu .menuBar.lang -tearoff 0
foreach lang {{English {}} {Japanese jp}} {
    .menuBar.lang add radiobutton -label [lindex $lang 0] \
	    -variable demoLang -value [lindex $lang 1] \
	    -command "setContents" -underline 0
}
# default language
set demoLang jp

# select/switch by language
proc langSel {defaultValue jpValue} {
    global demoLang
    if {$demoLang == "jp"} {
	return $jpValue
    }
    return $defaultValue
}
proc langSwitch {defaultCode jpCode} {
    uplevel [langSel $defaultCode $jpCode]
}
# select by japanized or not.
proc jp&orig {jp orig} {
    if { [ string length [ info commands kanji ] ] <= 0 } {
        return $orig
    } else {
        return $jp
    }
}

frame .statusBar
label .statusBar.lab -text "   " -relief sunken -bd 1 \
    -font Helvetica10 -anchor w
label .statusBar.foo -width 8 -relief sunken -bd 1 \
    -font Helvetica10 -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

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 60 -height 30 -font $font \
    -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 {Helvetica18bold}

# 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.0 end
    .t config -cursor xterm
    .statusBar.lab config -text ""
}
.t tag bind demo <Motion> {
    set newLine [.t index {@%x,%y linestart}]
    if {[string compare $newLine $lastLine] != 0} {
	.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.

proc setContents {} {
    .t configure -state normal
    .t delete 1.0 end
    langSwitch {
.t insert end "Tk Widget Demonstrations\n" title
.t insert end {
This application provides a front end for several short scripts that demonstrate what you can do with Tk widgets.  Each of the numbered lines below describes a demonstration;  you can click on it to invoke the demonstration.  Once the demonstration window appears, you can click the "See Code" button to see the Tcl/Tk code that created the demonstration.  If you wish, you can edit the code and click the "Rerun Demo" button in the code window to reinvoke the demonstration with the modified code.

}
.t insert end "Labels, buttons, checkbuttons, and radiobuttons" title
.t insert end " \n " {demospace}
.t insert end "1. Labels (text and bitmaps)." {demo demo-label}
.t insert end " \n " {demospace}
.t insert end "2. Buttons." {demo demo-button}
.t insert end " \n " {demospace}
.t insert end "3. Checkbuttons (select any of a group)." {demo demo-check}
.t insert end " \n " {demospace}
.t insert end "4. Radiobuttons (select one of a group)." {demo demo-radio}
.t insert end " \n " {demospace}
.t insert end "5. A 15-puzzle game made out of buttons." {demo demo-puzzle}
.t insert end " \n " {demospace}
.t insert end "6. Iconic buttons that use bitmaps." {demo demo-icon}
.t insert end " \n " {demospace}
.t insert end "7. Two labels displaying images." {demo demo-image1}
.t insert end " \n " {demospace}
.t insert end "8. A simple user interface for viewing images." \
    {demo demo-image2}
.t insert end " \n " {demospace}

.t insert end \n {} "Listboxes" title
.t insert end " \n " {demospace}
.t insert end "1. 50 states." {demo demo-states}
.t insert end " \n " {demospace}
.t insert end "2. Colors: change the color scheme for the application." \
	{demo demo-colors}
.t insert end " \n " {demospace}
.t insert end "3. A collection of famous sayings." {demo demo-sayings}
.t insert end " \n " {demospace}

.t insert end \n {} "Entries" title
.t insert end " \n " {demospace}
.t insert end "1. Without scrollbars." {demo demo-entry1}
.t insert end " \n " {demospace}
.t insert end "2. With scrollbars." {demo demo-entry2}
.t insert end " \n " {demospace}
.t insert end "3. Simple Rolodex-like form." {demo demo-form}
.t insert end " \n " {demospace}

.t insert end \n {} "Text" title
.t insert end " \n " {demospace}
.t insert end "1. Basic editable text." {demo demo-text}
.t insert end " \n " {demospace}
.t insert end "2. Text display styles." {demo demo-style}
.t insert end " \n " {demospace}
.t insert end "3. Hypertext (tag bindings)." {demo demo-bind}
.t insert end " \n " {demospace}
.t insert end "4. A text widget with embedded windows." {demo demo-twind}
.t insert end " \n " {demospace}
.t insert end "5. A search tool built with a text widget." {demo demo-search}
.t insert end " \n " {demospace}

.t insert end \n {} "Canvases" title
.t insert end " \n " {demospace}
.t insert end "1. The canvas item types." {demo demo-items}
.t insert end " \n " {demospace}
.t insert end "2. A simple 2-D plot." {demo demo-plot}
.t insert end " \n " {demospace}
.t insert end "3. Text items in canvases." {demo demo-ctext}
.t insert end " \n " {demospace}
.t insert end "4. An editor for arrowheads on canvas lines." {demo demo-arrow}
.t insert end " \n " {demospace}
.t insert end "5. A ruler with adjustable tab stops." {demo demo-ruler}
.t insert end " \n " {demospace}
.t insert end "6. A building floor plan." {demo demo-floor}
.t insert end " \n " {demospace}
.t insert end "7. A simple scrollable canvas." {demo demo-cscroll}
.t insert end " \n " {demospace}

.t insert end \n {} "Scales" title
.t insert end " \n " {demospace}
.t insert end "1. Vertical scale." {demo demo-vscale}
.t insert end " \n " {demospace}
.t insert end "2. Horizontal scale." {demo demo-hscale}
.t insert end " \n " {demospace}

.t insert end \n {} "Menus" title
.t insert end " \n " {demospace}
.t insert end "1. Menus and cascades." \
	{demo demo-menu}
.t insert end " \n " {demospace}
.t insert end "2. Menubuttons"\
	{demo demo-menubu}
.t insert end " \n " {demospace}

.t insert end \n {} "Common Dialogs" title
.t insert end " \n " {demospace}
.t insert end "1. Message boxes." {demo demo-msgbox}
.t insert end " \n " {demospace}
.t insert end "2. File selection dialog." {demo demo-filebox}
.t insert end " \n " {demospace}
.t insert end "3. Color picker." {demo demo-clrpick}
.t insert end " \n " {demospace}

.t insert end \n {} "Miscellaneous" title
.t insert end " \n " {demospace}
.t insert end "1. The built-in bitmaps." {demo demo-bitmap}
.t insert end " \n " {demospace}
.t insert end "2. A dialog box with a local grab." {demo demo-dialog1}
.t insert end " \n " {demospace}
.t insert end "3. A dialog box with a global grab." {demo demo-dialog2}
.t insert end " \n " {demospace}
if {[info commands kanji] != {}} {
    .t insert end "4. Compound Font" {demo demo-cfont}
    .t insert end " \n " {demospace}
}
} {
.t insert end "Tk Widget $B%G%b%s%9%H%l!<%7%g%s(B\n" title
.t insert end {
$B$3$N%"%W%j%1!<%7%g%s$O!"(BTk Widget $B$rMQ$$$F$I$N$h$&$J$3$H$,$G$-$k$+$r<($9$?$a$N!"$$$/$D$+$N>.$5$J%9%/%j%W%H$KBP$9$k%U%m%s%H%(%s%I$rDs6!$7$F$$$^$9!#0J2<$K=gHV$K5s$2$i$l$F$$$k%G%b%s%9%H%l!<%7%g%s$r<B9T$9$k$K$O%^%&%9$G%/%j%C%/$7$F$/$@$5$$!#%G%b%s%9%H%l!<%7%g%s$N%&%#%s%I%&$,8=$l$k$H!"%G%b%s%9%H%l!<%7%g%s$r@8@.$7$?(B Tcl/TK $B$N%3!<%I$r8+$k$?$a$K!"(B"$B%3!<%I;2>H(B" $B%\%?%s$r%/%j%C%/$9$k$3$H$,$G$-$^$9!#$"$J$?$,K>$`$J$i!"$=$N%3!<%I$r=$@5$9$k$3$H$,$G$-$^$9!#=$@5$7$?%3!<%I$G%G%b%s%9%H%l!<%7%g%s$r:F<B9T$9$k$?$a$K$O!"%3!<%I$,=q$+$l$?%&%#%s%I%&$K$"$k(B"$B%G%b:F<B9T(B" $B%\%?%s$r%/%j%C%/$7$F$/$@$5$$!#(B

}
.t insert end "$B%i%Y%k(B, $B%\%?%s(B, $B%A%'%C%/%\%?%s(B, $B%i%8%*%\%?%s(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B%i%Y%k(B ($B%F%-%9%H!"%S%C%H%^%C%W(B)" {demo demo-label}
.t insert end " \n " {demospace}
.t insert end "2. $B%\%?%s(B" {demo demo-button}
.t insert end " \n " {demospace}
.t insert end "3. $B%A%'%C%/%\%?%s(B ($BJ#?t$rA*Br2DG=(B)" {demo demo-check}
.t insert end " \n " {demospace}
.t insert end "4. $B%i%8%*%\%?%s(B ($BG$0U$N0l$D$rA*Br2DG=(B)" {demo demo-radio}
.t insert end " \n " {demospace}
.t insert end "5. $B%\%?%s$G:n$i$l$?(B15-$B%Q%:%k%2!<%`(B" {demo demo-puzzle}
.t insert end " \n " {demospace}
.t insert end "6. $B%S%C%H%^%C%W$r;HMQ$7$?%"%$%3%s%\%?%s(B" {demo demo-icon}
.t insert end " \n " {demospace}
.t insert end "7. $B2hA|$rI=<($9$kFs$D$N%i%Y%k(B" {demo demo-image1}
.t insert end " \n " {demospace}
.t insert end "8. $B2hA|$r8+$k$?$a$N4JC1$J%f!<%6%$%s%?%U%'!<%9(B" \
    {demo demo-image2}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%j%9%H%\%C%/%9(B" title
.t insert end " \n " {demospace}
.t insert end "1. $BETF;I\8)(B" {demo demo-states}
.t insert end " \n " {demospace}
.t insert end "2. $B?'(B: $B%"%W%j%1!<%7%g%s$N$?$a$NG[?'$rJQ$($k(B" \
	{demo demo-colors}
.t insert end " \n " {demospace}
.t insert end "3. $B3J8@=8(B" {demo demo-sayings}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%(%s%H%j(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B%9%/%m!<%k%P!<$J$7(B" {demo demo-entry1}
.t insert end " \n " {demospace}
.t insert end "2. $B%9%/%m!<%k%P!<$"$j(B" {demo demo-entry2}
.t insert end " \n " {demospace}
.t insert end "3. $B4JC1$J%U%)!<%`(B" {demo demo-form}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%F%-%9%H(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B4pK\E*$J%F%-%9%H(B" {demo demo-text}
.t insert end " \n " {demospace}
.t insert end "2. $BI=<(%9%?%$%k(B" {demo demo-style}
.t insert end " \n " {demospace}
.t insert end "3. $B%O%$%Q!<%F%-%9%H(B($B%?%0%P%$%s%I(B)" {demo demo-bind}
.t insert end " \n " {demospace}
.t insert end "4. $B%&%#%s%I%&$rKd$a9~$s$@%F%-%9%H(B" {demo demo-twind}
.t insert end " \n " {demospace}
.t insert end "5. $B8!:w(B" {demo demo-search}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%-%c%s%P%9(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B%"%$%F%`$N7?(B" {demo demo-items}
.t insert end " \n " {demospace}
.t insert end "2. 2 $B<!85$N%W%m%C%H(B" {demo demo-plot}
.t insert end " \n " {demospace}
.t insert end "3. $B%F%-%9%H(B" {demo demo-ctext}
.t insert end " \n " {demospace}
.t insert end "4. $BLp0u$N7A(B" {demo demo-arrow}
.t insert end " \n " {demospace}
.t insert end "5. $B%k!<%i!<(B" {demo demo-ruler}
.t insert end " \n " {demospace}
.t insert end "6. $B%U%m%"%W%i%s(B" {demo demo-floor}
.t insert end " \n " {demospace}
.t insert end "7. $B%9%/%m!<%k2DG=$J%-%c%s%P%9(B" {demo demo-cscroll}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%9%1!<%k(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B?bD>(B" {demo demo-vscale}
.t insert end " \n " {demospace}
.t insert end "2. $B?eJ?(B" {demo demo-hscale}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%a%K%e!<(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B%a%K%e!<$H%+%9%1!<%I(B" \
	{demo demo-menu}
.t insert end " \n " {demospace}
.t insert end "2. $B%a%K%e!<%\%?%s(B"\
	{demo demo-menubu}
.t insert end " \n " {demospace}

.t insert end \n {} "$B%3%b%s%@%$%"%m%0(B" title
.t insert end " \n " {demospace}
.t insert end "1. $B%a%C%;!<%8%\%C%/%9(B" {demo demo-msgbox}
.t insert end " \n " {demospace}
.t insert end "2. $B%U%!%$%kA*Br%@%$%"%m%0(B" {demo demo-filebox}
.t insert end " \n " {demospace}
.t insert end "3. $B?'A*Br%@%$%"%m%0(B" {demo demo-clrpick}
.t insert end " \n " {demospace}

.t insert end \n {} "$B$=$NB>(B" title
.t insert end " \n " {demospace}
.t insert end "1. $BAH$_9~$_$N%S%C%H%^%C%W(B" {demo demo-bitmap}
.t insert end " \n " {demospace}
.t insert end "2. $B%b!<%@%k%@%$%"%m%0(B($B%m!<%+%k%0%i%V(B)" {demo demo-dialog1}
.t insert end " \n " {demospace}
.t insert end "3. $B%b!<%@%k%@%$%"%m%0(B($B%0%m!<%P%k%0%i%V(B)" {demo demo-dialog2}
.t insert end " \n " {demospace}
if {[info commands kanji] != {}} {
    .t insert end "4. $B%3%s%Q%&%s%I%U%)%s%H(B" {demo demo-cfont}
    .t insert end " \n " {demospace}
}
}
    .t configure -state disabled
}
setContents

.t configure -state disabled
focus .s

# 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
    wm title $w "Variable values"
    label $w.title -text [langSel "Variable values:" "$BJQ?tCM(B:"] -width 20 -anchor center \
	    -font {Helvetica18}
    pack $w.title -side top -fill x
    set len 1
    foreach i $args {
	if {[string length $i] > $len} {
	    set len [string length $i]
	}
    }
    foreach i $args {
	frame $w.$i
	label $w.$i.name -text "$i: " -width [expr $len + 2] -anchor w
	label $w.$i.value -textvar $i -anchor w
	pack $w.$i.name -side left
	pack $w.$i.value -side left -expand 1 -fill x
	pack $w.$i -side top -anchor w -fill x
    }
    button $w.ok -text OK -command "destroy $w" -default active
    bind $w <Return> "tkButtonInvoke $w.ok"
    pack $w.ok -side bottom -pady 2
}

# 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_library
    set tags [.t tag names $index]
    set i [lsearch -glob $tags demo-*]
    if {$i < 0} {
	return
    }
    set cursor [.t cget -cursor]
    .t configure -cursor watch
    update
    set demo [string range [lindex $tags $i] 5 end]
    uplevel [list source [file join $tk_library demos.jp $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 {
    global tk_library
    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 xterm
    } else {
	set demo [string range [lindex $tags $i] 5 end]
	.statusBar.lab config -text [langSel "Run the \"$demo\" sample program" "$B%5%s%W%k%W%m%0%i%`(B \"$demo\" $B$r<B9T(B"]
	set newcursor hand2
    }
    if [string compare $cursor $newcursor] {
	.t config -cursor $newcursor
    }
}


# 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_library
    set file [string range $w 1 end].tcl
    if ![winfo exists .code] {
	toplevel .code
	frame .code.buttons
	pack .code.buttons -side bottom -fill x
	button .code.buttons.dismiss -text [langSel Dismiss $BN;2r(B] \
            -default active -command "destroy .code"
	button .code.buttons.rerun -text [langSel "Rerun Demo" "$B:F<B9T(B"] -command {
	    eval [.code.text get 1.0 end]
	}
	pack .code.buttons.dismiss .code.buttons.rerun -side left \
	    -expand 1 -pady 2
	frame .code.frame
	pack  .code.frame -expand yes -fill both -padx 1 -pady 1
	text .code.text -height 40 -wrap word\
	    -xscrollcommand ".code.xscroll set" \
	    -yscrollcommand ".code.yscroll set" \
	    -setgrid 1 -highlightthickness 0 -pady 2 -padx 3
	scrollbar .code.xscroll -command ".code.text xview" \
	    -highlightthickness 0 -orient horizontal
	scrollbar .code.yscroll -command ".code.text yview" \
	    -highlightthickness 0 -orient vertical

	grid .code.text -in .code.frame -padx 1 -pady 1 \
	    -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
	grid .code.yscroll -in .code.frame -padx 1 -pady 1 \
	    -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
#	grid .code.xscroll -in .code.frame -padx 1 -pady 1 \
#	    -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
	grid rowconfig    .code.frame 0 -weight 1 -minsize 0
	grid columnconfig .code.frame 0 -weight 1 -minsize 0
    } else {
	wm deiconify .code
	raise .code
    }
    wm title .code "Demo code: [file join $tk_library demos.jp $file]"
    wm iconname .code $file
    set id [open [file join $tk_library demos.jp $file]]
    .code.text delete 1.0 end
    .code.text insert 1.0 [read $id]
    .code.text mark set insert 1.0
    close $id
}

# aboutBox --
#
#	Pops up a message box with an "about" message
#
proc aboutBox {} {
    tk_messageBox -icon info -type ok -title "About Widget Demo" -message \
"Tk widget demonstration\n\n\
Copyright (c) 1996-1997 Sun Microsystems, Inc."
}

