#!/usr/local/bin/wish -f
#
# 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 auto-loaded by Tcl
# when they are needed.  To find the code for a particular
# demo, look below for the procedure that's invoked by its menu
# entry, then grep for the file that contains the procedure
# definition.

#set auto_path "$tk_library/demos $auto_path"

# msg_kanji_font: bZ[W\p
# kanji_font: ftHg̊tHg
set msg_kanji_font -*--24-*-jisx0208.1983-0
set kanji_font -*--16-*-jisx0208.1983-0

option add "*kanjiFont" $kanji_font startupFile

set pwd [exec pwd]
set auto_path "$pwd $auto_path"
wm title . "Widget Demonstration"

#-------------------------------------------------------
# The code below create the main window, consisting of a
# menu bar and a message explaining the basic operation
# of the program.
#-------------------------------------------------------

frame .menu -relief raised -borderwidth 1
message .msg -font -Adobe-times-medium-r-normal--*-180* \
	-kanjifont $msg_kanji_font \
	-relief raised -width 600 \
	-borderwidth 1 \
	-text "̃AvP[V Tk c[Lbg񋟂 widget \
fXg[VłB\
̃j[ widget ̃^CvɂĕĂ܂B\
ej[ɂ͂ꂼ widget ɂĂ̈܂\
ȏ̃fĂ܂B\
f𓮂ɂ͏̃j[{^̏Ń}EX̃{^1 ({^) A\
̂܂܃}EX𓮂Ă݂ڂ܂ŃhbOĂ{^𗣂ĂB

̃fIɂ́ȗvj[́uIvIłB"

pack .menu -side top -fill x
pack .msg -side bottom -expand yes -fill both

#-------------------------------------------------------
# The code below creates all the menus, which invoke procedures
# to create particular demonstrations of various widgets.
#-------------------------------------------------------

menubutton .menu.button -text "x/{^" -menu .menu.button.m \
    -underline 0
menu .menu.button.m
.menu.button.m add command -label "x" -command "mkLabel" -underline 0
.menu.button.m add command -label "{^" -command "mkButton" -underline 0
.menu.button.m add command -label "`FbN{^" -command "mkCheck" \
    -underline 0
.menu.button.m add command -label "WI{^" -command "mkRadio" \
    -underline 0
.menu.button.m add command -label "15-pY" -command "mkPuzzle" -underline 0
.menu.button.m add command -label "ACR{^" -command "mkIcon" \
    -underline 0

menubutton .menu.listbox -text "Xg" -menu .menu.listbox.m \
	-underline 0
menu .menu.listbox.m
.menu.listbox.m add command -label "s{" -command mkListbox -underline 0
.menu.listbox.m add command -label "F" -command mkListbox2 -underline 0
.menu.listbox.m add command -label "i" -command mkListbox3 \
    -underline 0

menubutton .menu.entry -text "Gg" -menu .menu.entry.m \
	-underline 0
menu .menu.entry.m
.menu.entry.m add command -label "XN[o[Ȃ" -command mkEntry \
    -underline 4
.menu.entry.m add command -label "XN[o[t" -command mkEntry2 \
    -underline 0
.menu.entry.m add command -label "ȒPȃtH[" -command mkForm \
    -underline 0

menubutton .menu.text -text "eLXg" -menu .menu.text.m -underline 0
menu .menu.text.m
.menu.text.m add command -label "{IȃeLXg" -command mkBasic \
    -underline 0
.menu.text.m add command -label "\X^C" -command mkStyles \
    -underline 0
.menu.text.m add command -label "R}hƂ̌ bindings" -command mkTextBind \
    -underline 0
.menu.text.m add command -label "" -command mkTextSearch \
    -underline 0

menubutton .menu.scroll -text "XN[o[" -menu .menu.scroll.m \
	-underline 0
menu .menu.scroll.m
.menu.scroll.m add command -label "" -command mkListbox2 -underline 0
.menu.scroll.m add command -label "" -command mkEntry2 -underline 0

menubutton .menu.scale -text "XP[" -menu .menu.scale.m -underline 2
menu .menu.scale.m
.menu.scale.m add command -label "" -command mkVScale -underline 0
.menu.scale.m add command -label "" -command mkHScale -underline 0

menubutton .menu.canvas -text "LoX" -menu .menu.canvas.m \
	-underline 0
menu .menu.canvas.m
.menu.canvas.m add command -label "ACě^" -command mkItems -underline 0
.menu.canvas.m add command -label "2̃vbg" -command mkPlot -underline 0
.menu.canvas.m add command -label "eLXg" -command mkCanvText -underline 0
.menu.canvas.m add command -label "̌`" -command mkArrow -underline 0
.menu.canvas.m add command -label "[[" -command mkRuler -underline 0
.menu.canvas.m add command -label "XN[\ȃLoX" -command mkScroll \
    -underline 0
.menu.canvas.m add command -label "tAv" -command mkFloor \
    -underline 0

menubutton .menu.menu -text "j[" -menu .menu.menu.m -underline 0
menu .menu.menu.m
.menu.menu.m add command -label "ɂ" -command {puts stdout "ɂ"} \
    -accelerator Control+a -underline 6
bind .msg <Control-a> {puts stdout "ɂ"}
.menu.menu.m add command -label "悤Ȃ" -command {\
    puts stdout "悤Ȃ"} -accelerator Control+b -underline 6
bind .msg <Control-b> {puts stdout "悤Ȃ"}
.menu.menu.m add command -label "F̔wi" \
    -command {.msg config -bg "LightBlue1"} -underline 0
.menu.menu.m add command -label "eBAItj[ɂ" -command mkTear \
    -underline 0
.menu.menu.m add cascade -label "`FbN{^" -menu .menu.menu.m.check \
    -underline 0
.menu.menu.m add cascade -label "WI{^" -menu .menu.menu.m.radio \
    -underline 0
.menu.menu.m add command -bitmap @$tk_library/demos/bitmaps/pattern \
    -command {
	mkDialog .pattern {-text {ȂIj[̍ڂ̓eLXgł͂Ȃrbg}bv\Ă܂BȊO̓_ł͑̃j[ڂƕς܂B} -aspect 250} { {}}
    }

menu .menu.menu.m.check
.menu.menu.m.check add check -label "IC_" -variable oil
.menu.menu.m.check add check -label "gX~bV_" -variable trans
.menu.menu.m.check add check -label "u[L_" -variable brakes
.menu.menu.m.check add check -label "Cg_" -variable lights
.menu.menu.m.check add separator
.menu.menu.m.check add command -label "݂̒l\" \
    -command "showVars .menu.menu.dialog oil trans brakes lights"
.menu.menu.m.check invoke 1
.menu.menu.m.check invoke 3

menu .menu.menu.m.radio
.menu.menu.m.radio add radio -label "10 |Cg" -variable pointSize -value 10
.menu.menu.m.radio add radio -label "14 |Cg" -variable pointSize -value 14
.menu.menu.m.radio add radio -label "18 |Cg" -variable pointSize -value 18
.menu.menu.m.radio add radio -label "24 |Cg" -variable pointSize -value 24
.menu.menu.m.radio add radio -label "32 |Cg" -variable pointSize -value 32
.menu.menu.m.radio add sep
.menu.menu.m.radio add radio -label "[}" -variable style -value roman
.menu.menu.m.radio add radio -label "{[h" -variable style -value bold
.menu.menu.m.radio add radio -label "C^bN" -variable style -value italic
.menu.menu.m.radio add sep
.menu.menu.m.radio add command -label "݂̒l\" -command \
    "showVars .menu.menu.dialog pointSize style"
.menu.menu.m.radio invoke 1
.menu.menu.m.radio invoke 7

menubutton .menu.misc -text ̑ -menu .menu.misc.m -underline 1
menu .menu.misc.m
.menu.misc.m add command -label "[__CAO ([JOu)" -command {
    mkDialog .modal {-text {̃_CAO{bNX̓[_łBTk  "grab" R}hgpă_CAO{bNXŁu[JOuvĂ܂B̃OuɂăAvP[V̑̃EBhEł̓|C^֌W̃Cxg󂯎邱ƂłȂȂĂ܂B́uv{^ (邢̓^[L[) _CAO{bNX͏AȏԂɖ߂܂B} -aspect 250 -justify left} { {}}
    dpos .modal
    tkwait visibility .modal
    grab .modal
    tkwait window .modal
} -underline 0
.menu.misc.m add command -label "[__CAO (O[oOu)" -command {
    mkDialog .modal {-text {͕ʂ̃[_ȃ_CAO{bNXłB̏ꍇɂ́uO[oOuvgĂA̓fBXvCbNĂ܂̂ł̃_CAOȊÔǂ̃AvP[V̂ǂ̃EBhEɂ͂ł܂B́uv{^ (邢̓^[L[)_CAO{bNX͏AȏԂɖ߂܂B} -aspect 250 -justify left} { {}}
    dpos .modal
    tkwait visibility .modal
    grab -global .modal
    tkwait window .modal
} -underline 0
.menu.misc.m add command -label "gݍ݂̃rbg}bv" -command mkBitmaps \
	-underline 0
.menu.misc.m add command -label "I" -command "destroy ." -underline 0

pack .menu.button .menu.listbox .menu.entry .menu.text .menu.scroll \
	.menu.scale .menu.canvas .menu.menu .menu.misc -side left

# Set up for keyboard-based menu traversal

bind . <Any-FocusIn> {
    if {("%d" == "NotifyVirtual") && ("%m" == "NotifyNormal")} {
	focus .menu
    }
}
tk_menuBar .menu .menu.button .menu.listbox .menu.entry .menu.text \
	.menu.scroll .menu.scale .menu.canvas .menu.menu .menu.misc

# Position a dialog box at a reasonable place on the screen.

proc dpos w {
    wm geometry $w +300+300
}
