#!/usr/bin/wish4.2
#############################################################################
# Visual Tcl v1.10 Project
#

#################################
# GLOBAL VARIABLES
#
global COLORS; 
global IMAGES_LIST; 
global bgfile; 
global bindir; 
global filename; 
global image_bg_color; 
global image_dos4boot; 
global image_fg_color; 
global image_hotkey_hide; 
global image_image; 
global image_initrd; 
global image_loader; 
global image_rewrite; 
global image_swapfd; 
global image_swaphd; 
global image_type; 
global mapfile; 
global modified; 
global state_bg_art; 
global state_bg_file; 
global state_color; 
global state_delay; 
global state_emergency; 
global state_autoboot; 
global state_infoline; 
global state_install; 
global state_selection; 
global widget; 
    set widget(banner) {.vchos.look.banner.ent}
    set widget(bootfile_options) {.vchos.frame32.frame34.frame23.frame25.frame26.frame19}
    set widget(colorselect) {.vchos.colorselect}
    set widget(image_add) {.vchos.frame32.frame34.frame23.frame25.button20}
    set widget(image_art_label) {.vchos.frame32.frame34.frame23.label24}
    set widget(image_cmdline) {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame18.02}
    set widget(image_hotkey) {.vchos.frame32.frame34.frame23.frame25.frame26.012.014}
    set widget(image_initrd_address) {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19.04}
    set widget(image_name) {.vchos.frame32.frame34.frame23.frame25.frame26.01.03}
    set widget(image_xpos) {.vchos.frame32.frame34.frame23.frame25.frame26.018.020}
    set widget(image_ypos) {.vchos.frame32.frame34.frame23.frame25.frame26.018.022}
    set widget(linux_options) {.vchos.frame32.frame34.frame23.frame25.frame26.frame17}
    set widget(listbox_images) {.vchos.frame32.frame34.frame35.frame17.listbox18}
    set widget(look_banner) {.vchos.frame18.frame20.frame25.frame27.01.03}
    set widget(look_menu_xpos) {.vchos.frame18.frame20.frame25.frame27.020.022}
    set widget(look_menu_ypos) {.vchos.frame18.frame20.frame25.frame27.020.024}
    set widget(look_timer_xpos) {.vchos.frame18.frame20.frame25.frame27.025.027}
    set widget(look_timer_ypos) {.vchos.frame18.frame20.frame25.frame27.025.029}
    set widget(menu_xpos) {.vchos.look.menupos.entcol}
    set widget(menu_ypos) {.vchos.look.menupos.entrow}
    set widget(note) {.vchos.frame18.fra32.02.03.04.text17}
    set widget(rev,.vchos.colorselect) {colorselect}
    set widget(rev,.vchos.configurations.left.images.listbox) {listbox_images}
    set widget(rev,.vchos.configurations.left.images.scrollbar) {scrollbar_images}
    set widget(rev,.vchos.configurations.right.add) {image_add}
    set widget(rev,.vchos.configurations.right.cmdline.ent) {image_cmdline}
    set widget(rev,.vchos.configurations.right.hotkey.ent) {image_hotkey}
    set widget(rev,.vchos.configurations.right.initrd.ent) {image_initrd_address}
    set widget(rev,.vchos.configurations.right.name.ent) {image_name}
    set widget(rev,.vchos.configurations.right.position.entxpos) {image_xpos}
    set widget(rev,.vchos.configurations.right.position.entypos) {image_ypos}
    set widget(rev,.vchos.frame18.fra32.02.03.04.text17) {note}
    set widget(rev,.vchos.frame18.frame20.frame25.frame27.01.03) {look_banner}
    set widget(rev,.vchos.frame18.frame20.frame25.frame27.020.022) {look_menu_xpos}
    set widget(rev,.vchos.frame18.frame20.frame25.frame27.020.024) {look_menu_ypos}
    set widget(rev,.vchos.frame18.frame20.frame25.frame27.025.027) {look_timer_xpos}
    set widget(rev,.vchos.frame18.frame20.frame25.frame27.025.029) {look_timer_ypos}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.button20) {image_add}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.01.03) {image_name}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.012.014) {image_hotkey}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.018.020) {image_xpos}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.018.022) {image_ypos}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.023.025) {image_cmdline}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.026.030) {image_initrd_address}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.031) {image_add}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.frame17) {linux_options}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame18.02) {image_cmdline}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19.04) {image_initrd_address}
    set widget(rev,.vchos.frame32.frame34.frame23.frame25.frame26.frame19) {bootfile_options}
    set widget(rev,.vchos.frame32.frame34.frame23.label24) {image_art_label}
    set widget(rev,.vchos.frame32.frame34.frame35.frame17.listbox18) {listbox_images}
    set widget(rev,.vchos.frame32.frame34.frame35.frame17.scrollbar19) {scrollbar_images}
    set widget(rev,.vchos.look.banner.ent) {banner}
    set widget(rev,.vchos.look.menupos.entcol) {menu_xpos}
    set widget(rev,.vchos.look.menupos.entrow) {menu_ypos}
    set widget(rev,.vchos.look.timerpos.entcol) {timer_xpos}
    set widget(rev,.vchos.look.timerpos.entrow) {timer_ypos}
    set widget(scrollbar_images) {.vchos.frame32.frame34.frame35.frame17.scrollbar19}
    set widget(timer_xpos) {.vchos.look.timerpos.entcol}
    set widget(timer_ypos) {.vchos.look.timerpos.entrow}

#################################
# USER DEFINED PROCEDURES
#
proc init {argc argv} {
global    tk_strictMotif modified
global    COLORS

    set tk_strictMotif 0
    set modified "no"

    set COLORS(black) black
    set COLORS(blue) blue
    set COLORS(green) green
    set COLORS(cyan) cyan
    set COLORS(red) red
    set COLORS(magenta) magenta
    set COLORS(brown) brown
    set COLORS(lightgray) gray90
    set COLORS(darkgray) gray60
    set COLORS(lightblue) steelblue1
    set COLORS(lightgreen) seagreen1
    set COLORS(lightcyan) cyan1
    set COLORS(lightred) indianred1
    set COLORS(lightmagenta) orchid1
    set COLORS(yellow) yellow
    set COLORS(white) white
}

init $argc $argv


proc about {} {
global ABOUT_OK

  toplevel .about
  wm title .about {About Visual CHOS 0.8}

  frame .about.oben -relief raised -bd 1
  pack .about.oben -fill both
  frame .about.unten -relief raised -bd 1
  pack .about.unten -fill both -side bottom

  message .about.oben.msg -font 10x20 -justify center -width 15c  -text "\nVisual CHOS 0.8\n\nfor CHOS v0.8\n\n\nby Andreas Blome 1997\nflower@informatik.uni-bremen.de"
  pack .about.oben.msg

  frame .about.unten.def -relief sunken -bd 1
  pack .about.unten.def -padx 3m -pady 2m
  button .about.unten.def.ok -text OK -command {set ABOUT_OK ok}
  pack .about.unten.def.ok -padx 3m -pady 3m -ipadx 2m -ipady 1m

  set ABOUT_OK ""
  tkwait variable ABOUT_OK
  destroy .about
}

proc add_image {command} {
global    image_type image_fg_color image_bg_color image_image image_hotkey_hide image_initrd image_loader image_dos4boot image_rewrite image_swapfd image_swaphd
    global    IMAGES widget modified IMAGES_LIST

    set image_name [$widget(image_name) get]

    if {($image_name == "") || ($image_image=="<none>") } {
        tk_dialog .confirm "Hey !!" "Please enter a name for the image.\nPlease chose a device or file for the image." info 0 "OK"
    } else {
        set modified "yes"

        set image_hotkey [$widget(image_hotkey) get]
        set image_xpos [$widget(image_xpos) get]
        set image_ypos [$widget(image_ypos) get]
        set image_cmdline [$widget(image_cmdline) get]
        set image_initrd_address [$widget(image_initrd_address) get]

        set IMAGES($image_name) [list $image_type $image_fg_color $image_bg_color $image_image $image_hotkey $image_hotkey_hide $image_xpos $image_ypos $image_cmdline $image_initrd $image_initrd_address $image_loader $image_dos4boot $image_rewrite $image_swapfd $image_swaphd]

        if {$command == "add"} {
            $widget(listbox_images) insert end $image_name
            lappend IMAGES_LIST $image_name 
       } else {
            $widget(image_add) configure -text "Add" -command {add_image add}
        }

        init_image $image_type

    }
}

proc delete_image {} {
global    widget IMAGES modified IMAGES_LIST


    if {[llength $IMAGES_LIST] > 0 } {
        set name [$widget(listbox_images) get [$widget(listbox_images) curselection] ] 
        set modified "yes"
        $widget(listbox_images) delete [$widget(listbox_images) curselection]
        catch {unset IMAGES($name)}
        set IMAGES_LIST [lreplace $IMAGES_LIST [lsearch $IMAGES_LIST $name]  [lsearch $IMAGES_LIST $name] ]
        init_image linux
    }
}

proc get_background {} {
global state_bg_file  modified


    set types {
                  {{Ascii File}       {.asc .ascii .txt}}
                  {{Dump Files}       {.bin .dump}}
                  {{CP437 Files}      .437}
                  {{All Files}        *}
              }

    set name [tk_getOpenFile -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set state_bg_file $name
    }
}

proc get_bgfile {} {
global modified bgfile

    set types {
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -filetypes $types]
  
    if {$name != ""} {
        set modified "yes"
        set bgfile $name
    }
}

proc get_bindir {} {
global modified bindir

    set types {
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -initialdir "/boot/" -filetypes $types]
  
    if {$name != ""} {
        set modified "yes"
        set bindir [file dir $name]
    }
}

proc get_emergency {} {
global state_emergency modified

    set types {
                  {{Install Devices}       {hda* sda*}        }
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -initialdir "/dev/" -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set state_emergency $name
    }
}

proc get_image {} {
global image_image  modified

    set types {
                  {{Linux Kernerls}       {vm*}        }
                  {{Dos Bootsector}       {hda* sda*}        }
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -initialdir "/" -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set image_image $name
    }
}

proc get_initrd {} {
global image_initrd  modified


    set types {
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set image_initrd $name
    }
}

proc get_install {} {
global state_install  modified


    set types {
                  {{Install Devices}       {hd* sd* fd0}        }
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -initialdir "/dev/" -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set state_install $name
    }
}

proc get_loader {} {
global image_loader  modified

    set types {
                  {{Loader}        *loader*             }
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -initialdir "/boot" -filetypes $types]

    if {$name != ""} { 
        set modified "yes"
        set image_loader $name
    }
}

proc get_mapfile {} {
global modified mapfile

    set types {
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -filetypes $types]
  
    if {$name != ""} {
        set modified "yes"
        set mapfile $name
    }
}

proc get_rewrite {} {
global modified image_rewrite

    set types {
                  {{All Files}        *             }
              }

    set name [tk_getOpenFile -filetypes $types]
  
    if {$name != ""} {
        set modified "yes"
        set image_rewrite $name
    }
}

proc init_image {art} {
global    image_fg_color image_bg_color image_image image_hotkey_hide image_initrd image_loader
    global    widget image_dos4boot image_rewrite image_swapfd image_swaphd

    # image init
    $widget(image_name) delete 0 end
    set image_fg_color "<FG-Color>"
    set image_bg_color "<BG-Color>"
    set image_image "<none>"
    set image_loader "<none>"
    $widget(image_hotkey) delete 0 end
    set image_hotkey_hide "show"
    $widget(image_xpos) delete 0 end
    $widget(image_ypos) delete 0 end
    $widget(image_cmdline) delete 0 end
    set image_initrd "<none>"
    set image_dos4boot "no"
    set image_rewrite "no"
    set image_swapfd "no"
    set image_swaphd "no"
    $widget(image_initrd_address) delete 0 end
    $widget(image_add) configure -text "Add" -command {add_image add}

    set txt ""
    switch $art {
        linux    {
            set txt "Linux Image:"
            pack $widget(linux_options) -fill x
            pack forget $widget(bootfile_options)
        }

        big_linux {
            set txt "Big Linux Image:" 
            pack $widget(linux_options) -fill x
            pack forget $widget(bootfile_options)
        }
 
        bootfile {
            set txt "Bootfile Image:" 
            pack $widget(bootfile_options) -fill x
            pack forget $widget(linux_options)
         }

        bootsect {
            set txt "Bootsector Image:" 
            pack $widget(bootfile_options) -fill x
            pack forget $widget(linux_options)
        }
       
    }
 
    $widget(image_art_label) configure -text $txt
}

proc install_config {} {
global modified filename

    if {$modified =="yes"} {
        if {[save_yes_no] == "yes"} {
            save_config
        }
    }
    set modified "no"

    catch {destroy .instlog}
    toplevel .instlog

    frame .instlog.f

    text .instlog.f.text -width 80 -height 30 -yscrollcommand {.instlog.f.scroll set}
    pack .instlog.f.text -fill y -expand 1 -side left

    scrollbar .instlog.f.scroll -orient vert -command {.instlog.f.text yview}
    pack .instlog.f.scroll -side left -fill y -expand 1

    pack .instlog.f -padx 10 -pady 10 -fill y -expand 1 -side top

    button .instlog.ok -text OK -command {destroy .instlog}
    pack .instlog.ok -side top -padx 10 -pady 10 -ipadx 10 -ipady 10

# Added -y here so it answers yes to all questions.  -tuomo
    catch {exec chos -y -v -c $filename} txt
    .instlog.f.text insert 0.0 $txt
}

proc load_config {} {
global    filename widget IMAGES IMAGES_LIST
    global    state_delay state_autoboot state_install state_emergency
    global    state_infoline state_color state_selection state_bg_art state_bg_file
    global    bindir bgfile mapfile
    global    modified

    if {$modified =="yes"} {
        if {[save_yes_no] == "yes"} {
            save_config
        }
    }
    set modified "no"

    new_config

    set types {
                  {{Config Files}       {.conf*}        }
                  {{All Files}        *             }
              }

    set filename [tk_getOpenFile -initialdir "/etc/" -filetypes $types]
    
    if {$filename != ""} {
        wm title .vchos "Visual CHOS V0.8 - $filename"
        set file [exec cat $filename]
        set file [split $file "\n"]

        # init image vars
        set tmp_name ""
        set tmp_type ""
        set tmp_fg_color "<FG-Color>"
        set tmp_bg_color "<BG-Color>"
        set tmp_image "<none>"
        set tmp_hotkey ""
        set tmp_hotkey_hide "show"
        set tmp_xpos ""
        set tmp_ypos ""
        set tmp_cmdline ""
        set tmp_initrd "<none>"
        set tmp_initrd_address ""
        set tmp_loader "<none>"
        set tmp_dos4boot "no"
        set tmp_swapfd "no"
        set tmp_swaphd "no"
        set tmp_rewrite "no"
        set in_image "no"

        foreach line $file {
            set line [lindex [split $line "#"] 0]
            set line [string trimleft $line]
            set line [string trimright $line]
        
            # delay
            if {[string first "delay=" $line] == 0} {
                set state_delay [string trimleft [lindex [split $line "="] 1]]
            }

            # autoboot
            if {[string first "autoboot=" $line] == 0} {
                set state_autoboot [string trimleft [lindex [split $line "="] 1]]
            }

            # install
            if {[string first "install=" $line] == 0} {
                set state_install [string trimleft [lindex [split $line "="] 1]]
            }

            # emergency
            if {[string first "emergency=" $line] == 0} {
                set state_emergency [string trimleft [lindex [split $line "="] 1]]
            }

            # banner
            if {[string first "banner=" $line] == 0} {
                $widget(look_banner) insert 0 [string trimleft [string range $line [string first "=" $line] [string length $line]] "="]
            }

            # infoline
            if {[string first "infoline=" $line] == 0} {
                set state_infoline [string trimleft [lindex [split $line "="] 1]]
            }

            # color
            if { ([string first "color=" $line] == 0) && ($in_image == "no")} {
                set state_color [string trimleft [lindex [split $line "="] 1]]
            }

            # infoline
            if {[string first "selection=" $line] == 0} {
                set state_selection [string trimleft [lindex [split $line "="] 1]]
            }

            # background
            if {[string first "background=" $line] == 0} {
                set tmp [lindex [split $line "="] 1]
                set state_bg_art [string trimleft [lindex [split $tmp ":"] 0]]
                set state_bg_file [string trimleft [lindex [split $tmp ":"] 1]]
            }

            # menupos
            if {[string first "menupos=" $line] == 0} {
                set tmp [lindex [split $line "="] 1]
                $widget(look_menu_xpos) insert 0 [string trimleft [lindex [split $tmp ","] 0]]
                $widget(look_menu_ypos) insert 0 [string trimleft [lindex [split $tmp ","] 1]]
            }

            # timerpos
            if {[string first "timerpos=" $line] == 0} {
                set tmp [lindex [split $line "="] 1]
                $widget(look_timer_xpos) insert 0 [string trimleft [lindex [split $tmp ","] 0]]
                $widget(look_timer_ypos) insert 0 [string trimleft [lindex [split $tmp ","] 1]]
            }
          
            # bindir
            if {[string first "bindir=" $line] == 0} {
                set bindir [string trimleft [lindex [split $line "="] 1]]
            }

            # bgfile
            if {[string first "bgfile=" $line] == 0} {
                set bgfile [string trimleft [lindex [split $line "="] 1]]
            }

            # mapfile
            if {[string first "mapfile=" $line] == 0} {
                set mapfile [string trimleft [lindex [split $line "="] 1]]
            }

            # start of image
            if { ([string first "linux" $line] == 0) || ([string first "big_linux" $line] == 0) ||  ([string first "bootfile" $line] == 0) || ([string first "bootsec" $line] == 0) } {
                set tmp_type [lindex [split $line " "] 0]
                set tmp_name [lindex [split $line "\""] 1]
                set tmp_fg_color "<FG-Color>"
                set tmp_bg_color "<BG-Color>"
                set tmp_image "<none>"
                set tmp_hotkey ""
                set tmp_hotkey_hide "show"
                set tmp_xpos ""
                set tmp_ypos ""
                set tmp_cmdline ""
                set tmp_initrd "<none>"
                set tmp_initrd_address ""
                set in_image "yes"
            }
 
            # color in image
            if { ([string first "color=" $line] == 0) && ($in_image == "yes") } {
                set tmp [lindex [split $line "="] 1]
                set tmp_fg_color [string trimleft [lindex [split $tmp ","] 0]]
                if {[lindex [split $tmp ","] 1] != ""} {
                    set tmp_bg_color [string trimleft [lindex [split $tmp ","] 1]]
                }
            }
 
            # image in image
            if { ([string first "image=" $line] == 0) && ($in_image == "yes")} {
                set tmp_image [string trimleft [lindex [split $line "="] 1]]
            }


            # hotkey in image
            if { ([string first "hotkey=" $line] == 0) && ($in_image == "yes") } {
                set tmp [lindex [split $line "="] 1]
                set tmp_hotkey [string trimleft [lindex [split $tmp ","] 0]]
                if {[string trimleft [lindex [split $tmp ","] 1]] == "hidden"} {
                    set tmp_hotkey_hide "hide"
                }
            }

            # position in image
            if { ([string first "position=" $line] == 0) && ($in_image == "yes")} {
                set tmp [lindex [split $line "="] 1]
                set tmp_xpos [string trimleft [lindex [split $tmp ","] 0]]
                set tmp_ypos [string trimleft [lindex [split $tmp ","] 1]]
            }

            # cmdline in image
            if { ([string first "cmdline=" $line] == 0) && ($in_image == "yes")} {
                set tmp_cmdline [string trimleft [string range $line [string first "=" $line] [string length $line]] "="]
            }

            # initrd in image
            if { ([string first "initrd=" $line] == 0) && ($in_image == "yes") } {
                set tmp [lindex [split $line "="] 1]
                set tmp_initrd [string trimleft [lindex [split $tmp ","] 0]]
                if {[lindex [split $tmp ","] 1] != ""} {
                    set tmp_initrd_address [string trimleft [lindex [split $tmp ","] 1]]
                }
            }

            # loader in image
            if { ([string first "loader=" $line] == 0) && ($in_image == "yes")} {
                set tmp_loader [string trimleft [lindex [split $line "="] 1]]
            }

            # dos4boot in image
            if { ([string first "dos4boot=" $line] == 0) && ($in_image == "yes")} {
                set tmp_dos4boot [string trimleft [lindex [split $line "="] 1]]
            }
  
            # rewrite in image
            if { ([string first "rewrite=" $line] == 0) && ($in_image == "yes")} {
                set tmp_rewrite [string trimleft [lindex [split $line "="] 1]]
            }
 
            # swapfd in image
            if { ([string first "swapfd=" $line] == 0) && ($in_image == "yes")} {
                set tmp_swapfd [string trimleft [lindex [split $line "="] 1]]
            }

            # swaphd in image
            if { ([string first "swaphd=" $line] == 0) && ($in_image == "yes")} {
                set tmp_swaphd [string trimleft [lindex [split $line "="] 1]]
            }
 
            # end of image
            if { ([string index $line 0] == "\}") && ($in_image == "yes")} {
                set IMAGES($tmp_name) [list $tmp_type $tmp_fg_color $tmp_bg_color $tmp_image $tmp_hotkey $tmp_hotkey_hide $tmp_xpos $tmp_ypos $tmp_cmdline $tmp_initrd $tmp_initrd_address $tmp_loader $tmp_dos4boot $tmp_rewrite $tmp_swapfd $tmp_swaphd]
                lappend IMAGES_LIST $tmp_name
                $widget(listbox_images) insert end $tmp_name
                set in_image "no"
            }

        }
    }
}

proc new_config {} {
global    state_delay state_autoboot state_install state_emergency
    global    state_infoline state_color state_selection state_bg_art state_bg_file
    global    bindir mapfile bgfile
    global    IMAGES widget modified filename IMAGES_LIST

    if {$modified =="yes"} {
        if {[save_yes_no] == "yes"} {
            save_config
        }
    }
    set modified "no"
    set filename ""
    wm title .vchos "Visual CHOS V0.8 - $filename"
    
    # init general
    set state_delay 30
    set state_autoboot no
    set state_install "<none>"
    set state_emergency "<none>"

    # init look
    $widget(look_banner) delete 0 end
    set state_infoline "on"
    set state_color "<Color>"
    set state_selection "<Color>"
    set state_bg_art "<none>"
    set state_bg_file "<none>"
    $widget(look_menu_xpos) delete 0 end
    $widget(look_menu_ypos) delete 0 end
    $widget(look_timer_xpos) delete 0 end
    $widget(look_timer_ypos) delete 0 end

    # init files
    set bindir "<default>"
    set mapfile "<default>" 
    set bgfile "<default>"
 
    # init image
    catch {unset IMAGES}
    catch {unset IMAGES_LIST}
    set IMAGES_LIST ""
    new_image linux
    $widget(listbox_images) delete 0 end
}

proc new_image {art} {
global    image_type widget

    init_image $art
    set image_type $art
}

proc save_config {{art save}} {
global    state_delay state_autoboot state_install
    global    state_infoline state_color state_selection state_bg_art state_bg_file 
    global    state_emergency
    global    bindir bgfile mapfile
    global    IMAGES IMAGES_LIST widget filename modified


    if {([llength $IMAGES_LIST] == 0) || ($state_install=="<none>") } {
        tk_dialog .confirm "Hey !!" "Please choose a install device.\nPlease add some images." info 0 "OK"
    } else {
        if { ($art == "save_as") || ($filename == "")} {
            set types {
                        {{Config Files}       {.conf*}        }
                        {{All Files}        *             }
                      }
            set filename [tk_getSaveFile -initialdir "/etc/" -initialfile "chos.conf" -filetypes $types]
        }
        wm title .vchos "Visual CHOS V0.8 - $filename"
        set file [open $filename w]

        puts $file "#\n# Choose-OS 0.8 configuration file."
        puts $file "#\n# generated with Visual CHOS by Andreas Blome flower@informatik.uni-bremen.de\n#\n\n"

        puts $file "#   General Settings\n#\n########################\n"

        puts $file "# DELAY"
        puts $file "delay=$state_delay\n"

        puts $file "# AUTOBOOT"
        puts $file "autoboot=$state_autoboot\n"

        puts $file "# INSTALL"
        puts $file "install=$state_install\n"

        if {$state_emergency != "<none>"} {
            puts $file "# EMERGENCY"
            puts $file "emergency=$state_emergency\n"
        }

        puts $file "#   LOOK SETTINGS\n#\n#####################\n"

        puts $file "# INFOLINE"
        puts $file "infoline=$state_infoline\n"

        set banner [$widget(look_banner) get]
        if {$banner != ""} {
            puts $file "# BANNER"
            puts $file "banner=$banner\n"
        }

        if {$state_color != "<Color>"} {
            puts $file "# COLOR"
            puts $file "color=$state_color\n"
        }

        if {$state_selection != "<Color>"} {
            puts $file "# SELECTION"
            puts $file "selection=$state_selection\n"
        }

        if {$state_bg_art != "<none>"} {
            puts $file "# BACKGOUND"
            puts $file "background=$state_bg_art:$state_bg_file\n"
        }
 
        set menu_xpos [$widget(look_menu_xpos) get]
        set menu_ypos [$widget(look_menu_ypos) get]
        if { $menu_xpos != ""} {
            puts $file "# MENUPOSITION"
            puts $file "menupos=$menu_xpos,$menu_ypos\n"
        }
 
        set timer_xpos [$widget(look_timer_xpos) get]
        set timer_ypos [$widget(look_timer_ypos) get]
        if {$timer_xpos != ""} {
            puts $file "# TIMERPOSITION"
            puts $file "timerpos=$timer_xpos,$timer_ypos\n"
        }

        puts $file "#   FILE SETTINGS\n#\n#####################\n"

        if {$bindir != "<default>"} {
            puts $file "# BINDIR"
            puts $file "bindir=$bindir\n"
        }

        if {$bgfile != "<default>"} {
            puts $file "# BGFILE"
            puts $file "bgfile=$bgfile\n"
        }
  
        if {$mapfile != "<default>"} {
            puts $file "# MAPFILE"
            puts $file "mapfile=$mapfile\n"
        }
  
        puts $file "#   IMAGES\n#\n##############\n"

        foreach ak_name $IMAGES_LIST {
            set tmp $IMAGES($ak_name)
            set ak_type [lindex $tmp 0]
            set ak_fg_color [lindex $tmp 1]
            set ak_bg_color [lindex $tmp 2]
            set ak_image [lindex $tmp 3] 
            set ak_hotkey [lindex $tmp 4]
            set ak_hotkey_hide [lindex $tmp 5]
            set ak_xpos [lindex $tmp 6]
            set ak_ypos [lindex $tmp 7]
            set ak_cmdline [lindex $tmp 8]
            set ak_initrd [lindex $tmp 9]
            set ak_initrd_address [lindex $tmp 10]
            set ak_loader [lindex $tmp 11]
            set ak_dos4boot [lindex $tmp 12]
            set ak_rewrite [lindex $tmp 13]
            set ak_swapfd [lindex $tmp 14]
            set ak_swaphd [lindex $tmp 15]

            puts $file "$ak_type \"$ak_name\" \{"

            if {$ak_fg_color != "<FG-Color>"} {
                puts -nonewline $file "  color=$ak_fg_color"
                if {$ak_bg_color != "<BG-Color>"} {
                    puts -nonewline $file ",$ak_bg_color"
                }
                puts $file ""
            }

            puts $file "  image=$ak_image"

            if {$ak_hotkey != ""} {
                puts -nonewline $file "  hotkey=$ak_hotkey"
                if {$ak_hotkey_hide != "show"} {
                    puts -nonewline $file ",hidden"
                }
                puts $file ""
            }
  
            if {$ak_xpos != ""} {
                puts $file "  position=$ak_xpos,$ak_ypos"
            }

            if {$ak_loader != "<none>"} {
                puts $file "  loader=$ak_loader"
            }

            switch $ak_type {
                linux    -
                big_linux {
                    if {$ak_cmdline != ""} {
                            puts $file "  cmdline=$ak_cmdline"
                    }

                    if {$ak_initrd != "<none>"} {
                        puts -nonewline $file "  initrd=$ak_initrd"
                        if {$ak_initrd_address != ""} {
                            puts -nonewline $file ",$ak_initrd_address"
                        }
                        puts $file ""
                    }
                }

                bootfile    -
                bootsect {
                    if {$ak_dos4boot != "no"} {
                            puts $file "  dos4boot=$ak_dos4boot"
                    }

                    if {$ak_rewrite != "no"} {
                            puts $file "  rewrite=$ak_rewrite"
                    }

                    if {$ak_swapfd != "no"} {
                            puts $file "  swapfd=$ak_swapfd"
                    }

                    if {$ak_swaphd != "no"} {
                            puts $file "  swaphd=$ak_swaphd"
                    }

                }
            }

            puts $file "\}\n"

        }

        close $file
        set modified "no"
    }
}

proc save_yes_no {} {
global SAVE_ergebnis 

  toplevel .sa
  wm title .sa {Save ???}
  # build widget .oben
  frame .sa.oben  -borderwidth {2}  -relief {raised}

  # build widget .oben.message
  message .sa.oben.message  -aspect {1500}  -borderwidth {0}  -font {10x20}  -justify {center}  -padx {5}  -pady {2}  -text {
   Configuration modified !!!  

Save now ?
}

  # pack widget .oben
  pack append .sa.oben  .sa.oben.message {right frame center}

  # build widget .unten
  frame .sa.unten  -borderwidth {2}  -relief {raised}

  # build widget .unten.ja
  button .sa.unten.ja  -font {10x20}  -height {2}  -text {Yes}  -command {set SAVE_ergebnis yes}

  # build widget .unten.nein
  button .sa.unten.nein  -font {10x20}  -height {2}  -text {No}  -command {set SAVE_ergebnis no}

  # pack widget .unten
  pack append .sa.unten  .sa.unten.nein {right frame center expand fill}  .sa.unten.ja {left frame center expand fill}

  # pack widget .
  pack append .sa  .sa.oben {top frame center}  .sa.unten {top frame center expand fillx}

  set SAVE_ergebnis ""  
  tkwait variable SAVE_ergebnis
  destroy .sa
  return $SAVE_ergebnis
}

proc select_color {flag} {
global CS_color modified COLORS

    set modified "yes"
    if {$flag == "bg"} {
        set colors "black blue green cyan red magenta brown lightgray"
    } else {
        set colors "black blue green cyan red magenta brown lightgray darkgray lightblue lightgreen lightcyan lightred lightmagenta yellow white"
    }

    toplevel .colsel
    wm title .colsel {Color Select}

    set i 0
    foreach color $colors {
        eval button .colsel.$color -text $color -bg $COLORS($color) -activebackground $COLORS($color) -command \{set CS_color $color\}
        pack .colsel.$color -fill both
        incr i
    }

    set CS_color ""

    grab .colsel    

    tkwait variable CS_color
    destroy .colsel    
    return $CS_color
}

proc select_image {} {
global widget IMAGES IMAGES_LIST

    if {[llength $IMAGES_LIST] > 0 } {
        set name [$widget(listbox_images) get [$widget(listbox_images) curselection] ]
        set_image_values $name
        $widget(image_add) configure -text "Modify" -command {add_image modify}
    }
}

proc set_bg_art {art} {
global state_bg_art modified

    set modified "yes"

    set state_bg_art $art
}

proc set_delay {delay} {
global state_delay modified

    set modified "yes"
    set state_delay $delay
}

proc set_autoboot {autoboot} {
global state_autoboot modified

    set modified "yes"

    set state_autoboot $autoboot
}

proc set_image_hotkey_hide {flag} {
global image_hotkey_hide modified

    set modified "yes"

    set image_hotkey_hide $flag
}

proc set_image_values {name} {
global    image_type image_fg_color image_bg_color image_image image_hotkey_hide image_initrd image_loader
    global    IMAGES widget image_dos4boot image_rewrite image_swapfd image_swaphd

    # get image infos
    set tmp $IMAGES($name)
    set ak_type [lindex $tmp 0]

    # init image
    init_image $ak_type

    set ak_fg_color [lindex $tmp 1]
    set ak_bg_color [lindex $tmp 2]
    set ak_image [lindex $tmp 3] 
    set ak_hotkey [lindex $tmp 4]
    set ak_hotkey_hide [lindex $tmp 5]
    set ak_xpos [lindex $tmp 6]
    set ak_ypos [lindex $tmp 7]
    set ak_cmdline [lindex $tmp 8]
    set ak_initrd [lindex $tmp 9]
    set ak_initrd_address [lindex $tmp 10]
    set ak_loader [lindex $tmp 11]
    set ak_dos4boot [lindex $tmp 12]
    set ak_rewrite [lindex $tmp 13]
    set ak_swapfd [lindex $tmp 14]
    set ak_swaphd [lindex $tmp 15]

    # set image values
    set image_type $ak_type
    $widget(image_name) insert 0 $name
    set image_fg_color $ak_fg_color
    set image_bg_color $ak_bg_color
    set image_image $ak_image
    $widget(image_hotkey) insert 0 $ak_hotkey
    set image_hotkey_hide $ak_hotkey_hide
    $widget(image_xpos) insert 0 $ak_xpos
    $widget(image_ypos) insert 0 $ak_ypos
    $widget(image_cmdline) insert 0 $ak_cmdline
    set image_initrd $ak_initrd
    $widget(image_initrd_address) insert 0 $ak_initrd_address
    set image_loader $ak_loader
    set image_dos4boot $ak_dos4boot
    set image_rewrite $ak_rewrite
    set image_swapfd $ak_swapfd
    set image_swaphd $ak_swaphd
}

proc show_vga_screen {} {
global    IMAGES state_bg_art state_bg_file widget state_infoline COLORS state_color
global    state_delay state_selection IMAGES_LIST

    set CHOS_VERSIONSTR "0.8"
    set infoline1 "Choose-OS v$CHOS_VERSIONSTR, Copyright (c) Tuomo Valkonen 1996-1997."
    set infoline2 "Up/Down arrows to select. Enter or hotkey to start. Space for command line."
    set def_banner "Choose-OS v$CHOS_VERSIONSTR BootUp Menu."    

    catch {destroy .vgascreen}

    toplevel .vgascreen
    wm title .vgascreen {VGA Screen}

    canvas .vgascreen.can -width 640 -height 400 -bg black

    pack .vgascreen.can 

#    for {set x 0} {$x < 640} {incr x 8} {
#        .vgascreen.can create line $x 0 $x 400
#    }

#    for {set y 0} {$y < 400} {incr y 16} {
#        .vgascreen.can create line 0 $y 640 $y 
#    }


    set banner [$widget(look_banner) get]
    if {$banner == ""} {
        set banner $def_banner
    }


    if {(($state_bg_art == "ascii") || ($state_bg_art == "cp437")) && ($state_bg_file != "")} {
	set banner ""
        set txt [exec cat $state_bg_file]
        .vgascreen.can create text 4 0 -text $txt -font vga -fill $COLORS(lightgray) -anchor nw
    }

    set loady -1
    if {($state_bg_art == "dump") && ($state_bg_file != "")} {
        set banner ""
        set loady [expr [file size $state_bg_file] /160]
        set f [split [exec od -t x1 -v $state_bg_file] "\n"]
        set t ""
        foreach l $f {
            append t [lrange $l 1 end]
            append t " "
        }
        set tt_hex [split $t " "]

        set colors "black blue green cyan red magenta brown lightgray darkgray lightblue lightgreen lightcyan lightred lightmagenta yellow white"

        for {set y 0} {$y<25} {incr y} {
            for {set x 0} {$x<80} {incr x} {
                set xposi [expr $x * 8 +4]
                set yposi [expr $y * 16]
                set txt "\\x[lindex $tt_hex [expr $x*2+$y*160]]"

                set digit [string index [lindex $tt_hex [expr $x*2+$y*160+1]] 1]
                set in [expr "0x0$digit"]
                set col  $COLORS([lindex $colors $in])
                if {$txt!="\\"} {
                    eval .vgascreen.can create text $xposi $yposi -text $txt -font vga -fill $col -anchor nw
                }
            }
        }

#        .vgascreen.can create text 4 0 -text $txt -font vga -fill $color -anchor nw
    }



    set color $state_color 
    if {$color == "<Color>"} {
        set color $COLORS(lightgray)
    } else {
        set color $COLORS($color)
    }

    set selection $state_selection 
    if {$selection == "<Color>"} {
        set selection $COLORS(lightgray)
    } else {
        set selection $COLORS($selection)
    }


    set menu_xpos [$widget(look_menu_xpos) get]
    set menu_ypos [$widget(look_menu_ypos) get]
    set a $menu_xpos
    if {($menu_xpos == "") && ($menu_ypos == "")} {
        set menu_xpos 3
        set menu_ypos 3
        set a 0
    } 

    set timer_xpos [$widget(look_timer_xpos) get]
    set timer_ypos [$widget(look_timer_ypos) get]
    set timestr ""
    set timestr_xpos $a
    if {($timer_xpos == "") && ($timer_ypos == "")} {
        set timestr "Time left: "
        set timer_ypos [expr $menu_ypos + 1 + [llength $IMAGES_LIST]]
        set timer_xpos [expr $a + [string length $timestr]]
        set timestr_xpos $a
    } 
 
    if {$timer_ypos > $loady} {
        set loady $timer_ypos
    }
    if {$state_delay != "off"} {
        .vgascreen.can create text [expr $timestr_xpos * 8 +4] [expr $timer_ypos * 16] -text $timestr -font vga -fill $color -anchor nw -tag timer
        .vgascreen.can create text [expr $timer_xpos * 8 +4] [expr $timer_ypos * 16] -text $state_delay -font vga -fill $color -anchor nw -tag timer
    }
 

    # IMAGES
    set i 1
    foreach ak_name $IMAGES_LIST {
        set tmp $IMAGES($ak_name)
        set ak_xpos [lindex $tmp 6]
        set ak_ypos [lindex $tmp 7]
        set ak_fg_color [lindex $tmp 1]
        set ak_bg_color [lindex $tmp 2]
        set ak_hotkey [lindex $tmp 4]
        set ak_hotkey_hide [lindex $tmp 5]
 
        if {($ak_xpos != "") && ($ak_ypos != "")} {
            set xpos [expr $ak_xpos * 8 +4]
            set ypos [expr $ak_ypos * 16]
        } else {
            set xpos [expr $menu_xpos * 8 +4]
            set ypos [expr $menu_ypos * 16]
            incr menu_ypos
        }
        set text ""
        if {$ak_hotkey_hide == "show"} {
            if {$ak_hotkey != ""} {
                set text "$ak_hotkey."
            } else {
                set text "$i."
            }
        }
        append text $ak_name

        if {$i == 1} {
            .vgascreen.can create rect $xpos $ypos [expr $xpos +8* [string length $text]] [expr $ypos + 16] -fill $selection -outline $selection
            if {$selection == $COLORS(lightgray) } {
                .vgascreen.can create text $xpos $ypos -text $text -font vga -fill $COLORS(white)  -anchor nw
            } else {
                .vgascreen.can create text $xpos $ypos -text $text -font vga -fill $COLORS(lightgray)  -anchor nw
            }
         } else {
            if {$ak_bg_color != "<BG-Color>"} {
                .vgascreen.can create rect $xpos $ypos [expr $xpos +8* [string length $text]] [expr $ypos + 16] -fill $COLORS($ak_bg_color) -outline $COLORS($ak_bg_color) 
             }

            set fg_color $COLORS(lightgray)
            if {$ak_fg_color != "<FG-Color>"} {
                set fg_color $COLORS($ak_fg_color)
            } 
            .vgascreen.can create text $xpos $ypos -text $text -font vga -fill $fg_color -anchor nw
        }
        incr i
    }

    if {$state_infoline == "on"} {
        .vgascreen.can create text 4 368 -text $infoline1 -font vga -fill $color -anchor nw
        .vgascreen.can create text 4 384 -text $infoline2 -font vga -fill $color -anchor nw
    }

    # banner
    .vgascreen.can create text 4 16 -text $banner -font vga -fill $color -anchor nw


################################################
#    .vgascreen.can bind timer <ButtonPress-1> {
#        global TIMER_XK TIMER_YK
#        set TIMER_XK [.vgascreen.can canvasx %x 8]
#        set TIMER_YK [.vgascreen.can canvasy %y 16]
#    }
#
#    .vgascreen.can bind timer <ButtonRelease-1> {
#        global modified
#
#        set xp [expr int (([lindex [.vgascreen.can coords current] 0] - 4) / 8)]
#        set yp [expr int ([lindex [.vgascreen.can coords current] 1] /16 )]
#        $widget(look_timer_xpos) delete 0 end
#        $widget(look_timer_xpos) insert 0 $xp
#        $widget(look_timer_ypos) delete 0 end
#        $widget(look_timer_ypos) insert 0 $yp
#        set modified "yes"
#    }
#
#    .vgascreen.can bind timer <B1-Motion> {
#        global TIMER_XK TIMER_YK
#        set xp [expr [.vgascreen.can canvasx %x 8] - $TIMER_XK ]
#        set yp [expr [.vgascreen.can canvasy %y 16] - $TIMER_YK ]
#       .vgascreen.can move timer $xp $yp
#        set TIMER_XK [.vgascreen.can canvasx %x 8]
#        set TIMER_YK [.vgascreen.can canvasy %y 16]
#    }
}

proc main {argc argv} {
new_config
}

proc Window {args} {
global vTcl
    set cmd [lindex $args 0]
    set name [lindex $args 1]
    set newname [lindex $args 2]
    set rest [lrange $args 3 end]
    if {$name == "" || $cmd == ""} {return}
    if {$newname == ""} {
        set newname $name
    }
    set exists [winfo exists $newname]
    switch $cmd {
        show {
            if {$exists == "1" && $name != "."} {wm deiconify $name; return}
            if {[info procs vTclWindow(pre)$name] != ""} {
                eval "vTclWindow(pre)$name $newname $rest"
            }
            if {[info procs vTclWindow$name] != ""} {
                eval "vTclWindow$name $newname $rest"
            }
            if {[info procs vTclWindow(post)$name] != ""} {
                eval "vTclWindow(post)$name $newname $rest"
            }
        }
        hide    { if $exists {wm withdraw $newname; return} }
        iconify { if $exists {wm iconify $newname; return} }
        destroy { if $exists {destroy $newname; return} }
    }
}

#################################
# VTCL GENERATED GUI PROCEDURES
#

proc vTclWindow. {base} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    wm focusmodel $base passive
    wm geometry $base 1x1+0+0
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm withdraw $base
    wm title $base "vt.tcl"
    ###################
    # SETTING GEOMETRY
    ###################
}

proc vTclWindow.vchos {base} {
    if {$base == ""} {
        set base .vchos
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    ###################
    # CREATING WIDGETS
    ###################
    toplevel $base -class Toplevel \
        -highlightthickness {1} 
    wm focusmodel $base passive
#    wm geometry $base 563x622+290+141
#    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 "Visual CHOS V0.8 - "
    frame $base.menu \
        -borderwidth {2} -height {75} -highlightthickness {1} \
        -relief {groove} -width {125} 
    menubutton $base.menu.file \
        -highlightthickness {1} -menu {.vchos.menu.file.m} -padx {4} \
        -pady {3} -text {Configuration} 
    menu $base.menu.file.m \
        -cursor {} -tearoff {0} 
    $base.menu.file.m add command \
        -command {new_config} -label {New} 
    $base.menu.file.m add command \
        -command {load_config} -label {Load} 
    $base.menu.file.m add command \
        -command {save_config} -label {Save} 
    $base.menu.file.m add command \
        -command {save_config save_as} -label {Save As} 
    $base.menu.file.m add separator
    $base.menu.file.m add command \
        \
        -command {global modified
    if {$modified =="yes"} {
        if {[save_yes_no] == "yes"} {
            save_config
        }
    }

exit} \
        -label {Exit} 
    menubutton $base.menu.help \
        -highlightthickness {1} -menu {.vchos.menu.help.m} -padx {4} \
        -pady {3} -text {Help} 
    menu $base.menu.help.m \
        -cursor {} -tearoff {0} 
    $base.menu.help.m add command \
        -command {about} -label {About} 
    menubutton $base.menu.menubutton17 \
        -menu {.vchos.menu.menubutton17.m} -padx {4} -pady {3} \
        -text {Special} 
    menu $base.menu.menubutton17.m \
        -cursor {} -tearoff {0} 
    $base.menu.menubutton17.m add command \
        -command {show_vga_screen} -label {Preview} 
    $base.menu.menubutton17.m add command \
        -command {install_config} -label {Install} 
    frame $base.frame18 \
        -borderwidth {2} -height {75} -width {125} 
    frame $base.frame18.frame19 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame18.frame19.label22 \
        -anchor {w} -borderwidth {1} -highlightthickness {1} -padx {4} \
        -text {General:} 
    frame $base.frame18.frame19.frame23 \
        -borderwidth {2} -height {75} -highlightthickness {1} \
        -relief {groove} -width {125} 
    frame $base.frame18.frame19.frame23.frame26 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    frame $base.frame18.frame19.frame23.frame26.01 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame19.frame23.frame26.01.02 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Delay:} 
    menubutton $base.frame18.frame19.frame23.frame26.01.03 \
        -highlightthickness {1} \
        -menu {.vchos.frame18.frame19.frame23.frame26.01.03.04} -padx {4} \
        -pady {3} -relief {raised} -text {30} -textvariable {state_delay} 
    menu $base.frame18.frame19.frame23.frame26.01.03.04 \
        -cursor {} -tearoff {0} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay "off"} -label {off} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 5} -label {5} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 10} -label {10} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 15} -label {15} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 20} -label {20} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 30} -label {30} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 40} -label {40} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 50} -label {50} 
    $base.frame18.frame19.frame23.frame26.01.03.04 add command \
        -command {set_delay 60} -label {60} 
    frame $base.frame18.frame19.frame23.frame26.05 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame19.frame23.frame26.05.06 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Autoboot:} 
    menubutton $base.frame18.frame19.frame23.frame26.05.07 \
        -highlightthickness {1} \
        -menu {.vchos.frame18.frame19.frame23.frame26.05.07.08} -padx {4} \
        -pady {3} -relief {raised} -text {no} -textvariable {state_autoboot} 
    menu $base.frame18.frame19.frame23.frame26.05.07.08 \
        -cursor {} -tearoff {0} 
    $base.frame18.frame19.frame23.frame26.05.07.08 add command \
        -command {set_autoboot "no"} -label {no} -state {active} 
    $base.frame18.frame19.frame23.frame26.05.07.08 add command \
        -command {set_autoboot "pressed"} -label {pressed} 
    $base.frame18.frame19.frame23.frame26.05.07.08 add command \
        -command {set_autoboot "not_pressed"} -label {not pressed} 
    frame $base.frame18.frame19.frame23.frame26.09 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame19.frame23.frame26.09.010 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Install:} 
    button $base.frame18.frame19.frame23.frame26.09.011 \
        -command {get_install} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {state_install} 
    frame $base.frame18.frame19.frame23.frame26.012 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame19.frame23.frame26.012.013 \
        -borderwidth {0} -foreground {#000000} -highlightthickness {1} \
        -relief {raised} -text {Emergency:} 
    button $base.frame18.frame19.frame23.frame26.012.014 \
        -command {get_emergency} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {state_emergency} 
    frame $base.frame18.frame20 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame18.frame20.label24 \
        -anchor {w} -borderwidth {1} -highlightthickness {1} -padx {4} \
        -text {Look:} 
    frame $base.frame18.frame20.frame25 \
        -borderwidth {2} -height {75} -relief {groove} -width {125} 
    frame $base.frame18.frame20.frame25.frame27 \
        -borderwidth {2} -height {75} -width {125} 
    frame $base.frame18.frame20.frame25.frame27.01 \
        -height {75} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.01.02 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Banner:} 
    entry $base.frame18.frame20.frame25.frame27.01.03 \
        -background {#fefefe} -highlightthickness {1} -width {10} 
    bind $base.frame18.frame20.frame25.frame27.01.03 <Key> {
        global modified
set modified yes
    }
    frame $base.frame18.frame20.frame25.frame27.04 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.04.05 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Infoline:} 
    radiobutton $base.frame18.frame20.frame25.frame27.04.06 \
        -highlightthickness {1} -text {on} -value {on} \
        -variable {state_infoline} 
    bind $base.frame18.frame20.frame25.frame27.04.06 <ButtonRelease> {
        global modified

    set modified yes
    }
    radiobutton $base.frame18.frame20.frame25.frame27.04.07 \
        -highlightthickness {1} -text {off} -value {off} \
        -variable {state_infoline} 
    bind $base.frame18.frame20.frame25.frame27.04.07 <ButtonRelease> {
        global  modified

    set modified yes
    }
    frame $base.frame18.frame20.frame25.frame27.08 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.08.09 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Color:} 
    button $base.frame18.frame20.frame25.frame27.08.010 \
        -command {global state_color

    set state_color [select_color fg]} \
        -highlightthickness {1} -padx {9} -pady {3} -text {<Color>} \
        -textvariable {state_color} 
    frame $base.frame18.frame20.frame25.frame27.011 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.011.012 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Selection:} 
    button $base.frame18.frame20.frame25.frame27.011.013 \
        \
        -command {global state_selection

    set state_selection [select_color bg]} \
        -highlightthickness {1} -padx {9} -pady {3} -text {<Color>} \
        -textvariable {state_selection} 
    frame $base.frame18.frame20.frame25.frame27.014 \
        -height {75} -highlightthickness {1} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.014.015 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Background:} 
    label $base.frame18.frame20.frame25.frame27.014.018 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} -text {:} 
    menubutton $base.frame18.frame20.frame25.frame27.014.016 \
        -highlightthickness {1} \
        -menu {.vchos.frame18.frame20.frame25.frame27.014.016.017} -padx {4} \
        -pady {3} -relief {raised} -text {<none>} \
        -textvariable {state_bg_art} 
    menu $base.frame18.frame20.frame25.frame27.014.016.017 \
        -cursor {} -tearoff {0} 
    $base.frame18.frame20.frame25.frame27.014.016.017 add command \
        -command {set_bg_art "<none>"} -label {<none>} 
    $base.frame18.frame20.frame25.frame27.014.016.017 add command \
        -command {set_bg_art "dump"} -label {dump} 
    $base.frame18.frame20.frame25.frame27.014.016.017 add command \
        -command {set_bg_art "ascii"} -label {ascii} 
    $base.frame18.frame20.frame25.frame27.014.016.017 add command \
        -command {set_bg_art "cp437"} -label {cp437} 
    button $base.frame18.frame20.frame25.frame27.014.019 \
        -command {get_background} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {state_bg_file} 
    frame $base.frame18.frame20.frame25.frame27.020 \
        -height {75} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.020.021 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Menupos:} 
    entry $base.frame18.frame20.frame25.frame27.020.022 \
        -background {#fefefe} -highlightthickness {1} -width {2} 
    bind $base.frame18.frame20.frame25.frame27.020.022 <Key> {
        global modified
set modified yes
    }
    label $base.frame18.frame20.frame25.frame27.020.023 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} -text {,} 
    entry $base.frame18.frame20.frame25.frame27.020.024 \
        -background {#fefefe} -highlightthickness {1} -width {2} 
    bind $base.frame18.frame20.frame25.frame27.020.024 <Key> {
        global modified
set modified yes
    }
    frame $base.frame18.frame20.frame25.frame27.025 \
        -height {75} -relief {groove} -width {125} 
    label $base.frame18.frame20.frame25.frame27.025.026 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} \
        -text {Timerpos:} 
    entry $base.frame18.frame20.frame25.frame27.025.027 \
        -background {#fefefe} -highlightthickness {1} -width {2} 
    bind $base.frame18.frame20.frame25.frame27.025.027 <Key> {
        global modified
set modified yes
    }
    label $base.frame18.frame20.frame25.frame27.025.028 \
        -borderwidth {0} -highlightthickness {1} -relief {raised} -text {,} 
    entry $base.frame18.frame20.frame25.frame27.025.029 \
        -background {#fefefe} -highlightthickness {1} -width {2} 
    bind $base.frame18.frame20.frame25.frame27.025.029 <Key> {
        global modified
set modified yes
    }
    frame $base.frame18.fra32 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame18.fra32.01 \
        -anchor {w} -borderwidth {1} -highlightthickness {1} -justify {left} \
        -padx {4} -text {Files:} 
    frame $base.frame18.fra32.02 \
        -borderwidth {2} -height {75} -highlightthickness {1} \
        -relief {groove} -width {125} 
    frame $base.frame18.fra32.02.03 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    frame $base.frame18.fra32.02.03.04 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame18.fra32.02.03.04.05 \
        -borderwidth {1} -highlightthickness {1} -text {Bindir:} 
    button $base.frame18.fra32.02.03.04.06 \
        -command {get_bindir} -highlightthickness {1} -padx {11} -pady {4} \
        -text {<default>} -textvariable {bindir} 
    frame $base.frame18.fra32.02.03.010 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame18.fra32.02.03.010.011 \
        -borderwidth {1} -highlightthickness {1} -text {Bgfile:} 
    button $base.frame18.fra32.02.03.010.012 \
        -command {get_bgfile} -highlightthickness {1} -padx {11} -pady {4} \
        -text {<default>} -textvariable {bgfile} 
    frame $base.frame18.fra32.02.03.013 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame18.fra32.02.03.013.014 \
        -borderwidth {1} -highlightthickness {1} -text {Mapfile:} 
    button $base.frame18.fra32.02.03.013.015 \
        -command {get_mapfile} -highlightthickness {1} -padx {11} -pady {4} \
        -text {<default>} -textvariable {mapfile} 
    frame $base.frame32 \
        -borderwidth {6} -height {75} -width {125} 
    label $base.frame32.label33 \
        -anchor {w} -borderwidth {1} -highlightthickness {1} -padx {4} \
        -text {Images:} 
    frame $base.frame32.frame34 \
        -borderwidth {2} -height {75} -relief {groove} -width {125} 
    frame $base.frame32.frame34.frame35 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    frame $base.frame32.frame34.frame35.frame17 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    listbox $base.frame32.frame34.frame35.frame17.listbox18 \
        -highlightthickness {1} \
        -yscrollcommand {global widget
$widget(scrollbar_images) set} 
    bind $base.frame32.frame34.frame35.frame17.listbox18 <ButtonRelease> {
        select_image
    }
    scrollbar $base.frame32.frame34.frame35.frame17.scrollbar19 \
        -background {grey77} \
        -command {global widget
$widget(listbox_images) yview} \
        -highlightthickness {1} -orient {vert} 
    frame $base.frame32.frame34.frame35.frame20 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    menubutton $base.frame32.frame34.frame35.frame20.menubutton21 \
        -highlightthickness {1} \
        -menu {.vchos.frame32.frame34.frame35.frame20.menubutton21.01} \
        -padx {4} -pady {3} -relief {raised} -text {New} 
    menu $base.frame32.frame34.frame35.frame20.menubutton21.01 \
        -cursor {} -tearoff {0} 
    $base.frame32.frame34.frame35.frame20.menubutton21.01 add command \
        -command {new_image "linux"} -label {Linux} 
    $base.frame32.frame34.frame35.frame20.menubutton21.01 add command \
        -command {new_image "big_linux"} -label {Big Linux} 
    $base.frame32.frame34.frame35.frame20.menubutton21.01 add command \
        -command {new_image "bootfile"} -label {Bootfile} 
    $base.frame32.frame34.frame35.frame20.menubutton21.01 add command \
        -command {new_image "bootsect"} -label {Bootsector} 
    button $base.frame32.frame34.frame35.frame20.button22 \
        -command {delete_image} -highlightthickness {1} -padx {4} -pady {3} \
        -text {Delete} 
    frame $base.frame32.frame34.frame23 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.label24 \
        -anchor {w} -borderwidth {1} -highlightthickness {1} -padx {4} \
        -text {Linux Image:} 
    frame $base.frame32.frame34.frame23.frame25 \
        -borderwidth {2} -height {75} -relief {groove} -width {125} 
    frame $base.frame32.frame34.frame23.frame25.frame26 \
        -borderwidth {2} -height {75} -width {125} 
    frame $base.frame32.frame34.frame23.frame25.frame26.01 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.01.02 \
        -borderwidth {1} -highlightthickness {1} -text {Name:} 
    entry $base.frame32.frame34.frame23.frame25.frame26.01.03 \
        -background {#fefefe} -highlightthickness {1} 
    frame $base.frame32.frame34.frame23.frame25.frame26.09 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.09.010 \
        -borderwidth {1} -highlightthickness {1} -text {Image:} 
    button $base.frame32.frame34.frame23.frame25.frame26.09.011 \
        -command {get_image} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {image_image} 
    frame $base.frame32.frame34.frame23.frame25.frame26.04 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.04.05 \
        -borderwidth {1} -highlightthickness {1} -text {Color:} 
    button $base.frame32.frame34.frame23.frame25.frame26.04.06 \
        \
        -command {global image_fg_color

    set image_fg_color [select_color fg]} \
        -highlightthickness {1} -padx {9} -pady {3} -text {<FG-Color>} \
        -textvariable {image_fg_color} 
    label $base.frame32.frame34.frame23.frame25.frame26.04.07 \
        -borderwidth {1} -highlightthickness {1} -text {,} 
    button $base.frame32.frame34.frame23.frame25.frame26.04.08 \
        \
        -command {global image_bg_color

    set image_bg_color [select_color bg]} \
        -highlightthickness {1} -padx {9} -pady {3} -text {<BG-Color>} \
        -textvariable {image_bg_color} 
    frame $base.frame32.frame34.frame23.frame25.frame26.012 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.012.013 \
        -borderwidth {1} -highlightthickness {1} -text {Hotkey:} 
    entry $base.frame32.frame34.frame23.frame25.frame26.012.014 \
        -background {#fefefe} -highlightthickness {1} -width {1} 
    label $base.frame32.frame34.frame23.frame25.frame26.012.015 \
        -borderwidth {1} -highlightthickness {1} -text {,} 
    menubutton $base.frame32.frame34.frame23.frame25.frame26.012.016 \
        -highlightthickness {1} \
        -menu {.vchos.frame32.frame34.frame23.frame25.frame26.012.016.017} \
        -padx {4} -pady {3} -relief {raised} -text {show} \
        -textvariable {image_hotkey_hide} 
    menu $base.frame32.frame34.frame23.frame25.frame26.012.016.017 \
        -cursor {} -tearoff {0} 
    $base.frame32.frame34.frame23.frame25.frame26.012.016.017 add command \
        -command {set_image_hotkey_hide "show"} -label {show} 
    $base.frame32.frame34.frame23.frame25.frame26.012.016.017 add command \
        -command {set_image_hotkey_hide "hide"} -label {hide} 
    frame $base.frame32.frame34.frame23.frame25.frame26.018 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.018.019 \
        -borderwidth {1} -highlightthickness {1} -text {Position:} 
    entry $base.frame32.frame34.frame23.frame25.frame26.018.020 \
        -background {#fefcfe} -highlightthickness {1} -width {2} 
    label $base.frame32.frame34.frame23.frame25.frame26.018.021 \
        -borderwidth {1} -highlightthickness {1} -text {,} 
    entry $base.frame32.frame34.frame23.frame25.frame26.018.022 \
        -background {#fefefe} -highlightthickness {1} -width {2} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame18 \
        -borderwidth {2} -height {75} -highlightthickness {1} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame18.01 \
        -borderwidth {1} -highlightthickness {1} -text {Loader:} 
    button $base.frame32.frame34.frame23.frame25.frame26.frame18.02 \
        -command {get_loader} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {image_loader} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame17 \
        -borderwidth {2} -height {75} -width {125} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18.01 \
        -borderwidth {1} -highlightthickness {1} -text {Cmdline:} 
    entry $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18.02 \
        -background {#fefefe} -highlightthickness {1} -width {10} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.01 \
        -borderwidth {1} -highlightthickness {1} -text {Initrd:} 
    button $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.02 \
        -command {get_initrd} -highlightthickness {1} -padx {9} -pady {3} \
        -text {<none>} -textvariable {image_initrd} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.03 \
        -borderwidth {1} -highlightthickness {1} -text {,} 
    entry $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.04 \
        -background {#fefcfe} -highlightthickness {1} -width {8} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame19 \
        -borderwidth {2} -height {75} -width {125} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.label21 \
        -borderwidth {0} -relief {raised} -text {Dos4boot:} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.radiobutton22 \
        -text {yes} -value {yes} -variable {image_dos4boot} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.radiobutton23 \
        -text {no} -value {no} -variable {image_dos4boot} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.label25 \
        -borderwidth {0} -relief {raised} -text {Rewrite:} 
    menubutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26 \
        \
        -menu {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26.m} \
        -padx {4} -pady {3} -relief {raised} -text {no} \
        -textvariable {image_rewrite} 
    menu $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26.m \
        -cursor {} -tearoff {0} 
    $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26.m add command \
        \
        -command {global modified image_rewrite

set image_rewrite "no"
set modified "yes"} \
        -label {no} 
    $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26.m add command \
        \
        -command {global modified image_rewrite

set image_rewrite "yes"
set modified "yes"} \
        -label {yes} 
    $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26.m add command \
        -command {get_rewrite} -label {<device>} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.label28 \
        -borderwidth {0} -relief {raised} -text {Swap FD:} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.radiobutton29 \
        -text {yes} -value {yes} -variable {image_swapfd} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.radiobutton30 \
        -text {no} -value {no} -variable {image_swapfd} 
    frame $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31 \
        -borderwidth {2} -height {75} -width {125} 
    label $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.label32 \
        -borderwidth {0} -relief {raised} -text {Swap HD:} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.radiobutton33 \
        -text {yes} -value {yes} -variable {image_swaphd} 
    radiobutton $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.radiobutton34 \
        -text {no} -value {no} -variable {image_swaphd} 
    button $base.frame32.frame34.frame23.frame25.button20 \
        -command {add_image add} -highlightthickness {1} -padx {9} -pady {3} \
        -text {Add} 
    ###################
    # SETTING GEOMETRY
    ###################
    pack $base.menu \
        -in {.vchos} -anchor {center} -expand {0} -fill {x} -side {top} 
    pack $base.menu.file \
        -in {.vchos.menu} -anchor {center} -expand {0} -fill {none} \
        -side {left} 
    pack $base.menu.help \
        -in {.vchos.menu} -anchor {center} -expand {0} -fill {none} \
        -side {right} 
    pack $base.menu.menubutton17 \
        -in {.vchos.menu} -anchor {center} -expand {0} -fill {none} \
        -side {left} 
    pack $base.frame18 \
        -in {.vchos} -anchor {center} -expand {0} -fill {x} -side {top} 
    pack $base.frame18.frame19 \
        -in {.vchos.frame18} -anchor {center} -expand {1} -fill {both} \
        -padx {2} -side {left} 
    pack $base.frame18.frame19.label22 \
        -in {.vchos.frame18.frame19} -anchor {center} -expand {0} -fill {x} \
        -side {top} 
    pack $base.frame18.frame19.frame23 \
        -in {.vchos.frame18.frame19} -anchor {center} -expand {1} \
        -fill {both} -side {top} 
    pack $base.frame18.frame19.frame23.frame26 \
        -in {.vchos.frame18.frame19.frame23} -anchor {center} -expand {0} \
        -fill {none} -side {top} 
    pack $base.frame18.frame19.frame23.frame26.01 \
        -in {.vchos.frame18.frame19.frame23.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame19.frame23.frame26.01.02 \
        -in {.vchos.frame18.frame19.frame23.frame26.01} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame19.frame23.frame26.01.03 \
        -in {.vchos.frame18.frame19.frame23.frame26.01} -anchor {center} \
        -expand {0} -fill {none} -side {right} 
    pack $base.frame18.frame19.frame23.frame26.05 \
        -in {.vchos.frame18.frame19.frame23.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame19.frame23.frame26.05.06 \
        -in {.vchos.frame18.frame19.frame23.frame26.05} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame19.frame23.frame26.05.07 \
        -in {.vchos.frame18.frame19.frame23.frame26.05} -anchor {center} \
        -expand {0} -fill {none} -side {right} 
    pack $base.frame18.frame19.frame23.frame26.09 \
        -in {.vchos.frame18.frame19.frame23.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame19.frame23.frame26.09.010 \
        -in {.vchos.frame18.frame19.frame23.frame26.09} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame19.frame23.frame26.09.011 \
        -in {.vchos.frame18.frame19.frame23.frame26.09} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame19.frame23.frame26.012 \
        -in {.vchos.frame18.frame19.frame23.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame19.frame23.frame26.012.013 \
        -in {.vchos.frame18.frame19.frame23.frame26.012} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame19.frame23.frame26.012.014 \
        -in {.vchos.frame18.frame19.frame23.frame26.012} -anchor {center} \
        -expand {0} -fill {none} -side {right} 
    pack $base.frame18.frame20 \
        -in {.vchos.frame18} -anchor {center} -expand {1} -fill {both} \
        -padx {2} -side {left} 
    pack $base.frame18.frame20.label24 \
        -in {.vchos.frame18.frame20} -anchor {center} -expand {0} -fill {x} \
        -side {top} 
    pack $base.frame18.frame20.frame25 \
        -in {.vchos.frame18.frame20} -anchor {center} -expand {1} \
        -fill {both} -side {top} 
    pack $base.frame18.frame20.frame25.frame27 \
        -in {.vchos.frame18.frame20.frame25} -anchor {center} -expand {1} \
        -fill {both} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.01 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {1} -fill {x} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.01.02 \
        -in {.vchos.frame18.frame20.frame25.frame27.01} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.01.03 \
        -in {.vchos.frame18.frame20.frame25.frame27.01} -anchor {center} \
        -expand {1} -fill {x} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.04 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.04.05 \
        -in {.vchos.frame18.frame20.frame25.frame27.04} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.04.06 \
        -in {.vchos.frame18.frame20.frame25.frame27.04} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.04.07 \
        -in {.vchos.frame18.frame20.frame25.frame27.04} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.08 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.08.09 \
        -in {.vchos.frame18.frame20.frame25.frame27.08} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.08.010 \
        -in {.vchos.frame18.frame20.frame25.frame27.08} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.011 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.011.012 \
        -in {.vchos.frame18.frame20.frame25.frame27.011} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.011.013 \
        -in {.vchos.frame18.frame20.frame25.frame27.011} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.014 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.014.015 \
        -in {.vchos.frame18.frame20.frame25.frame27.014} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.014.018 \
        -in {.vchos.frame18.frame20.frame25.frame27.014} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.014.016 \
        -in {.vchos.frame18.frame20.frame25.frame27.014} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.014.019 \
        -in {.vchos.frame18.frame20.frame25.frame27.014} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.020 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.020.021 \
        -in {.vchos.frame18.frame20.frame25.frame27.020} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.020.022 \
        -in {.vchos.frame18.frame20.frame25.frame27.020} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.020.023 \
        -in {.vchos.frame18.frame20.frame25.frame27.020} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.020.024 \
        -in {.vchos.frame18.frame20.frame25.frame27.020} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.025 \
        -in {.vchos.frame18.frame20.frame25.frame27} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame18.frame20.frame25.frame27.025.026 \
        -in {.vchos.frame18.frame20.frame25.frame27.025} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.025.027 \
        -in {.vchos.frame18.frame20.frame25.frame27.025} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.025.028 \
        -in {.vchos.frame18.frame20.frame25.frame27.025} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.frame20.frame25.frame27.025.029 \
        -in {.vchos.frame18.frame20.frame25.frame27.025} -anchor {center} \
        -expand {0} -fill {none} -side {left} 
    pack $base.frame18.fra32 \
        -in {.vchos.frame18} -anchor {center} -expand {1} -fill {both} \
        -side {top} 
    pack $base.frame18.fra32.01 \
        -in {.vchos.frame18.fra32} -anchor {center} -expand {0} -fill {x} \
        -side {top} 
    pack $base.frame18.fra32.02 \
        -in {.vchos.frame18.fra32} -anchor {center} -expand {1} -fill {both} \
        -side {top} 
    pack $base.frame18.fra32.02.03 \
        -in {.vchos.frame18.fra32.02} -anchor {center} -expand {1} \
        -fill {both} -side {left} 
    pack $base.frame18.fra32.02.03.04 \
        -in {.vchos.frame18.fra32.02.03} -anchor {center} -expand {0} \
        -fill {none} -side {top} 
    pack $base.frame18.fra32.02.03.04.05 \
        -in {.vchos.frame18.fra32.02.03.04} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame18.fra32.02.03.04.06 \
        -in {.vchos.frame18.fra32.02.03.04} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame18.fra32.02.03.010 \
        -in {.vchos.frame18.fra32.02.03} -anchor {center} -expand {0} \
        -fill {none} -side {top} 
    pack $base.frame18.fra32.02.03.010.011 \
        -in {.vchos.frame18.fra32.02.03.010} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame18.fra32.02.03.010.012 \
        -in {.vchos.frame18.fra32.02.03.010} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame18.fra32.02.03.013 \
        -in {.vchos.frame18.fra32.02.03} -anchor {center} -expand {0} \
        -fill {none} -side {top} 
    pack $base.frame18.fra32.02.03.013.014 \
        -in {.vchos.frame18.fra32.02.03.013} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame18.fra32.02.03.013.015 \
        -in {.vchos.frame18.fra32.02.03.013} -anchor {center} -expand {0} \
        -fill {none} -side {left} 
    pack $base.frame32 \
        -in {.vchos} -anchor {center} -expand {1} -fill {both} -side {top} 
    pack $base.frame32.label33 \
        -in {.vchos.frame32} -anchor {center} -expand {0} -fill {x} \
        -side {top} 
    pack $base.frame32.frame34 \
        -in {.vchos.frame32} -anchor {center} -expand {1} -fill {both} \
        -side {left} 
    pack $base.frame32.frame34.frame35 \
        -in {.vchos.frame32.frame34} -anchor {center} -expand {0} -fill {y} \
        -side {left} 
    pack $base.frame32.frame34.frame35.frame17 \
        -in {.vchos.frame32.frame34.frame35} -anchor {center} -expand {1} \
        -fill {y} -side {top} 
    pack $base.frame32.frame34.frame35.frame17.listbox18 \
        -in {.vchos.frame32.frame34.frame35.frame17} -anchor {center} \
        -expand {0} -fill {y} -side {left} 
    pack $base.frame32.frame34.frame35.frame17.scrollbar19 \
        -in {.vchos.frame32.frame34.frame35.frame17} -anchor {center} \
        -expand {0} -fill {y} -side {left} 
    pack $base.frame32.frame34.frame35.frame20 \
        -in {.vchos.frame32.frame34.frame35} -anchor {center} -expand {0} \
        -fill {x} -side {top} 
    pack $base.frame32.frame34.frame35.frame20.menubutton21 \
        -in {.vchos.frame32.frame34.frame35.frame20} -anchor {center} \
        -expand {0} -fill {none} -ipadx {5} -ipady {5} -padx {10} -pady {10} \
        -side {left} 
    pack $base.frame32.frame34.frame35.frame20.button22 \
        -in {.vchos.frame32.frame34.frame35.frame20} -anchor {center} \
        -expand {0} -fill {none} -ipadx {5} -ipady {5} -padx {10} -pady {10} \
        -side {right} 
    pack $base.frame32.frame34.frame23 \
        -in {.vchos.frame32.frame34} -anchor {center} -expand {1} \
        -fill {both} -side {left} 
    pack $base.frame32.frame34.frame23.label24 \
        -in {.vchos.frame32.frame34.frame23} -anchor {center} -expand {0} \
        -fill {x} -side {top} 
    pack $base.frame32.frame34.frame23.frame25 \
        -in {.vchos.frame32.frame34.frame23} -anchor {center} -expand {1} \
        -fill {both} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26 \
        -in {.vchos.frame32.frame34.frame23.frame25} -anchor {center} \
        -expand {1} -fill {both} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.01 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.01.02 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.01} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.01.03 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.01} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.09 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.09.010 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.09} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.09.011 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.09} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.04 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.04.05 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.04} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.04.06 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.04} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.04.07 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.04} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.04.08 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.04} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.012 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.012.013 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.012} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.012.014 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.012} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.012.015 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.012} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.012.016 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.012} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.018 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.018.019 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.018} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.018.020 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.018} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.018.021 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.018} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.018.022 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.018} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame18 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame18.01 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame18} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame18.02 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame18} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26} -anchor {center} \
        -expand {0} -fill {x} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17} \
        -anchor {center} -expand {0} -fill {x} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18.01 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame18} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame18.02 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame18} \
        -anchor {center} -expand {1} -fill {x} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.01 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.02 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.03 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame17.frame19.04 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame17.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.label21 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame20} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.radiobutton22 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame20} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame20.radiobutton23 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame20} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.label25 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame24} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame24.menubutton26 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame24} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.label28 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame27} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.radiobutton29 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame27} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame27.radiobutton30 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame27} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19} \
        -anchor {center} -expand {0} -fill {none} -side {top} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.label32 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame31} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.radiobutton33 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame31} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.frame26.frame19.frame31.radiobutton34 \
        -in {.vchos.frame32.frame34.frame23.frame25.frame26.frame19.frame31} \
        -anchor {center} -expand {0} -fill {none} -side {left} 
    pack $base.frame32.frame34.frame23.frame25.button20 \
        -in {.vchos.frame32.frame34.frame23.frame25} -anchor {center} \
        -expand {0} -fill {none} -ipadx {5} -ipady {5} -padx {10} -pady {10} \
        -side {top} 
}

Window show .
Window show .vchos

main $argc $argv
