#!/bin/sh
# the next line restarts using wish\
exec wish "$0" "$@" 

if {![info exists vTcl(sourcing)]} {
    switch $tcl_platform(platform) {
	windows {
	}
	default {
	    option add *Scrollbar.width 10
	}
    }
    
}
#############################################################################
# Visual Tcl v1.51 Project
#

#################################
# VTCL LIBRARY PROCEDURES
#

if {![info exists vTcl(sourcing)]} {
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 }
    if {$name == "."} { wm withdraw $name; return }
    set exists [winfo exists $newname]
    switch $cmd {
        show {
            if {$exists} {
                wm deiconify $newname
            } elseif {[info procs vTclWindow$name] != ""} {
                eval "vTclWindow$name $newname $rest"
            }
            if {[wm state $newname] == "normal"} {
                vTcl:FireEvent $newname <<Show>>
            }
        }
        hide    {
            if {$exists} {
                wm withdraw $newname
                vTcl:FireEvent $newname <<Hide>>
                return}
        }
        iconify { if $exists {wm iconify $newname; return} }
        destroy { if $exists {destroy $newname; return} }
    }
}
}

if {![info exists vTcl(sourcing)]} {
proc {vTcl:DefineAlias} {target alias widgetProc top_or_alias cmdalias} {
    global widget

    set widget($alias) $target
    set widget(rev,$target) $alias

    if {$cmdalias} {
        interp alias {} $alias {} $widgetProc $target
    }

    if {$top_or_alias != ""} {
        set widget($top_or_alias,$alias) $target

        if {$cmdalias} {
            interp alias {} $top_or_alias.$alias {} $widgetProc $target
        }
    }
}

proc {vTcl:DoCmdOption} {target cmd} {
    ## menus are considered toplevel windows
    set parent $target
    while {[winfo class $parent] == "Menu"} {
        set parent [winfo parent $parent]
    }

    regsub -all {\%widget} $cmd $target cmd
    regsub -all {\%top} $cmd [winfo toplevel $parent] cmd

    uplevel #0 [list eval $cmd]
}

proc {vTcl:FireEvent} {target event} {
    foreach bindtag [bindtags $target] {
        set tag_events [bind $bindtag]
        set stop_processing 0
        foreach tag_event $tag_events {
            if {$tag_event == $event} {
                set bind_code [bind $bindtag $tag_event]
                regsub -all %W $bind_code $target bind_code
                set result [catch {uplevel #0 $bind_code} errortext]
                if {$result == 3} {
                    # break exception, stop processing
                    set stop_processing 1
                } elseif {$result != 0} {
                    bgerror $errortext
                }
                break
            }
        }
        if {$stop_processing} {break}
    }
}

proc {vTcl:Toplevel:WidgetProc} {w args} {
    if {[llength $args] == 0} {
        return -code error "wrong # args: should be \"$w option ?arg arg ...?\""
    }

    ## The first argument is a switch, they must be doing a configure.
    if {[string index $args 0] == "-"} {
        set command configure

        ## There's only one argument, must be a cget.
        if {[llength $args] == 1} {
            set command cget
        }
    } else {
        set command [lindex $args 0]
        set args [lrange $args 1 end]
    }

    switch -- $command {
        "hide" -
        "Hide" {
            Window hide $w
        }

        "show" -
        "Show" {
            Window show $w
        }

        "ShowModal" {
            Window show $w
            raise $w
            grab $w
            tkwait window $w
            grab release $w
        }

        default {
            eval $w $command $args
        }
    }
}

proc {vTcl:WidgetProc} {w args} {
    if {[llength $args] == 0} {
        return -code error "wrong # args: should be \"$w option ?arg arg ...?\""
    }

    ## The first argument is a switch, they must be doing a configure.
    if {[string index $args 0] == "-"} {
        set command configure

        ## There's only one argument, must be a cget.
        if {[llength $args] == 1} {
            set command cget
        }
    } else {
        set command [lindex $args 0]
        set args [lrange $args 1 end]
    }

    eval $w $command $args
}

proc {vTcl:toplevel} {args} {
    uplevel #0 eval toplevel $args
    set target [lindex $args 0]
    namespace eval ::$target {}
}
}

if {[info exists vTcl(sourcing)]} {
proc vTcl:project:info {} {
    namespace eval ::widgets::.yaprimaxgui {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.01 {
        array set save {-activebackground 1 -activeforeground 1 -anchor 1 -background 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -menu 1 -padx 1 -pady 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.01.02 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -cursor 1 -foreground 1 -tearoff 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.03 {
        array set save {-activebackground 1 -activeforeground 1 -anchor 1 -background 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -menu 1 -padx 1 -pady 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.03.04 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -cursor 1 -foreground 1 -tearoff 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.05 {
        array set save {-activebackground 1 -activeforeground 1 -anchor 1 -background 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -menu 1 -padx 1 -pady 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.cpd17.05.06 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -cursor 1 -foreground 1 -tearoff 1}
    }
    namespace eval ::widgets::.yaprimaxgui.preview-border {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.preview-border.preview {
        array set save {-background 1 -closeenough 1 -height 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -insertbackground 1 -selectbackground 1 -selectborderwidth 1 -selectforeground 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.color {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.resolution {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.contrast {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.brightness {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.gamma {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.size {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.filesize {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.compression {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control.preview {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control.clear {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control.scan {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control.but46 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.control.but48 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.file {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.file.name {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui.file.select {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.file.label {
        array set save {-background 1 -borderwidth 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.lamp {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.lamp.lamp-on {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.lamp.lamp-off {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui.lamp.label {
        array set save {-background 1 -borderwidth 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui.lamp.status {
        array set save {-background 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.resolution {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -command 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -label 1 -orient 1 -relief 1 -resolution 1 -showvalue 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.select {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -indicatoron 1 -menu 1 -padx 1 -pady 1 -relief 1 -text 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.select.m {
        array set save {-activebackground 1 -activeforeground 1 -cursor 1 -foreground 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.red {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.green {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.blue {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -state 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.rgb {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.gray {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.bw {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.label {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.channels {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.channels.1 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightcolor 1 -padx 1 -pady 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.channels.2 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightcolor 1 -padx 1 -pady 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.channels.4 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightcolor 1 -padx 1 -pady 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.channels.3 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightcolor 1 -padx 1 -pady 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.photo.color.label37 {
        array set save {-background 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.button34 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.button35 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image.button36 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.brightness {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -command 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -label 1 -orient 1 -relief 1 -resolution 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.contrast {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -command 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -label 1 -orient 1 -relief 1 -resolution 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.gamma {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -command 1 -cursor 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -label 1 -orient 1 -relief 1 -resolution 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.back {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.back.label {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.back.compression {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -indicatoron 1 -menu 1 -padx 1 -pady 1 -relief 1 -text 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.back.compression.m {
        array set save {-activebackground 1 -activeforeground 1 -cursor 1 -foreground 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.more.warning {
        array set save {-background 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.close {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-image-more.default {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.ok {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.apply {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.cancel {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.default {
        array set save {-activebackground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38.01 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38.02 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38.03 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38.04 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame38.05 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.01 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.02 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -insertbackground 1 -insertborderwidth 1 -selectbackground 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.03 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.05 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.06 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -insertbackground 1 -selectbackground 1 -selectforeground 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.rad41 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame39.rad43 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.01 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.02 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -insertbackground 1 -insertborderwidth 1 -selectbackground 1 -selectforeground 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.03 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.05 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.06 {
        array set save {-background 1 -borderwidth 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -insertbackground 1 -selectbackground 1 -selectforeground 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.rad44 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-options.back.frame40.rad45 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxguihelp {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxguihelp.ok {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxguihelp.text {
        array set save {-background 1 -borderwidth 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -insertborderwidth 1 -padx 1 -pady 1 -selectbackground 1 -selectforeground 1 -wrap 1 -yscrollcommand 1}
    }
    namespace eval ::widgets::.yaprimaxguihelp.scroll {
        array set save {-activebackground 1 -background 1 -borderwidth 1 -command 1 -cursor 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -troughcolor 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner {
        array set save {-background 1 -highlightbackground 1 -highlightcolor 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra18 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra18.lab19 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra18.rad20 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra18.rad22 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra23 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra23.lab24 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra23.ent25 {
        array set save {-background 1 -borderwidth 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -insertbackground 1 -selectbackground 1 -selectforeground 1 -textvariable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra23.lab26 {
        array set save {-background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra23.sca28 {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -label 1 -orient 1 -relief 1 -resolution 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra29 {
        array set save {-background 1 -borderwidth 1 -height 1 -highlightbackground 1 -highlightcolor 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra29.che30 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra29.che31 {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -selectcolor 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.settings.fra29.sca32 {
        array set save {-activebackground 1 -background 1 -bigincrement 1 -font 1 -foreground 1 -from 1 -highlightbackground 1 -highlightcolor 1 -label 1 -orient 1 -relief 1 -resolution 1 -tickinterval 1 -to 1 -troughcolor 1 -variable 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.ok {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.apply {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.cancel {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.default {
        array set save {-activebackground 1 -activeforeground 1 -background 1 -borderwidth 1 -command 1 -disabledforeground 1 -font 1 -foreground 1 -highlightbackground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.menubutton36 {
        array set save {-activebackground 1 -activeforeground 1 -borderwidth 1 -font 1 -foreground 1 -height 1 -highlightbackground 1 -highlightcolor 1 -highlightthickness 1 -indicatoron 1 -menu 1 -padx 1 -pady 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.yaprimaxgui-scanner.menubutton36.m {
        array set save {-activebackground 1 -activeforeground 1 -cursor 1 -foreground 1}
    }
    namespace eval ::widgets_bindings {
        set tagslist {}
    }
}
}
#################################
# USER DEFINED PROCEDURES
#
###########################################################
## Procedure:  button-down

proc {button-down} {sx sy} {
global selection xposa yposa xposb yposb

set xposa $sx
set yposa $sy
set xposb $sx
set yposb $sy

.yaprimaxgui.preview-border.preview delete $selection

set selection [.yaprimaxgui.preview-border.preview create rectangle $xposa $yposa $xposa $yposa -outline blue]
}
###########################################################
## Procedure:  button-motion

proc {button-motion} {nx ny} {
global widget selection xposa yposa xposb yposb

set xposb $nx
set yposb $ny

if { $xposb <= "0" } {
    if { $yposb <= "0" } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 0 0
        set xposb 0
        set yposb 0
        show-size 0
    } elseif { $yposb >= 314 } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 0 314
        set xposb 0
        set yposb 314
        show-size 0
    } else {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 0 $ny
        set xposb 0
        show-size 0
    }
} elseif { $xposb >= 228 } {
    if { $yposb <= "0" } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 228 0
        set xposb 228
        set yposb 0
        show-size 0
    } elseif { $yposb >= 314 } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 228 314
        set xposb 228
        set yposb 314
        show-size 0
    } else {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 228 $ny
        set xposb 228
        show-size 0
    }
} elseif { $yposb <= "0" } {
    if { $xposb <= "0" } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 0 0
        set yposb 0
        set xposb 0
        show-size 0
    } elseif { $xposb >= 228 } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 228 0
        set yposb 0
        set xposb 228
        show-size 0
    } else {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $nx 0
        set yposb 0
        show-size 0
    }
} elseif { $yposb >= "314" } {
    if { $xposb <= "0" } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 0 314
        set xposb 0
        set yposb 314
        show-size 0
    } elseif { $xposb >= 228 } {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa 228 314
        set xposb 228
        set yposb 314
        show-size 0
    } else {
        .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $nx 314
        set yposb 314
        show-size 0
    }
} else {
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $nx $ny
    show-size 0
}
}
###########################################################
## Procedure:  button-release

proc {button-release} {} {
global selection xposa yposa xposb yposb

set range ok

if { [expr $xposb - $xposa] == "0" } {
    set range out
} elseif { [expr $yposb - $yposa] == "0" } {
    set range out
}

if { $range == "ok" } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline green
} else {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline red
    after 500 {.yaprimaxgui.preview-border.preview delete $selection
    set selection [.yaprimaxgui.preview-border.preview create rectangle 0 0 228 314 -outline green]
    set xposa 0
    set yposa 0
    set xposb 228
    set yposb 314
    show-size 0}
}

show-size 0
}
###########################################################
## Procedure:  button2-down

proc {button2-down} {sx sy} {
global orix oriy
set orix $sx
set oriy $sy
}
###########################################################
## Procedure:  button2-motion

proc {button2-motion} {nx ny} {
global pos xposa yposa xposb yposb orix oriy selection

if { $pos == "move" } {
    set movex [expr $nx - $orix]
    set movey [expr $ny - $oriy]
    set xposa [expr $xposa + $movex ]
    set yposa [expr $yposa + $movey ]
    set xposb [expr $xposb + $movex ]
    set yposb [expr $yposb + $movey ]
    set orix $nx
    set oriy $ny
    if { $xposb > 228 | $xposa < 0 | $xposb < 0 | $xposa > 228 } {
        set xposa [expr $xposa - $movex ]
        set xposb [expr $xposb - $movex ]
    }
    if { $yposb > 314 | $yposa < 0 | $yposb < 0 | $yposa > 314 } {
        set yposa [expr $yposa - $movey ]
        set yposb [expr $yposb - $movey ]
    }
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize1a" } {
    set movex [expr $nx - $orix]
    set xposb [expr $xposb + $movex ]
    set orix $nx
    set oriy $ny
    if { $xposb < 0 } {
        set xposb 0
    } elseif { $xposb > 228 } {
        set xposb 228
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize2a" } {
    set movey [expr $ny - $oriy]
    set yposa [expr $yposa + $movey ]
    set orix $nx
    set oriy $ny
    if { $yposa < 0 } {
        set yposa 0
    } elseif { $yposa > 314 } {
        set yposa 314
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize3a" } {
    set movex [expr $nx - $orix]
    set xposa [expr $xposa + $movex ]
    set orix $nx
    set oriy $ny
    if { $xposa < 0 } {
        set xposa 0
    } elseif { $xposa > 228 } {
        set xposa 228
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize4a" } {
    set movey [expr $ny - $oriy]
    set yposb [expr $yposb + $movey ]
    set orix $nx
    set oriy $ny
    if { $yposb < 0 } {
        set yposb 0
    } elseif { $yposb > 314 } {
        set yposb 314
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize1b" } {
    set movex [expr $nx - $orix]
    set xposa [expr $xposa + $movex ]
    set orix $nx
    set oriy $ny
    if { $xposa < 0 } {
        set xposa 0
    } elseif { $xposa > 228 } {
        set xposa 228
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize2b" } {
    set movey [expr $ny - $oriy]
    set yposb [expr $yposb + $movey ]
    set orix $nx
    set oriy $ny
    if { $yposb < 0 } {
        set yposb 0
    } elseif { $yposb > 314 } {
        set yposb 314
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize3b" } {
    set movex [expr $nx - $orix]
    set xposb [expr $xposb + $movex ]
    set orix $nx
    set oriy $ny
    if { $xposb < 0 } {
        set xposb 0
    } elseif { $xposb > 228 } {
        set xposb 228
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
} elseif { $pos == "resize4b" } {
    set movey [expr $ny - $oriy]
    set yposa [expr $yposa + $movey ]
    set orix $nx
    set oriy $ny
    if { $yposa < 0 } {
        set yposa 0
    } elseif { $yposa > 314 } {
        set yposa 314
    }
    show-size 0
    .yaprimaxgui.preview-border.preview coords $selection $xposa $yposa $xposb $yposb
}
}
###########################################################
## Procedure:  button2-release

proc {button2-release} {sx sy} {
global selection xposa yposa xposb yposb

set range ok

if { [expr $xposb - $xposa] == "0" } {
    set range out
} elseif { [expr $yposb - $yposa] == "0" } {
    set range out
}

if { $range == "ok" } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline green
} else {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline red
    after 500 {.yaprimaxgui.preview-border.preview delete $selection
    set selection [.yaprimaxgui.preview-border.preview create rectangle 0 0 228 314 -outline green]
    set xposa 0
    set yposa 0
    set xposb 228
    set yposb 314
    show-size 0}
}

show-size 0
}
###########################################################
## Procedure:  motion

proc {motion} {sx sy} {
global xposa xposb yposa yposb selection pos

if { $sx > $xposa & $sx < $xposb & $sy > $yposa & $sy < $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline blue
    set pos move
} elseif { $sx < $xposa & $sx > $xposb & $sy < $yposa & $sy > $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline blue
    set pos move
} elseif { $sx < $xposb & $sx > $xposa & $sy < $yposa & $sy > $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline blue
    set pos move
} elseif { $sx < $xposa & $sx > $xposb & $sy < $yposb & $sy > $yposa } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline blue
    set pos move
} elseif { $sx == $xposa & $sy > $yposa & $sy < $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize3a
} elseif { $sx == $xposb & $sy > $yposa & $sy < $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize1a
} elseif { $sy == $yposa & $sx > $xposa & $sx < $xposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize2a
} elseif { $sy == $yposb & $sx > $xposa & $sx < $xposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize4a
} elseif { $sx == $xposa & $sy < $yposa & $sy > $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize1b
} elseif { $sx == $xposb & $sy < $yposa & $sy > $yposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize3b
} elseif { $sy == $yposa & $sx < $xposa & $sx > $xposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize4b
} elseif { $sy == $yposb & $sx < $xposa & $sx > $xposb } {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline yellow
    set pos resize2b
} else {
    .yaprimaxgui.preview-border.preview itemconfigure $selection -outline green
    set pos 0
}
}
###########################################################
## Procedure:  none

proc {none} {0} {
global widget
}
###########################################################
## Procedure:  options-save

proc {options-save} {} {
global rc

puts "Saving options..."

set file [open [glob ~]/.yaprimaxGUIrc "w"]

puts $file {;# Yet Another Primax GUI}
puts $file {;# ^^^^^^^^^^^^^^^^^^^^^^}
puts $file {;# Do not edit!}

foreach var [lsort [array names rc]] {
        puts $file "set rc($var) \{$rc($var)\}"
}

close $file

puts "Done!"
}
###########################################################
## Procedure:  prev

proc {prev} {} {
global rc previmage selection

puts "Preview..."

if { $rc(primax) == "primax_scan" } {
    puts "$rc(primax) --port=$rc(hex) --speed=$rc(speed) --Scanner=$rc(maxres) --contrast=$rc(contrast) --brightness=$rc(brightness) --gamma=$rc(gamma) --Compression=$rc(compression) $rc(color) -p0x0 -d 8.5x11.7 -r 27 -f /tmp/thumb.tif"
    exec $rc(primax) --port=$rc(hex) --speed=$rc(speed) --Scanner=$rc(maxres) --contrast=$rc(contrast) --brightness=$rc(brightness) --gamma=$rc(gamma) --Compression=$rc(compression) $rc(color) --pos=0x0 --dim=8.5x11.7 --res=27 --file=/tmp/thumb.tif >>& /dev/null
}

if { $rc(primax) == "pxscan" } {
    if { $rc(color) == "--RGB" } {
        set color ""
    } elseif {$rc(color) == "--GRAY" } {
        set color "-G"
    } else {
        set color $rc(color)
    }
    puts "$rc(primax) --port=$rc(hex) --pos=0x0 --dim=8.5x11.7 --color=$rc(contrast)/$rc(brightness)/$rc(gamma) --res=27 -n /tmp/thumb.tif $color"
    exec $rc(primax) --port=$rc(hex) --pos=0x0 --dim=8.5x11.7 --color=$rc(contrast)/$rc(brightness)/$rc(gamma) --res=27 -n /tmp/thumb.tif $color >>& /dev/null
}
puts "tifftopnm /tmp/thumb.tif \> /tmp/thumb.pnm"
exec tifftopnm /tmp/thumb.tif > /tmp/thumb.pnm 2> /dev/null

puts "Deleting /tmp/thumb.tif"
file delete -force /tmp/thumb.tif

puts "Generating preview"
image create photo "scan" -file [file join /tmp/thumb.pnm]
image create photo "preview"
preview copy scan -subsample 1 1 -shrink
set previmage [.yaprimaxgui.preview-border.preview create image 115 157 -image preview]
.yaprimaxgui.preview-border.preview delete $selection
set selection [.yaprimaxgui.preview-border.preview create rectangle 0 0 228 314 -outline green]
set xposa 0
set yposa 0
set xposb 228
set yposb 314
show-size 0

puts "Deleting /tmp/thumb.pnm"
file delete -force /tmp/thumb.pnm

puts "Done!"
}
###########################################################
## Procedure:  quit

proc {quit} {} {
global rc
options-save
if { $rc(off) == 1 } {
puts "Turning lamp off.."
eval exec $rc(primax) --port=$rc(hex) --lamp=off
.yaprimaxgui.lamp.status configure -text "Turned off"
.yaprimaxgui.lamp.status configure -background red
puts "Done!"
}
puts "Exiting...\nAny bugs, sugestions or comments, please CONTACT THE AUTHOR: neo_fpo@ig.com.br\nCheck for new versions at: http://orbita.starmedia.com/~neofpo/"
exit
}
###########################################################
## Procedure:  scan-image

proc {scan-image} {} {
global rc xpos ypos xsize ysize cancel tiff

if { $tiff == "" } {
    set types {
    {{TIFF Images} {.tif}}
    {{All Files} *}
    }
    set gettiff [tk_getSaveFile -defaultextension .tif -filetypes $types -initialdir $rc(path2tiff) -initialfile scanned-image.tif -parent .yaprimaxgui -title "Select filename to save"]
    if { $gettiff != "" } {
        set tiff $gettiff
        set rc(path2tiff) [string range $tiff 0 [string last / $tiff]]
        set cancel 0
    } else {
        set cancel 1
    }
} else {
    set cancel 0
}

if { $cancel != "1" } {
    puts "Scanning selected area..."
    if { $rc(primax) == "primax_scan" } {
        puts "$rc(primax) --port=$rc(hex) --speed=$rc(speed) --Scanner=$rc(maxres) --contrast=$rc(contrast) --brightness=$rc(brightness) --gamma=$rc(gamma) --Compression=$rc(compression) $rc(color) --pos=$xpos\x$ypos --dim=$xsize\x$ysize --res=$rc(resolution) --file=$tiff"
        exec $rc(primax) --port=$rc(hex) --speed=$rc(speed) --Scanner=$rc(maxres) --contrast=$rc(contrast) --brightness=$rc(brightness) --gamma=$rc(gamma) --Compression=$rc(compression) $rc(color) --pos=$xpos\x$ypos --dim=$xsize\x$ysize --res=$rc(resolution) --file=$tiff >>& /dev/null
    }
    if { $rc(primax) == "pxscan" } {
        if { $rc(color) == "--RGB" } {
            set color ""
        } elseif {$rc(color) == "--GRAY" } {
            set color "-G"
        } else {
            set color $rc(color)
        }
    puts "$rc(primax) --port=$rc(hex) --pos=$xpos\x$ypos --dim=$xsize\x$ysize --color=$rc(contrast)/$rc(brightness)/$rc(gamma) --res=$rc(resolution) -n $tiff $color"
    exec $rc(primax) --port=$rc(hex) --pos=$xpos\x$ypos --dim=$xsize\x$ysize --color=$rc(contrast)/$rc(brightness)/$rc(gamma) --res=$rc(resolution) -n $tiff $color >>& /dev/null
    }
    puts "Done!"
}
}
###########################################################
## Procedure:  show-size

proc {show-size} {arg} {
global rc xposa yposa xposb yposb xpos ypos xsize ysize

if { $xposb > $xposa } {
    set xpos [expr $xposa  * (11.7/314)]
    set xsize [expr ($xposb - $xposa) * (11.7/314)]
} else {
    set xpos [expr $xposb * (11.7/314)]
    set xsize [expr ($xposa - $xposb) * (11.7/314)]
}

if { $yposb > $yposa } {
    set ypos [expr $yposa  * (11.7/314)]
    set ysize [expr ($yposb - $yposa) * (11.7/314)]
} else {
    set ypos [expr $yposb * (11.7/314)]
    set ysize [expr ($yposa - $yposb) * (11.7/314)]
}

if { "$rc(color)" == "--RGB" } {
    set xco 3
} elseif { "$rc(color)" == "--GRAY" } {
    set xco 1
} elseif { "$rc(color)" == "--GREEN" } {
    set xco 1
} elseif { "$rc(color)" == "--BLUE" } {
    set xco 1
} elseif { "$rc(color)" == "--RED" } {
    set xco 1
} elseif { "$rc(color)" == "--BW" } {
    set xco 0.125
}

set size [expr $xsize * $ysize * $rc(resolution) * $rc(resolution) * $xco]

if { $size < 1024 } {
     set human [string range $size 0 [expr [string first . $size] -1 ] ]
    .yaprimaxgui.filesize configure -text "$human bytes"
} else {
    if { $size > 1048576 } {
        set value [expr $size / 1048576]
        set human [string range $value 0 [expr [string first . $value] -1 ] ][string range $value [string first . $value] [expr [string first . $value] + 2]]
        .yaprimaxgui.filesize configure -text "$human Mb"
    } else {
        set value [expr $size / 1024]
        set human [string range $value 0 [expr [string first . $value] -1 ] ][string range $value [string first . $value] [expr [string first . $value] + 2]]
        .yaprimaxgui.filesize configure -text "$human Kb"
    }
}

if { "$rc(unit)" == "mm" } {
    set xvalue [expr $xsize / 0.03937]
    set yvalue [expr $ysize / 0.03937 ]
    set humanx [string range $xvalue 0 [expr [string first . $xvalue] -1 ] ][string range $xvalue [string first . $xvalue] [expr [string first . $xvalue] + 2]]
    set humany [string range $yvalue 0 [expr [string first . $yvalue] -1 ] ][string range $yvalue [string first . $yvalue] [expr [string first . $yvalue] + 2]]
    .yaprimaxgui.size configure -text "$humanx x $humany mm"
} elseif { "$rc(unit)" == "cm" } {
    set xvalue [expr $xsize / 0.3937]
    set yvalue [expr $ysize / 0.3937 ]
    set humanx [string range $xvalue 0 [expr [string first . $xvalue] -1 ] ][string range $xvalue [string first . $xvalue] [expr [string first . $xvalue] + 2]]
    set humany [string range $yvalue 0 [expr [string first . $yvalue] -1 ] ][string range $yvalue [string first . $yvalue] [expr [string first . $yvalue] + 2]]
    .yaprimaxgui.size configure -text "$humanx x $humany cm"
} elseif { "$rc(unit)" == "inches" } {
    set humanx [string range $xsize 0 [expr [string first . $xsize] -1 ] ][string range $xsize [string first . $xsize] [expr [string first . $xsize] + 2]]
    set humany [string range $ysize 0 [expr [string first . $ysize] -1 ] ][string range $ysize [string first . $ysize] [expr [string first . $ysize] + 2]]
    .yaprimaxgui.size configure -text "$humanx x $humany inche(s)"
} elseif { "$rc(unit)" == "pixels" } {
    set xvalue [expr $xsize * $rc(resolution)]
    set yvalue [expr $ysize * $rc(resolution)]
    set humanx [string range $xvalue 0 [expr [string first . $xvalue] -1 ] ][string range $xvalue [string first . $xvalue] [expr [string first . $xvalue] + 2]]
    set humany [string range $yvalue 0 [expr [string first . $yvalue] -1 ] ][string range $yvalue [string first . $yvalue] [expr [string first . $yvalue] + 2]]
    .yaprimaxgui.size configure -text "$humanx x $humany pixel(s)"
}
}
###########################################################
## Procedure:  tick

proc {tick} {} {
global timex rc warmup todo
        if { $timex == 0 } {
            .yaprimaxgui.lamp.status configure -text "Turned on"
            .yaprimaxgui.lamp.status configure -background green
            puts "Done!"
            set warmup 2
            .yaprimaxgui.control.preview configure -state normal
            .yaprimaxgui.control.scan configure -state normal
            .yaprimaxgui.control.but46 configure -state normal
            .yaprimaxgui.control.but48 configure -state normal
            .yaprimaxgui.lamp.lamp-on configure -state normal
            .yaprimaxgui.lamp.lamp-off configure -state normal
            .yaprimaxgui.control.clear configure -state normal
            eval $todo
        } else {
            after 100 tick
            set warmup 1
            if { $timex == "" } {
                set timex $rc(time)
            } else {
            set timex [expr $timex - 0.1]
            }
            .yaprimaxgui.lamp.status configure -text "Warming up: $timex\s"
        }
}
###########################################################
## Procedure:  usera

proc {usera} {} {
global cancel rc tiff

scan-image

if { $cancel != "1" } {
	if { $rc(runa) == "back" } {
		puts "Running $rc(descriptiona)\.\.\."
		puts "[string range $rc(usera) 0 [expr [string first \$ $rc(usera)] - 1]]$tiff[string range $rc(usera) [expr [string first \$ $rc(usera)] + 5] end]"
		eval exec "[string range $rc(usera) 0 [expr [string first \$ $rc(usera)] - 1]]$tiff[string range $rc(usera) [expr [string first \$ $rc(usera)] + 5] end]" &
		puts "Done!"
	} else {
		puts "Running $rc(descriptiona)\.\.\."
		puts "[string range $rc(usera) 0 [expr [string first \$ $rc(usera)] - 1]]$tiff[string range $rc(usera) [expr [string first \$ $rc(usera)] + 5] end]"
		eval exec "[string range $rc(usera) 0 [expr [string first \$ $rc(usera)] - 1]]$tiff[string range $rc(usera) [expr [string first \$ $rc(usera)] + 5] end]"
		puts "Done!"
	}
	if { $rc(runa) == "delete" } {
		puts "Deleting $tiff\.\.\."
		file delete $tiff
		puts "Done!"
	}
}
}
###########################################################
## Procedure:  userb

proc {userb} {} {
global cancel rc tiff

scan-image
puts $tiff
if { $cancel != "1" } {
	if { $rc(runb) == "back" } {
		puts "Running $rc(descriptionb)\.\.\."
		puts "[string range $rc(userb) 0 [expr [string first \$ $rc(userb)] - 1]]$tiff[string range $rc(userb) [expr [string first \$ $rc(userb)] + 5] end]"
		eval exec "[string range $rc(userb) 0 [expr [string first \$ $rc(userb)] - 1]]$tiff[string range $rc(userb) [expr [string first \$ $rc(userb)] + 5] end]" &
		puts "Done!"
	} else {
		puts "Running $rc(descriptionb)\.\.\."
		puts "[string range $rc(userb) 0 [expr [string first \$ $rc(userb)] - 1]]$tiff[string range $rc(userb) [expr [string first \$ $rc(userb)] + 5] end]"
		eval exec "[string range $rc(userb) 0 [expr [string first \$ $rc(userb)] - 1]]$tiff[string range $rc(userb) [expr [string first \$ $rc(userb)] + 5] end]"
		puts "Done!"
	}
	if { $rc(runb) == "delete" } {
		puts "Deleting $tiff\.\.\."
		file delete $tiff
		puts "Done!"
	}
}
}
###########################################################
## Procedure:  warm

proc {warm} {arg} {
global rc timex warmup todo
set todo $arg
if { $warmup == 0 } {
    set timex ""
    proc tick {} {
        global timex rc warmup todo
        if { $timex == 0 } {
            .yaprimaxgui.lamp.status configure -text "Turned on"
            .yaprimaxgui.lamp.status configure -background green
            puts "Done!"
            set warmup 2
            .yaprimaxgui.control.preview configure -state normal
            .yaprimaxgui.control.scan configure -state normal
            .yaprimaxgui.control.but46 configure -state normal
            .yaprimaxgui.control.but48 configure -state normal
            .yaprimaxgui.lamp.lamp-on configure -state normal
            .yaprimaxgui.lamp.lamp-off configure -state normal
            .yaprimaxgui.control.clear configure -state normal
            eval $todo
        } else {
            after 100 tick
            set warmup 1
            if { $timex == "" } {
                set timex $rc(time)
            } else {
            set timex [expr $timex - 0.1]
            }
            .yaprimaxgui.lamp.status configure -text "Warming up: $timex\s"
        }
    }
    puts "Warming up lamp..."
    .yaprimaxgui.lamp.status configure -background yellow
    eval exec $rc(primax) --port=$rc(hex) --lamp=on
    .yaprimaxgui.control.preview configure -state disabled
    .yaprimaxgui.control.scan configure -state disabled
    .yaprimaxgui.control.but46 configure -state disabled
    .yaprimaxgui.control.but48 configure -state disabled
    .yaprimaxgui.lamp.lamp-on configure -state disabled
    .yaprimaxgui.lamp.lamp-off configure -state disabled
    .yaprimaxgui.control.clear configure -state disabled
    tick
} else {
eval $todo
}
}
###########################################################
## Procedure:  init
###########################################################
## Procedure:  main

proc {main} {argc argv} {
global rc xposa yposa xposb yposb selection

wm protocol .yaprimaxgui WM_DELETE_WINDOW {quit}

.yaprimaxgui.control.but46 configure -text $rc(descriptiona)
.yaprimaxgui.control.but48 configure -text $rc(descriptionb)

if { $rc(primax) == "primax_scan" } {
    .yaprimaxgui.compression configure -state normal
}

if { $rc(primax) == "pxscan" } {
    .yaprimaxgui.compression configure -state disabled
}

if { "$rc(color)" == "--RED" } {
.yaprimaxgui.color configure -text "Only red channel"
} elseif { "$rc(color)" == "--BLUE" } {
.yaprimaxgui.color configure -text "Only blue channel"
} elseif { "$rc(color)" == "--GREEN" } {
.yaprimaxgui.color configure -text "Only green channel"
} elseif { "$rc(color)" == "--RGB" } {
.yaprimaxgui.color configure -text "24-Bit RGB"
} elseif { "$rc(color)" == "--GRAY" } {
.yaprimaxgui.color configure -text "8-Bit Gray"
} elseif { "$rc(color)" == "--BW" } {
.yaprimaxgui.color configure -text "1-Bit Black-White"
}


.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
.yaprimaxgui.brightness configure -text "Brightness: $rc(brightness)"
.yaprimaxgui.contrast configure -text "Contrast: $rc(contrast)"
.yaprimaxgui.gamma configure -text "Gamma: $rc(gamma)"
.yaprimaxgui.compression configure -text "Compression $rc(compression)"

set selection [.yaprimaxgui.preview-border.preview create rectangle 0 0 228 314 -outline green]
set xposa 0
set yposa 0
set xposb 228
set yposb 314

show-size 0

if { $rc(warm) == 1 } {
warm {none 0}
}
}

proc init {argc argv} {
global rc warmup window

set window(image) 0
set window(more) 0
set warmup "0"
set rc(primax) primax_scan
set rc(resolution) 300
set rc(color) --RGB
set rc(brightness) 0
set rc(contrast) 0
set rc(gamma) 1.0
set rc(compression) none
set rc(path2tiff) /
set rc(usera) "gimp-remote -n \$tiff"
set rc(descriptiona) "The GIMP 1.2"
set rc(runa) back
set rc(userb) "tiff2ps -2 \$tiff \| lpr -J \"Scanned copy\""
set rc(descriptionb) Copy
set rc(runb) delete
set rc(unit) mm
set rc(hex) 0x378
set rc(speed) 15
set rc(time) 60
set rc(maxres) 300
set rc(off) 0
set rc(warm) 0
set rc(version) 3.1.2

puts "Yet Another Primax GUI v$rc(version)"

if { [file exists /usr/local/etc/.yaprimaxGUIrc] == 1 } {
puts "Old configuration file from versions <= 2.3 found, deleting it now..."
file delete /usr/local/etc/.yaprimaxGUIrc
puts "Deleted!"
}

if { [file exists [glob ~]/.yaprimaxGUIrc] != 1 } {
puts "Configuration file [glob ~]/.yaprimaxGUIrc not found, creating one now..."

set file [open [glob ~]/.yaprimaxGUIrc "w"]

puts $file {;# Yet Another Primax GUI}
puts $file {;# ^^^^^^^^^^^^^^^^^^^^^^}
puts $file {;# Do not edit!}

foreach var [lsort [array names rc]] {
        puts $file "set rc($var) \{$rc($var)\}"
}

close $file

puts "Done!"
}


puts "Loading options..."
catch {source [glob ~]/.yaprimaxGUIrc}
if { $rc(version) == "2.99-beta" } {
puts "Fixing compatibility with configuration file from verion 2.99-beta..."
set rc(primax) primax_scan
}
set rc(version) "3.1.2"
puts "Done!"
}

init $argc $argv

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

proc vTclWindow. {base {container 0}} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    wm focusmodel $base passive
    wm geometry $base 1x1+0+0; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm withdraw $base
    wm title $base "vt.tcl"
    bindtags $base "$base Vtcl.tcl all"
    vTcl:FireEvent $base <<Create>>
    }
    ###################
    # SETTING GEOMETRY
    ###################

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxgui {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxgui
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget
    vTcl:DefineAlias "$base.menubutton36" "Menubutton5" vTcl:WidgetProc "$base" 1
    vTcl:DefineAlias "$base.menubutton36.m" "Menu4" vTcl:WidgetProc "$base" 1

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background grey85 -highlightbackground grey85 \
        -highlightcolor #000000 
    wm focusmodel $base passive
    wm geometry $base 399x397+69+77; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm deiconify $base
    wm title $base "Yet Another Primax GUI"
    vTcl:FireEvent $base <<Create>>
    }
    frame $base.cpd17 \
        -background grey85 -borderwidth 2 -height 30 \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -width 30 
    menubutton $base.cpd17.01 \
        -activebackground #d9d9d9 -activeforeground #000000 -anchor w \
        -background grey85 -disabledforeground #a3a3a3 \
        -font {Helvetica -12 bold} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 \
        -menu "$base.cpd17.01.02" -padx 4 -pady 3 -relief flat -text File \
        -width 4 
    menu $base.cpd17.01.02 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -cursor {} -foreground black -tearoff 0 
    $base.cpd17.01.02 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} -command quit -foreground {} -image {} -label Exit 
    menubutton $base.cpd17.03 \
        -activebackground #d9d9d9 -activeforeground #000000 -anchor w \
        -background grey85 -disabledforeground #a3a3a3 \
        -font {Helvetica -12 bold} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 \
        -menu "$base.cpd17.03.04" -padx 4 -pady 3 -text Settings -width 7 
    menu $base.cpd17.03.04 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -cursor {} -foreground black -tearoff 0 
    $base.cpd17.03.04 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} \
        -command {Window show .yaprimaxgui-image
global rc window
wm protocol .yaprimaxgui-image WM_DELETE_WINDOW {
global window
set window(image) 0
destroy .yaprimaxgui-image
}
set window(image) 1
if { $rc(color) == "--RED" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background red
    .yaprimaxgui-image.photo.color.channels.2 configure -background red
    .yaprimaxgui-image.photo.color.channels.3 configure -background red
    .yaprimaxgui-image.photo.color.channels.4 configure -background red
} elseif { $rc(color) == "--GREEN" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background green
    .yaprimaxgui-image.photo.color.channels.2 configure -background green
    .yaprimaxgui-image.photo.color.channels.3 configure -background green
    .yaprimaxgui-image.photo.color.channels.4 configure -background green
} elseif { $rc(color) == "--BLUE" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background blue
    .yaprimaxgui-image.photo.color.channels.2 configure -background blue
    .yaprimaxgui-image.photo.color.channels.3 configure -background blue
    .yaprimaxgui-image.photo.color.channels.4 configure -background blue
} elseif { $rc(color) == "--RGB" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background red
    .yaprimaxgui-image.photo.color.channels.2 configure -background green
    .yaprimaxgui-image.photo.color.channels.3 configure -background green
    .yaprimaxgui-image.photo.color.channels.4 configure -background blue
} elseif { $rc(color) == "--GRAY" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background white
    .yaprimaxgui-image.photo.color.channels.2 configure -background gray
    .yaprimaxgui-image.photo.color.channels.3 configure -background gray
    .yaprimaxgui-image.photo.color.channels.4 configure -background black
} elseif { $rc(color) == "--BW" } {
    .yaprimaxgui-image.photo.color.channels.1 configure -background white
    .yaprimaxgui-image.photo.color.channels.2 configure -background white
    .yaprimaxgui-image.photo.color.channels.3 configure -background black
    .yaprimaxgui-image.photo.color.channels.4 configure -background black
}

if { $rc(primax) == "pxscan" } {
    .yaprimaxgui-image.photo.color.red configure -state disabled
    .yaprimaxgui-image.photo.color.green configure -state disabled
    .yaprimaxgui-image.photo.color.blue configure -state disabled
    if { $rc(color) == "--RED" | $rc(color) == "--GREEN" | $rc(color) == "--BLUE" } {
        set rc(color) --RGB
        .yaprimaxgui-image.photo.color.channels.1 configure -background red
        .yaprimaxgui-image.photo.color.channels.2 configure -background green
        .yaprimaxgui-image.photo.color.channels.3 configure -background green
        .yaprimaxgui-image.photo.color.channels.4 configure -background blue
        .yaprimaxgui.color configure -text "24-Bit RGB"
        show-size 0
    }
}

if { $rc(primax) == "primax_scan" } {
    .yaprimaxgui-image.photo.color.red configure -state normal
    .yaprimaxgui-image.photo.color.green configure -state normal
    .yaprimaxgui-image.photo.color.blue configure -state normal
}} \
        -foreground {} -image {} -label Image 
    $base.cpd17.03.04 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} \
        -command {global usera descriptiona runa userb descriptionb runb unit rc
set usera $rc(usera)
set descriptiona $rc(descriptiona)
set runa $rc(runa)
set userb $rc(userb)
set descriptionb $rc(descriptionb)
set runb $rc(runb)
set unit $rc(unit)
Window show .yaprimaxgui-options} \
        -foreground {} -image {} -label Options 
    $base.cpd17.03.04 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} \
        -command {global rc hex speed time maxres off warm primax
set hex $rc(hex)
set speed $rc(speed)
set time $rc(time)
set maxres $rc(maxres)
set off $rc(off)
set warm $rc(warm)
set primax $rc(primax)
Window show .yaprimaxgui-scanner

if { $rc(primax) == "primax_scan" } {
.yaprimaxgui-scanner.settings.fra23.lab26 configure -state normal
.yaprimaxgui-scanner.menubutton36 configure -state normal
.yaprimaxgui-scanner.settings.fra23.sca28 configure -state normal
.yaprimaxgui-scanner.settings.fra23.sca28 configure -foreground Black
}

if { $rc(primax) == "pxscan" } {
.yaprimaxgui-scanner.settings.fra23.lab26 configure -state disabled
.yaprimaxgui-scanner.menubutton36 configure -state disabled
.yaprimaxgui-scanner.settings.fra23.sca28 configure -state disabled 
.yaprimaxgui-scanner.settings.fra23.sca28 configure -foreground #a3a3a3
}} \
        -foreground {} -image {} -label Scanner 
    $base.cpd17.03.04 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} -command options-save -foreground {} -image {} \
        -label Save 
    menubutton $base.cpd17.05 \
        -activebackground #d9d9d9 -activeforeground #000000 -anchor w \
        -background grey85 -disabledforeground #a3a3a3 \
        -font {Helvetica -12 bold} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 \
        -menu "$base.cpd17.05.06" -padx 4 -pady 3 -text Help -width 4 
    menu $base.cpd17.05.06 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -cursor {} -foreground black -tearoff 0 
    $base.cpd17.05.06 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} \
        -command {global rc
Window show .yaprimaxguihelp
.yaprimaxguihelp.text insert end "Yet Another Primax GUI
^^^^^^^^^^^^^^^^^^^^^^
v$rc(version)

I. Introduction

Yet Another Primax GUI is a front end to two text only driver programs for some Primax scanners unser Linux/UNIX.

These text only programs, primax_scan and pxscan, can be downloaded from http://primax.sourceforge.net/ and from http://home2.swipnet.se/~w-25069/pxscan.html. It seems that there is a SANE backend for primax_scan, but Yet Another Primax GUI is still another alternative...

The following scanners are supported by primax_scan by now:
* Primax Colorado Direct 300
* Primax Colorado Direct 600/30bit
* Primax Colorado Direct 9600
* Primax Colorado 1200p
* Primax Colorado USB 19200
* Nework Scanny MM100
* Genius Colorpage-Vivid+
* Storm Totalscan

The pxscan program was developed to work together:
* Primax Colorado Direct 9600

New versions of Yet Another Primax GUI can be downloades from http://orbita.starmedia.com/~neofpo/.

The author would apreciate sugestions, bug reports or anything you wish to say about this program. Please contact me by ICQ or email:
ICQ UIN: 6516089
email: neo_fpo@ig.com.br

II. Usage

The usage is very simple, it is similar to the \"original\" program for Winblows from Primax.

You click \"Preview\" button to make a preview of the image, then with your button 1 of your mouse, you may select an area you wish to scan. Once the selection is done, moving your mouse over it, it will become blue, so you can move it using button 2 or 3. On the edges, the selection will become yellow, witch indicates that you can resize it with button 2 or 3. On the botton of the main window, The size of selected area is shown, and an estimative, without compression, of the file size is given.

After selection is done, you may click on \"Scan\" to scan the image to a tiff file. If none is selected, you will be prompted for its name. There are 2 alternative buttons, witch can be costumized to open the file with you prefered photo editor or anything you wish to do with the file you have just scanned.

III. Configuration

Configuration in accessible from \"Settings\" menu.

\"Image\" will let you set resolution and color. Clicking \"More\" will give you more advanced (useless...) configuation.

\"Options\" menu will let you configure the two alternative button and select default unit. The alternative buttons configuration is simple: first gap goes the command line to lauch the program, where \$tiff will always be the PATH for the scanned image (NEVER use mode than one time \$tiff\, or you WILL have problems!!\)\; on the second gap goes a short description of the program\; the last option will be to choose either to run the program in background and leave the tiff file alone, or to wait the program exits and delete the tiff file. This last is useful when you convert the tiff file to pnm, for example, the original tiff will be trash. Nothe that you may use pipes \(\|\) to send the stout of a program to another. Click \"Default\" button to have an example.

\"Scanner\" menu will let you specify witch program driver you wish to use, primax_scan or pxscan, then the adress of the parallel port, the optical resolution of the scanenr \(primax_scan only\), the speed of the carriage \(note that smaller values  increases the speed\!\\, primax_scan only\) and the time of warm up of the lamp. You may also select to turn of lamp on exit and to auto warm up un start up.

IV. Known BUGS

There are still some known bugs (and may be lots of unknown). Here they are:

-the program seems to have crashed while scanning something (it is only waiting primax_scan or pxscan finish to continue, do not worry)
-can not guess if the lamp was on before the program starts
-can not know what happened with pxscan or primax_scan after run, if something went wrong, Yet Another Primax GUI may not handle it correctly"
.yaprimaxguihelp.text configure -state disabled} \
        -foreground {} -image {} -label {Help Index} 
    $base.cpd17.05.06 add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -background {} \
        -command {global rc
set about "Yet Another Primax GUI
^^^^^^^^^^^^^^^^^^^^^^
v$rc(version)
Fabio Pigliese Ornellas
neo_fpo@ig.com.br
<http://orbita.starmedia.com/~neofpo/>
2001-12-26"

tk_messageBox -icon info -message $about -parent .yaprimaxgui -title About... -type ok} \
        -foreground {} -image {} -label About 
    frame $base.preview-border \
        -background #000000 -borderwidth 2 -height 75 \
        -highlightbackground grey85 -highlightcolor #000000 -width 125 
    canvas $base.preview-border.preview \
        -background #94a4d7 -closeenough 1.0 -height 207 \
        -highlightbackground grey85 -highlightcolor #000000 \
        -highlightthickness 0 -insertbackground Black \
        -selectbackground #c3c3c3 -selectborderwidth 0 \
        -selectforeground Black -width 295 
    bind $base.preview-border.preview <B1-Motion> {
        button-motion %x %y
    }
    bind $base.preview-border.preview <B2-Motion> {
        button2-motion %x %y
    }
    bind $base.preview-border.preview <B3-Motion> {
        button2-motion %x %y
    }
    bind $base.preview-border.preview <Button-1> {
        button-down %x %y
    }
    bind $base.preview-border.preview <Button-2> {
        button2-down %x %y
    }
    bind $base.preview-border.preview <Button-3> {
        button2-down %x %y
    }
    bind $base.preview-border.preview <ButtonRelease-1> {
        button-release
    }
    bind $base.preview-border.preview <ButtonRelease-2> {
        button2-release %x %y
    }
    bind $base.preview-border.preview <ButtonRelease-3> {
        button2-release %x %y
    }
    bind $base.preview-border.preview <Motion> {
        motion %x %y
    }
    label $base.color \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {8-Bit Gray} 
    label $base.resolution \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {300 dpi} 
    label $base.contrast \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {Contrast: 0} 
    label $base.brightness \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {Brightness: 0} 
    label $base.gamma \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {Gamma: 1.0} 
    label $base.size \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {2548.66 x 3510.0 pixel(s)} 
    label $base.filesize \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {8.53 Mb} 
    label $base.compression \
        -background grey85 -font {Helvetica -10} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {Compression none} 
    frame $base.control \
        -background grey85 -borderwidth 2 -height 75 \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -width 125 
    button $base.control.preview \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 -command {warm prev} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground black \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Preview 
    button $base.control.clear \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global previmage
puts "Preview cleared!"
.yaprimaxgui.preview-border.preview delete $previmage} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground black \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Clear 
    button $base.control.scan \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global tiff
warm scan-image
set tiff ""} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground black \
        -height 0 -highlightbackground #a3a3a3 -highlightcolor #000000 \
        -text {Scan image} -width 0 
    button $base.control.but46 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global tiff
warm usera
set tiff ""} -font {Helvetica -12} \
        -foreground black -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text {The GIMP} 
    button $base.control.but48 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global tiff
warm userb
set tiff ""} -font {Helvetica -12} \
        -foreground black -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text GQview 
    frame $base.file \
        -background grey85 -borderwidth 2 -height 75 \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -width 125 
    entry $base.file.name \
        -background #94a4d7 -borderwidth 1 -foreground black \
        -highlightbackground #c3c3c3 -highlightcolor #000000 \
        -textvariable tiff 
    button $base.file.select \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global tiff rc
set types {
{{TIFF Images} {.tif}}
{{All Files} *}
}
set gettiff [tk_getSaveFile -defaultextension .tif -filetypes $types -initialdir $rc(path2tiff) -initialfile scanned-image.tif -parent .yaprimaxgui -title "Select filename to save"]
if { $gettiff != "" } {
set tiff $gettiff
set rc(path2tiff) [string range $tiff 0 [string last / $tiff]]
}} \
        -font {Helvetica -12} -foreground black -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text Select 
    label $base.file.label \
        -background grey85 -borderwidth 1 -font {Helvetica -12} \
        -foreground black -height 0 -highlightbackground grey85 \
        -highlightcolor #000000 -relief raised -text {Name for tiff file} 
    frame $base.lamp \
        -background grey85 -borderwidth 2 -height 75 \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -width 125 
    button $base.lamp.lamp-on \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 -command {warm "none 0"} \
        -font {Helvetica -12} -foreground black -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text {Turn lamp ON} 
    button $base.lamp.lamp-off \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background grey85 -borderwidth 1 \
        -command {global rc warmup
puts "Turning lamp off..."
eval exec $rc(primax) --port=$rc(hex) --lamp=off
.yaprimaxgui.lamp.status configure -text "Turned off"
.yaprimaxgui.lamp.status configure -background red
set warmup 0
puts "Done!"} \
        -font {Helvetica -12} -foreground black -height 0 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 \
        -text {Turn lamp OFF} -width 0 
    label $base.lamp.label \
        -background grey85 -borderwidth 1 -font {Helvetica -12} \
        -foreground black -highlightbackground grey85 -highlightcolor #000000 \
        -relief raised -text {Lamp status:} 
    label $base.lamp.status \
        -background yellow -font {Helvetica -12} -foreground black \
        -highlightbackground grey85 -highlightcolor #000000 -relief groove \
        -text {Turned off} -width 0 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.cpd17 \
        -x 5 -y 5 -width 390 -height 26 -anchor nw 
    pack $base.cpd17.01 \
        -in $base.cpd17 -anchor center -expand 0 -fill none -side left 
    pack $base.cpd17.03 \
        -in $base.cpd17 -anchor center -expand 0 -fill none -side left 
    pack $base.cpd17.05 \
        -in $base.cpd17 -anchor center -expand 0 -fill none -side right 
    place $base.preview-border \
        -x 5 -y 35 -width 231 -height 317 -anchor nw -bordermode ignore 
    place $base.preview-border.preview \
        -x 1 -y 1 -width 229 -height 315 -anchor nw -bordermode ignore 
    place $base.color \
        -x 5 -y 355 -width 123 -height 18 -anchor nw -bordermode ignore 
    place $base.resolution \
        -x 214 -y 375 -width 71 -height 18 -anchor nw -bordermode ignore 
    place $base.contrast \
        -x 225 -y 355 -width 87 -height 18 -anchor nw -bordermode ignore 
    place $base.brightness \
        -x 130 -y 355 -width 93 -height 18 -anchor nw -bordermode ignore 
    place $base.gamma \
        -x 314 -y 355 -width 81 -height 18 -anchor nw -bordermode ignore 
    place $base.size \
        -x 5 -y 375 -width 133 -height 18 -anchor nw -bordermode ignore 
    place $base.filesize \
        -x 140 -y 375 -width 71 -height 18 -anchor nw -bordermode ignore 
    place $base.compression \
        -x 287 -y 375 -width 108 -height 18 -anchor nw -bordermode ignore 
    place $base.control \
        -x 240 -y 35 -width 155 -height 155 -anchor nw -bordermode ignore 
    place $base.control.preview \
        -x 5 -y 5 -width 65 -height 28 -anchor nw -bordermode ignore 
    place $base.control.clear \
        -x 83 -y 5 -width 65 -height 28 -anchor nw -bordermode ignore 
    place $base.control.scan \
        -x 5 -y 40 -width 143 -height 36 -anchor nw -bordermode ignore 
    place $base.control.but46 \
        -x 5 -y 85 -width 142 -height 26 -anchor nw -bordermode ignore 
    place $base.control.but48 \
        -x 5 -y 120 -width 142 -height 26 -anchor nw -bordermode ignore 
    place $base.file \
        -x 240 -y 193 -width 155 -height 56 -anchor nw -bordermode ignore 
    place $base.file.name \
        -x 5 -y 30 -width 93 -height 20 -anchor nw -bordermode ignore 
    place $base.file.select \
        -x 100 -y 30 -width 47 -height 20 -anchor nw -bordermode ignore 
    place $base.file.label \
        -x 5 -y 5 -width 142 -height 18 -anchor nw -bordermode ignore 
    place $base.lamp \
        -x 240 -y 252 -width 155 -height 100 -anchor nw -bordermode ignore 
    place $base.lamp.lamp-on \
        -x 5 -y 5 -width 142 -height 21 -anchor nw -bordermode ignore 
    place $base.lamp.lamp-off \
        -x 5 -y 30 -width 142 -height 21 -anchor nw -bordermode ignore 
    place $base.lamp.label \
        -x 35 -y 54 -width 78 -height 18 -anchor nw -bordermode ignore 
    place $base.lamp.status \
        -x 5 -y 76 -width 143 -height 18 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxgui-image {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxgui-image
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background #d9d9d9 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 
    wm withdraw $base
    wm focusmodel $base passive
    wm geometry $base 270x246+118+152; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm title $base "Image"
    vTcl:FireEvent $base <<Create>>
    }
    frame $base.photo \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief ridge \
        -width 125 
    scale $base.photo.resolution \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -command {global rc
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size} \
        -font {Helvetica -12} -foreground #000000 -from 2.0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -highlightthickness 0 -label Resolution -orient horizontal \
        -relief groove -resolution 1.0 -showvalue 0 -tickinterval 0.0 \
        -to 300.0 -troughcolor #94a4d7 -variable rc(resolution) -width 8 
    menubutton $base.photo.select \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 \
        -highlightthickness 1 -indicatoron 1 \
        -menu .yaprimaxgui-image.photo.select.m -padx 4 -pady 3 \
        -relief raised -text 300 -textvariable rc(resolution) 
    menu $base.photo.select.m \
        -activebackground #d9d9d9 -activeforeground #000000 -cursor {} \
        -foreground #000000 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 2
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 2 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 75
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 75 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 100
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 100 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 150
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 150 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 200
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 200 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 250
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 250 
    $base.photo.select.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc
set rc(resolution) 300
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
show-size 0} \
        -foreground {} -image {} -label 300 
    frame $base.photo.color \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief groove \
        -width 125 
    radiobutton $base.photo.color.red \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background red
.yaprimaxgui-image.photo.color.channels.2 configure -background red
.yaprimaxgui-image.photo.color.channels.3 configure -background red
.yaprimaxgui-image.photo.color.channels.4 configure -background red
.yaprimaxgui.color configure -text "Only red channel"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {Only red channel} -value --RED \
        -variable rc(color) 
    radiobutton $base.photo.color.green \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background green
.yaprimaxgui-image.photo.color.channels.2 configure -background green
.yaprimaxgui-image.photo.color.channels.3 configure -background green
.yaprimaxgui-image.photo.color.channels.4 configure -background green
.yaprimaxgui.color configure -text "Only green channel"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {Only green channel} -value --GREEN \
        -variable rc(color) 
    radiobutton $base.photo.color.blue \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background blue
.yaprimaxgui-image.photo.color.channels.2 configure -background blue
.yaprimaxgui-image.photo.color.channels.3 configure -background blue
.yaprimaxgui-image.photo.color.channels.4 configure -background blue
.yaprimaxgui.color configure -text "Only blue channel"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -state active -text {Only blue channel} \
        -value --BLUE -variable rc(color) 
    radiobutton $base.photo.color.rgb \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background red
.yaprimaxgui-image.photo.color.channels.2 configure -background green
.yaprimaxgui-image.photo.color.channels.3 configure -background green
.yaprimaxgui-image.photo.color.channels.4 configure -background blue
.yaprimaxgui.color configure -text "24-Bit RGB"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {24-Bit RGB} -value --RGB \
        -variable rc(color) 
    radiobutton $base.photo.color.gray \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background white
.yaprimaxgui-image.photo.color.channels.2 configure -background gray
.yaprimaxgui-image.photo.color.channels.3 configure -background gray
.yaprimaxgui-image.photo.color.channels.4 configure -background black
.yaprimaxgui.color configure -text "8-Bit Gray"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {8-Bit Gray} -value --GRAY \
        -variable rc(color) 
    radiobutton $base.photo.color.bw \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {.yaprimaxgui-image.photo.color.channels.1 configure -background white
.yaprimaxgui-image.photo.color.channels.2 configure -background white
.yaprimaxgui-image.photo.color.channels.3 configure -background black
.yaprimaxgui-image.photo.color.channels.4 configure -background black
.yaprimaxgui.color configure -text "1-Bit Black-White"
show-size 0} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {1-Bit Black-White} -value --BW \
        -variable rc(color) 
    label $base.photo.color.label \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief raised \
        -text Channels 
    frame $base.photo.color.channels \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief groove \
        -width 125 
    label $base.photo.color.channels.1 \
        -background red -borderwidth 0 -foreground #000000 \
        -highlightcolor #000000 -padx 0 -pady 0 
    label $base.photo.color.channels.2 \
        -background green -borderwidth 0 -foreground #000000 \
        -highlightcolor #000000 -padx 0 -pady 0 
    label $base.photo.color.channels.4 \
        -background blue -borderwidth 0 -foreground #000000 \
        -highlightcolor #000000 -padx 0 -pady 0 
    label $base.photo.color.channels.3 \
        -background green -borderwidth 0 -foreground #000000 \
        -highlightcolor #000000 -padx 0 -pady 0 
    label $base.photo.color.label37 \
        -background #d9d9d9 -disabledforeground #a3a3a3 -font {Helvetica -10} \
        -foreground #000000 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 -relief groove \
        -text {Warning: Press "Preview" button to apply changes} 
    button $base.button34 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {set rc(resolution) 300
set rc(color) --RGB
.yaprimaxgui-image.photo.color.channels.1 configure -background red
.yaprimaxgui-image.photo.color.channels.2 configure -background green
.yaprimaxgui-image.photo.color.channels.3 configure -background green
.yaprimaxgui-image.photo.color.channels.4 configure -background blue

global rc
.yaprimaxgui.resolution configure -text "$rc(resolution) dpi"
.yaprimaxgui.color configure -text "24-Bit RGB"} \
        -disabledforeground #a3a3a3 -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Default 
    button $base.button35 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {Window show .yaprimaxgui-image-more
global window rc
if { $window(more) == "1" } {
    if { $rc(primax) == "pxscan" } {
        .yaprimaxgui-image-more.more.back.label configure -state disabled
        .yaprimaxgui-image-more.more.back.compression configure -state disabled
    }
    if { $rc(primax) == "primax_scan" } {
        .yaprimaxgui-image-more.more.back.label configure -state normal
        .yaprimaxgui-image-more.more.back.compression configure -state normal
    }
}

wm protocol .yaprimaxgui-image-more WM_DELETE_WINDOW {
global window
set window(more) 0
destroy .yaprimaxgui-image-more
}
set window(more) 1} \
        -disabledforeground #a3a3a3 -foreground #000000 -height 0 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text More... \
        -width 0 
    button $base.button36 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {destroy .yaprimaxgui-image
global window(image)
set window(image) 0} \
        -disabledforeground #a3a3a3 -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Close 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.photo \
        -x 5 -y 5 -width 260 -height 205 -anchor nw -bordermode ignore 
    place $base.photo.resolution \
        -x 6 -y 5 -width 251 -height 40 -anchor nw -bordermode ignore 
    place $base.photo.select \
        -x 125 -y 8 -width 77 -height 16 -anchor nw -bordermode ignore 
    place $base.photo.color \
        -x 6 -y 47 -width 250 -height 153 -anchor nw -bordermode ignore 
    place $base.photo.color.red \
        -x 5 -y 5 -anchor nw -bordermode ignore 
    place $base.photo.color.green \
        -x 5 -y 25 -anchor nw -bordermode ignore 
    place $base.photo.color.blue \
        -x 5 -y 45 -anchor nw -bordermode ignore 
    place $base.photo.color.rgb \
        -x 5 -y 65 -anchor nw -bordermode ignore 
    place $base.photo.color.gray \
        -x 5 -y 85 -anchor nw -bordermode ignore 
    place $base.photo.color.bw \
        -x 5 -y 105 -anchor nw -bordermode ignore 
    place $base.photo.color.label \
        -x 165 -y 10 -anchor nw -bordermode ignore 
    place $base.photo.color.channels \
        -x 155 -y 35 -width 83 -height 83 -anchor nw -bordermode ignore 
    place $base.photo.color.channels.1 \
        -x 2 -y 2 -width 78 -height 26 -anchor nw -bordermode ignore 
    place $base.photo.color.channels.2 \
        -x 2 -y 28 -width 78 -height 13 -anchor nw -bordermode ignore 
    place $base.photo.color.channels.4 \
        -x 2 -y 54 -width 78 -height 26 -anchor nw -bordermode ignore 
    place $base.photo.color.channels.3 \
        -x 2 -y 41 -width 78 -height 13 -anchor nw -bordermode ignore 
    place $base.photo.color.label37 \
        -x 5 -y 130 -anchor nw -bordermode ignore 
    place $base.button34 \
        -x 6 -y 215 -anchor nw -bordermode ignore 
    place $base.button35 \
        -x 125 -y 215 -anchor nw -bordermode ignore 
    place $base.button36 \
        -x 205 -y 215 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxgui-image-more {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxgui-image-more
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background #d9d9d9 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 
    wm withdraw $base
    wm focusmodel $base passive
    wm geometry $base 266x249+119+148; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm title $base "More..."
    vTcl:FireEvent $base <<Create>>
    }
    frame $base.more \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief ridge \
        -width 125 
    scale $base.more.brightness \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -command {global rc
.yaprimaxgui.brightness configure -text "Brightness: $rc(brightness)"
none} \
        -font {Helvetica -12} -foreground #000000 -from -200.0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -highlightthickness 0 -label Brightness -orient horizontal \
        -relief groove -resolution 1.0 -tickinterval 0.0 -to 200.0 \
        -troughcolor #94a4d7 -variable rc(brightness) -width 8 
    scale $base.more.contrast \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -command {global rc(contrast)
.yaprimaxgui.contrast configure -text "Contrast: $rc(contrast)"
none} \
        -font {Helvetica -12} -foreground #000000 -from -2000.0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -highlightthickness 0 -label Contrast -orient horizontal \
        -relief groove -resolution 1.0 -tickinterval 0.0 -to 1000.0 \
        -troughcolor #94a4d7 -variable rc(contrast) -width 8 
    scale $base.more.gamma \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -command {global rc
.yaprimaxgui.gamma configure -text "Gamma: $rc(gamma)"
none} \
        -cursor fleur -font {Helvetica -12} -foreground #000000 -from 0.2 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -highlightthickness 0 -label Gamma -orient horizontal -relief groove \
        -resolution 0.1 -tickinterval 0.0 -to 5.0 -troughcolor #94a4d7 \
        -variable rc(gamma) -width 8 
    frame $base.more.back \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief groove \
        -width 125 
    label $base.more.back.label \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 -highlightcolor #000000 \
        -relief raised -text Compression 
    menubutton $base.more.back.compression \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 \
        -highlightthickness 1 -indicatoron 1 \
        -menu .yaprimaxgui-image-more.more.back.compression.m -padx 4 -pady 3 \
        -relief raised -text none -textvariable rc(compression) 
    menu $base.more.back.compression.m \
        -activebackground #d9d9d9 -activeforeground #000000 -cursor {} \
        -foreground #000000 
    $base.more.back.compression.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc(compression)
set rc(compression) jpeg
.yaprimaxgui.compression configure -text "Compression: $rc(compression)"} \
        -foreground {} -image {} -label jpeg 
    $base.more.back.compression.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc(compression)
set rc(compression) lzw
.yaprimaxgui.compression configure -text "Compression: $rc(compression)"} \
        -foreground {} -image {} -label lzw 
    $base.more.back.compression.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc(compression)
set rc(compression) packbits
.yaprimaxgui.compression configure -text "Compression: $rc(compression)"} \
        -foreground {} -image {} -label packbits 
    $base.more.back.compression.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global rc(compression)
set rc(compression) none
.yaprimaxgui.compression configure -text "Compression: $rc(compression)"} \
        -foreground {} -image {} -label none 
    label $base.more.warning \
        -background #d9d9d9 -disabledforeground #a3a3a3 -font {Helvetica -10} \
        -foreground #000000 -height 0 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 -relief groove \
        -text {Warning: Press "Preview" button to apply changes} -width 0 
    button $base.close \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {destroy .yaprimaxgui-image-more
global window
set window(image) 0} \
        -disabledforeground #a3a3a3 -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Close 
    button $base.default \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {set rc(brightness) 0
set rc(contrast) 0
set rc(gamma) 1.0
set rc(compression) none
.yaprimaxgui.brightness configure -text "Brightness: $rc(brightness)"
.yaprimaxgui.contrast configure -text "Contrast: $rc(contrast)"
.yaprimaxgui.gamma configure -text "Gamma: $rc(gamma)"
.yaprimaxgui.compression configure -text "Compression: $rc(compression)"} \
        -disabledforeground #a3a3a3 -foreground #000000 -height 0 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Default \
        -width 0 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.more \
        -x 5 -y 5 -width 255 -height 208 -anchor nw -bordermode ignore 
    place $base.more.brightness \
        -x 6 -y 5 -width 246 -height 58 -anchor nw -bordermode ignore 
    place $base.more.contrast \
        -x 6 -y 65 -width 246 -height 58 -anchor nw -bordermode ignore 
    place $base.more.gamma \
        -x 6 -y 125 -width 121 -height 58 -anchor nw -bordermode ignore 
    place $base.more.back \
        -x 130 -y 125 -width 122 -height 58 -anchor nw -bordermode ignore 
    place $base.more.back.label \
        -x 5 -y 5 -width 111 -height 18 -anchor nw -bordermode ignore 
    place $base.more.back.compression \
        -x 20 -y 30 -width 82 -height 19 -anchor nw -bordermode ignore 
    place $base.more.warning \
        -x 6 -y 185 -width 246 -height 18 -anchor nw -bordermode ignore 
    place $base.close \
        -x 200 -y 218 -anchor nw -bordermode ignore 
    place $base.default \
        -x 6 -y 218 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxgui-options {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxgui-options
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background #d9d9d9 -highlightbackground #d9d9d9 \
        -highlightcolor Black 
    wm withdraw $base
    wm focusmodel $base passive
    wm geometry $base 305x376+110+82; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm title $base "Options"
    vTcl:FireEvent $base <<Create>>
    }
    button $base.ok \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {global usera descriptiona runa userb descriptionb runb unit rc
set rc(usera) $usera
set rc(descriptiona) $descriptiona
set rc(runa) $runa
set rc(userb) $userb
set rc(descriptionb) $descriptionb
set rc(runb) $runb
set rc(unit) $unit
.yaprimaxgui.control.but46 configure -text $rc(descriptiona)
.yaprimaxgui.control.but48 configure -text $rc(descriptionb)
show-size 0
destroy .yaprimaxgui-options} \
        -disabledforeground #a3a3a3 -foreground Black \
        -highlightbackground #a3a3a3 -highlightcolor Black -text OK 
    button $base.apply \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {global usera descriptiona runa userb descriptionb runb unit rc
set rc(usera) $usera
set rc(descriptiona) $descriptiona
set rc(runa) $runa
set rc(userb) $userb
set rc(descriptionb) $descriptionb
set rc(runb) $runb
set rc(unit) $unit
.yaprimaxgui.control.but46 configure -text $rc(descriptiona)
.yaprimaxgui.control.but48 configure -text $rc(descriptionb)
show-size 0} \
        -disabledforeground #a3a3a3 -foreground Black \
        -highlightbackground #a3a3a3 -highlightcolor Black -text Apply 
    button $base.cancel \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -command {destroy .yaprimaxgui-options} \
        -disabledforeground #a3a3a3 -foreground Black \
        -highlightbackground #a3a3a3 -highlightcolor Black -text Cancel 
    button $base.default \
        -activebackground #ececec -background #d9d9d9 -borderwidth 1 \
        -command {global usera descriptiona runa userb descriptionb runb unit
set usera "gimp-remote -n \$tiff"
set descriptiona "The GIMP 1.2"
set runa back
set userb "tiff2ps -2 \$tiff \| lpr -J \"Scanned copy\""
set descriptionb Copy
set runb delete
set unit mm} \
        -disabledforeground #a3a3a3 -foreground Black \
        -highlightbackground #a3a3a3 -highlightcolor Black -text Default 
    frame $base.back \
        -background #d9d9d9 -borderwidth 2 -height 335 \
        -highlightbackground #d9d9d9 -relief ridge -width 295 
    frame $base.back.frame38 \
        -background #d9d9d9 -borderwidth 2 -height 60 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief groove \
        -width 280 
    label $base.back.frame38.01 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground Black -highlightbackground #d9d9d9 \
        -highlightcolor Black -relief raised -text {Measurement rc(unit)} 
    radiobutton $base.back.frame38.02 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -height 0 -highlightbackground #d9d9d9 \
        -highlightcolor Black -selectcolor #94a4d7 -text cm -value cm \
        -variable unit -width 0 
    radiobutton $base.back.frame38.03 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text inches -value inches -variable unit 
    radiobutton $base.back.frame38.04 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text pixels -value pixels -variable unit 
    radiobutton $base.back.frame38.05 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text mm -value mm -variable unit 
    frame $base.back.frame39 \
        -background #d9d9d9 -borderwidth 2 -height 125 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief groove \
        -width 280 
    label $base.back.frame39.01 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground Black -highlightbackground #d9d9d9 \
        -highlightcolor Black -relief raised \
        -text {User defined command #1 (tiff file = $tiff)} 
    entry $base.back.frame39.02 \
        -background #94a4d7 -borderwidth 1 -foreground Black \
        -highlightbackground #c3c3c3 -highlightcolor Black \
        -insertbackground Black -insertborderwidth 1 \
        -selectbackground #c3c3c3 -textvariable usera 
    button $base.back.frame39.03 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {set file [tk_getOpenFile -parent .yaprimaxgui-options -title "Please select program"]
if { $file != "" } {
set usera $file
}} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground Black \
        -height 0 -highlightbackground #a3a3a3 -highlightcolor Black \
        -text Select 
    label $base.back.frame39.05 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground Black -height 0 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief raised \
        -text Description -width 0 
    entry $base.back.frame39.06 \
        -background #94a4d7 -borderwidth 1 -foreground Black \
        -highlightbackground #c3c3c3 -highlightcolor Black \
        -insertbackground Black -selectbackground #c3c3c3 \
        -selectforeground Black -textvariable descriptiona 
    radiobutton $base.back.frame39.rad41 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text {Run in backgroung and leave tiff file} \
        -value back -variable runa 
    radiobutton $base.back.frame39.rad43 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {.yaprimaxgui-options.back.frame39.rad41 deselect} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground Black \
        -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text {Delete tiff file after program exits} \
        -value delete -variable runa 
    frame $base.back.frame40 \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief groove \
        -width 125 
    label $base.back.frame40.01 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground Black -highlightbackground #d9d9d9 \
        -highlightcolor Black -relief raised \
        -text {User defined command #2 (tiff file = $tiff)} 
    entry $base.back.frame40.02 \
        -background #94a4d7 -borderwidth 1 -foreground Black \
        -highlightbackground #c3c3c3 -highlightcolor Black \
        -insertbackground Black -insertborderwidth 1 \
        -selectbackground #c3c3c3 -selectforeground Black -textvariable userb 
    button $base.back.frame40.03 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {set file [tk_getOpenFile -parent .yaprimaxgui-options -title "Please select program"]
if { $file != "" } {
set userb $file
}} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground Black \
        -height 0 -highlightbackground #a3a3a3 -highlightcolor Black \
        -text Select 
    label $base.back.frame40.05 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground Black -height 0 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief raised \
        -text Description -width 0 
    entry $base.back.frame40.06 \
        -background #94a4d7 -borderwidth 1 -foreground Black \
        -highlightbackground #c3c3c3 -highlightcolor Black \
        -insertbackground Black -selectbackground #c3c3c3 \
        -selectforeground Black -textvariable descriptionb 
    radiobutton $base.back.frame40.rad44 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text {Run in backgroung and leave tiff file} \
        -value back -variable runb 
    radiobutton $base.back.frame40.rad45 \
        -activebackground #ececec -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 -disabledforeground #a3a3a3 -font {Helvetica -12} \
        -foreground Black -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text {Delete tiff file after program exits} \
        -value delete -variable runb 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.ok \
        -x 10 -y 345 -anchor nw -bordermode ignore 
    place $base.apply \
        -x 60 -y 345 -anchor nw -bordermode ignore 
    place $base.cancel \
        -x 230 -y 345 -anchor nw -bordermode ignore 
    place $base.default \
        -x 125 -y 345 -anchor nw -bordermode ignore 
    place $base.back \
        -x 5 -y 5 -width 295 -height 335 -anchor nw -bordermode ignore 
    place $base.back.frame38 \
        -x 10 -y 270 -width 280 -height 60 -anchor nw -bordermode ignore 
    place $base.back.frame38.01 \
        -x 5 -y 5 -width 266 -height 18 -anchor nw -bordermode ignore 
    place $base.back.frame38.02 \
        -x 10 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame38.03 \
        -x 130 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame38.04 \
        -x 210 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame38.05 \
        -x 65 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame39 \
        -x 10 -y 5 -width 280 -height 125 -anchor nw -bordermode ignore 
    place $base.back.frame39.01 \
        -x 25 -y 5 -anchor nw -bordermode ignore 
    place $base.back.frame39.02 \
        -x 20 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame39.03 \
        -x 200 -y 30 -width 62 -height 21 -anchor nw -bordermode ignore 
    place $base.back.frame39.05 \
        -x 10 -y 55 -anchor nw -bordermode ignore 
    place $base.back.frame39.06 \
        -x 95 -y 55 -anchor nw -bordermode ignore 
    place $base.back.frame39.rad41 \
        -x 10 -y 80 -anchor nw -bordermode ignore 
    place $base.back.frame39.rad43 \
        -x 10 -y 100 -anchor nw -bordermode ignore 
    place $base.back.frame40 \
        -x 10 -y 135 -width 280 -height 130 -anchor nw -bordermode ignore 
    place $base.back.frame40.01 \
        -x 25 -y 5 -anchor nw -bordermode ignore 
    place $base.back.frame40.02 \
        -x 20 -y 30 -anchor nw -bordermode ignore 
    place $base.back.frame40.03 \
        -x 200 -y 30 -width 62 -height 21 -anchor nw -bordermode ignore 
    place $base.back.frame40.05 \
        -x 10 -y 55 -anchor nw -bordermode ignore 
    place $base.back.frame40.06 \
        -x 95 -y 55 -anchor nw -bordermode ignore 
    place $base.back.frame40.rad44 \
        -x 10 -y 80 -anchor nw -bordermode ignore 
    place $base.back.frame40.rad45 \
        -x 10 -y 100 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxgui-scanner {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxgui-scanner
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget
    vTcl:DefineAlias "$base.menubutton36" "Menubutton5" vTcl:WidgetProc "$base" 1
    vTcl:DefineAlias "$base.menubutton36.m" "Menu4" vTcl:WidgetProc "$base" 1

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background #d9d9d9 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 
    wm withdraw $base
    wm focusmodel $base passive
    wm geometry $base 339x322+96+122; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm title $base "Scanner"
    vTcl:FireEvent $base <<Create>>
    }
    frame $base.settings \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief ridge \
        -width 125 
    frame $base.settings.fra18 \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -relief groove -width 125 
    label $base.settings.fra18.lab19 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief raised \
        -text {Scanner driver program to use} 
    radiobutton $base.settings.fra18.rad20 \
        -activebackground #d9d9d9 -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {.yaprimaxgui-scanner.settings.fra23.lab26 configure -state normal
.yaprimaxgui-scanner.menubutton36 configure -state normal
.yaprimaxgui-scanner.settings.fra23.sca28 configure -state normal
.yaprimaxgui-scanner.settings.fra23.sca28 configure -foreground Black} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground Black \
        -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text primax_scan -value primax_scan \
        -variable primax 
    radiobutton $base.settings.fra18.rad22 \
        -activebackground #d9d9d9 -activeforeground Black -background #d9d9d9 \
        -borderwidth 1 \
        -command {.yaprimaxgui-scanner.settings.fra23.lab26 configure -state disabled
.yaprimaxgui-scanner.menubutton36 configure -state disabled
.yaprimaxgui-scanner.settings.fra23.sca28 configure -state disabled 
.yaprimaxgui-scanner.settings.fra23.sca28 configure -foreground #a3a3a3} \
        -disabledforeground #a3a3a3 -font {Helvetica -12} -foreground Black \
        -height 0 -highlightbackground #d9d9d9 -highlightcolor Black \
        -selectcolor #94a4d7 -text pxscan -value pxscan -variable primax 
    frame $base.settings.fra23 \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief groove \
        -width 125 
    label $base.settings.fra23.lab24 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief raised \
        -text {Hex-adress of the parallel port} 
    entry $base.settings.fra23.ent25 \
        -background #94a4d7 -borderwidth 1 -font {Helvetica -12} \
        -foreground #000000 -highlightbackground #c3c3c3 \
        -highlightcolor #000000 -insertbackground Black \
        -selectbackground #c3c3c3 -selectforeground Black -textvariable hex 
    label $base.settings.fra23.lab26 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 -height 0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 -relief raised \
        -text {Max. optical resolution of the scanner} 
    scale $base.settings.fra23.sca28 \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -font {Helvetica -12} -foreground Black -from 0.0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -label {Speed of carriage} -orient horizontal -relief groove \
        -resolution 1.0 -tickinterval 0.0 -to 15.0 -troughcolor #94a4d7 \
        -variable speed -width 8 
    frame $base.settings.fra29 \
        -background #d9d9d9 -borderwidth 2 -height 75 \
        -highlightbackground #d9d9d9 -highlightcolor Black -relief groove \
        -width 125 
    checkbutton $base.settings.fra29.che30 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {Turn lamp off on exit} -variable off 
    checkbutton $base.settings.fra29.che31 \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 -disabledforeground #a3a3a3 \
        -font {Helvetica -12} -foreground #000000 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -selectcolor #94a4d7 -text {Auto warm up on start up} -variable warm 
    scale $base.settings.fra29.sca32 \
        -activebackground #d9d9d9 -background #d9d9d9 -bigincrement 0.0 \
        -font {Helvetica -12} -foreground #000000 -from 0.0 \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -label {Warm up time (seconds)} -orient horizontal -relief groove \
        -resolution 1.0 -tickinterval 0.0 -to 120.0 -troughcolor #94a4d7 \
        -variable time -width 8 
    button $base.ok \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {global rc hex speed time maxres off warm primax window
set rc(hex) $hex
set rc(speed) $speed
set rc(time) $time
set rc(maxres) $maxres
set rc(off) $off
set rc(warm) $warm
set rc(primax) $primax

if { $rc(primax) == "primax_scan" } {
.yaprimaxgui.compression configure -state normal
    if { $window(image) == "1" } {
        .yaprimaxgui-image.photo.color.red configure -state normal
        .yaprimaxgui-image.photo.color.green configure -state normal
        .yaprimaxgui-image.photo.color.blue configure -state normal
    }
    if { $window(more) == "1" } {
        .yaprimaxgui-image-more.more.back.label configure -state normal
        .yaprimaxgui-image-more.more.back.compression configure -state normal
    }
}

if { $rc(primax) == "pxscan" } {
    .yaprimaxgui.compression configure -state disabled
    if { $rc(color) == "--RED" | $rc(color) == "--GREEN" | $rc(color) == "--BLUE" } {
        set rc(color) --RGB
        .yaprimaxgui.color configure -text "24-Bit RGB"
        .yaprimaxgui-image.photo.color.channels.1 configure -background red
        .yaprimaxgui-image.photo.color.channels.2 configure -background green
        .yaprimaxgui-image.photo.color.channels.3 configure -background green
        .yaprimaxgui-image.photo.color.channels.4 configure -background blue
        show-size 0
    }
    if { $window(image) == "1" } {
        .yaprimaxgui-image.photo.color.channels.1 configure -background red
        .yaprimaxgui-image.photo.color.channels.2 configure -background green
        .yaprimaxgui-image.photo.color.channels.3 configure -background green
        .yaprimaxgui-image.photo.color.channels.4 configure -background blue
        .yaprimaxgui-image.photo.color.red configure -state disabled
        .yaprimaxgui-image.photo.color.green configure -state disabled
        .yaprimaxgui-image.photo.color.blue configure -state disabled
    }
    if { $window(more) == "1" } {
        .yaprimaxgui-image-more.more.back.label configure -state disabled
        .yaprimaxgui-image-more.more.back.compression configure -state disabled
    }
}

destroy .yaprimaxgui-scanner} \
        -disabledforeground #a3a3a3 -font {Helvetica -12 bold} \
        -foreground #000000 -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text OK 
    button $base.apply \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {global rc hex speed time maxres off warm primax window
set rc(hex) $hex
set rc(speed) $speed
set rc(time) $time
set rc(maxres) $maxres
set rc(off) $off
set rc(warm) $warm
set rc(primax) $primax

if { $rc(primax) == "primax_scan" } {
.yaprimaxgui.compression configure -state normal
    if { $window(image) == "1" } {
        .yaprimaxgui-image.photo.color.red configure -state normal
        .yaprimaxgui-image.photo.color.green configure -state normal
        .yaprimaxgui-image.photo.color.blue configure -state normal
    }
    if { $window(more) == "1" } {
        .yaprimaxgui-image-more.more.back.label configure -state normal
        .yaprimaxgui-image-more.more.back.compression configure -state normal
    }
}

if { $rc(primax) == "pxscan" } {
    .yaprimaxgui.compression configure -state disabled
    if { $rc(color) == "--RED" | $rc(color) == "--GREEN" | $rc(color) == "--BLUE" } {
        set rc(color) --RGB
        .yaprimaxgui.color configure -text "24-Bit RGB"
        .yaprimaxgui-image.photo.color.channels.1 configure -background red
        .yaprimaxgui-image.photo.color.channels.2 configure -background green
        .yaprimaxgui-image.photo.color.channels.3 configure -background green
        .yaprimaxgui-image.photo.color.channels.4 configure -background blue
        show-size 0
    }
    if { $window(image) == "1" } {
        .yaprimaxgui-image.photo.color.channels.1 configure -background red
        .yaprimaxgui-image.photo.color.channels.2 configure -background green
        .yaprimaxgui-image.photo.color.channels.3 configure -background green
        .yaprimaxgui-image.photo.color.channels.4 configure -background blue
        .yaprimaxgui-image.photo.color.red configure -state disabled
        .yaprimaxgui-image.photo.color.green configure -state disabled
        .yaprimaxgui-image.photo.color.blue configure -state disabled
    }
    if { $window(more) == "1" } {
        .yaprimaxgui-image-more.more.back.label configure -state disabled
        .yaprimaxgui-image-more.more.back.compression configure -state disabled
    }
}} \
        -disabledforeground #a3a3a3 -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Apply 
    button $base.cancel \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {destroy .yaprimaxgui-scanner} -disabledforeground #a3a3a3 \
        -font {Helvetica -12 bold} -foreground #000000 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 -text Cancel 
    button $base.default \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {global rc hex speed time maxres off warm primax
set hex 0x378
set speed 15
set time 60
set maxres 300
set off 0
set warm 0
set primax primax_scan
.yaprimaxgui-scanner.settings.fra23.lab26 configure -state normal
.yaprimaxgui-scanner.settings.fra23.ent27 configure -state normal
.yaprimaxgui-scanner.settings.fra23.ent27 configure -foreground Black
.yaprimaxgui-scanner.settings.fra23.sca28 configure -state normal
.yaprimaxgui-scanner.settings.fra23.sca28 configure -foreground Black} \
        -disabledforeground #a3a3a3 -font {Helvetica -12 bold} \
        -foreground #000000 -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text Default 
    menubutton $base.menubutton36 \
        -activebackground #d9d9d9 -activeforeground #000000 -borderwidth 1 \
        -font {Helvetica -12} -foreground #000000 -height 24 \
        -highlightbackground #a3a3a3 -highlightcolor #000000 \
        -highlightthickness 1 -indicatoron 1 \
        -menu .yaprimaxgui-scanner.menubutton36.m -padx 4 -pady 3 \
        -relief raised -text {600 dpi} -width 74 
    menu $base.menubutton36.m \
        -activebackground #d9d9d9 -activeforeground #000000 -cursor {} \
        -foreground #000000 
    $base.menubutton36.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global maxres
set maxres 300
.yaprimaxgui-scanner.menubutton36 configure -text "300 dpi"} \
        -foreground {} -image {} -label {300 dpi} 
    $base.menubutton36.m add command \
        -activebackground {} -activeforeground {} -accelerator {} \
        -command {global maxres
set maxres 600
.yaprimaxgui-scanner.menubutton36 configure -text "600 dpi"} \
        -foreground {} -image {} -label {600 dpi} 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.settings \
        -x 5 -y 5 -width 330 -height 279 -anchor nw -bordermode ignore 
    place $base.settings.fra18 \
        -x 6 -y 5 -width 320 -height 55 -anchor nw -bordermode ignore 
    place $base.settings.fra18.lab19 \
        -x 6 -y 5 -width 305 -height 18 -anchor nw -bordermode ignore 
    place $base.settings.fra18.rad20 \
        -x 35 -y 30 -anchor nw -bordermode ignore 
    place $base.settings.fra18.rad22 \
        -x 200 -y 30 -anchor nw -bordermode ignore 
    place $base.settings.fra23 \
        -x 6 -y 63 -width 320 -height 119 -anchor nw -bordermode ignore 
    place $base.settings.fra23.lab24 \
        -x 6 -y 6 -width 226 -height 18 -anchor nw -bordermode ignore 
    place $base.settings.fra23.ent25 \
        -x 240 -y 5 -width 73 -height 20 -anchor nw -bordermode ignore 
    place $base.settings.fra23.lab26 \
        -x 6 -y 31 -width 226 -height 18 -anchor nw -bordermode ignore 
    place $base.settings.fra23.sca28 \
        -x 10 -y 55 -width 308 -height 58 -anchor nw -bordermode ignore 
    place $base.settings.fra29 \
        -x 6 -y 185 -width 320 -height 90 -anchor nw -bordermode ignore 
    place $base.settings.fra29.che30 \
        -x 5 -y 65 -anchor nw -bordermode ignore 
    place $base.settings.fra29.che31 \
        -x 150 -y 65 -anchor nw -bordermode ignore 
    place $base.settings.fra29.sca32 \
        -x 6 -y 5 -width 308 -height 58 -anchor nw -bordermode ignore 
    place $base.ok \
        -x 5 -y 290 -anchor nw -bordermode ignore 
    place $base.apply \
        -x 55 -y 290 -anchor nw -bordermode ignore 
    place $base.cancel \
        -x 270 -y 290 -anchor nw -bordermode ignore 
    place $base.default \
        -x 120 -y 290 -anchor nw -bordermode ignore 
    place $base.menubutton36 \
        -x 250 -y 95 -width 74 -height 24 -anchor nw 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.yaprimaxguihelp {base {container 0}} {
    if {$base == ""} {
        set base .yaprimaxguihelp
    }
    if {[winfo exists $base] && (!$container)} {
        wm deiconify $base; return
    }

    global widget

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    vTcl:toplevel $base -class Toplevel \
        -background #d9d9d9 -highlightbackground #d9d9d9 \
        -highlightcolor #000000 
    wm withdraw $base
    wm focusmodel $base passive
    wm geometry $base 368x374+83+89; update
    wm maxsize $base 1009 738
    wm minsize $base 1 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm title $base "Help"
    vTcl:FireEvent $base <<Create>>
    }
    button $base.ok \
        -activebackground #d9d9d9 -activeforeground #000000 \
        -background #d9d9d9 -borderwidth 1 \
        -command {destroy .yaprimaxguihelp} -disabledforeground #a3a3a3 \
        -foreground #000000 -height 0 -highlightbackground #a3a3a3 \
        -highlightcolor #000000 -text Close -width 0 
    text $base.text \
        -background #d9d9d9 -borderwidth 1 -font {Helvetica -12} \
        -foreground #000000 -highlightbackground #ffffff \
        -highlightcolor #000000 -highlightthickness 0 -insertborderwidth 1 \
        -padx 0 -pady 0 -selectbackground #94a4d7 -selectforeground #ffffff \
        -wrap word -yscrollcommand "$base.scroll set" 
    scrollbar $base.scroll \
        -activebackground #d9d9d9 -background #d9d9d9 -borderwidth 1 \
        -command "$base.text yview" -cursor left_ptr \
        -highlightbackground #d9d9d9 -highlightcolor #000000 \
        -highlightthickness 0 -troughcolor #d9d9d9 -width 10 
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.ok \
        -x 305 -y 345 -anchor nw -bordermode ignore 
    place $base.text \
        -x 5 -y 5 -width 338 -height 335 -anchor nw -bordermode ignore 
    place $base.scroll \
        -x 345 -y 5 -width 16 -height 335 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

Window show .
Window show .yaprimaxgui
Window show .yaprimaxgui-image
Window show .yaprimaxgui-image-more
Window show .yaprimaxgui-options
Window show .yaprimaxgui-scanner
Window show .yaprimaxguihelp

main $argc $argv
