main window
TCL/TK UseCase2
Abstract : Sets up the main drawing window and menus. 
Comments : Also contains the printing procedure and some 
           misc. procedures.
proc getXCoord { coord } {
    return [lindex $coord 0]
}
proc getYCoord { coord } {
    return [lindex $coord 1]
}
proc clearDocument {} {
    global Vertex Edge can
    $can delete all
    catch { unset Vertex Edge }
}
proc destroyDocument {} {
global iGraph
clearDocument
# $iGraph cppClear:
}
proc savecheck {} {
global changes flagno
#puts $changes
if {$changes != "no"} {
	yesno "You are about to destroy your work without saving\
any changes. Do you wish to continue?" 20 20
if {$flagno == 1} {
	set changes no
	return 1
	}
	return 0
}
return 1
}
# Steve's new print stuff...
# Printing canvas:
proc printcanvas {printer} {
    global can
    # Sets string variables.
    set tmp_file temp.ps
    # Generates postscript file
    Postscript $can $tmp_file
    # Automatically print the file:
    if [catch { exec print -P$printer -N $tmp_file } result] {
        puts $result
    }
    # Remove the temporary file:
    if [catch { exec rm -f $tmp_file } result] {
        puts $result
    }
}
# Generate postscript file:
proc Postscript { c file} {
    $c postscript -file $file -pagewidth 8.i -pageheight 11.i
}
# End Steve's print stuff
proc setup_menu {} {
menubutton .mbar.file -text File -underline 0 \
	-menu .mbar.file.menu
menubutton .mbar.help -text Help -underline 0 \
	-menu .mbar.help.menu
menu .mbar.file.menu
menu .mbar.help.menu
.mbar.help.menu add command -label "Help Me..." \
	-command {ask "Go Paul Go!"}
.mbar.file.menu add command -label "New" \
	-command { if {[savecheck] == 1} {destroyDocument} }
.mbar.file.menu add command -label "Open" \
	-command { if {[savecheck] == 1} { destroyDocument ; openfile } }
# Leaving close out for now.
#.mbar.file.menu add command -label "Close" \
#        -command { clearDocument } 
.mbar.file.menu add separator
.mbar.file.menu add command -label "Save" \
        -command savefile
.mbar.file.menu add command -label "Save As" \
        -command savefile
.mbar.file.menu add separator
.mbar.file.menu add command -label "Gen-CD" \
        -command savecd
.mbar.file.menu add command -label "Print" \
        -command printwindow
.mbar.file.menu add separator
.mbar.file.menu add command -label "Quit" \
	-command { if {[savecheck] == 1} {destroyDocument ; exit } }
pack .mbar.file -side left
pack .mbar.help -side right
}
proc setup_mainwin {} {
    global can inform changes
	set inform 0
	set changes no
    frame .mbar -relief raised -bd 2
    canvas .area -background gray
    set can .area
    wm title . "Our Funky CD Drawing Program"
    #wm minsize . 0 0
    wm maxsize . 9999 9999
    pack .mbar -side top -fill x
    pack .area -fill both -expand true
    setup_menu
}
 
 
 
 
 
 
 
 
