|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tixWidgetClass tixPrimitive { |
|
|
-virtual true |
|
|
-superclass {} |
|
|
-classname TixPrimitive |
|
|
-method { |
|
|
cget configure subwidget subwidgets |
|
|
} |
|
|
-flag { |
|
|
-background -borderwidth -cursor |
|
|
-height -highlightbackground -highlightcolor -highlightthickness |
|
|
-options -relief -takefocus -width -bd -bg |
|
|
} |
|
|
-static { |
|
|
-options |
|
|
} |
|
|
-configspec { |
|
|
{-background background Background #d9d9d9} |
|
|
{-borderwidth borderWidth BorderWidth 0} |
|
|
{-cursor cursor Cursor ""} |
|
|
{-height height Height 0} |
|
|
{-highlightbackground highlightBackground HighlightBackground #c3c3c3} |
|
|
{-highlightcolor highlightColor HighlightColor black} |
|
|
{-highlightthickness highlightThickness HighlightThickness 0} |
|
|
{-options options Options ""} |
|
|
{-relief relief Relief flat} |
|
|
{-takefocus takeFocus TakeFocus 0 tixVerifyBoolean} |
|
|
{-width width Width 0} |
|
|
} |
|
|
-alias { |
|
|
{-bd -borderwidth} |
|
|
{-bg -background} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:Constructor {w args} { |
|
|
|
|
|
upvar #0 $w data |
|
|
upvar #0 $data(className) classRec |
|
|
|
|
|
|
|
|
|
|
|
set data(w:root) $w |
|
|
set data(rootCmd) $w:root |
|
|
|
|
|
|
|
|
|
|
|
tixCallMethod $w CreateRootWidget |
|
|
|
|
|
|
|
|
|
|
|
tixPrimitive:ParseDefaultOptions $w |
|
|
|
|
|
|
|
|
|
|
|
tixPrimitive:ParseUserOptions $w $args |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tixPrimitive:MkWidgetCmd $w |
|
|
|
|
|
|
|
|
|
|
|
tixCallMethod $w InitWidgetRec |
|
|
|
|
|
|
|
|
|
|
|
tixCallMethod $w ConstructWidget |
|
|
|
|
|
|
|
|
|
|
|
tixCallMethod $w SetBindings |
|
|
|
|
|
|
|
|
|
|
|
foreach option $classRec(forceCall) { |
|
|
tixInt_ChangeOptions $w $option $data($option) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:CreateRootWidget {w args} { |
|
|
upvar #0 $w data |
|
|
upvar #0 $data(className) classRec |
|
|
|
|
|
frame $w -class $data(ClassName) |
|
|
} |
|
|
|
|
|
proc tixPrimitive:ParseDefaultOptions {w} { |
|
|
upvar #0 $w data |
|
|
upvar #0 $data(className) classRec |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach option $classRec(options) { |
|
|
set spec [tixInt_GetOptionSpec $data(className) $option] |
|
|
|
|
|
if {[lindex $spec 0] eq "="} { |
|
|
continue |
|
|
} |
|
|
|
|
|
set o_name [lindex $spec 1] |
|
|
set o_class [lindex $spec 2] |
|
|
set o_default [lindex $spec 3] |
|
|
|
|
|
if {![catch {option get $w $o_name $o_class} db_default]} { |
|
|
if {$db_default ne ""} { |
|
|
set data($option) $db_default |
|
|
} else { |
|
|
set data($option) $o_default |
|
|
} |
|
|
} else { |
|
|
set data($option) $o_default |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
proc tixPrimitive:ParseUserOptions {w arglist} { |
|
|
upvar #0 $w data |
|
|
upvar #0 $data(className) classRec |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach {option arg} $arglist { |
|
|
if {[lsearch $classRec(options) $option] != "-1"} { |
|
|
set spec [tixInt_GetOptionSpec $data(className) $option] |
|
|
|
|
|
if {[lindex $spec 0] ne "="} { |
|
|
set data($option) $arg |
|
|
} else { |
|
|
set realOption [lindex $spec 1] |
|
|
set data($realOption) $arg |
|
|
} |
|
|
} else { |
|
|
error "unknown option $option. Should be: [tixInt_ListOptions $w]" |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:InitWidgetRec {w} { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bind TixDestroyHandler <Destroy> { |
|
|
[tixGetMethod %W [set %W(className)] Destructor] %W |
|
|
} |
|
|
|
|
|
proc tixPrimitive:SetBindings {w} { |
|
|
upvar #0 $w data |
|
|
|
|
|
if {[winfo toplevel $w] eq $w} { |
|
|
bindtags $w [concat TixDestroyHandler [bindtags $w]] |
|
|
} else { |
|
|
bind $data(w:root) <Destroy> \ |
|
|
"[tixGetMethod $w $data(className) Destructor] $w" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:ConstructWidget {w} { |
|
|
upvar #0 $w data |
|
|
|
|
|
$data(rootCmd) config \ |
|
|
-background $data(-background) \ |
|
|
-borderwidth $data(-borderwidth) \ |
|
|
-cursor $data(-cursor) \ |
|
|
-relief $data(-relief) |
|
|
|
|
|
if {$data(-width) != 0} { |
|
|
$data(rootCmd) config -width $data(-width) |
|
|
} |
|
|
if {$data(-height) != 0} { |
|
|
$data(rootCmd) config -height $data(-height) |
|
|
} |
|
|
|
|
|
set rootname *[string range $w 1 end] |
|
|
|
|
|
foreach {spec value} $data(-options) { |
|
|
option add $rootname*$spec $value 100 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:MkWidgetCmd {w} { |
|
|
upvar #0 $w data |
|
|
|
|
|
rename $w $data(rootCmd) |
|
|
tixInt_MkInstanceCmd $w |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach opt {-height -width -background -borderwidth -cursor |
|
|
-highlightbackground -highlightcolor -relief -takefocus -bd -bg} { |
|
|
|
|
|
set tixPrimOpt($opt) 1 |
|
|
} |
|
|
|
|
|
proc tixPrimitive:config {w option value} { |
|
|
global tixPrimOpt |
|
|
upvar #0 $w data |
|
|
|
|
|
if {[info exists tixPrimOpt($option)]} { |
|
|
$data(rootCmd) config $option $value |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:subwidgets {w type args} { |
|
|
upvar #0 $w data |
|
|
|
|
|
case $type { |
|
|
-class { |
|
|
set name [lindex $args 0] |
|
|
set args [lrange $args 1 end] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set sub "" |
|
|
foreach des [tixDescendants $w] { |
|
|
if {[winfo class $des] eq $name} { |
|
|
lappend sub $des |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if {$args eq ""} { |
|
|
return $sub |
|
|
} else { |
|
|
foreach des $sub { |
|
|
eval [linsert $args 0 $des] |
|
|
} |
|
|
return "" |
|
|
} |
|
|
} |
|
|
-group { |
|
|
set name [lindex $args 0] |
|
|
set args [lrange $args 1 end] |
|
|
|
|
|
|
|
|
if {[info exists data(g:$name)]} { |
|
|
if {$args eq ""} { |
|
|
set ret "" |
|
|
foreach item $data(g:$name) { |
|
|
lappend ret $w.$item |
|
|
} |
|
|
return $ret |
|
|
} else { |
|
|
foreach item $data(g:$name) { |
|
|
eval [linsert $args 0 $w.$item] |
|
|
} |
|
|
return "" |
|
|
} |
|
|
} else { |
|
|
error "no such subwidget group $name" |
|
|
} |
|
|
} |
|
|
-all { |
|
|
set sub [tixDescendants $w] |
|
|
|
|
|
if {$args eq ""} { |
|
|
return $sub |
|
|
} else { |
|
|
foreach des $sub { |
|
|
eval [linsert $args 0 $des] |
|
|
} |
|
|
return "" |
|
|
} |
|
|
} |
|
|
default { |
|
|
error "unknown flag $type, should be -all, -class or -group" |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:subwidget {w name args} { |
|
|
upvar #0 $w data |
|
|
|
|
|
if {[info exists data(w:$name)]} { |
|
|
if {$args eq ""} { |
|
|
return $data(w:$name) |
|
|
} else { |
|
|
return [eval [linsert $args 0 $data(w:$name)]] |
|
|
} |
|
|
} else { |
|
|
error "no such subwidget $name" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc tixPrimitive:Destructor {w} { |
|
|
upvar #0 $w data |
|
|
|
|
|
if {![info exists data(w:root)]} { |
|
|
return |
|
|
} |
|
|
|
|
|
if {[llength [info commands $w]]} { |
|
|
|
|
|
rename $w "" |
|
|
} |
|
|
|
|
|
if {[llength [info commands $data(rootCmd)]]} { |
|
|
|
|
|
rename $data(rootCmd) "" |
|
|
} |
|
|
|
|
|
|
|
|
catch {unset data} |
|
|
} |
|
|
|