Changeset 91


Ignore:
Timestamp:
Dec 4, 2009 5:00:15 PM (11 years ago)
Author:
toby
Message:

# on 1999/07/21 16:22:54, toby did:
adopt putontop and afterputontop
new autoexpload option
change file lists to -dictionary
add ShowBigMessage?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 1999/04/08 20:44:22 to 1999/07/21 16:22:54
    • Property rcs:lines changed from +5 -2 to +126 -130
    • Property rcs:rev changed from 1.11 to 1.12
    r83 r91  
    5050            global env expgui
    5151            # Windows environment variables
    52             # -95 does not seem to be able to use these
    5352            set env(GSAS) [file nativename $expgui(gsasdir)]
    5453            # PGPLOT_FONT is needed by PGPLOT
     
    5756            set env(LENPAGE) 60
    5857            # all winexec commands are background commands -- ignore background arg
    59 
    6058            # can't get pause to work! -- ignore wait
    6159
     
    137135                -command "set expgui(temp) {}; destroy $w"] -side left
    138136    }
     137    bind $w <Return> "destroy $w"
     138
    139139    # force the window to stay on top
    140     wm transient $w [winfo toplevel [winfo parent $w]]
    141 
    142     bind $w <Return> "destroy $w"
    143     wm withdraw $w
    144     update idletasks
    145     # center the new window in the middle of the parent
    146     set x [expr [winfo x [winfo parent $w]] + [winfo width .]/2 - \
    147             [winfo reqwidth $w]/2 - [winfo vrootx [winfo parent $w]]]
    148     set y [expr [winfo y [winfo parent $w]] + [winfo height .]/2 - \
    149             [winfo reqheight $w]/2 - [winfo vrooty [winfo parent $w]]]
    150     wm geom $w +$x+$y
    151     wm deiconify $w
    152 
    153     set oldFocus [focus]
    154     set oldGrab [grab current $w]
    155     if {$oldGrab != ""} {
    156         set grabStatus [grab status $oldGrab]
    157     }
    158     grab $w
     140    putontop $w
     141
    159142    focus $w.b.2
    160143    tkwait window $w
    161     catch {focus $oldFocus}
    162     if {$oldGrab != ""} {
    163         if {$grabStatus == "global"} {
    164             grab -global $oldGrab
    165         } else {
    166             grab $oldGrab
    167         }
    168     }
     144    afterputontop
     145
    169146    return $expgui(temp)
    170147}
     
    190167    # Save the current exp file
    191168    savearchiveexp
     169    # load the changed .EXP file automatically?
     170    if {$expgui(autoexpload)} {
     171        # disable the file changed monitor
     172        set expgui(expModifiedLast) 0
     173    }
    192174    set cmd {}
    193175    set expnam [file root [file tail $expgui(expfile)]]
     
    202184    }
    203185    forknewterm "$prog -- $expnam" $cmd 0 1 1
    204     wm deiconify .
     186    # load the changed .EXP file automatically?
     187    if {$expgui(autoexpload)} {
     188        # load the revised exp file
     189        loadexp $expgui(expfile)
     190    }
     191#    wm deiconify .
    205192}
    206193
     
    513500    unixcnvbox $frmB outfile 0
    514501    set infile(done) 0
     502    bind $frm <Return> "valid_conv_unix"
    515503    # force the window to stay on top
    516     wm transient $frm [winfo toplevel [winfo parent $frm]]
    517 
    518     bind $frm <Return> "valid_conv_unix"
    519     wm withdraw $frm
    520     update idletasks
    521     # center the new window in the middle of the parent
    522     set x [expr [winfo x [winfo parent $frm]] + [winfo width .]/2 - \
    523             [winfo reqwidth $frm]/2 - [winfo vrootx [winfo parent $frm]]]
    524     set y [expr [winfo y [winfo parent $frm]] + [winfo height .]/2 - \
    525             [winfo reqheight $frm]/2 - [winfo vrooty [winfo parent $frm]]]
    526     wm geom $frm +$x+$y
    527     wm deiconify $frm
    528 
    529     set oldFocus [focus]
    530     set oldGrab [grab current $frm]
    531     if {$oldGrab != ""} {
    532         set grabStatus [grab status $oldGrab]
    533     }
    534     grab $frm
     504    putontop $frm
    535505    focus $frmC.q
    536506    update
     
    545515    }
    546516    destroy $frm
     517    afterputontop
    547518}
    548519
     
    702673    pack [label $frmA.0 -text "Select a file to convert"] -side top -anchor center
    703674    winfilebox $frm
     675    bind $frm <Return> "ValidWinCnv $frm"
     676
    704677    # force the window to stay on top
    705     wm transient $frm [winfo toplevel [winfo parent $frm]]
    706 
    707     bind $frm <Return> "ValidWinCnv $frm"
    708     wm withdraw $frm
    709     update idletasks
    710     # center the new window in the middle of the parent
    711     set x [expr [winfo x [winfo parent $frm]] + [winfo width .]/2 - \
    712             [winfo reqwidth $frm]/2 - [winfo vrootx [winfo parent $frm]]]
    713     set y [expr [winfo y [winfo parent $frm]] + [winfo height .]/2 - \
    714             [winfo reqheight $frm]/2 - [winfo vrooty [winfo parent $frm]]]
    715     wm geom $frm +$x+$y
    716     wm deiconify $frm
    717 
    718     set oldFocus [focus]
    719     set oldGrab [grab current $frm]
    720     if {$oldGrab != ""} {
    721         set grabStatus [grab status $oldGrab]
    722     }
    723     grab $frm
     678    putontop $frm
    724679    focus $frmC.q
    725680    tkwait window $frm
    726     catch {focus $oldFocus}
    727     if {$oldGrab != ""} {
    728         if {$grabStatus == "global"} {
    729             grab -global $oldGrab
    730         } else {
    731             grab $oldGrab
    732         }
    733     }
     681    afterputontop
    734682}
    735683
     
    919867    set filelist [glob -nocomplain \
    920868            [file join [set expgui(FileMenuDir)] *] ]
    921     foreach file [lsort $filelist] {
     869    foreach file [lsort -dictionary $filelist] {
    922870        if {[file isdirectory $file]} {
    923871            $files insert end [file tail $file]
     
    925873        }
    926874    }
    927     foreach file [lsort $filelist] {
     875    foreach file [lsort -dictionary $filelist] {
    928876        if {![file isdirectory $file]} {
    929877            set modified [clock format [file mtime $file] -format "%T %D"]
     
    965913            ] -side top
    966914    bind $frm <Return> {if ![catch {expr $liveplot(hst)}] "destroy .file"}
     915   
    967916    # force the window to stay on top
    968     wm transient $frm [winfo toplevel [winfo parent $frm]]
    969     wm withdraw $frm
    970     update idletasks
    971     # center the new window in the middle of the parent
    972     set x [expr [winfo x [winfo parent $frm]] + [winfo width .]/2 - \
    973             [winfo reqwidth $frm]/2 - [winfo vrootx [winfo parent $frm]]]
    974     set y [expr [winfo y [winfo parent $frm]] + [winfo height .]/2 - \
    975             [winfo reqheight $frm]/2 - [winfo vrooty [winfo parent $frm]]]
    976     wm geom $frm +$x+$y
    977     wm deiconify $frm
    978 
    979     set oldFocus [focus]
    980     set oldGrab [grab current $frm]
    981     if {$oldGrab != ""} {
    982         set grabStatus [grab status $oldGrab]
    983     }
    984     grab $frm
     917    putontop $frm
    985918    focus $frm.2
    986919    tkwait window $frm
    987     catch {focus $oldFocus}
    988     if {$oldGrab != ""} {
    989         if {$grabStatus == "global"} {
    990             grab -global $oldGrab
    991         } else {
    992             grab $oldGrab
    993         }
    994     }
     920    afterputontop
    995921}
    996922
     
    1029955    expfilebox $frmA $mode
    1030956    # force the window to stay on top
    1031     wm transient $frm [winfo toplevel [winfo parent $frm]]
    1032 
    1033     wm withdraw $frm
    1034     update idletasks
    1035     # center the new window in the middle of the parent
    1036     set x [expr [winfo x [winfo parent $frm]] + [winfo width .]/2 - \
    1037             [winfo reqwidth $frm]/2 - [winfo vrootx [winfo parent $frm]]]
    1038     set y [expr [winfo y [winfo parent $frm]] + [winfo height .]/2 - \
    1039             [winfo reqheight $frm]/2 - [winfo vrooty [winfo parent $frm]]]
    1040     wm geom $frm +$x+$y
    1041     wm deiconify $frm
    1042 
    1043     set oldFocus [focus]
    1044     set oldGrab [grab current $frm]
    1045     if {$oldGrab != ""} {
    1046         set grabStatus [grab status $oldGrab]
    1047     }
    1048     grab $frm
     957    putontop $frm
    1049958    focus $frmC.b
    1050959    tkwait window $frm
    1051     catch {focus $oldFocus}
    1052     if {$oldGrab != ""} {
    1053         if {$grabStatus == "global"} {
    1054             grab -global $oldGrab
    1055         } else {
    1056             grab $oldGrab
    1057         }
    1058     }
     960    afterputontop
    1059961    if {$expgui(FileMenuEXPNAM) == ""} return
    1060962    return [file join $expgui(FileMenuDir) $expgui(FileMenuEXPNAM)]
     
    12371139    set filelist [glob -nocomplain \
    12381140            [file join [set expgui(FileMenuDir)] *] ]
    1239     foreach file [lsort $filelist] {
     1141    foreach file [lsort -dictionary $filelist] {
    12401142        if {[file isdirectory $file]} {
    12411143            $files insert end [file tail $file]
     
    12441146    }
    12451147    set pairlist {}
    1246     foreach file [lsort $filelist] {
     1148    foreach file [lsort -dictionary $filelist] {
    12471149        if {![file isdirectory $file]  && \
    12481150                [string toupper [file extension $file]] == ".EXP"} {
     
    12871189    return
    12881190}
     1191
     1192proc putontop {w} {
     1193    # center window $w above its parent and make it stay on top
     1194    set wp [winfo parent $w]
     1195    wm transient $w [winfo toplevel $wp]
     1196    wm withdraw $w
     1197    update idletasks
     1198    # center the new window in the middle of the parent
     1199    set x [expr [winfo x $wp] + [winfo width $wp]/2 - \
     1200            [winfo reqwidth $w]/2 - [winfo vrootx $wp]]
     1201    if {$x < 0} {set x 0}
     1202    set xborder 10
     1203    if {$x+[winfo reqwidth $w] +$xborder > [winfo screenwidth $w]} {
     1204        incr x [expr \
     1205                [winfo screenwidth $w] - ($x+[winfo reqwidth $w] + $xborder)]
     1206    }
     1207    set y [expr [winfo y $wp] + [winfo height $wp]/2 - \
     1208            [winfo reqheight $w]/2 - [winfo vrooty $wp]]
     1209    if {$y < 0} {set y 0}
     1210    set yborder 25
     1211    if {$y+[winfo reqheight $w] +$yborder > [winfo screenheight $w]} {
     1212        incr y [expr \
     1213                [winfo screenheight $w] - ($y+[winfo reqheight $w] + $yborder)]
     1214    }
     1215    wm geom $w +$x+$y
     1216    wm deiconify $w
     1217
     1218    global makenew
     1219    set makenew(OldFocus) [focus]
     1220    set makenew(OldGrab) [grab current $w]
     1221    if {$makenew(OldGrab) != ""} {
     1222        set makenew(GrabStatus) [grab status $makenew(OldGrab)]
     1223    }
     1224    grab $w
     1225}
     1226
     1227proc afterputontop {} {
     1228    # restore focus
     1229    global makenew
     1230    catch {focus $makenew(OldFocus)}
     1231    if {$makenew(OldGrab) != ""} {
     1232        if {$makenew(GrabStatus) == "global"} {
     1233            grab -global $makenew(OldGrab)
     1234        } else {
     1235            grab $makenew(OldGrab)
     1236        }
     1237    }
     1238}
     1239
     1240proc ShowBigMessage {win labeltext msg "optionlist OK"} {
     1241    catch {destroy $win}
     1242    toplevel $win
     1243
     1244    # grab focus, etc.
     1245    pack [label $win.l1 -text $labeltext] -side top
     1246    pack [frame $win.f1] -side top
     1247    grid [text  $win.f1.t  \
     1248            -height 20 -width 55  -wrap none -font Courier \
     1249            -xscrollcommand "$win.f1.bscr set" \
     1250            -yscrollcommand "$win.f1.rscr set" \
     1251            ] -row 1 -column 0 -sticky news
     1252    grid [scrollbar $win.f1.bscr -orient horizontal \
     1253            -command "$win.f1.t xview" \
     1254            ] -row 2 -column 0 -sticky ew
     1255    grid [scrollbar $win.f1.rscr  -command "$win.f1.t yview" \
     1256            ] -row 1 -column 1 -sticky ns
     1257    # give extra space to the text box
     1258    grid columnconfigure $win.f1 0 -weight 1
     1259    grid rowconfigure $win.f1 1 -weight 1
     1260    $win.f1.t insert end $msg
     1261
     1262    global makenew
     1263    set makenew(result) 0
     1264    bind $win <Return> "destroy $win"
     1265    bind $win <KeyPress-Prior> "$win.f1.t yview scroll -1 page"
     1266    bind $win <KeyPress-Next> "$win.f1.t yview scroll 1 page"
     1267    bind $win <KeyPress-Right> "$win.f1.t xview scroll 1 unit"
     1268    bind $win <KeyPress-Left> "$win.f1.t xview scroll -1 unit"
     1269    bind $win <KeyPress-Up> "$win.f1.t yview scroll -1 unit"
     1270    bind $win <KeyPress-Down> "$win.f1.t yview scroll 1 unit"
     1271    bind $win <KeyPress-Home> "$win.f1.t yview 0"
     1272    bind $win <KeyPress-End> "$win.f1.t yview end"
     1273    set i 0
     1274    foreach item $optionlist {
     1275        pack [button $win.q[incr i] \
     1276                -command "set makenew(result) $i; destroy $win" -text $item] -side left
     1277    }
     1278    putontop $win
     1279    tkwait window $win
     1280
     1281    # fix focus...
     1282    afterputontop
     1283    return $makenew(result)
     1284}
Note: See TracChangeset for help on using the changeset viewer.