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

if {![info exists vTcl(sourcing)]} {

    # Provoke name search
    catch {package require bogus-package-name}
    set packageNames [package names]

    package require Tk
    switch $tcl_platform(platform) {
	windows {
            option add *Button.padY 0
	}
	default {
            option add *Scrollbar.width 10
            option add *Scrollbar.highlightThickness 0
            option add *Scrollbar.elementBorderWidth 2
            option add *Scrollbar.borderWidth 2
	}
    }
    
    # Needs Itcl
    package require Itcl

    # Needs Itk
    package require Itk

    # Needs Iwidgets
    package require Iwidgets

    switch $tcl_platform(platform) {
	windows {
            option add *Pushbutton.padY         0
	}
	default {
	    option add *Scrolledhtml.sbWidth    10
	    option add *Scrolledtext.sbWidth    10
	    option add *Scrolledlistbox.sbWidth 10
	    option add *Scrolledframe.sbWidth   10
	    option add *Hierarchy.sbWidth       10
            option add *Pushbutton.padY         2
        }
    }
    
}

#############################################################################
# Visual Tcl v1.60 Project
#


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

if {![info exists vTcl(sourcing)]} {
#############################################################################
## Library Procedure:  Window

proc ::Window {args} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    global vTcl
    foreach {cmd name newname} [lrange $args 0 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 {[winfo exists $newname] && [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} }
    }
}
#############################################################################
## Library Procedure:  vTcl:DefineAlias

proc ::vTcl:DefineAlias {target alias widgetProc top_or_alias cmdalias} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    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
        }
    }
}
#############################################################################
## Library Procedure:  vTcl:DoCmdOption

proc ::vTcl:DoCmdOption {target cmd} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    ## 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]
}
#############################################################################
## Library Procedure:  vTcl:FireEvent

proc ::vTcl:FireEvent {target event {params {}}} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    ## The window may have disappeared
    if {![winfo exists $target]} return
    ## Process each binding tag, looking for the 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]
                foreach rep "\{%W $target\} $params" {
                    regsub -all [lindex $rep 0] $bind_code [lindex $rep 1] 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}
    }
}
#############################################################################
## Library Procedure:  vTcl:Toplevel:WidgetProc

proc ::vTcl:Toplevel:WidgetProc {w args} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    if {[llength $args] == 0} {
        ## If no arguments, returns the path the alias points to
        return $w
    }
    set command [lindex $args 0]
    set args [lrange $args 1 end]
    switch -- [string tolower $command] {
        "setvar" {
            foreach {varname value} $args {}
            if {$value == ""} {
                return [set ::${w}::${varname}]
            } else {
                return [set ::${w}::${varname} $value]
            }
        }
        "hide" - "show" {
            Window [string tolower $command] $w
        }
        "showmodal" {
            ## modal dialog ends when window is destroyed
            Window show $w; raise $w
            grab $w; tkwait window $w; grab release $w
        }
        "startmodal" {
            ## ends when endmodal called
            Window show $w; raise $w
            set ::${w}::_modal 1
            grab $w; tkwait variable ::${w}::_modal; grab release $w
        }
        "endmodal" {
            ## ends modal dialog started with startmodal, argument is var name
            set ::${w}::_modal 0
            Window hide $w
        }
        default {
            uplevel $w $command $args
        }
    }
}
#############################################################################
## Library Procedure:  vTcl:WidgetProc

proc ::vTcl:WidgetProc {w args} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

    if {[llength $args] == 0} {
        ## If no arguments, returns the path the alias points to
        return $w
    }
    ## 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]
    }
    uplevel $w $command $args
}
#############################################################################
## Library Procedure:  vTcl:toplevel

proc ::vTcl:toplevel {args} {
    ## This procedure may be used free of restrictions.
    ##    Exception added by Christian Gavin on 08/08/02.
    ## Other packages and widget toolkits have different licensing requirements.
    ##    Please read their license agreements for details.

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


if {[info exists vTcl(sourcing)]} {

proc vTcl:project:info {} {
    set base .top87
    namespace eval ::widgets::$base {
        set set,origin 1
        set set,size 1
        set runvisible 1
    }
    namespace eval ::widgets::$base.che88 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che89 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che90 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che91 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che92 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che93 {
        array set save {-command 1 -disabledforeground 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che94 {
        array set save {-disabledforeground 1 -state 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che95 {
        array set save {-disabledforeground 1 -state 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che96 {
        array set save {-disabledforeground 1 -state 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che97 {
        array set save {-disabledforeground 1 -state 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.che98 {
        array set save {-disabledforeground 1 -state 1 -text 1 -variable 1}
    }
    namespace eval ::widgets::$base.but99 {
        array set save {-activebackground 1 -activeforeground 1 -command 1 -disabledforeground 1 -highlightcolor 1 -text 1 -width 1}
    }
    namespace eval ::widgets::$base.spi115 {
        array set save {-decrement 1 -increment 1 -labeltext 1 -range 1 -width 1}
    }
    namespace eval ::widgets::$base.opt119 {
        array set save {}
    }
    namespace eval ::widgets::$base.but120 {
        array set save {-activebackground 1 -command 1 -disabledforeground 1 -text 1}
    }
    namespace eval ::widgets::$base.but121 {
        array set save {-activebackground 1 -command 1 -disabledforeground 1 -text 1}
    }
    namespace eval ::widgets::$base.sca122 {
        array set save {-bigincrement 1 -command 1 -from 1 -label 1 -orient 1 -resolution 1 -tickinterval 1 -to 1 -variable 1}
    }
    namespace eval ::widgets::$base.sca123 {
        array set save {-bigincrement 1 -command 1 -from 1 -label 1 -orient 1 -resolution 1 -tickinterval 1 -to 1 -variable 1}
    }
    namespace eval ::widgets::$base.sca124 {
        array set save {-bigincrement 1 -command 1 -from 1 -label 1 -orient 1 -resolution 1 -tickinterval 1 -to 1 -variable 1}
    }
    namespace eval ::widgets::$base.but125 {
        array set save {-activebackground 1 -command 1 -disabledforeground 1 -text 1}
    }
    namespace eval ::widgets::$base.but129 {
        array set save {-command 1 -disabledforeground 1 -text 1}
    }
    namespace eval ::widgets::$base.but87 {
        array set save {-command 1 -disabledforeground 1 -text 1}
    }
    set base .top88
    namespace eval ::widgets::$base {
        set set,origin 1
        set set,size 1
        set runvisible 0
    }
    namespace eval ::widgets::$base.ent91 {
        array set save {-labeltext 1 -width 1}
    }
    namespace eval ::widgets::$base.ent92 {
        array set save {-labeltext 1 -width 1}
    }
    namespace eval ::widgets::$base.but93 {
        array set save {-activebackground 1 -activeforeground 1 -command 1 -disabledforeground 1 -foreground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::$base.but94 {
        array set save {-activebackground 1 -activeforeground 1 -command 1 -disabledforeground 1 -foreground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets::$base.but95 {
        array set save {-activebackground 1 -activeforeground 1 -command 1 -disabledforeground 1 -foreground 1 -highlightcolor 1 -text 1}
    }
    namespace eval ::widgets_bindings {
        set tagslist _TopLevel
    }
    namespace eval ::vTcl::modules::main {
        set procs {
            init
            main
            set_defaults
            jogar
            prepara_opcoes
            carrega_opcoes
            salva_opcoes
            atualiza_gui
        }
        set compounds {
        }
        set projectType single
    }
}
}

#################################
# USER DEFINED PROCEDURES
#
#############################################################################
## Procedure:  main

proc ::main {argc argv} {
set_defaults;
carrega_opcoes;
destroy .top88;
}
#############################################################################
## Procedure:  set_defaults

proc ::set_defaults {} {
global widget

global exe
global op
#global comando
global limpa_tela
global oculta
global diagonais
global ponto1
global pena
global revisita
global tamanho
global nulas
global maximo
global alternancia
global semente

set exe {xterm -fn 9x15 -title +-\ MaisOuMenos -e +-};
set op "&";
#set comando "$exe $op";

set limpa_tela 1;
set ::.top87::che88 $limpa_tela;    # limpa tela
set oculta 0;
set ::.top87::che89 $oculta;    # oculta com '?'
set diagonais 1;
set ::.top87::che90 $diagonais;    # diagonais
set ponto1 0;
set ::.top87::che91 $ponto1;    # 1 ponto por rodada
set pena 0;
set ::.top87::che92 $pena;    # pena -50%
set revisita 0;
set ::.top87::che93 $revisita;    # revisita '.'
set tamanho 8;
set ::.top87::sca122 $tamanho;   # tamanho
set nulas 0;
set ::.top87::sca123 $nulas;  # casas nulas
set maximo 10;
set ::.top87::sca124 $maximo; # valor maximo
;# modo de alternancia de +/- :
set alternancia 1; # + - + - ...
;# semente
set semente 0;
$widget(Toplevel1,Spinint1) delete 0 end;
$widget(Toplevel1,Spinint1) insert 0 $semente;
}
#############################################################################
## Procedure:  jogar

proc ::jogar {} {
global widget
global comando

prepara_opcoes
puts $comando
catch "exec $comando" result
}
#############################################################################
## Procedure:  prepara_opcoes

proc ::prepara_opcoes {} {
global widget

global exe
global op
global comando
global limpa_tela
global oculta
global diagonais
global ponto1
global pena
global revisita
global nulas
global tamanho
global maximo
global semente
global alternancia

set opcoes "";
if { $limpa_tela != 0 } {
    append opcoes " -c"; } else {
    append opcoes " +c"; };
if { $oculta != 0 } {
    append opcoes " -o"; } else {
    append opcoes " +o"; };
if { $diagonais != 0 } {
    append opcoes " -d"; } else {
    append opcoes " +d"; };
if { $ponto1 != 0 } {
    append opcoes " -p"; } else {
    append opcoes " +p"; };
if { $pena != 0 } {
    append opcoes " -P"; } else {
    append opcoes " +P"; };
if { $nulas >= 0 } {
    if { $revisita == 1} {
       append opcoes " -." $nulas "r"; } else {
       append opcoes " -." $nulas; }; } else {
    append opcoes " +.";
};

set atual [::.top87.opt119 get]
if { [string compare "+ - + -" $atual] == 0} {
    set alternancia 1
 } else {
    if { [string compare "+ + - - + + - -" $atual] == 0} {
        set alternancia 2
    } else {
        set alternancia 0 }
}

if { $alternancia == 1 } {
    append opcoes " -a" } else {
       if { $alternancia == 2 } { append opcoes " -A"
        } else { append opcoes " +a +A" };
 };

append opcoes " -t" $tamanho;
append opcoes " -m" $maximo;

set semente [::.top87.spi115 get];
append opcoes " -s" $semente;

set comando "$exe $opcoes $op";
}
#############################################################################
## Procedure:  carrega_opcoes

proc ::carrega_opcoes {} {
global widget
global tcl_platform
global rcfile

global exe
global op
#global comando
global limpa_tela
global oculta
global diagonais
global ponto1
global pena
global revisita
global nulas
global tamanho
global maximo
global semente
global alternancia

if {[string compare $tcl_platform(platform) unix] == 0} {
	set rcfile {.maisoumenosrc}
    } else {
	set rcfile {maisoumenos.rc}
    }

if {![file readable $rcfile]} {
	set rcfile ~/$rcfile
}
if {[file readable $rcfile]} {
    if {[catch {source $rcfile}]} {
	    bgerror {Init file error}
	}
    }
atualiza_gui;
}
#############################################################################
## Procedure:  salva_opcoes

proc ::salva_opcoes {} {
global widget
global rcfile

global exe
global op
#global comando
global limpa_tela
global oculta
global diagonais
global ponto1
global pena
global revisita
global nulas
global tamanho
global maximo
global semente
global alternancia

set handle [open $rcfile w]
puts $handle "set exe {$exe}"
puts $handle "set op {$op}"
#puts $handle "set comando {$comando}"
puts $handle "set limpa_tela $limpa_tela"
puts $handle "set oculta $oculta"
puts $handle "set diagonais $diagonais"
puts $handle "set ponto1 $ponto1"
puts $handle "set pena $pena"
puts $handle "set revisita $revisita"
puts $handle "set nulas $nulas"
puts $handle "set tamanho $tamanho"
puts $handle "set maximo $maximo"
puts $handle "set semente $semente"
puts $handle "set alternancia $alternancia"
close $handle
}
#############################################################################
## Procedure:  atualiza_gui

proc ::atualiza_gui {} {
global widget

global exe
global op
global limpa_tela
global oculta
global diagonais
global ponto1
global pena
global revisita
global tamanho
global nulas
global maximo
global alternancia
global semente

#$widget(Toplevel2,Entryfield1) delete 0 end;
#$widget(Toplevel2,Entryfield1) insert 0 $exe;

#$widget(Toplevel2,Entryfield2) delete 0 end;
#$widget(Toplevel2,Entryfield2) insert 0 $op;

#set limpa_tela 1;
set ::.top87::che88 $limpa_tela;    # limpa tela
#set oculta 0;
set ::.top87::che89 $oculta;    # oculta com '?'
#set diagonais 1;
set ::.top87::che90 $diagonais;    # diagonais
#set ponto1 0;
set ::.top87::che91 $ponto1;    # 1 ponto por rodada
#set pena 1;
set ::.top87::che92 $pena;    # pena -50%
#set revisita 0;
set ::.top87::che93 $revisita;    # revisita '.'
#set tamanho 5;
set ::.top87::sca122 $tamanho;   # tamanho
#set nulas 30;
set ::.top87::sca123 $nulas;  # casas nulas
#set maximo 100;
set ::.top87::sca124 $maximo; # valor maximo
;# modo de alternancia de +/- :
#set alternancia 1; # atualizar proxima linha tambem
namespace inscope ::iwidgets::Optionmenu {::.top87.opt119 _setItem {+ - + -}}
;# semente
#set semente 0;
$widget(Toplevel1,Spinint1) delete 0 end;
$widget(Toplevel1,Spinint1) insert 0 $semente;
}

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

proc ::init {argc argv} {}

init $argc $argv

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

proc vTclWindow. {base} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    wm focusmodel $top passive
    wm geometry $top 1x1+0+0; update
    wm maxsize $top 785 570
    wm minsize $top 1 1
    wm overrideredirect $top 0
    wm resizable $top 1 1
    wm withdraw $top
    wm title $top "vtcl.tcl"
    bindtags $top "$top Vtcl.tcl all"
    vTcl:FireEvent $top <<Create>>
    wm protocol $top WM_DELETE_WINDOW "vTcl:FireEvent $top <<DeleteWindow>>"

    ###################
    # SETTING GEOMETRY
    ###################

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.top87 {base} {
    if {$base == ""} {
        set base .top87
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    set top $base
    ###################
    # CREATING WIDGETS
    ###################
    vTcl:toplevel $top -class Toplevel \
        -highlightcolor black 
    wm focusmodel $top passive
    wm geometry $top 201x401+7+134; update
    wm maxsize $top 785 570
    wm minsize $top 1 1
    wm overrideredirect $top 0
    wm resizable $top 0 0
    wm deiconify $top
    wm title $top "tk+- tkMaisOuMenos"
    vTcl:DefineAlias "$top" "Toplevel1" vTcl:Toplevel:WidgetProc "" 1
    bindtags $top "$top Toplevel all _TopLevel"
    vTcl:FireEvent $top <<Create>>
    wm protocol $top WM_DELETE_WINDOW "vTcl:FireEvent $top <<DeleteWindow>>"

    checkbutton $top.che88 \
        \
        -command {global limpa_tela
if {$limpa_tela == 0} {set limpa_tela 1} else {set limpa_tela 0};} \
        -disabledforeground #a1a4a1 -text {Limpa tela} \
        -variable "$top\::che88" 
    vTcl:DefineAlias "$top.che88" "Checkbutton1" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che89 \
        \
        -command {global oculta
if { $oculta == 0 } {set oculta 1} else {set oculta 0};} \
        -disabledforeground #a1a4a1 -text {Oculta c/ '?'} \
        -variable "$top\::che89" 
    vTcl:DefineAlias "$top.che89" "Checkbutton2" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che90 \
        \
        -command {global diagonais
if { $diagonais == 1 } { set diagonais 0 } else {set diagonais 1 };} \
        -disabledforeground #a1a4a1 -text Diagonais -variable "$top\::che90" 
    vTcl:DefineAlias "$top.che90" "Checkbutton3" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che91 \
        \
        -command {global ponto1
if { $ponto1 == 1 } { set ponto1 0 } else { set ponto1 1 };} \
        -disabledforeground #a1a4a1 -text {1pt / rodada} \
        -variable "$top\::che91" 
    vTcl:DefineAlias "$top.che91" "Checkbutton4" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che92 \
        \
        -command {global pena
if {$pena == 0} {set pena 1} else {set pena 0};} \
        -disabledforeground #a1a4a1 -text {Pena -50%} \
        -variable "$top\::che92" 
    vTcl:DefineAlias "$top.che92" "Checkbutton5" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che93 \
        \
        -command {global revisita
if {$revisita == 0} {set revisita 1} else {set revisita 0};} \
        -disabledforeground #a1a4a1 -text {Revisita '.'} \
        -variable "$top\::che93" 
    vTcl:DefineAlias "$top.che93" "Checkbutton6" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che94 \
        -disabledforeground #a1a4a1 -state disabled -text +- \
        -variable "$top\::che94" 
    vTcl:DefineAlias "$top.che94" "Checkbutton7" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che95 \
        -disabledforeground #a1a4a1 -state disabled -text +- \
        -variable "$top\::che95" 
    vTcl:DefineAlias "$top.che95" "Checkbutton8" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che96 \
        -disabledforeground #a1a4a1 -state disabled -text +- \
        -variable "$top\::che96" 
    vTcl:DefineAlias "$top.che96" "Checkbutton9" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che97 \
        -disabledforeground #a1a4a1 -state disabled -text +- \
        -variable "$top\::che97" 
    vTcl:DefineAlias "$top.che97" "Checkbutton10" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $top.che98 \
        -disabledforeground #a1a4a1 -state disabled -text +- \
        -variable "$top\::che98" 
    vTcl:DefineAlias "$top.che98" "Checkbutton11" vTcl:WidgetProc "Toplevel1" 1
    button $top.but99 \
        -activebackground #00ff00 -activeforeground #000000 -command {jogar;} \
        -disabledforeground #a1a4a1 -highlightcolor #000000 -text Jogar! \
        -width 186 
    vTcl:DefineAlias "$top.but99" "Button1" vTcl:WidgetProc "Toplevel1" 1
    ::iwidgets::spinint $top.spi115 \
        \
        -decrement {namespace inscope ::iwidgets::Spinner {::.top87.spi115 down}} \
        -increment {namespace inscope ::iwidgets::Spinner {::.top87.spi115 up}} \
        -labeltext Semente -range {0 4294967295} -width 10 
    vTcl:DefineAlias "$top.spi115" "Spinint1" vTcl:WidgetProc "Toplevel1" 1
    ::iwidgets::optionmenu $top.opt119
    vTcl:DefineAlias "$top.opt119" "Optionmenu1" vTcl:WidgetProc "Toplevel1" 1
    $top.opt119 insert 1 {+/- Ordem aleatria}
    $top.opt119 insert 2 {+ - + -}
    $top.opt119 insert 3 {+ + - - + + - -}
    button $top.but120 \
        -activebackground #ffff00 -command {set_defaults;} \
        -disabledforeground #a1a4a1 -text Defaults 
    vTcl:DefineAlias "$top.but120" "Button2" vTcl:WidgetProc "Toplevel1" 1
    button $top.but121 \
        -activebackground #ff0000 -command exit -disabledforeground #a1a4a1 \
        -text Sair 
    vTcl:DefineAlias "$top.but121" "Button3" vTcl:WidgetProc "Toplevel1" 1
    scale $top.sca122 \
        -bigincrement 0.0 -command {global tamanho
set tamanho} -from 3.0 \
        -label Tamanho -orient horizontal -resolution 1.0 -tickinterval 0.0 \
        -to 20.0 -variable "$top\::sca122" 
    vTcl:DefineAlias "$top.sca122" "Scale1" vTcl:WidgetProc "Toplevel1" 1
    scale $top.sca123 \
        -bigincrement 0.0 -command {global nulas
set nulas} -from -10.0 \
        -label {% Casas nulas} -orient horizontal -resolution 10.0 \
        -tickinterval 0.0 -to 90.0 -variable "$top\::sca123" 
    vTcl:DefineAlias "$top.sca123" "Scale2" vTcl:WidgetProc "Toplevel1" 1
    scale $top.sca124 \
        -bigincrement 0.0 -command {global maximo
set maximo} -from 3.0 \
        -label {Valor mximo} -orient horizontal -resolution 1.0 \
        -tickinterval 0.0 -to 100.0 -variable "$top\::sca124" 
    vTcl:DefineAlias "$top.sca124" "Scale3" vTcl:WidgetProc "Toplevel1" 1
    button $top.but125 \
        -activebackground #ffffff \
        -command tk_messageBox\ -message\ \[\ set\ msg\ \"\"\;\ \\\n\ \ \ \ append\ msg\ \"tk+-\ tkMaisOuMenos\\n\\nInterface\ de\ controle\ do\ jogo\ +-\\n\\n\"\ \\\n\ \ \ \ \"(C)\ 2007\ Hudson\ Lacerda\\nhfml@brfree.com.br\\n\"\ \\\n\ \ \ \ \"http://br.geocities.com/hfmlacerda/\\n\\n\"\ \\\n\ \ \ \ \"Permission\ is\ granted\ to\ use,\ copying,\ modification,\ distribution,\"\ \\\n\ \ \ \ \"\ and\ distribution\ of\ modified\ versions\ of\ this\ work\ as\ long\ as\"\ \\\n\ \ \ \ \"\ this\ copyright\ notice\ is\ included.\\n\\n\"\ \\\n\ \ \ \ \"\ permitido\ o\ uso,\ cpia,\ modificao,\ distribuio,\ e\ distribuio\"\ \\\n\ \ \ \ \"\ de\ verses\ modificadas\ desta\ obra\ desde\ que\ esta\ nota\ de\ direito\ autoral\"\ \\\n\ \ \ \ \"\ seja\ mantida.\\n\\n\"\ \\\n\ \ \ \ \]\ \\\n\ -title\ \"tk+-\ tkMaisOuMenos\"\; \
        -disabledforeground #a1a4a1 -text Info 
    vTcl:DefineAlias "$top.but125" "Button4" vTcl:WidgetProc "Toplevel1" 1
    button $top.but129 \
        \
        -command {Window show .top88
Window show .top88

$widget(Toplevel2,Entryfield1) delete 0 end;
$widget(Toplevel2,Entryfield1) insert 0 $exe;

$widget(Toplevel2,Entryfield2) delete 0 end;
$widget(Toplevel2,Entryfield2) insert 0 $op;} \
        -disabledforeground #a1a4a1 -text exe 
    vTcl:DefineAlias "$top.but129" "Button5" vTcl:WidgetProc "Toplevel1" 1
    button $top.but87 \
        \
        -command set\ reply\ \[tk_dialog\ .foo\ \"Salvar\ ou\ recarregar\ opes\"\ \"O\ que\ voc\ quer\ fazer\ com\ as\ opes?\"\ \\\n\ \ \ questhead\ 0\ \"Salvar\"\ \"Recarregar\"\ \"Nada\"\ \]\n\nif\ \{\ \$reply\ ==\ 0\ \}\ \{\ salva_opcoes\ \}\;\nif\ \{\ \$reply\ ==\ 1\ \}\ \{\ carrega_opcoes\ \}\;\nif\ \{\ \$reply\ ==\ 2\ \}\ \{\ \ \}\; \
        -disabledforeground #a1a4a1 -text op 
    vTcl:DefineAlias "$top.but87" "Button6" vTcl:WidgetProc "Toplevel1" 1
    ###################
    # SETTING GEOMETRY
    ###################
    place $top.che88 \
        -in $top -x 5 -y 5 -anchor nw -bordermode ignore 
    place $top.che89 \
        -in $top -x 100 -y 5 -anchor nw -bordermode ignore 
    place $top.che90 \
        -in $top -x 5 -y 30 -anchor nw -bordermode ignore 
    place $top.che91 \
        -in $top -x 100 -y 30 -anchor nw -bordermode ignore 
    place $top.che92 \
        -in $top -x 5 -y 55 -anchor nw -bordermode ignore 
    place $top.che93 \
        -in $top -x 100 -y 55 -anchor nw -bordermode ignore 
    place $top.che94 \
        -in $top -x 5 -y 125 -anchor nw -bordermode ignore 
    place $top.che95 \
        -in $top -x 5 -y 145 -anchor nw -bordermode ignore 
    place $top.che96 \
        -in $top -x 5 -y 165 -anchor nw -bordermode ignore 
    place $top.che97 \
        -in $top -x 5 -y 185 -anchor nw -bordermode ignore 
    place $top.che98 \
        -in $top -x 5 -y 205 -anchor nw -bordermode ignore 
    place $top.but99 \
        -in $top -x 7 -y 335 -width 186 -height 31 -anchor nw \
        -bordermode ignore 
    place $top.spi115 \
        -in $top -x 20 -y 305 -anchor nw -bordermode ignore 
    place $top.opt119 \
        -in $top -x 13 -y 270 -anchor nw -bordermode ignore 
    place $top.but120 \
        -in $top -x 80 -y 370 -anchor ne -bordermode ignore 
    place $top.but121 \
        -in $top -x 145 -y 370 -anchor nw -bordermode ignore 
    place $top.sca122 \
        -in $top -x 80 -y 85 -anchor nw -bordermode ignore 
    place $top.sca123 \
        -in $top -x 80 -y 145 -anchor nw -bordermode ignore 
    place $top.sca124 \
        -in $top -x 80 -y 205 -anchor nw -bordermode ignore 
    place $top.but125 \
        -in $top -x 85 -y 370 -width 53 -height 28 -anchor nw \
        -bordermode ignore 
    place $top.but129 \
        -in $top -x 5 -y 235 -width 35 -height 30 -anchor nw \
        -bordermode ignore 
    place $top.but87 \
        -in $top -x 40 -y 235 -width 35 -height 30 -anchor nw \
        -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.top88 {base} {
    if {$base == ""} {
        set base .top88
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    set top $base
    ###################
    # CREATING WIDGETS
    ###################
    vTcl:toplevel $top -class Toplevel \
        -highlightcolor black 
    wm withdraw $top
    wm focusmodel $top passive
    wm geometry $top 300x100+224+435; update
    wm maxsize $top 785 570
    wm minsize $top 1 1
    wm overrideredirect $top 0
    wm resizable $top 0 0
    wm title $top "Configuraes de comando"
    vTcl:DefineAlias "$top" "Toplevel2" vTcl:Toplevel:WidgetProc "" 1
    bindtags $top "$top Toplevel all _TopLevel"
    vTcl:FireEvent $top <<Create>>
    wm protocol $top WM_DELETE_WINDOW "vTcl:FireEvent $top <<DeleteWindow>>"

    ::iwidgets::entryfield $top.ent91 \
        -labeltext Executvel -width 270 
    vTcl:DefineAlias "$top.ent91" "Entryfield1" vTcl:WidgetProc "Toplevel2" 1
    ::iwidgets::entryfield $top.ent92 \
        -labeltext {Opes adicionais} -width 270 
    vTcl:DefineAlias "$top.ent92" "Entryfield2" vTcl:WidgetProc "Toplevel2" 1
    button $top.but93 \
        -activebackground #f7fbf7 -activeforeground black \
        -command {global exe
global op

set exe [$widget(Toplevel2,Entryfield1) get]
set op [$widget(Toplevel2,Entryfield2) get]

destroy .top88} \
        -disabledforeground #a1a4a1 -foreground black -highlightcolor black \
        -text Aplica 
    vTcl:DefineAlias "$top.but93" "Button1" vTcl:WidgetProc "Toplevel2" 1
    button $top.but94 \
        -activebackground #f7fbf7 -activeforeground black \
        -command {global exe
global op

set exe [$widget(Toplevel2,Entryfield1) get]
set op [$widget(Toplevel2,Entryfield2) get]

salva_opcoes

destroy .top88} \
        -disabledforeground #a1a4a1 -foreground black -highlightcolor black \
        -text Salva 
    vTcl:DefineAlias "$top.but94" "Button2" vTcl:WidgetProc "Toplevel2" 1
    button $top.but95 \
        -activebackground #f7fbf7 -activeforeground black \
        -command {$widget(Toplevel2,Entryfield1) delete 0 end;
$widget(Toplevel2,Entryfield1) insert 0 $exe;
$widget(Toplevel2,Entryfield2) delete 0 end;
$widget(Toplevel2,Entryfield2) insert 0 $op;

destroy .top88} \
        -disabledforeground #a1a4a1 -foreground black -highlightcolor black \
        -text Cancela 
    vTcl:DefineAlias "$top.but95" "Button3" vTcl:WidgetProc "Toplevel2" 1
    ###################
    # SETTING GEOMETRY
    ###################
    place $top.ent91 \
        -in $top -x 15 -y 10 -width 275 -height 22 -anchor nw \
        -bordermode ignore 
    place $top.ent92 \
        -in $top -x 15 -y 35 -width 275 -height 22 -anchor nw \
        -bordermode ignore 
    place $top.but93 \
        -in $top -x 15 -y 65 -anchor nw -bordermode ignore 
    place $top.but94 \
        -in $top -x 120 -y 65 -anchor nw -bordermode ignore 
    place $top.but95 \
        -in $top -x 220 -y 65 -anchor nw -bordermode ignore 

    vTcl:FireEvent $base <<Ready>>
}

#############################################################################
## Binding tag:  _TopLevel

bind "_TopLevel" <<Create>> {
    if {![info exists _topcount]} {set _topcount 0}; incr _topcount
}
bind "_TopLevel" <<DeleteWindow>> {
    if {[set ::%W::_modal]} {
                vTcl:Toplevel:WidgetProc %W endmodal
            } else {
                destroy %W; if {$_topcount == 0} {exit}
            }
}
bind "_TopLevel" <Destroy> {
    if {[winfo toplevel %W] == "%W"} {incr _topcount -1}
}

Window show .
Window show .top87
Window show .top88

main $argc $argv
