# setting menu for mkcommand, bell and language
#
# Copyright (C) 2004  G. Lamprecht, W. Lotz, R. Weibezahn; IWD, Bremen University


proc xv  {} {

proc xvcsel {sel} {
 global Wx mkcommand
 writescr0 $Wx.d.tt ""
 set mkcommand [string range $sel 0 10]
}

proc xvbsel {sel} {
 global Wx vv bell_level
 writescr0 $Wx.d.tt ""
 for {set i 1} {$i<=4} {incr i} {if {$sel==$vv(xveb$i)} {set bell_level $i}}
}

proc xvsbsel {sel} {
 global Wx vv textxscroll xtemTyh xvTyh
 writescr0 $Wx.d.tt ""
 for {set i 0} {$i<=2} {incr i} {if {$sel==$vv(xvesb$i)} {set textxscroll $i}}
 destroy .d; InsertTextFrame "" $xtemTyh "" "" ""
 destroy $Wx.d; InsertTextFrame $Wx $xvTyh "" "" ""
}

proc xvWxae {} {global Wx; destros $Wx; MkcmdSource; knoepfe; unlock_list}

proc xvlsel {sel} {global Wx; writescr0 $Wx.d.tt "language switch not yet installed"}


global vv Wx mkcommand xvsep bell_level xtem_path xvcsel_v xvlsel_v xvbsel_v xvsbsel_v
global button2end xvTyh textxscroll language

toplevel_init $Wx "$vv(xvvor)" 0 0;   set xvTyh 17


# top buttons

insertTopButtons $Wx xv_h xvWxae
button $Wx.a.g -text "$vv(ag)" -command {
  vstr_exec exit;# set xvbsel_v "$vv(xveb$bell_level)"
  writescr0 $Wx.d.tt "$vv(ausg1)\n\n mkcommand : $mkcommand\n bell_level: $bell_level\n" \
	" $vv(xvesb) $textxscroll ($vv(xvesb$textxscroll))"
}
pack configure $Wx.a.g -side left -padx 3 -pady 3
Bind3HF $Wx.a.g xv_grund $Wx.d.tt


# frame b for mkcommand

frame $Wx.b; pack configure $Wx.b -anchor w -pady 10 -padx 10
set mkcmdsel ""
frame $Wx.b.comm; pack configure $Wx.b.comm -side left
set foid [open_vst mkcommand.vst]
getscl $foid ein;  set xvsep [string index [string trim $ein] 0]
set l ""
while {[getscl $foid ein]>0} {
  set m [getvalue $ein [MkcmdTclVCol exit] $xvsep]
  if {[regexp {mkcommand.[1237]} $m]&&([info commands infox]=="")} {set m ""};#incompatible!
  if {$m!=""} {
    set t "[string range $m 0 10] :  [getvalue $ein 0 $xvsep]";#####wish
    if {$m==$mkcommand} {set xvcsel_v "$t"}
    if {[lsearch $l $t]==-1} {lappend l "$t"}
  }
}
close $foid
CreateLSBox $Wx.b.comm $vv(xvcel) top 80 9 2 xv_mksel $Wx.d.tt "" "$l" xvcsel "" xvWxae
if [winfo exists $Wx.b.cmd.$mkcmdsel] {$Wx.b.cmd.$mkcmdsel select}


# frame c for setting of bell, scrollbar and language

frame $Wx.c; pack configure $Wx.c -anchor w -pady 5
frame $Wx.c.bell; pack configure $Wx.c.bell -side left -padx 10
frame $Wx.c.scroll; pack configure $Wx.c.scroll -side left -padx 10
frame $Wx.c.lang; pack configure $Wx.c.lang -side left

# setting bell
if {$bell_level<1} {set bell_level 1}; if {$bell_level>4} {set bell_level 4}
set l ""; for {set i 1} {$i<=4} {incr i} {lappend l "$vv(xveb$i)"}
CreateLSBox $Wx.c.bell $vv(xveb) top 25 5 2 xv_bell $Wx.d.tt "" "$l" xvbsel "" xvWxae
set xvbsel_v "$vv(xveb$bell_level)"

# setting scrollbar
if {$textxscroll<0} {set textxscroll 0}; if {$textxscroll>2} {set textxscroll 2}
set sb ""; for {set i 0} {$i<=2} {incr i} {lappend sb "$vv(xvesb$i)"}
CreateLSBox $Wx.c.scroll $vv(xvesb) top 25 5 2 xv_scroll $Wx.d.tt "" "$sb" xvsbsel "" xvWxae
set xvsbsel_v "$vv(xvesb$textxscroll)"

# setting language
if {$mkcommand!="mkcommand.9"} {
#  set lsd [exec ls -x $xtem_path]
#  foreach d "$lsd" {if {[file isdirectory $d]&&[string match help_* $d]} {lappend l [string range $d 5 end]}}
#  lock
#  CreateLSBox $Wx.c.lang $vv(xvel) top 30 5 2 xv_language $Wx.d.tt "" $l xvlsel "" xvWxae
#  set xvlsel_v $language
}


InsertTextFrame $Wx $xvTyh "" "" ""
}
