# config.tcl
#
# Prozeduren, die die Konfiguration des Displays betreffen



###############################################################################
#
# parse_config
#
# Prozedur, die das Config-File einliest
#
# Parameter: keine
#
###############################################################################

proc parse_config { name } {

    global chart

    my_trace "Entering proc parse_config $name"

    # pruefe, ob Config-file existiert
    if { [file exists "~/.chartdisplay"] == 0 } {
        my_trace "No file ~/.chartdisplay found"
        dialog_config
    } else {
        my_trace "Found ~/.chartdisplay, open it..."
        set fileid [open "~/.chartdisplay" r]
        while { [eof $fileid] != 1 } {
            set line [gets $fileid]
            my_trace "Reading in $line"
            switch -regexp -- $line {
                {^[a-zA-Z]} { 
                    set paar [split $line =]
                    set descriptor [lindex $paar 0]
                    set value [lindex $paar 1]
                    my_trace "found $descriptor $value"
                    fill_in_config $name $descriptor $value
                }
            }
        }
        catch {close $fileid}
        my_trace "Closing the .chartdisplay File"

    }

    my_trace "Leaving parse_config"

}


###############################################################################
#
# fill_in_config
#
# Uebertragen der Werte aus dem Config-File in die Variablen
#
# Parameter: - name: ID der aktuellen Chart
#            - descriptor: Schluesselwort des Parameters
#            - value: Wert des Parameters
#
# Rueckgabewert: keiner
#
###############################################################################

proc fill_in_config { name descriptor value } {

    global chart

    my_trace "Entering proc fill_in_config $name $descriptor $value"
    
    # wenn ueberhaupt ein Wert eingetragen
    if { [string length $value] > 0 } {
        if { $chart(colormodel) == 1 } {
            switch -exact -- [string toupper $descriptor] {
                TOKEN_C { set chart(color,token_color) $value; set chart($name,color,token_color) $value }
                ACTIVE_EDGE_C { set chart(color,active_color) $value ; set chart($name,color,active_color) $value }
                PASSIVE_EDGE_C { set chart(color,passive_color) $value ; set chart($name,color,passive_color) $value }
                BLINK_C { set chart(color,blink_color) $value ; set chart($name,color,blink_color) $value }
                MARK_C { set chart(color,mark_color) $value ; set chart($name,color,mark_color) $value }
                DYE_C { set chart(color,dye_color) $value ; set chart($name,color,dye_color) $value }
            }
        } else {
            switch -exact -- [string toupper $descriptor] {
                TOKEN_BW { set chart(color,token_color) $value }
                ACTIVE_EDGE_C { set chart(color,active_color) $value }
                PASSIVE_EDGE_C { set chart(color,passive_color) $value }
                BLINK_C { set chart(color,blink_color) $value }
                TOKEN_BW { set chart(bw,token_color) $value ; set chart($name,color,token_color) $value }
                ACTIVE_EDGE_BW { set chart(bw,active_color) $value  ; set chart($name,color,active_color) $value }
                PASSIVE_EDGE_BW { set chart(bw,passive_color) $value  ; set chart($name,color,passive_color) $value }
                BLINK_BW { set chart(bw,blink_color) $value ; set chart($name,color,blink_color) $value }
                MARK_BW { set chart(bw,mark_color) $value ; set chart($name,color,mark_color) $value }
                DYE_BW { set chart(bw,dye_color) $value ; set chart($name,color,dye_color) $value }

            }
        }
        # keine Kommentare in switch statements!
        # 981127 Tokendistanz
        # 981130 Abstand nach unten

        switch -exact -- [string toupper $descriptor] {
            FONT { set chart(defaultfont) $value }
	    LINEWIDTH { set chart(defaultlinewidth) $value }
	    TOKENWIDTH { set chart(defaulttokenwidth) $value }
	    TOKENDIAMETER { set chart(defaulttokendiameter) $value }
            TOKENDISTANCE { set chart(default_minimum_space) $value }
            DOWNSPACE { set chart(downspace) $value }
	    STRETCHFACTOR { set chart(defaultstretchfactor) $value }
	    HEIGHT { set chart(defaultheight) $value }
	    WIDTH { set chart(defaultwidth) $value }
	    SCROLLHEIGHT { set chart(defaultscrollheight) $value }
	    SCROLLWIDTH { set chart(defaultscrollwidth) $value }
	    HEIGHTINCREMENT { set chart(defaultheightincrement) $value }
	    WIDTHINCREMENT { set chart(defaultwidthincrement) $value }
	    VERBOSE { set chart(verbose) $value }
	    BLINK { set chart(blink) $value }
            TRACE { set chart(chart_trace) $value; 
                if {$value == 1 } { trace_window }}
        }
    }

    my_trace "Leaving fill_in_config"

}

proc dialog_config { } {
    
    global chart

    my_trace "Entering proc dialog_config"

    set t [toplevel .dialog_config]
    wm title $t "Chart-Display"

    focus $t
    grab $t
    
    message $t.m -justify center -text "\n\nNo Chart-Display Configuration-File \n\n~/.chartdisplay \n\nfound !\n\nCreate a new one ?\n\n" -width 300

    set bb [ frame $t.bb ]
    button $bb.b1 -text "Yes" -command "create_new_config;destroy $t" -justify center -anchor c
    button $bb.b2 -text "No" -command "destroy $t" -justify center -anchor c
    pack $bb.b1 $bb.b2 -side left -ipadx 5 -ipady 5

    pack $t.m -side top
    pack $bb -side top

    tkwait window $t

    my_trace "Leaving dialog_config"

}

###############################################################################
#
# create_new_config
#
# schreibt ein neues Konfigurationsfile ~/.chartdisplay
#
# Parameter: keine
#
# Rueckgabewert: keiner
#
###############################################################################

proc create_new_config { } {

    global chart

    my_trace "Entering create_new_config"

    set fileid [open ~/.chartdisplay w ]
    puts $fileid "# Beispielfile fuer die moeglichen Konfigurationen des Chartdisplays"
    puts $fileid "#"
    puts $fileid "# die Reihenfolge der Schluesselworte ist egal"
    puts $fileid "#"
    puts $fileid "# Toggles"
    puts $fileid "VERBOSE=$chart(verbose)"
    puts $fileid "BLINK=$chart(blink)"
    puts $fileid "TRACE=$chart(chart_trace)\n"

    puts $fileid "# Farben\n"
    puts $fileid "# zuerst Definitionen fuer Schwarz-Weiss-Bildschirme"
    puts $fileid "TOKEN_BW=$chart(bw,token_color)"
    puts $fileid "ACTIVE_EDGE_BW=$chart(bw,active_color)"
    puts $fileid "PASSIVE_EDGE_BW=$chart(bw,passive_color)"
    puts $fileid "BLINK_BW=$chart(bw,blink_color)"
    puts $fileid "DYE_BW=$chart(bw,dye_color)"
    puts $fileid "MARK_BW=$chart(bw,mark_color)\n"
    puts $fileid "# Definitionen fuer Farb-Bildschirme"
    puts $fileid "TOKEN_C=$chart(color,token_color)"
    puts $fileid "ACTIVE_EDGE_C=$chart(color,active_color)"
    puts $fileid "PASSIVE_EDGE_C=$chart(color,passive_color)"
    puts $fileid "BLINK_C=$chart(color,blink_color)"
    puts $fileid "MARK_C=$chart(color,mark_color)\n"
    puts $fileid "DYE_C=$chart(color,dye_color)"

    puts $fileid "# diverse Defaults"
    puts $fileid "LINEWIDTH=$chart(defaultlinewidth)"
    puts $fileid "TOKENWIDTH=$chart(defaulttokenwidth)"
    puts $fileid "TOKENDIAMETER=$chart(defaulttokendiameter)"
    # 981127 Tokendistance
    puts $fileid "TOKENDISTANCE=$chart(default_minimum_space)"
    # 981130 Downspace
    puts $fileid "DOWNSPACE=$chart(downspace)"
    puts $fileid "STRETCHFACTOR=$chart(defaultstretchfactor)"
    puts $fileid "HEIGHT=$chart(defaultheight)"
    puts $fileid "WIDTH=$chart(defaultwidth)"
    puts $fileid "SCROLLHEIGHT=$chart(defaultscrollheight)"
    puts $fileid "SCROLLWIDTH=$chart(defaultscrollwidth)"
    puts $fileid "HEIGHTINCREMENT=$chart(defaultheightincrement)"
    puts $fileid "WIDTHINCREMENT=$chart(defaultwidthincrement)"
    puts $fileid "FONT=$chart(defaultfont)\n"
    # hier noch Workaround ueberlegen
    
    puts $fileid "# Printer-Name\n"
    puts $fileid "PRINTER=\n"
    puts $fileid "# Printer-File\n"
    puts $fileid "PRINT_FILE=test.ps"
    
    catch {close $fileid}
    
    my_trace "Leaving create_new_config"

}

proc set_popup_values { name } {
    
    global chart
    
    my_trace "Entering set_popup_values $name"

    # flag fuer aenderung
    set change 0

    # ueberpruefe, ob Aenderungen stattgefunden haben
    if { $chart(colormodel) == 1 } {
	if { [ string compare $chart(help,ac) $chart(color,active_color) ] != 0 } {
	    set change 1
	    set chart(color,active_color) $chart(help,ac)
	    set chart($name,color,active_color) $chart(help,ac)
	}
	
	if { [ string compare $chart(color,passive_color) $chart(help,pc) ] != 0 } {
	    set change 1
	    set chart(color,passive_color) $chart(help,pc)
	    set chart($name,color,passive_color) $chart(help,pc)
	}
	
	if { [ string compare $chart(color,blink_color) $chart(help,bc) ] != 0 } {
	    set change 1
	    set chart(color,blink_color) $chart(help,bc)
	    set chart($name,color,blink_color) $chart(help,bc)
	}

# 990520 DYE_COLOR
 	if { [ string compare $chart(color,dye_color) $chart(help,dc) ] != 0 } {
 	    set change 1
 	    set chart(color,dye_color) $chart(help,dc)
 	    set chart($name,color,dye_color) $chart(help,dc)
 	}

# 990528 MARK_COLOR
 	if { [ string compare $chart(color,mark_color) $chart(help,mc) ] != 0 } {
 	    set change 1
 	    set chart(color,mark_color) $chart(help,mc)
 	    set chart($name,color,mark_color) $chart(help,mc)
 	}

	
	if { [ string compare $chart(color,token_color) $chart(help,tc) ] != 0 } {
	    set change 1
	    set chart(color,token_color) $chart(help,tc)
	    set chart($name,color,token_color) $chart(help,tc)
	}
    } else {
	if { [ string compare $chart(help,ac) $chart(bw,active_color) ] != 0 } {
	    set change 1
	    set chart(bw,active_color) $chart(help,ac)
	    set chart($name,bw,active_color) $chart(help,ac)
	}
	
	if { [ string compare $chart(bw,passive_color) $chart(help,pc) ] != 0 } {
	    set change 1
	    set chart(bw,passive_color) $chart(help,pc)
	    set chart($name,bw,passive_color) $chart(help,pc)
	}
	
	if { [ string compare $chart(bw,blink_color) $chart(help,bc) ] != 0 } {
	    set change 1
	    set chart(bw,blink_color) $chart(help,bc)
	    set chart($name,bw,blink_color) $chart(help,bc)
	}

# 990520 DYE_COLOR	
 	if { [ string compare $chart(bw,dye_color) $chart(help,dc) ] != 0 } {
 	    set change 1
 	    set chart(bw,dye_color) $chart(help,dc)
 	    set chart($name,bw,dye_color) $chart(help,dc)
 	}

# 990528 MARK_COLOR	
 	if { [ string compare $chart(bw,mark_color) $chart(help,mc) ] != 0 } {
 	    set change 1
 	    set chart(bw,mark_color) $chart(help,mc)
 	    set chart($name,bw,mark_color) $chart(help,mc)
 	}

	if { [ string compare $chart(bw,token_color) $chart(help,tc) ] != 0 } {
	    set change 1
	    set chart(bw,token_color) $chart(help,tc)
	    set chart($name,bw,token_color) $chart(help,tc)
	}
    }

    if { [ string compare $chart(defaultfont) $chart(help,fn) ] != 0 } {
	set change 1
	set chart(defaultfont) $chart(help,fn)
	set chart($name,defaultfont) $chart(help,fn)
    }

    if { [ string compare $chart(defaultlinewidth) $chart(help,lw) ] != 0 } {
	set change 1
	set chart(defaultlinewidth) $chart(help,lw)
	set chart($name,defaultlinewidth) $chart(help,lw)
    }

    if { [ string compare $chart(defaulttokenwidth) $chart(help,tw) ] != 0 } {
	set change 1
	set chart(defaulttokenwidth) $chart(help,tw)
	set chart($name,defaulttokenwidth) $chart(help,tw)
    }

    if { [ string compare $chart(defaulttokendiameter) $chart(help,td) ] != 0 } {
	set change 1
	set chart(defaulttokendiameter) $chart(help,td)
	set chart($name,defaulttokendiameter) $chart(help,td)
    }

    # 981127 Tokendistance
    if { [ string compare $chart(default_minimum_space) $chart(help,tdi) ] != 0 } {
	set change 1
	set chart(default_minimum_space) $chart(help,tdi)
	set chart($name,default_minimum_space) $chart(help,tdi)
    }

    # 981130 Downspace
    if { [ string compare $chart(downspace) $chart(help,ds) ] != 0 } {
	set change 1
	set chart(downspace) $chart(help,ds)
	set chart($name,downspace) $chart(help,ds)
    }
    
    if { [ string compare $chart(defaultstretchfactor) $chart(help,sf) ] != 0 } {
	set change 1
        if { $chart(help,sf) > 10 } {
            set chart(help,sf) 10
            set chart($name,help,sf) 10
        }
	set chart(defaultstretchfactor) $chart(help,sf)
	set chart($name,defaultstretchfactor) $chart(help,sf)
    }

    if { [ string compare $chart(defaultheight) $chart(help,wh) ] != 0 } {
	set chart(defaultheight) $chart(help,wh)
	set chart($name,defaultheight) $chart(help,wh)
    }
    if { [ string compare $chart(defaultwidth) $chart(help,ww) ] != 0 } {
	set chart(defaultwidth) $chart(help,ww)
	set chart($name,defaultwidth) $chart(help,ww)
    }
    if { [ string compare $chart(defaultscrollheight) $chart(help,sh) ] != 0 } {

	set chart(defaultscrollheight) $chart(help,sh)
	set chart($name,defaultscrollheight) $chart(help,sh)
    }
    if { [ string compare $chart(defaultscrollwidth) $chart(help,sw) ] != 0 } {
	set chart(defaultscrollwidth) $chart(help,sw)
	set chart($name,defaultscrollwidth) $chart(help,sw)
    }
    if { [ string compare $chart(defaultheightincrement) $chart(help,hi) ] != 0 } {
	set chart(defaultheightincrement) $chart(help,hi)
	set chart($name,defaultheightincrement) $chart(help,hi)
    }
    if { [ string compare $chart(defaultwidthincrement) $chart(help,wi) ] != 0 } {
	set chart(defaultwidthincrement) $chart(help,wi)
	set chart($name,defaultwidthincrement) $chart(help,wi)
    }


    if { [ string compare $chart(verbose) $chart(help,v) ] != 0 } {
	set chart(verbose) $chart(help,v)
    }

    if { [ string compare $chart(blink) $chart(help,b) ] != 0 } {
	set chart(blink) $chart(help,b)
	set chart($name,blink) $chart(help,b)
    }

    if { [ string compare $chart(chart_trace) $chart(help,tr_wi)] != 0 } {
	set chart(chart_trace) $chart(help,tr_wi)
	if { $chart(chart_trace) == 1 } {
	    trace_window
	} else {
	    destroy .chart_trace
	}
    }

    # redraw, falls Aenderung
    if { $change == 1 } {
	redraw_chart $name allrules
        # 981130 Update die Window-Groessen, weil sie sich geaendert haben koennten
        set chart(help,sw) $chart(defaultscrollwidth)
        set chart(help,sh) $chart(defaultscrollheight)
    }

    my_trace "Leaving set_popup_values"

}


###############################################################################
#
# chart_config
#
# Aufbau des Konfigurationsdialogs
#
# Parameter: - name: ID des betreffenden Chart-Displays
#
# Rueckgabewert: keiner
#
###############################################################################

proc chart_config { name base } {

    global chart

    my_trace "Entering proc chart_config $name $base"
    
    if {$base == ""} {
        set base .config_dialog
    }
    if {[winfo exists $base]} {
        wm deiconify $base
	focus $base
	return
    }

    # Farbe oder b/w ?
    if { $chart(colormodel) == 1 } {
        set colors { blue red green white black yellow gray }
    } else {
        set colors { black white }
    }

    # definiere temporaere Variablen fuer die Menues
    set chart(help,lw) $chart(defaultlinewidth)
    set chart(help,tw) $chart(defaulttokenwidth)
    set chart(help,td) $chart(defaulttokendiameter)

    # 981127 Tokendistance
    set chart(help,tdi) $chart(default_minimum_space)
    
    # 981130 ABstand nach unten
    set chart(help,ds) $chart(downspace)

    set chart(help,sf) $chart(defaultstretchfactor)
    set chart(help,wh) $chart(defaultheight)
    set chart(help,ww) $chart(defaultwidth)
    set chart(help,sw) $chart(defaultscrollwidth)
    set chart(help,sh) $chart(defaultscrollheight)
    set chart(help,wi) $chart(defaultwidthincrement)
    set chart(help,hi) $chart(defaultheightincrement)
    set chart(help,v) $chart(verbose)
    set chart(help,b) $chart(blink)
    if { $chart(colormodel) == 1 } {
	set chart(help,ac) $chart(color,active_color)
	set chart(help,pc) $chart(color,passive_color)
	set chart(help,tc) $chart(color,token_color)
	set chart(help,bc) $chart(color,blink_color)
# 990520
	set chart(help,dc) $chart(color,dye_color)
# 990528
        set chart(help,mc) $chart(color,mark_color)
    } else {
	set chart(help,ac) $chart(bw,active_color)
	set chart(help,pc) $chart(bw,passive_color)
	set chart(help,tc) $chart(bw,token_color)
	set chart(help,bc) $chart(bw,blink_color)
# 990520
	set chart(help,dc) $chart(bw,dye_color)
# 990528
	set chart(help,mc) $chart(bw,mark_color)
    }

    set chart(help,fn) $chart(defaultfont)
    set chart(help,tr_wi) $chart(chart_trace)

    
    
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel
    wm focusmodel $base passive
    wm geometry $base 350x720+283+20
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm deiconify $base
    wm title $base "Chart Display: Configuration"
    label $base.lab18 \
	    -background #000000 -foreground #fefefe -padx 9 -pady 5 \
	    -relief raised -text {Color & Font} -width 51 
    frame $base.fra21 \
	    -borderwidth 2 -height 181 -width 363 
    frame $base.fra21.fra22 \
	    -borderwidth 2 -height 126 -width 168 
    label $base.fra21.fra22.lab24 \
	    -highlightthickness 2 -padx 9 -pady 3 -text {Active Edges} 
    label $base.fra21.fra22.lab25 \
	    -highlightthickness 2 -padx 9 -pady 3 -text {Passive Edges} 
    label $base.fra21.fra22.lab26 \
	    -highlightthickness 2 -padx 9 -pady 3 -text Tokens 
    label $base.fra21.fra22.lab27 \
	    -highlightthickness 2 -padx 9 -pady 3 -text Blinking 
# 990520
    label $base.fra21.fra22.lab28 \
	    -highlightthickness 2 -padx 9 -pady 3 -text Dying
# 990528
    label $base.fra21.fra22.lab29 \
	    -highlightthickness 2 -padx 9 -pady 3 -text Marking
    label $base.fra21.fra22.lab32 \
	    -highlightthickness 2 -padx 9 -pady 3 -text Font 
    frame $base.fra21.fra23 \
	    -borderwidth 2 -height 75 -width 170 

    menubutton $base.fra21.fra23.but28 \
	    -padx 9 -pady 5 -textvar chart(help,ac) -background $chart(help,ac) -activeforeground $chart(help,ac) -activebackground black -width 8 -menu $base.fra21.fra23.but28.menu -relief raised

    # Bestimme Anzahl der Farben
    set count_colors [ llength $colors ]

    # Menue fuer Farbenauswahl
    set m [menu $base.fra21.fra23.but28.menu -tearoff 0]
    for { set i 0 } { $i < $count_colors } { incr i } {
	set this_color [ lindex $colors $i ]
	$m add command -label $this_color -background $this_color \
		-activebackground black -activeforeground $this_color \
		-command "$base.fra21.fra23.but28 configure \
		-activeforeground $this_color -background $this_color;set chart(help,ac) $this_color"
    }

    menubutton $base.fra21.fra23.but29 \
	    -padx 9 -pady 5 -textvar chart(help,pc) \
	    -background $chart(help,pc) -activeforeground $chart(help,pc) \
	    -activebackground black -width 8 \
	    -menu $base.fra21.fra23.but29.menu -relief raised

    # Menue fuer Farbenauswahl
    set m [menu $base.fra21.fra23.but29.menu -tearoff 0]
    for { set i 0 } { $i < $count_colors } { incr i } {
	set this_color [ lindex $colors $i ]
	$m add command -label $this_color -background $this_color \
		-activebackground black -activeforeground $this_color \
		-command "$base.fra21.fra23.but29 configure \
		-activeforeground $this_color -background $this_color;set chart(help,pc) $this_color"
    }

    menubutton $base.fra21.fra23.but30 \
	    -padx 9 -pady 5 -textvar chart(help,tc) \
	    -background $chart(help,tc) -activeforeground $chart(help,tc) \
	    -activebackground black -width 8 \
	    -menu $base.fra21.fra23.but30.menu -relief raised

    # Menue fuer Farbenauswahl
    set m [menu $base.fra21.fra23.but30.menu -tearoff 0]
    for { set i 0 } { $i < $count_colors } { incr i } {
	set this_color [ lindex $colors $i ]
	$m add command -label $this_color -background $this_color \
		-activebackground black -activeforeground $this_color \
		-command "$base.fra21.fra23.but30 configure \
		-activeforeground $this_color -background $this_color;set chart(help,tc) $this_color"
    }
    
    menubutton $base.fra21.fra23.but31 \
	    -padx 9 -pady 5 -textvar chart(help,bc) \
	    -background $chart(help,bc) -activeforeground $chart(help,bc) \
	    -activebackground black -width 8 \
	    -menu $base.fra21.fra23.but31.menu -relief raised

    # Menue fuer Farbenauswahl
    set m [menu $base.fra21.fra23.but31.menu -tearoff 0]
    for { set i 0 } { $i < $count_colors } { incr i } {
	set this_color [ lindex $colors $i ]
	$m add command -label $this_color -background $this_color \
		-activebackground black -activeforeground $this_color \
		-command "$base.fra21.fra23.but31 configure \
		-activeforeground $this_color -background $this_color;set chart(help,bc) $this_color"
    }

# 990520
     menubutton $base.fra21.fra23.but32 \
 	    -padx 9 -pady 5 -textvar chart(help,dc) \
 	    -background $chart(help,dc) -activeforeground $chart(help,dc) \
 	    -activebackground black -width 8 \
 	    -menu $base.fra21.fra23.but32.menu -relief raised

     # Menue fuer Farbenauswahl
     set m [menu $base.fra21.fra23.but32.menu -tearoff 0]
     for { set i 0 } { $i < $count_colors } { incr i } {
 	set this_color [ lindex $colors $i ]
 	$m add command -label $this_color -background $this_color \
 		-activebackground black -activeforeground $this_color \
 		-command "$base.fra21.fra23.but32 configure \
 		-activeforeground $this_color -background $this_color;set chart(help,dc) $this_color"
     }
# 990528
     menubutton $base.fra21.fra23.but33 \
 	    -padx 9 -pady 5 -textvar chart(help,mc) \
 	    -background $chart(help,mc) -activeforeground $chart(help,mc) \
 	    -activebackground black -width 8 \
 	    -menu $base.fra21.fra23.but33.menu -relief raised

     # Menue fuer Farbenauswahl
     set m [menu $base.fra21.fra23.but33.menu -tearoff 0]
     for { set i 0 } { $i < $count_colors } { incr i } {
 	set this_color [ lindex $colors $i ]
 	$m add command -label $this_color -background $this_color \
 		-activebackground black -activeforeground $this_color \
 		-command "$base.fra21.fra23.but33 configure \
 		-activeforeground $this_color -background $this_color;set chart(help,mc) $this_color"
     }


    entry $base.fra21.fra23.ent33 -textvar chart(help,fn)

    label $base.lab35 \
	    -background #000000 -foreground #fefefe -padx 9 -pady 5 \
	    -relief raised -text Toggles 
    frame $base.fra36 \
	    -borderwidth 2 -height 90 -relief groove -width 125 
    frame $base.fra36.fra37 \
	    -borderwidth 2 -height 75 -width 189 
    checkbutton $base.fra36.fra37.che40 \
	    -text {messages on stderr} -variable chart(help,v)

    checkbutton $base.fra36.fra37.che41 \
	    -text {messages in window} -variable chart(help,tr_wi)
    frame $base.fra36.fra39 \
	    -borderwidth 2 -height 75 -width 164 
    checkbutton $base.fra36.fra39.che86 \
	    -text blinking -variable chart(help,b)


    label $base.lab42 \
	    -background #000000 -foreground #fefefe -padx 9 -pady 5 \
	    -relief raised -text Defaults 
    frame $base.fra44 \
	    -borderwidth 2 -height 75 -width 125 
    frame $base.fra44.fra48 \
	    -borderwidth 2 -height 75 -width 163 
    label $base.fra44.fra48.lab51 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 -text Linewidth 
    label $base.fra44.fra48.lab52 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 -text Tokenwidth 
    label $base.fra44.fra48.lab53 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text Tokendiameter 

    # 981127 neuer Parameter fuer Abstand der Tokens
    label $base.fra44.fra48.lab54 \
            -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
            -text Tokendistance

    # 981130neuer Parameter fuer Abstand zum Boden
    label $base.fra44.fra48.lab55 \
            -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
            -text "Abstand nach unten"

    label $base.fra44.fra48.lab71 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text Stretchfactor 
    label $base.fra44.fra48.lab72 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Window Height} 
    label $base.fra44.fra48.lab75 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Window Width} 
    label $base.fra44.fra48.lab76 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Scroll Height} 
    label $base.fra44.fra48.lab77 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Scroll Width} 
    label $base.fra44.fra48.lab78 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Height Increment} 
    label $base.fra44.fra48.lab79 \
	    -borderwidth 3 -highlightthickness 2 -padx 0 -pady 0 \
	    -text {Width Increment} 
    frame $base.fra44.fra50 \
	    -borderwidth 2 -height 75 -width 125 
    entry $base.fra44.fra50.ent61 \
	    -textvariable chart(help,lw) 
    entry $base.fra44.fra50.ent62 \
	    -textvariable chart(help,tw) 
    entry $base.fra44.fra50.ent67 \
	    -textvariable chart(help,td) 

    # 981127 Tokendistance
    entry $base.fra44.fra50.ent68 \
            -textvariable chart(help,tdi)
    # 981130 Abstand zum Boden
    entry $base.fra44.fra50.ent69 \
            -textvariable chart(help,ds)

    entry $base.fra44.fra50.ent73 \
	    -textvariable chart(help,sf) 
    entry $base.fra44.fra50.ent74 \
        -textvariable chart(help,wh) 
    entry $base.fra44.fra50.ent80 \
        -textvariable chart(help,ww) 
    entry $base.fra44.fra50.ent81 \
        -textvariable chart(help,sh) 
    entry $base.fra44.fra50.ent82 \
        -textvariable chart(help,sw) 
    entry $base.fra44.fra50.ent83 \
        -textvariable chart(help,hi) 
    entry $base.fra44.fra50.ent84 \
        -textvariable chart(help,wi) 
    frame $base.fra85 \
        -borderwidth 5 -height 86 -relief groove -width 125 
    button $base.fra85.but87 \
        -padx 15 -pady 5 -text Save -command "set_popup_values $name; create_new_config ; destroy $base"
    button $base.fra85.but88 \
        -padx 15 -pady 5 -text Apply -command "set_popup_values $name"
    button $base.fra85.but89 \
        -padx 15 -pady 5 -text Cancel -command "destroy $base"
    ###################
    # SETTING GEOMETRY
    ###################
    pack $base.lab35 \
        -in .top17 -anchor center -expand 0 -fill x -side top 
    pack $base.fra36 \
        -in .top17 -anchor center -expand 0 -fill x -side top 
    pack $base.fra36.fra37 \
        -in .top17.fra36 -anchor center -expand 0 -fill none -side left 
    pack $base.fra36.fra37.che40 \
	    -in .top17.fra36.fra37 -anchor center -expand 0 -fill x -side top 
    pack $base.fra36.fra37.che41 \
	    -in .top17.fra36.fra37 -anchor center -expand 0 -fill none -side top
    pack $base.fra36.fra39 \
        -in .top17.fra36 -anchor center -expand 0 -fill x -side right 
    pack $base.fra36.fra39.che86 \
        -in .top17.fra36.fra39 -anchor center -expand 0 -fill x -side top 
    pack $base.lab18 \
        -in .top17 -anchor center -expand 0 -fill x -side top 
    pack $base.fra21 \
        -in .top17 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra22 \
        -in .top17.fra21 -anchor center -expand 0 -fill y -side left 
    pack $base.fra21.fra22.lab24 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra22.lab25 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra22.lab26 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra22.lab27 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
# Dying
    pack $base.fra21.fra22.lab28 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
# Marking
    pack $base.fra21.fra22.lab29 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra22.lab32 \
        -in .top17.fra21.fra22 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra23 \
        -in .top17.fra21 -anchor center -expand 0 -fill y -side right 
    pack $base.fra21.fra23.but28 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra23.but29 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra23.but30 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra23.but31 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
# 990520
    pack $base.fra21.fra23.but32 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
# 990528
    pack $base.fra21.fra23.but33 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
    pack $base.fra21.fra23.ent33 \
        -in .top17.fra21.fra23 -anchor center -expand 0 -fill none -side top 
    pack $base.lab42 \
        -in .top17 -anchor center -expand 0 -fill x -side top 
    pack $base.fra44 \
        -in .top17 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48 \
        -in .top17.fra44 -anchor center -expand 0 -fill none -side left 
    pack $base.fra44.fra48.lab51 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab52 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab53 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    # 981127 Tokendistance
    pack $base.fra44.fra48.lab54 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    # 981130 Abstand zum Boden
    pack $base.fra44.fra48.lab55 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 

    pack $base.fra44.fra48.lab71 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab72 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab75 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab76 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab77 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab78 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra48.lab79 \
        -in .top17.fra44.fra48 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50 \
        -in .top17.fra44 -anchor center -expand 0 -fill none -side right 
    pack $base.fra44.fra50.ent61 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent62 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent67 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 

    # 981127 Tokendistance
    pack $base.fra44.fra50.ent68 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    # 981130 Abstand zum Boden
    pack $base.fra44.fra50.ent69 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 

    pack $base.fra44.fra50.ent73 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent74 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent80 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent81 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent82 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent83 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra44.fra50.ent84 \
        -in .top17.fra44.fra50 -anchor center -expand 0 -fill none -side top 
    pack $base.fra85 \
        -in .top17 -anchor center -expand 0 -fill none -padx 5 -pady 5 \
        -side top 
    pack $base.fra85.but87 \
        -in .top17.fra85 -anchor center -expand 0 -fill none -side left 
    pack $base.fra85.but88 \
        -in .top17.fra85 -anchor center -expand 0 -fill none -side left 
    pack $base.fra85.but89 \
        -in .top17.fra85 -anchor center -expand 0 -fill none -side left 

    my_trace "Leaving chart_config"

}
