|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tixWidgetClass tixDialogShell { |
|
-superclass tixShell |
|
-classname TixDialogShell |
|
-method { |
|
popdown popup center |
|
} |
|
-flag { |
|
-mapped -minheight -minwidth -parent -transient |
|
} |
|
-static {} |
|
-configspec { |
|
{-mapped mapped Mapped 0} |
|
{-minwidth minWidth MinWidth 0} |
|
{-minheight minHeight MinHeight 0} |
|
{-transient transient Transient true} |
|
{-parent parent Parent ""} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
proc tixDialogShell:ConstructWidget {w} { |
|
upvar #0 $w data |
|
|
|
tixChainMethod $w ConstructWidget |
|
|
|
|
|
|
|
if {$data(-title) == ""} { |
|
|
|
|
|
set data(-title) [winfo name $w] |
|
} |
|
wm title $w $data(-title) |
|
|
|
|
|
|
|
if {$data(-parent) == ""} { |
|
set data(-parent) [winfo parent $w] |
|
} |
|
|
|
|
|
|
|
wm minsize $w $data(-minwidth) $data(-minheight) |
|
wm transient $w "" |
|
} |
|
|
|
|
|
|
|
proc tixDialogShell:popup {w {parent ""}} { |
|
upvar #0 $w data |
|
|
|
|
|
|
|
update idletask |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wm deiconify $w |
|
after idle raise $w |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixDialogShell:center {w {parent ""}} { |
|
upvar #0 $w data |
|
|
|
|
|
wm sizefrom $w user |
|
wm positionfrom $w user |
|
|
|
if {$parent == ""} { |
|
set parent $data(-parent) |
|
} |
|
if {$parent == "" || [catch {set parent [winfo toplevel $parent]}]} { |
|
set parent "." |
|
} |
|
|
|
|
|
|
|
if {$parent != ""} { |
|
set pargeo [split [wm geometry $parent] "+x"] |
|
set parentW [lindex $pargeo 0] |
|
set parentH [lindex $pargeo 1] |
|
set parx [lindex $pargeo 2] |
|
set pary [lindex $pargeo 3] |
|
|
|
if {[string is true -strict $data(-transient)]} { |
|
wm transient $w $parent |
|
} |
|
} else { |
|
set parentW [winfo screenwidth $w] |
|
set parentH [winfo screenheight $w] |
|
set parx 0 |
|
set pary 0 |
|
set parent [winfo parent $w] |
|
} |
|
|
|
|
|
set vrootx [winfo vrootx $parent] |
|
set vrooty [winfo vrooty $parent] |
|
|
|
|
|
set dialogW [winfo reqwidth $w] |
|
set dialogH [winfo reqheight $w] |
|
|
|
if {$dialogW < $parentW-30 || $dialogW < $parentH-30} { |
|
set dialogx [expr {$parx+($parentW-$dialogW)/2+$vrootx}] |
|
set dialogy [expr {$pary+($parentH-$dialogH)/2+$vrooty}] |
|
} else { |
|
|
|
|
|
set dialogx [expr {$parx+20+$vrootx}] |
|
set dialogy [expr {$pary+20+$vrooty}] |
|
} |
|
|
|
set maxx [expr {[winfo screenwidth $parent] - $dialogW}] |
|
set maxy [expr {[winfo screenheight $parent] - $dialogH}] |
|
|
|
|
|
|
|
if {$dialogx < 0} { |
|
set dialogx 0 |
|
} else { |
|
if {$dialogx > $maxx} { |
|
set dialogx $maxx |
|
} |
|
} |
|
if {$dialogy < 0} { |
|
set dialogy 0 |
|
} else { |
|
if {$dialogy > $maxy} { |
|
set dialogy $maxy |
|
} |
|
} |
|
|
|
|
|
|
|
if {[wm geometry $w] == "1x1+0+0"} { |
|
wm geometry $w ${dialogW}x${dialogH}+${dialogx}+${dialogy} |
|
} |
|
} |
|
|
|
proc tixDialogShell:popdown {w args} { |
|
wm withdraw $w |
|
} |
|
|
|
|