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

#############################################################################
# Visual Tcl v1.51 Project
#
global imScilab widget
global tcl_platform

#################################
# imScilab LIBRARY PROCEDURES
#

if {![info exists imScilab(sourcing)]} {
proc Window {args} {
    global imScilab
    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 imScilabWindow$name] != ""} {
                eval "imScilabWindow$name $newname $rest"
            }
            if {[wm state $newname] == "normal"} {
                imScilab:FireEvent $newname <<Show>>
            }
        }
        hide    {
            if {$exists} {
                wm withdraw $newname
                imScilab:FireEvent $newname <<Hide>>
                return}
        }
        iconify { if $exists {wm iconify $newname; return} }
        destroy { if $exists {destroy $newname; return} }
    }
}

proc imScilab:WindowsCleanup {} {
    global imScilab
    if {[info exists imScilab(sourcing)]} { return }
    foreach w [winfo children .] {
    	wm protocol $w WM_DELETE_WINDOW { exit }
    }
}
}

if {![info exists imScilab(sourcing)]} {
proc {imScilab: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 {imScilab: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 {imScilab: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 {imScilab: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 {imScilab: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 {imScilab:toplevel} {args} {
    uplevel #0 eval toplevel $args
    set target [lindex $args 0]
    namespace eval ::$target {}
}
}

if {[info exists imScilab(sourcing)]} {
proc imScilab:project:info {} {
    namespace eval ::widgets::.top23 {
        array set save {}
    }
    namespace eval ::widgets::.top23.fra25 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.mes30 {
        array set save {-text 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra31 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra31.lab39 {
        array set save {-text 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra31.ent40 {
        array set save {-background 1 -textvariable 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra32 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra32.ent42 {
        array set save {-background 1 -textvariable 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra28.fra32.lab47 {
        array set save {-height 1 -text 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra33 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra33.ent43 {
        array set save {-background 1 -textvariable 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra33.lab45 {
        array set save {-text 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra34 {
        array set save {-borderwidth 1 -height 1 -relief 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra34.ent44 {
        array set save {-background 1 -textvariable 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.fra34.lab46 {
        array set save {-text 1 -width 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.lab37 {
        array set save {-height 1 -text 1}
    }
    namespace eval ::widgets::.top23.fra25.fra29.lab38 {
        array set save {-background 1 -relief 1 -text 1 -width 1}
    }
    namespace eval ::widgets_bindings {
        set tagslist {}
    }
}
}
#################################
# USER DEFINED PROCEDURES
#

proc {avisavesub_cancel} {} {
global imScilab
	destroy .avisave_sub
	set imScilab(avisave,ready) 0
	return
}

proc {avisavesub_ok} {} {
global imScilab
	destroy .avisave_sub
	set imScilab(avisave,ready) 1
	return
}


###########################################################
## Procedure:  init

###########################################################
## Procedure:  main

proc {main} {} {
global imScilab

}

proc init {} {
global imScilab
	set imScilab(avisave,scale) 400000
	set imScilab(avisave,rate) 10000000
	set imScilab(avisave,ready) 0
	set imScilab(avisave,from) 0
	set imScilab(avisave,fps) [string range [expr $imScilab(avisave,rate)/$imScilab(avisave,scale).0] 0 3]
}

init

#################################
# imScilab GENERATED GUI PROCEDURES
#
	global imScilab
proc imScilabWindow. {base {container 0}} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    wm focusmodel $base passive
    wm geometry $base 200x200+66+87; update
    wm maxsize $base 1028 746
    wm minsize $base 115 1
    wm overrideredirect $base 0
    wm resizable $base 1 1
    wm withdraw $base
    wm title $base "imScilab"
    bindtags $base "$base imScilab all"
    imScilab:FireEvent $base <<Create>>
    }
    ###################
    # SETTING GEOMETRY
    ###################

    imScilab:FireEvent $base <<Ready>>
}

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

    global widget imScilab
    imScilab:DefineAlias "$base" "Toplevel1" imScilab:Toplevel:WidgetProc "" 1
    imScilab:DefineAlias "$base.fra25" "Frame2" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28" "Frame4" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra31" "Frame6" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra31.ent40" "Entry1" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra31.lab39" "Label3" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra32" "Frame7" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra32.ent42" "Entry3" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.fra32.lab47" "Label6" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra28.mes30" "Message2" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29" "Frame5" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra33" "Frame8" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra33.ent43" "Entry4" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra33.lab45" "Label4" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra34" "Frame9" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra34.ent44" "Entry5" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.fra34.lab46" "Label5" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.lab37" "Label1" imScilab:WidgetProc "Toplevel1" 1
    imScilab:DefineAlias "$base.fra25.fra29.lab38" "Label2" imScilab:WidgetProc "Toplevel1" 1

    ###################
    # CREATING WIDGETS
    ###################
    if {!$container} {
    imScilab:toplevel $base -class Toplevel
    wm transient $base .avi
    wm focusmodel $base passive
    wm geometry $base 397x127+233+287; update
    wm maxsize $base 1028 746
    wm minsize $base 115 1
    wm overrideredirect $base 0
    wm resizable $base 0 0
    wm deiconify $base
    wm title $base "Avisave_sub"
    imScilab:FireEvent $base <<Create>>
    }
    frame $base.fra25 \
        -borderwidth 2 -relief groove -height 120 -width 390 

### Choose save frame    
    frame $base.fra25.fra28 \
        -borderwidth 2 -relief groove -height 55 -width 380 
    message $base.fra25.fra28.mes30 \
        -text {Choose Save Frame} -width 110
    message $base.fra25.fra28.mes31 \
        -text {(Total Frame} -width 70
    message $base.fra25.fra28.mes32 \
        -width 80 -background white -relief groove -text $imScilab(aviframeSum)
    message $base.fra25.fra28.mes33 \
        -text {)} -width 5
    
    button $base.fra25.fra28.btncancel \
        -height 20 -text Cancel -width 60 -relief groove -pady 0 \
        -command {avisavesub_cancel}
    bind $base.fra25.fra28.btncancel <Enter> {
        .avisave_sub.fra25.fra28.btncancel configure -relief raise
    }
    bind $base.fra25.fra28.btncancel <Leave> {
        .avisave_sub.fra25.fra28.btncancel configure -relief groove
    }
    button $base.fra25.fra28.btnok \
        -height 20 -text OK -width 60 -relief groove -pady 0 \
        -command {avisavesub_ok}
    bind $base.fra25.fra28.btnok <Enter> {
        .avisave_sub.fra25.fra28.btnok configure -relief raise
    }
    bind $base.fra25.fra28.btnok <Leave> {
        .avisave_sub.fra25.fra28.btnok configure -relief groove
    }
    	
    frame $base.fra25.fra28.fra31 \
        -borderwidth 2 -relief groove -height 25 -width 185 
    label $base.fra25.fra28.fra31.lab39 \
        -text FROM -width 43 
    entry $base.fra25.fra28.fra31.ent40 \
        -background white -textvariable "imScilab(avisave,from)" -width 76

        bind .avisave_sub.fra25.fra28.fra31.ent40 <Return> {
	
        avisavesub_ok
 }
    frame $base.fra25.fra28.fra32 \
        -borderwidth 2 -relief groove -height 25 -width 185 
    entry $base.fra25.fra28.fra32.ent42 \
        -background white -textvariable "imScilab(avisave,to)" -width 76

        bind .avisave_sub.fra25.fra28.fra32.ent42 <Return> {
	
        avisavesub_ok
 }
    label $base.fra25.fra28.fra32.lab47 \
        -height 0 -text TO -width 28 
    
### Set avi fps    
    frame $base.fra25.fra29 \
        -borderwidth 2 -relief groove -height 55 -width 380 
    frame $base.fra25.fra29.fra33 \
        -borderwidth 2 -relief groove -height 25 -width 185 
    entry $base.fra25.fra29.fra33.ent43 \
        -background white -textvariable "imScilab(avisave,scale)" -width 76
    bind .avisave_sub.fra25.fra29.fra33.ent43 <Return> {
	avisavesub_ok
	}
    label $base.fra25.fra29.fra33.lab45 \
        -text Scale -width 33 
    frame $base.fra25.fra29.fra34 \
        -borderwidth 2 -relief groove -height 25 -width 185 
    entry $base.fra25.fra29.fra34.ent44 \
        -background white -textvariable "imScilab(avisave,rate)" -width 76
    bind .avisave_sub.fra25.fra29.fra34.ent44 <Return> {
	avisavesub_ok
	}
    label $base.fra25.fra29.fra34.lab46 \
        -text Rate -width 28 
    button $base.fra25.fra29.btnfps \
        -height 20 -text fps -width 60 -relief groove -pady 0 \
        -command {.avisave_sub.fra25.fra29.lab38 configure -text [expr $imScilab(avisave,rate)/$imScilab(avisave,scale)]}
    bind $base.fra25.fra29.btnfps <Enter> {
        .avisave_sub.fra25.fra29.btnfps configure -relief raise
    }
    bind $base.fra25.fra29.btnfps <Leave> {
        .avisave_sub.fra25.fra29.btnfps configure -relief groove
    } 
    label $base.fra25.fra29.lab38 \
        -background #ffffff -relief groove -text $imScilab(avisave,fps) -width 83
    ###################
    # SETTING GEOMETRY
    ###################
    place $base.fra25 \
        -in $base -x 5 -y 5 -width 390 -height 120 -anchor nw \
        -bordermode ignore 
    
    place $base.fra25.fra28 \
        -in $base.fra25 -x 5 -y 5 -width 380 -height 55 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra28.mes30 \
        -in $base.fra25.fra28 -x 5 -y 5 -width 110 -height 18 -anchor nw \
        -bordermode ignore
    place $base.fra25.fra28.mes31 \
        -in $base.fra25.fra28 -x 110 -y 5 -width 70 -height 18 -anchor nw \
        -bordermode ignore
    place $base.fra25.fra28.mes32 \
        -in $base.fra25.fra28 -x 180 -y 5 -width 40 -height 18 -anchor nw \
        -bordermode ignore
    place $base.fra25.fra28.mes33 \
        -in $base.fra25.fra28 -x 220 -y 5 -width 5 -height 18 -anchor nw \
        -bordermode ignore
    place $base.fra25.fra28.btncancel \
        -in $base.fra25.fra28 -x 250 -y 5 -width 60 -height 20 -anchor nw \
        -bordermode ignore
    place $base.fra25.fra28.btnok \
        -in $base.fra25.fra28 -x 315 -y 5 -width 60 -height 20 -anchor nw \
        -bordermode ignore
            
    place $base.fra25.fra28.fra31 \
        -in $base.fra25.fra28 -x 4 -y 27 -width 185 -height 25 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra28.fra31.lab39 \
        -in $base.fra25.fra28.fra31 -x 5 -y 7 -width 43 -height 14 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra28.fra31.ent40 \
        -in $base.fra25.fra28.fra31 -x 104 -y 2 -width 75 -height 20 \
        -anchor nw -bordermode ignore 
    place $base.fra25.fra28.fra32 \
        -in $base.fra25.fra28 -x 191 -y 27 -width 185 -height 25 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra28.fra32.ent42 \
        -in $base.fra25.fra28.fra32 -x 105 -y 2 -width 75 -height 20 \
        -anchor nw -bordermode ignore 
    place $base.fra25.fra28.fra32.lab47 \
        -in $base.fra25.fra28.fra32 -x 5 -y 7 -width 28 -height 14 -anchor nw \
        -bordermode ignore 
    
    place $base.fra25.fra29 \
        -in $base.fra25 -x 5 -y 62 -width 380 -height 55 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra29.fra33 \
        -in $base.fra25.fra29 -x 4 -y 2 -width 185 -height 25 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra29.fra33.ent43 \
        -in $base.fra25.fra29.fra33 -x 104 -y 2 -width 75 -height 20 \
        -anchor nw -bordermode ignore 
    place $base.fra25.fra29.fra33.lab45 \
        -in $base.fra25.fra29.fra33 -x 8 -y 6 -width 33 -height 14 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra29.fra34 \
        -in $base.fra25.fra29 -x 4 -y 28 -width 185 -height 25 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra29.fra34.ent44 \
        -in $base.fra25.fra29.fra34 -x 104 -y 2 -width 75 -height 20 \
        -anchor nw -bordermode ignore 
    place $base.fra25.fra29.fra34.lab46 \
        -in $base.fra25.fra29.fra34 -x 10 -y 6 -width 28 -height 14 \
        -anchor nw -bordermode ignore 
    place $base.fra25.fra29.btnfps \
        -in $base.fra25.fra29 -x 198 -y 19 -width 60 -height 19 -anchor nw \
        -bordermode ignore 
    place $base.fra25.fra29.lab38 \
        -in $base.fra25.fra29 -x 296 -y 18 -width 75 -height 20 -anchor nw \
        -bordermode ignore 

    imScilab:FireEvent $base <<Ready>>
}

Window show .
Window show .avisave_sub

main
