# Voreinstellungsmenü für Index-Erstellung
#
# Copyright (C) 2004  G. Lamprecht, W. Lotz, R. Weibezahn; IWD, Bremen University

proc iv  {} {

proc ivanzeige {s1} {
  global vv Wi intext index inoptions dirprefix main_file texpostind ivFoc
  set cmd [lindex $index 0]
  if [winfo exists $Wi.b.ad] {
    if {$cmd==""}	{$Wi.b.ad configure -text "$vv(ivbad1)"} \
    else		{$Wi.b.ad configure -text "$vv(ivbad2)  $intext"}
  }
  if {($s1=="disp")&&($ivFoc!=0)} {ivopt}
  $Wi.cb delete 0 end; $Wi.cb insert end "$inoptions"
  if {$s1!=""} {
    set t "$s1\n\n$intext\n\n $vv(ausg2)   $index\n $vv(ausg3)   $inoptions"; set opteval "\n"
    if {$dirprefix==""} {set mainfile $main_file} else {set mainfile [fileName $main_file]}
    if {([string first {$mainfile} "$inoptions"]>=0)&&("$mainfile"!="")} {
      regsub -all {\$mainfile} "$inoptions" $mainfile opteval
      set opteval " $vv(ausg4)  $opteval\n"
    }
    writescr0 $Wi.d.tt "$t\n$opteval\n texpostind: $texpostind\n"
  }
}

proc ivsel {s} {
 global Wi vv ivsep
 ivfocus $Wi.d.tt; set_index_vars "$ivsep" "$s"; ivanzeige "$vv(iv1)"; knoepfe
}

proc ivfocus {w} {global Wi ivFoc; if {$ivFoc==1} {ivopt}; if {$w!=""} {focus $w} {Focus $Wi}}

proc ivopt {} {
  global Wi vv inoptions ivFoc
  set inoptions [$Wi.cb get]; writescr0 $Wi.d.tt "$vv(aus4)\n $inoptions\n"
  set ivFoc 0
}

proc ivWiae {} {global Wi; ivfocus ""; destros $Wi; knoepfe; unlock_list}


global vv Wi intext ivsep ivFoc

toplevel_init $Wi "$vv(ivvor)" 0 0;  set tyh 18


# Bereich a fuer erste Buttons

insertTopButtons $Wi iv_h ivWiae
button $Wi.a.g -text "$vv(ag)" -command \
	{ivfocus $Wi.d.tt; vstr_index; ivanzeige "$vv(ausg1)"; knoepfe}
Bind3HF $Wi.a.g iv_grund $Wi.d.tt
pack configure $Wi.a.g -side left -padx 3 -pady 3


# Bereich bv fuer eigene Einstellungen

frame  $Wi.bv;  pack configure $Wi.bv -pady 13 -anchor w
label  $Wi.bv.dv -text "$vv(bvdv)" -width 23 -anchor w
Bind3HF $Wi.bv.dv z_voreinst1 $Wi.d.tt
button $Wi.bv.va -text "$vv(bvva)" -command {ivfocus ""; ivanzeige "$vv(aus0)"}
Bind3HF $Wi.bv.va z_voreinst1 $Wi.d.tt
pack configure $Wi.bv.dv $Wi.bv.va -side left


# Bereich b fuer Anzeigen

frame $Wi.b; pack configure $Wi.b -anchor w
label $Wi.b.ad -width 90 -anchor w; pack configure $Wi.b.ad -anchor w
Bind3HF $Wi.b.ad iv_anzeig $Wi.d.tt


# Bereich c fuer Wechsel

frame $Wi.c; pack configure $Wi.c -anchor w
frame $Wi.c.ipp; pack configure $Wi.c.ipp -pady 1 -anchor e;#makeindex program
frame $Wi.c.ira; pack configure $Wi.c.ira -pady 1 -anchor e;#makeindex after Tex automatically

set ivsep [getsep index.vst]
CreateLSBox $Wi.c.ipp $vv(ivcl) left 56 8 2 iv_progsel $Wi.d.tt \
	$ivsep [vst2list index.vst 1 $ivsep "$intext" ivsel_v] ivsel "" ivWiae
if ![winfo exists $Wi.c.ipp.f.f.li] {destroy $Wi.b}
CreateRBBox $Wi.c.ira $vv(ivcr) "" left 45 2 iv_texpost $Wi.d.tt texpostind \
	{ivanzeige disp; ivfocus $Wi.d.tt} ivWiae ""

# Ausgabe und Veraendern des Optionen-Strings

label $Wi.ca -anchor sw -text "$vv(ivca)"; pack configure $Wi.ca -anchor sw -ipady 5
Bind3HF $Wi.ca iv_optedi $Wi.d.tt
entry $Wi.cb -width 80 -relief sunken;  pack configure $Wi.cb -anchor nw -padx 4
bind  $Wi.cb <Button-1> {ivfocus $Wi.cb; set ivFoc 1}
Bind3HF $Wi.cb iv_optedi $Wi.d.tt
bind  $Wi.cb <Return> {ivopt; ivfocus $Wi.d.tt}


InsertTextFrame $Wi $tyh "" "" ""

ivanzeige ""; set ivFoc 0
}
