#!/usr/local/bin/wish -file

#
# $Id: entryDialog,v 1.3 1993/06/15 02:17:06 mh Exp $
#

proc Lc {s} {return $s}

proc EntryDialog {type t msg} {
    global EntryDialog_Value
    catch {destroy .EntryDialog}
    $type $t -borderwidth 12 -relief raised
    message $t.msg -text $msg  -aspect 99999
    entry $t.e -width 50 -borderwidth 2 -relief sunken
    frame $t.bar 
    button $t.bar.ok -text [Lc "OK"] \
	-command "global EntryDialog_Value
	    set EntryDialog_Value \[$t.e get\]
	    destroy $t"
    button $t.bar.cancel -text [Lc "Cancel"] \
	-command "global EntryDialog_Value exitVal
	set exitVal 1; set EntryDialog_Value {}
	destroy $t"
    pack append $t.bar \
	$t.bar.ok {left padx 8 pady 8} \
	$t.bar.cancel {right padx 8 pady 8}
    pack append $t \
	$t.msg {top fillx} \
	$t.e {top padx 8 pady 8} \
	$t.bar {bottom fillx}
    bind . <ResizeRequest> {
	wm geometry . +%x+%y; update
    }
    bind $t <Visibility> "grab -global $t; focus $t.e"
    bind $t.e <Enter> "+focus $t.e"
    pack append . $t {expand fill}
}
set EntryDialog_Value ""
set exitVal 0
wm title . ""
set msg ""
foreach m $argv { append msg "$m " }
set msg [string trimright $msg " "]
EntryDialog frame .ed $msg
tkwait window .ed
puts stdout "$EntryDialog_Value"
exit $exitVal
