|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tclParseConfigSpec {w specs flags argList} { |
|
upvar #0 $w data |
|
|
|
|
|
|
|
foreach spec $specs { |
|
if {[llength $spec] < 4} { |
|
return -code error -errorcode {TK VALUE CONFIG_SPEC} \ |
|
"\"spec\" should contain 5 or 4 elements" |
|
} |
|
set cmdsw [lindex $spec 0] |
|
set cmd($cmdsw) "" |
|
set rname($cmdsw) [lindex $spec 1] |
|
set rclass($cmdsw) [lindex $spec 2] |
|
set def($cmdsw) [lindex $spec 3] |
|
set verproc($cmdsw) [lindex $spec 4] |
|
} |
|
|
|
if {[llength $argList] & 1} { |
|
set cmdsw [lindex $argList end] |
|
if {![info exists cmd($cmdsw)]} { |
|
return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \ |
|
"bad option \"$cmdsw\": must be [tclListValidFlags cmd]" |
|
} |
|
return -code error -errorcode {TK VALUE_MISSING} \ |
|
"value for \"$cmdsw\" missing" |
|
} |
|
|
|
|
|
|
|
if {"DONTSETDEFAULTS" ni $flags} { |
|
foreach cmdsw [array names cmd] { |
|
set data($cmdsw) $def($cmdsw) |
|
} |
|
} |
|
|
|
|
|
|
|
foreach {cmdsw value} $argList { |
|
if {![info exists cmd($cmdsw)]} { |
|
return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \ |
|
"bad option \"$cmdsw\": must be [tclListValidFlags cmd]" |
|
} |
|
set data($cmdsw) $value |
|
} |
|
|
|
|
|
} |
|
|
|
proc tclListValidFlags {v} { |
|
upvar $v cmd |
|
|
|
set len [llength [array names cmd]] |
|
set i 1 |
|
set separator "" |
|
set errormsg "" |
|
foreach cmdsw [lsort [array names cmd]] { |
|
append errormsg "$separator$cmdsw" |
|
incr i |
|
if {$i == $len} { |
|
set separator ", or " |
|
} else { |
|
set separator ", " |
|
} |
|
} |
|
return $errormsg |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_Create {t} { |
|
variable ::tk::Priv |
|
if {[winfo toplevel $t] ne $t} { |
|
return -code error -errorcode [list TK LOOKUP TOPLEVEL $t] \ |
|
"$t is not a toplevel window" |
|
} |
|
if {![info exists Priv(fg,$t)]} { |
|
set Priv(fg,$t) 1 |
|
set Priv(focus,$t) "" |
|
bind $t <FocusIn> [list tk::FocusGroup_In $t %W %d] |
|
bind $t <FocusOut> [list tk::FocusGroup_Out $t %W %d] |
|
bind $t <Destroy> [list tk::FocusGroup_Destroy $t %W] |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_BindIn {t w cmd} { |
|
variable FocusIn |
|
variable ::tk::Priv |
|
if {![info exists Priv(fg,$t)]} { |
|
return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \ |
|
"focus group \"$t\" doesn't exist" |
|
} |
|
set FocusIn($t,$w) $cmd |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_BindOut {t w cmd} { |
|
variable FocusOut |
|
variable ::tk::Priv |
|
if {![info exists Priv(fg,$t)]} { |
|
return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \ |
|
"focus group \"$t\" doesn't exist" |
|
} |
|
set FocusOut($t,$w) $cmd |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_Destroy {t w} { |
|
variable FocusIn |
|
variable FocusOut |
|
variable ::tk::Priv |
|
|
|
if {$t eq $w} { |
|
unset Priv(fg,$t) |
|
unset Priv(focus,$t) |
|
|
|
foreach name [array names FocusIn $t,*] { |
|
unset FocusIn($name) |
|
} |
|
foreach name [array names FocusOut $t,*] { |
|
unset FocusOut($name) |
|
} |
|
} else { |
|
if {[info exists Priv(focus,$t)] && ($Priv(focus,$t) eq $w)} { |
|
set Priv(focus,$t) "" |
|
} |
|
unset -nocomplain FocusIn($t,$w) FocusOut($t,$w) |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_In {t w detail} { |
|
variable FocusIn |
|
variable ::tk::Priv |
|
|
|
if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} { |
|
|
|
|
|
return |
|
} |
|
if {![info exists FocusIn($t,$w)]} { |
|
set FocusIn($t,$w) "" |
|
return |
|
} |
|
if {![info exists Priv(focus,$t)]} { |
|
return |
|
} |
|
if {$Priv(focus,$t) eq $w} { |
|
|
|
|
|
return |
|
} else { |
|
set Priv(focus,$t) $w |
|
eval $FocusIn($t,$w) |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FocusGroup_Out {t w detail} { |
|
variable FocusOut |
|
variable ::tk::Priv |
|
|
|
if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} { |
|
|
|
return |
|
} |
|
if {![info exists Priv(focus,$t)]} { |
|
return |
|
} |
|
if {![info exists FocusOut($t,$w)]} { |
|
return |
|
} else { |
|
eval $FocusOut($t,$w) |
|
set Priv(focus,$t) "" |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc ::tk::FDGetFileTypes {string} { |
|
foreach t $string { |
|
if {[llength $t] < 2 || [llength $t] > 3} { |
|
return -code error -errorcode {TK VALUE FILE_TYPE} \ |
|
"bad file type \"$t\", should be \"typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?\"" |
|
} |
|
lappend fileTypes([lindex $t 0]) {*}[lindex $t 1] |
|
} |
|
|
|
set types {} |
|
foreach t $string { |
|
set label [lindex $t 0] |
|
set exts {} |
|
|
|
if {[info exists hasDoneType($label)]} { |
|
continue |
|
} |
|
|
|
|
|
|
|
|
|
foreach macType [lindex $t 2] { |
|
if {[string length $macType] != 4} { |
|
return -code error -errorcode {TK VALUE MAC_TYPE} \ |
|
"bad Macintosh file type \"$macType\"" |
|
} |
|
} |
|
|
|
set name "$label \(" |
|
set sep "" |
|
set doAppend 1 |
|
foreach ext $fileTypes($label) { |
|
if {$ext eq ""} { |
|
continue |
|
} |
|
regsub {^[.]} $ext "*." ext |
|
if {![info exists hasGotExt($label,$ext)]} { |
|
if {$doAppend} { |
|
if {[string length $sep] && [string length $name]>40} { |
|
set doAppend 0 |
|
append name $sep... |
|
} else { |
|
append name $sep$ext |
|
} |
|
} |
|
lappend exts $ext |
|
set hasGotExt($label,$ext) 1 |
|
} |
|
set sep "," |
|
} |
|
append name "\)" |
|
lappend types [list $name $exts] |
|
|
|
set hasDoneType($label) 1 |
|
} |
|
|
|
return $types |
|
} |
|
|