#!/usr/local/bin/wish
#======================================================================
#            Perl & Tcl/Tk visips batch model
#    Copyright (C) 1996 Takuya Nakayama <takuya-n@is.aist-nara.ac.jp>
#======================================================================
option add *background bisque
option add *activeBackground bisque2
option add *selectBackground cyan2
option add *highlightThickness 0
option add *padY 3
option add *padX 3


proc Call_TkV {} {
    global selected_file A_MODE E_DIR DataType Ziped

    if {$Ziped == 0} {
	set writer cat
    } else {
	set writer zcat
    }
    exec $writer $selected_file | $E_DIR/data_conv $DataType | $E_DIR/tk-visips.tcl -mode $A_MODE > /dev/null &
}

set E_DIR [file dirname $argv0]
set A_MODE default
set DataType b
set Ziped 0

source "$E_DIR/fileselecter.tcl"
set selected_file "visips.data"

entry .filename -relief sunken -bd 4 \
    -textvariable selected_file -width 50 \
    -xscrollcommand ".scr set"
pack .filename -fill x

scrollbar .scr -command ".filename xview" -orient horizontal
pack .scr -fill x

frame .m -relief raised -bd 2
pack .m -expand y -fill both

button .m.file -text "File" -command {SelectFile .fsel {Select File} 0}
button .m.run -text "Run" -command {Call_TkV}

menubutton .m.option -text "Option" -underline 0 \
    -menu .m.option.m -relief raised -bd 2
menu .m.option.m
.m.option.m add cascade -label "Read Mode" \
    -menu .m.option.m.mode
.m.option.m add cascade -label "File Type" \
    -menu .m.option.m.file

menu .m.option.m.mode
.m.option.m.mode add radiobutton -label "Batch" \
    -variable A_MODE -value 1
.m.option.m.mode add radiobutton -label "Semi-Interactive" \
    -variable A_MODE -value 3
.m.option.m.mode add radiobutton -label "Default" \
    -variable A_MODE -value default

menu .m.option.m.file
.m.option.m.file add radiobutton -label "Batch Model Type" \
    -variable DataType -value b
.m.option.m.file add radiobutton -label "Server Model Type" \
    -variable DataType -value s
.m.option.m.file add separator
.m.option.m.file add checkbutton -label "ZIP file" \
    -variable Ziped


pack .m.file .m.run .m.option\
    -side left

button .m.quit -text "Quit" -command "destroy ."
pack .m.quit -side right

update idletasks

wm maxsize . [lindex [wm maxsize .] 0] [winfo height .]
