Changeset 783


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

# on 2004/04/27 14:12:04, toby did:
update non-modal dialogs to match newer versions of Tk
add window resize for OS X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsascmds.tcl

    • Property rcs:date changed from 2004/01/30 00:50:00 to 2004/04/27 14:12:04
    • Property rcs:lines changed from +42 -1 to +44 -24
    • Property rcs:rev changed from 1.55 to 1.56
    r775 r783  
    133133    wm iconname $w Dialog
    134134    wm protocol $w WM_DELETE_WINDOW { }
    135     wm transient $w $data(-parent)
    136     if {![string compare $tcl_platform(platform) "macintosh"]} {
    137         unsupported1 style $w dBoxProc
     135    # Make the message box transient if the parent is viewable.
     136    if {[winfo viewable [winfo toplevel $data(-parent)]] } {
     137        wm transient $w $data(-parent)
     138    }
     139   
     140    catch {
     141        if {[string equal [tk windowingsystem] "classic"]
     142        || [string equal [tk windowingsystem] "aqua"]} {
     143            unsupported::MacWindowStyle style $w dBoxProc
     144        }
    138145    }
    139146
     
    343350proc putontop {w "center 0"} {
    344351    # center window $w above its parent and make it stay on top
    345     set wp [winfo parent $w]
    346     wm transient $w [winfo toplevel $wp]
     352    set wpt [winfo toplevel [set wp [winfo parent $w]]]
     353    if {[winfo viewable $wpt]} {
     354        wm transient $w $wpt
     355    }
    347356    wm withdraw $w
    348357    update idletasks
    349358    if {$center} {
    350359        set x [expr {[winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
    351                 - [winfo vrootx [winfo parent $w]]}]
     360                - [winfo vrootx $wpt]}]
    352361        set y [expr {[winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
    353                 - [winfo vrooty [winfo parent $w]]}]
     362                - [winfo vrooty $wpt]}]
    354363    } else {
    355364        # center the new window in the middle of the parent
    356         set x [expr [winfo x $wp] + [winfo width $wp]/2 - \
    357                 [winfo reqwidth $w]/2 - [winfo vrootx $wp]]
     365        set x [expr [winfo x $wpt] + [winfo width $wpt]/2 - \
     366                [winfo reqwidth $w]/2 - [winfo vrootx $wpt]]
    358367        if {$x < 0} {set x 0}
    359368        set xborder 10
     
    362371                    ($x+[winfo reqwidth $w] + $xborder)]
    363372        }
    364         set y [expr [winfo y $wp] + [winfo height $wp]/2 - \
    365                 [winfo reqheight $w]/2 - [winfo vrooty $wp]]
     373        set y [expr [winfo y $wpt] + [winfo height $wpt]/2 - \
     374                [winfo reqheight $w]/2 - [winfo vrooty $wpt]]
    366375        if {$y < 0} {set y 0}
    367376        set yborder 25
     
    375384
    376385    global makenew
    377     set makenew(OldGrab) ""
    378     set makenew(OldFocus) ""
    379     catch {set makenew(OldFocus) [focus]}
    380     catch {set makenew(OldGrab) [grab current $w]}
    381     catch {grab $w}
    382 }
    383 
     386    # set grab & focus; use new approach for 8.3 & later
     387    if {[info proc ::tk::SetFocusGrab] == ""} {
     388        set makenew(OldGrab) ""
     389        set makenew(OldFocus) ""
     390        catch {set makenew(OldFocus) [focus]}
     391        catch {set makenew(OldGrab) [grab current $w]}
     392        catch {grab $w}
     393    } else {
     394        set makenew(OldGrab) $w
     395        set makenew(OldFocus) $w
     396        ::tk::SetFocusGrab $w $w
     397    }
     398}
     399
     400# restore focus after putontop has completed
    384401proc afterputontop {} {
    385     # restore focus
    386402    global makenew
    387     # reset focus & grab
    388     catch {
     403    # reset focus & grab; use new approach for 8.3 & later
     404    if {[info proc ::tk::SetFocusGrab] == ""} {
    389405        if {$makenew(OldFocus) != ""} {
    390             focus $makenew(OldFocus)
    391         }
    392     }
    393     catch {
     406            catch {focus $makenew(OldFocus)}
     407        }
    394408        if {$makenew(OldGrab) != ""} {
    395             grab $makenew(OldGrab)
    396         }
     409            catch {grab $makenew(OldGrab)}
     410        }
     411    } else {
     412        catch {::tk::RestoreFocusGrab $makenew(OldGrab) $makenew(OldFocus)}
    397413    }
    398414}
     
    852868            incr colstr 5
    853869        }
     870    }
     871    if {$::tcl_platform(os) == "Darwin"} {
     872        # on OS X force a window resize
     873        wm geometry [winfo toplevel $w] {}
    854874    }
    855875}
Note: See TracChangeset for help on using the changeset viewer.