
destroy .new
toplevel .new
wm title .new "GOBLET New Graph"
wm resizable .new 0 0

global ObjectType NNodes
set ObjectType "sparse graph"
     
frame .new.f1
    label .new.f1.label -text "Object Type:" -anchor w
    radiobutton .new.f1.mixedGraph -text "Mixed Graph" \
        -variable ObjectType -value "mixed graph" -anchor w
    radiobutton .new.f1.sparseGraph -text "Sparse Graph" \
        -variable ObjectType -value "sparse graph" -anchor w
    radiobutton .new.f1.denseGraph -text "Dense Graph" \
        -variable ObjectType -value "dense graph" -anchor w
    radiobutton .new.f1.sparseDiGraph -text "Sparse Digraph" \
        -variable ObjectType -value "sparse digraph" -anchor w
    radiobutton .new.f1.denseDiGraph -text "Dense Digraph" \
        -variable ObjectType -value "dense digraph" -anchor w
    radiobutton .new.f1.sparseBiGraph -text "Sparse Bigraph" \
        -variable ObjectType -value "sparse bigraph" -anchor w
    radiobutton .new.f1.denseBiGraph -text "Dense Bigraph" \
        -variable ObjectType -value "dense bigraph" -anchor w
    pack .new.f1.label .new.f1.mixedGraph .new.f1.sparseGraph \
        .new.f1.denseGraph \
        .new.f1.sparseDiGraph .new.f1.denseDiGraph \
        .new.f1.sparseBiGraph .new.f1.denseBiGraph \
        -side top -fill x

set NNodes 0
frame .new.f3
    label .new.f3.nText -text "Number of Nodes:" -anchor w
    grid .new.f3.nText -in .new.f3  \
        -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news -padx 1m
    entry .new.f3.nodes -textvariable NNodes -bg white -width 5
    grid .new.f3.nodes -in .new.f3 \
        -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news -padx 1m

    grid rowconfig    .new.f3 0 -weight 1 -minsize 0
    grid columnconfig .new.f3 0 -weight 1 -minsize 0

    
proc Generate {} {
    global ObjectType ThisGraph NNodes OrigFileName FileName Unchanged Mode env
    destroy .new
    $ThisGraph delete
    DeleteTempFiles
    set OrigFileName [file join [pwd] unnamed]
    set FileName [file join $env(HOME) unnamed]
    wm title . "GOBLET: unnamed"
    if {[string equal $ObjectType "sparse bigraph"] ||
        [string equal $ObjectType "dense bigraph"]} {
        eval goblin $ObjectType $ThisGraph $NNodes $NNodes
    } else {
        eval goblin $ObjectType $ThisGraph $NNodes
    }
    set goblinNodeStyle 1
    InitFile
}

frame .new.buttons
    button .new.buttons.generate -text "Generate" -command Generate

    button .new.buttons.cancel -text "Cancel" -command {destroy .new}
    
    pack .new.buttons.generate .new.buttons.cancel \
        -side left -fill x -padx 3m
     
bind .new.f3.nodes <Return> {Generate}

pack .new.buttons -padx 3m -pady 3m -side bottom
pack .new.f1 .new.f3 -padx 10m -pady 5m -side top -anchor w
