--- ray/src/util/trad.wsh 1994/10/28 10:43:38 2.2 +++ ray/src/util/trad.wsh 2003/02/22 02:07:30 2.15 @@ -1,5 +1,5 @@ -#!/usr/local/bin/wish -f -# SCCSid "$SunId$ LBL" +#!/usr/local/bin/wish4.0 +# RCSid: $Id: trad.wsh,v 2.15 2003/02/22 02:07:30 greg Exp $ # # TCL/TK-based Rad Input File Editor # @@ -11,6 +11,14 @@ set helplib $radlib set auto_path [linsert $auto_path 0 $radlib] +# Assign global globbing variables + +set myglob(rif) *.rif +set myglob(materials) *.mat +set myglob(illum) *.rad +set myglob(scene) *.rad +set myglob(objects) * + # Create required procedures proc modified {} { # check for radvar modification @@ -27,18 +35,18 @@ proc modified {} { # check for radvar modification proc chksave {} { # check if RIF is saved and accost user if not global readonly rifname oldradvar curmess - if $readonly { - set warnmess "You have modified variables, but the file\ -\"[file tail $rifname]\" was opened read-only. + if [modified] { + if $readonly { + set warnmess "You have modified variables, but the\ +file \"[file tail $rifname]\" was opened read-only. Do you wish to save this information somehow?" - set yesmess {Go to File Screen} - } else { - set warnmess "The file \"[file tail $rifname]\" has been\ -modified since it was last saved. +set yesmess {Go to File Screen} + } else { + set warnmess "The file \"[file tail $rifname]\" has\ +been modified since it was last saved. Do you wish to save it now?" - set yesmess {Save File} - } - if [modified] { + set yesmess {Save File} + } switch [tk_dialog .dlg {File Modified} $warnmess \ warning 0 $yesmess {Discard Changes} \ {Cancel Operation}] { @@ -46,14 +54,16 @@ Do you wish to save it now?" 2 { return 0 } } if $readonly { - .file invoke set curmess {Rename file or uncheck read-only to save.} + .file invoke return 0 - } else { - catch {unset oldradvar} - save_vars $rifname + } elseif {[save_vars $rifname]} { + gotfile 1 + return 1 } - } else { return 1 } + return 0 + } + return 1 } # Set global variable default values @@ -73,19 +83,28 @@ trace variable rifname w setrname # Make main window frames -frame .upper -geometry 640x410 +set smallscrn [expr [winfo screenwidth .] < 830] + +message .mess -relief ridge -font fixed -textvariable curmess -anchor nw +if $smallscrn { + frame .upper -width 640 -height 410 + frame .upper.right -width 120 -height 410 + .mess configure -width 640 +} else { + frame .upper -width 830 -height 410 + frame .upper.right -width 130 -height 410 + .mess configure -width 830 +} pack .upper -side top -frame .upper.right -geometry 120x410 place .upper.right -relx .98 -rely 0 -anchor ne -message .mess -relief ridge -font fixed -textvariable curmess \ - -anchor nw -width 620 pack .mess -side top -expand yes -fill both helplink .mess trad trad messages +. configure -cursor top_left_arrow # Make mode buttons proc changescreen {} { # switch screen according to curmode - global curscreen curmode curmess + global curscreen curmode curmess smallscrn if [info exists curscreen] { if {"$curmode" == "$curscreen"} {return} destroy .upper.left @@ -94,7 +113,11 @@ proc changescreen {} { # switch screen according to c } set curscreen $curmode do_$curscreen .upper.left - .upper.left configure -geometry 520x410 + if $smallscrn { + .upper.left configure -width 520 -height 410 + } else { + .upper.left configure -width 700 -height 410 + } place .upper.left -x 0 -y 0 } @@ -120,17 +143,23 @@ setbutt results rename setbutt {} button .upper.right.help -text HELP -width 9 \ -command "gethelp trad trad intro" -pack .upper.right.help -side top -pady 10 -anchor se +pack .upper.right.help -side top -pady 5 -anchor se helplink .upper.right.help trad trad help button .upper.right.quit -text QUIT \ -command {if [chksave] {destroy .}} -width 9 -pack .upper.right.quit -side top -pady 10 -anchor se +pack .upper.right.quit -side top -pady 5 -anchor se helplink .upper.right.quit trad trad quit -wm minsize . 640 460 +if $smallscrn { + wm minsize . 640 460 + wm maxsize . 640 512 +} else { + wm minsize . 830 460 + wm maxsize . 830 512 +} wm iconbitmap . @$radlib/trad.icon -proc gotfile {{o 1}} { # set file possession state +proc gotfile o { # set file possession state global oldradvar radvar catch {unset oldradvar} if $o { @@ -148,16 +177,19 @@ proc gotfile {{o 1}} { # set file possession state # Decide where to go and start +gotfile 0 if {[llength $argv] == 0} { - gotfile 0 set curmess "Choose a Radiance project file." .file invoke } elseif {[llength $argv] == 1} { cd [file dirname $argv] set curfile [file tail $argv] - if {! [file exists $curfile]} { - newnew $argv - .scene invoke + if {! [file isfile $curfile]} { + if [newnew $curfile] { + .scene invoke + } else { + .file invoke + } } elseif {[newload $curfile]} { if $alldone { set curmess "All renderings are finished."