annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/itcl4.2.3/itclHullCmds.tcl @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 #
jpayne@68 2 # itclHullCmds.tcl
jpayne@68 3 # ----------------------------------------------------------------------
jpayne@68 4 # Invoked automatically upon startup to customize the interpreter
jpayne@68 5 # for [incr Tcl] when one of setupcomponent or createhull is called.
jpayne@68 6 # ----------------------------------------------------------------------
jpayne@68 7 # AUTHOR: Arnulf P. Wiedemann
jpayne@68 8 #
jpayne@68 9 # ----------------------------------------------------------------------
jpayne@68 10 # Copyright (c) 2008 Arnulf P. Wiedemann
jpayne@68 11 # ======================================================================
jpayne@68 12 # See the file "license.terms" for information on usage and
jpayne@68 13 # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@68 14
jpayne@68 15 package require Tk 8.6
jpayne@68 16
jpayne@68 17 namespace eval ::itcl::internal::commands {
jpayne@68 18
jpayne@68 19 # ======================= widgetDeleted ===========================
jpayne@68 20
jpayne@68 21 proc widgetDeleted {oldName newName op} {
jpayne@68 22 # The widget is beeing deleted, so we have to delete the object
jpayne@68 23 # which had the widget as itcl_hull too!
jpayne@68 24 # We have to get the real name from for example
jpayne@68 25 # ::itcl::internal::widgets::hull1.lw
jpayne@68 26 # we need only .lw here
jpayne@68 27
jpayne@68 28 #puts stderr "widgetDeleted!$oldName!$newName!$op!"
jpayne@68 29 set cmdName [namespace tail $oldName]
jpayne@68 30 set flds [split $cmdName {.}]
jpayne@68 31 set cmdName .[join [lrange $flds 1 end] {.}]
jpayne@68 32 #puts stderr "DELWIDGET![namespace current]!$cmdName![::info command $cmdName]!"
jpayne@68 33 rename $cmdName {}
jpayne@68 34 }
jpayne@68 35
jpayne@68 36 }
jpayne@68 37
jpayne@68 38 namespace eval ::itcl::builtin {
jpayne@68 39
jpayne@68 40 # ======================= createhull ===========================
jpayne@68 41 # the hull widget is a tk widget which is the (mega) widget handled behind the itcl
jpayne@68 42 # extendedclass/itcl widget.
jpayne@68 43 # It is created be renaming the itcl class object to a temporary name <itcl object name>_
jpayne@68 44 # creating the widget with the
jpayne@68 45 # appropriate options and the installing that as the "hull" widget (the container)
jpayne@68 46 # All the options in args and the options delegated to component itcl_hull are used
jpayne@68 47 # Then a unique name (hull_widget_name) in the itcl namespace is created for widget:
jpayne@68 48 # ::itcl::internal::widgets::hull<unique number><namespace tail path>
jpayne@68 49 # and widget is renamed to that name
jpayne@68 50 # Finally the <itcl object name>_ is renamed to the original <itcl object name> again
jpayne@68 51 # Component itcl_hull is created if not existent
jpayne@68 52 # itcl_hull is set to the hull_widget_name and the <itcl object name>
jpayne@68 53 # is returned to the caller
jpayne@68 54 # ==============================================================
jpayne@68 55
jpayne@68 56 proc createhull {widget_type path args} {
jpayne@68 57 variable hullCount
jpayne@68 58 upvar this this
jpayne@68 59 upvar win win
jpayne@68 60
jpayne@68 61
jpayne@68 62 #puts stderr "il-1![::info level -1]!$this!"
jpayne@68 63 #puts stderr "createhull!$widget_type!$path!$args!$this![::info command $this]!"
jpayne@68 64 #puts stderr "ns1![uplevel 1 namespace current]!"
jpayne@68 65 #puts stderr "ns2![uplevel 2 namespace current]!"
jpayne@68 66 #puts stderr "ns3![uplevel 3 namespace current]!"
jpayne@68 67 #puts stderr "level-1![::info level -1]!"
jpayne@68 68 #puts stderr "level-2![::info level -2]!"
jpayne@68 69 # set my_this [namespace tail $this]
jpayne@68 70 set my_this $this
jpayne@68 71 set tmp $my_this
jpayne@68 72 #puts stderr "II![::info command $this]![::info command $tmp]!"
jpayne@68 73 #puts stderr "rename1!rename $my_this ${tmp}_!"
jpayne@68 74 rename ::$my_this ${tmp}_
jpayne@68 75 set options [list]
jpayne@68 76 foreach {option_name value} $args {
jpayne@68 77 switch -glob -- $option_name {
jpayne@68 78 -class {
jpayne@68 79 lappend options $option_name [namespace tail $value]
jpayne@68 80 }
jpayne@68 81 -* {
jpayne@68 82 lappend options $option_name $value
jpayne@68 83 }
jpayne@68 84 default {
jpayne@68 85 return -code error "bad option name\"$option_name\" options must start with a \"-\""
jpayne@68 86 }
jpayne@68 87 }
jpayne@68 88 }
jpayne@68 89 set my_win [namespace tail $path]
jpayne@68 90 set cmd [list $widget_type $my_win]
jpayne@68 91 #puts stderr "my_win!$my_win!cmd!$cmd!$path!"
jpayne@68 92 if {[llength $options] > 0} {
jpayne@68 93 lappend cmd {*}$options
jpayne@68 94 }
jpayne@68 95 set widget [uplevel 1 $cmd]
jpayne@68 96 #puts stderr "widget!$widget!"
jpayne@68 97 trace add command $widget delete ::itcl::internal::commands::widgetDeleted
jpayne@68 98 set opts [uplevel 1 info delegated options]
jpayne@68 99 foreach entry $opts {
jpayne@68 100 foreach {optName compName} $entry break
jpayne@68 101 if {$compName eq "itcl_hull"} {
jpayne@68 102 set optInfos [uplevel 1 info delegated option $optName]
jpayne@68 103 set realOptName [lindex $optInfos 4]
jpayne@68 104 # strip off the "-" at the beginning
jpayne@68 105 set myOptName [string range $realOptName 1 end]
jpayne@68 106 set my_opt_val [option get $my_win $myOptName *]
jpayne@68 107 if {$my_opt_val ne ""} {
jpayne@68 108 $my_win configure -$myOptName $my_opt_val
jpayne@68 109 }
jpayne@68 110 }
jpayne@68 111 }
jpayne@68 112 set idx 1
jpayne@68 113 while {1} {
jpayne@68 114 set widgetName ::itcl::internal::widgets::hull${idx}$my_win
jpayne@68 115 #puts stderr "widgetName!$widgetName!"
jpayne@68 116 if {[string length [::info command $widgetName]] == 0} {
jpayne@68 117 break
jpayne@68 118 }
jpayne@68 119 incr idx
jpayne@68 120 }
jpayne@68 121 #puts stderr "rename2!rename $widget $widgetName!"
jpayne@68 122 set dorename 0
jpayne@68 123 rename $widget $widgetName
jpayne@68 124 #puts stderr "rename3!rename ${tmp}_ $tmp![::info command ${tmp}_]!my_this!$my_this!"
jpayne@68 125 rename ${tmp}_ ::$tmp
jpayne@68 126 set exists [uplevel 1 ::info exists itcl_hull]
jpayne@68 127 if {!$exists} {
jpayne@68 128 # that does not yet work, beacause of problems with resolving
jpayne@68 129 ::itcl::addcomponent $my_this itcl_hull
jpayne@68 130 }
jpayne@68 131 upvar itcl_hull itcl_hull
jpayne@68 132 ::itcl::setcomponent $my_this itcl_hull $widgetName
jpayne@68 133 #puts stderr "IC![::info command $my_win]!"
jpayne@68 134 set exists [uplevel 1 ::info exists itcl_interior]
jpayne@68 135 if {!$exists} {
jpayne@68 136 # that does not yet work, beacause of problems with resolving
jpayne@68 137 ::itcl::addcomponent $this itcl_interior
jpayne@68 138 }
jpayne@68 139 upvar itcl_interior itcl_interior
jpayne@68 140 set itcl_interior $my_win
jpayne@68 141 #puts stderr "hull end!win!$win!itcl_hull!$itcl_hull!itcl_interior!$itcl_interior!"
jpayne@68 142 return $my_win
jpayne@68 143 }
jpayne@68 144
jpayne@68 145 # ======================= addToItclOptions ===========================
jpayne@68 146
jpayne@68 147 proc addToItclOptions {my_class my_win myOptions argsDict} {
jpayne@68 148 upvar win win
jpayne@68 149 upvar itcl_hull itcl_hull
jpayne@68 150
jpayne@68 151 set opt_lst [list configure]
jpayne@68 152 foreach opt [lsort $myOptions] {
jpayne@68 153 #puts stderr "IOPT!$opt!$my_class!$my_win![::itcl::is class $my_class]!"
jpayne@68 154 set isClass [::itcl::is class $my_class]
jpayne@68 155 set found 0
jpayne@68 156 if {$isClass} {
jpayne@68 157 if {[catch {
jpayne@68 158 set resource [namespace eval $my_class info option $opt -resource]
jpayne@68 159 set class [namespace eval $my_class info option $opt -class]
jpayne@68 160 set default_val [uplevel 2 info option $opt -default]
jpayne@68 161 set found 1
jpayne@68 162 } msg]} {
jpayne@68 163 # puts stderr "MSG!$opt!$my_class!$msg!"
jpayne@68 164 }
jpayne@68 165 } else {
jpayne@68 166 set tmp_win [uplevel #0 $my_class .___xx]
jpayne@68 167
jpayne@68 168 set my_info [$tmp_win configure $opt]
jpayne@68 169 set resource [lindex $my_info 1]
jpayne@68 170 set class [lindex $my_info 2]
jpayne@68 171 set default_val [lindex $my_info 3]
jpayne@68 172 uplevel #0 destroy $tmp_win
jpayne@68 173 set found 1
jpayne@68 174 }
jpayne@68 175 if {$found} {
jpayne@68 176 if {[catch {
jpayne@68 177 set val [uplevel #0 ::option get $win $resource $class]
jpayne@68 178 } msg]} {
jpayne@68 179 set val ""
jpayne@68 180 }
jpayne@68 181 if {[::dict exists $argsDict $opt]} {
jpayne@68 182 # we have an explicitly set option
jpayne@68 183 set val [::dict get $argsDict $opt]
jpayne@68 184 } else {
jpayne@68 185 if {[string length $val] == 0} {
jpayne@68 186 set val $default_val
jpayne@68 187 }
jpayne@68 188 }
jpayne@68 189 set ::itcl::internal::variables::${my_win}::itcl_options($opt) $val
jpayne@68 190 set ::itcl::internal::variables::${my_win}::__itcl_option_infos($opt) [list $resource $class $default_val]
jpayne@68 191 #puts stderr "OPT1!$opt!$val!"
jpayne@68 192 # uplevel 1 [list set itcl_options($opt) [list $val]]
jpayne@68 193 if {[catch {uplevel 1 $win configure $opt [list $val]} msg]} {
jpayne@68 194 #puts stderr "addToItclOptions ERR!$msg!$my_class!$win!configure!$opt!$val!"
jpayne@68 195 }
jpayne@68 196 }
jpayne@68 197 }
jpayne@68 198 }
jpayne@68 199
jpayne@68 200 # ======================= setupcomponent ===========================
jpayne@68 201
jpayne@68 202 proc setupcomponent {comp using widget_type path args} {
jpayne@68 203 upvar this this
jpayne@68 204 upvar win win
jpayne@68 205 upvar itcl_hull itcl_hull
jpayne@68 206
jpayne@68 207 #puts stderr "setupcomponent!$comp!$widget_type!$path!$args!$this!$win!$itcl_hull!"
jpayne@68 208 #puts stderr "CONT![uplevel 1 info context]!"
jpayne@68 209 #puts stderr "ns1![uplevel 1 namespace current]!"
jpayne@68 210 #puts stderr "ns2![uplevel 2 namespace current]!"
jpayne@68 211 #puts stderr "ns3![uplevel 3 namespace current]!"
jpayne@68 212 set my_comp_object [lindex [uplevel 1 info context] 1]
jpayne@68 213 if {[::info exists ::itcl::internal::component_objects($my_comp_object)]} {
jpayne@68 214 set my_comp_object [set ::itcl::internal::component_objects($my_comp_object)]
jpayne@68 215 } else {
jpayne@68 216 set ::itcl::internal::component_objects($path) $my_comp_object
jpayne@68 217 }
jpayne@68 218 set options [list]
jpayne@68 219 foreach {option_name value} $args {
jpayne@68 220 switch -glob -- $option_name {
jpayne@68 221 -* {
jpayne@68 222 lappend options $option_name $value
jpayne@68 223 }
jpayne@68 224 default {
jpayne@68 225 return -code error "bad option name\"$option_name\" options must start with a \"-\""
jpayne@68 226 }
jpayne@68 227 }
jpayne@68 228 }
jpayne@68 229 if {[llength $args]} {
jpayne@68 230 set argsDict [dict create {*}$args]
jpayne@68 231 } else {
jpayne@68 232 set argsDict [dict create]
jpayne@68 233 }
jpayne@68 234 set cmd [list $widget_type $path]
jpayne@68 235 if {[llength $options] > 0} {
jpayne@68 236 lappend cmd {*}$options
jpayne@68 237 }
jpayne@68 238 #puts stderr "cmd0![::info command $widget_type]!$path![::info command $path]!"
jpayne@68 239 #puts stderr "cmd1!$cmd!"
jpayne@68 240 # set my_comp [uplevel 3 $cmd]
jpayne@68 241 set my_comp [uplevel #0 $cmd]
jpayne@68 242 #puts stderr 111![::info command $path]!
jpayne@68 243 ::itcl::setcomponent $this $comp $my_comp
jpayne@68 244 set opts [uplevel 1 info delegated options]
jpayne@68 245 foreach entry $opts {
jpayne@68 246 foreach {optName compName} $entry break
jpayne@68 247 if {$compName eq $my_comp} {
jpayne@68 248 set optInfos [uplevel 1 info delegated option $optName]
jpayne@68 249 set realOptName [lindex $optInfos 4]
jpayne@68 250 # strip off the "-" at the beginning
jpayne@68 251 set myOptName [string range $realOptName 1 end]
jpayne@68 252 set my_opt_val [option get $my_win $myOptName *]
jpayne@68 253 if {$my_opt_val ne ""} {
jpayne@68 254 $my_comp configure -$myOptName $my_opt_val
jpayne@68 255 }
jpayne@68 256 }
jpayne@68 257 }
jpayne@68 258 set my_class $widget_type
jpayne@68 259 set my_parent_class [uplevel 1 namespace current]
jpayne@68 260 if {[catch {
jpayne@68 261 set myOptions [namespace eval $my_class {info classoptions}]
jpayne@68 262 } msg]} {
jpayne@68 263 set myOptions [list]
jpayne@68 264 }
jpayne@68 265 foreach entry [$path configure] {
jpayne@68 266 foreach {opt dummy1 dummy2 dummy3} $entry break
jpayne@68 267 lappend myOptions $opt
jpayne@68 268 }
jpayne@68 269 #puts stderr "OPTS!$myOptions!"
jpayne@68 270 addToItclOptions $widget_type $my_comp_object $myOptions $argsDict
jpayne@68 271 #puts stderr END!$path![::info command $path]!
jpayne@68 272 }
jpayne@68 273
jpayne@68 274 proc itcl_initoptions {args} {
jpayne@68 275 puts stderr "ITCL_INITOPT!$args!"
jpayne@68 276 }
jpayne@68 277
jpayne@68 278 # ======================= initoptions ===========================
jpayne@68 279
jpayne@68 280 proc initoptions {args} {
jpayne@68 281 upvar win win
jpayne@68 282 upvar itcl_hull itcl_hull
jpayne@68 283 upvar itcl_option_components itcl_option_components
jpayne@68 284
jpayne@68 285 #puts stderr "INITOPT!!$win!"
jpayne@68 286 if {[llength $args]} {
jpayne@68 287 set argsDict [dict create {*}$args]
jpayne@68 288 } else {
jpayne@68 289 set argsDict [dict create]
jpayne@68 290 }
jpayne@68 291 set my_class [uplevel 1 namespace current]
jpayne@68 292 set myOptions [namespace eval $my_class {info classoptions}]
jpayne@68 293 if {[dict exists $::itcl::internal::dicts::classComponents $my_class]} {
jpayne@68 294 set class_info_dict [dict get $::itcl::internal::dicts::classComponents $my_class]
jpayne@68 295 # set myOptions [lsort -unique [namespace eval $my_class {info options}]]
jpayne@68 296 foreach comp [uplevel 1 info components] {
jpayne@68 297 if {[dict exists $class_info_dict $comp -keptoptions]} {
jpayne@68 298 foreach my_opt [dict get $class_info_dict $comp -keptoptions] {
jpayne@68 299 if {[lsearch $myOptions $my_opt] < 0} {
jpayne@68 300 #puts stderr "KEOPT!$my_opt!"
jpayne@68 301 lappend myOptions $my_opt
jpayne@68 302 }
jpayne@68 303 }
jpayne@68 304 }
jpayne@68 305 }
jpayne@68 306 } else {
jpayne@68 307 set class_info_dict [list]
jpayne@68 308 }
jpayne@68 309 #puts stderr "OPTS!$win!$my_class![join [lsort $myOptions]] \n]!"
jpayne@68 310 set opt_lst [list configure]
jpayne@68 311 set my_win $win
jpayne@68 312 foreach opt [lsort $myOptions] {
jpayne@68 313 set found 0
jpayne@68 314 if {[catch {
jpayne@68 315 set resource [uplevel 1 info option $opt -resource]
jpayne@68 316 set class [uplevel 1 info option $opt -class]
jpayne@68 317 set default_val [uplevel 1 info option $opt -default]
jpayne@68 318 set found 1
jpayne@68 319 } msg]} {
jpayne@68 320 # puts stderr "MSG!$opt!$msg!"
jpayne@68 321 }
jpayne@68 322 #puts stderr "OPT!$opt!$found!"
jpayne@68 323 if {$found} {
jpayne@68 324 if {[catch {
jpayne@68 325 set val [uplevel #0 ::option get $my_win $resource $class]
jpayne@68 326 } msg]} {
jpayne@68 327 set val ""
jpayne@68 328 }
jpayne@68 329 if {[::dict exists $argsDict $opt]} {
jpayne@68 330 # we have an explicitly set option
jpayne@68 331 set val [::dict get $argsDict $opt]
jpayne@68 332 } else {
jpayne@68 333 if {[string length $val] == 0} {
jpayne@68 334 set val $default_val
jpayne@68 335 }
jpayne@68 336 }
jpayne@68 337 set ::itcl::internal::variables::${win}::itcl_options($opt) $val
jpayne@68 338 set ::itcl::internal::variables::${win}::__itcl_option_infos($opt) [list $resource $class $default_val]
jpayne@68 339 #puts stderr "OPT1!$opt!$val!"
jpayne@68 340 # uplevel 1 [list set itcl_options($opt) [list $val]]
jpayne@68 341 if {[catch {uplevel 1 $my_win configure $opt [list $val]} msg]} {
jpayne@68 342 puts stderr "initoptions ERR!$msg!$my_class!$my_win!configure!$opt!$val!"
jpayne@68 343 }
jpayne@68 344 }
jpayne@68 345 foreach comp [dict keys $class_info_dict] {
jpayne@68 346 #puts stderr "OPT1!$opt!$comp![dict get $class_info_dict $comp]!"
jpayne@68 347 if {[dict exists $class_info_dict $comp -keptoptions]} {
jpayne@68 348 if {[lsearch [dict get $class_info_dict $comp -keptoptions] $opt] >= 0} {
jpayne@68 349 if {$found == 0} {
jpayne@68 350 # we use the option value of the first component for setting
jpayne@68 351 # the option, as the components are traversed in the dict
jpayne@68 352 # depending on the ordering of the component creation!!
jpayne@68 353 set my_info [uplevel 1 \[set $comp\] configure $opt]
jpayne@68 354 set resource [lindex $my_info 1]
jpayne@68 355 set class [lindex $my_info 2]
jpayne@68 356 set default_val [lindex $my_info 3]
jpayne@68 357 set found 2
jpayne@68 358 set val [uplevel #0 ::option get $my_win $resource $class]
jpayne@68 359 if {[::dict exists $argsDict $opt]} {
jpayne@68 360 # we have an explicitly set option
jpayne@68 361 set val [::dict get $argsDict $opt]
jpayne@68 362 } else {
jpayne@68 363 if {[string length $val] == 0} {
jpayne@68 364 set val $default_val
jpayne@68 365 }
jpayne@68 366 }
jpayne@68 367 #puts stderr "OPT2!$opt!$val!"
jpayne@68 368 set ::itcl::internal::variables::${win}::itcl_options($opt) $val
jpayne@68 369 set ::itcl::internal::variables::${win}::__itcl_option_infos($opt) [list $resource $class $default_val]
jpayne@68 370 # uplevel 1 [list set itcl_options($opt) [list $val]]
jpayne@68 371 }
jpayne@68 372 if {[catch {uplevel 1 \[set $comp\] configure $opt [list $val]} msg]} {
jpayne@68 373 puts stderr "initoptions ERR2!$msg!$my_class!$comp!configure!$opt!$val!"
jpayne@68 374 }
jpayne@68 375 if {![uplevel 1 info exists itcl_option_components($opt)]} {
jpayne@68 376 set itcl_option_components($opt) [list]
jpayne@68 377 }
jpayne@68 378 if {[lsearch [set itcl_option_components($opt)] $comp] < 0} {
jpayne@68 379 if {![catch {
jpayne@68 380 set optval [uplevel 1 [list set itcl_options($opt)]]
jpayne@68 381 } msg3]} {
jpayne@68 382 uplevel 1 \[set $comp\] configure $opt $optval
jpayne@68 383 }
jpayne@68 384 lappend itcl_option_components($opt) $comp
jpayne@68 385 }
jpayne@68 386 }
jpayne@68 387 }
jpayne@68 388 }
jpayne@68 389 }
jpayne@68 390 # uplevel 1 $opt_lst
jpayne@68 391 }
jpayne@68 392
jpayne@68 393 # ======================= setoptions ===========================
jpayne@68 394
jpayne@68 395 proc setoptions {args} {
jpayne@68 396
jpayne@68 397 #puts stderr "setOPT!!$args!"
jpayne@68 398 if {[llength $args]} {
jpayne@68 399 set argsDict [dict create {*}$args]
jpayne@68 400 } else {
jpayne@68 401 set argsDict [dict create]
jpayne@68 402 }
jpayne@68 403 set my_class [uplevel 1 namespace current]
jpayne@68 404 set myOptions [namespace eval $my_class {info options}]
jpayne@68 405 #puts stderr "OPTS!$win!$my_class![join [lsort $myOptions]] \n]!"
jpayne@68 406 set opt_lst [list configure]
jpayne@68 407 foreach opt [lsort $myOptions] {
jpayne@68 408 set found 0
jpayne@68 409 if {[catch {
jpayne@68 410 set resource [uplevel 1 info option $opt -resource]
jpayne@68 411 set class [uplevel 1 info option $opt -class]
jpayne@68 412 set default_val [uplevel 1 info option $opt -default]
jpayne@68 413 set found 1
jpayne@68 414 } msg]} {
jpayne@68 415 # puts stderr "MSG!$opt!$msg!"
jpayne@68 416 }
jpayne@68 417 #puts stderr "OPT!$opt!$found!"
jpayne@68 418 if {$found} {
jpayne@68 419 set val ""
jpayne@68 420 if {[::dict exists $argsDict $opt]} {
jpayne@68 421 # we have an explicitly set option
jpayne@68 422 set val [::dict get $argsDict $opt]
jpayne@68 423 } else {
jpayne@68 424 if {[string length $val] == 0} {
jpayne@68 425 set val $default_val
jpayne@68 426 }
jpayne@68 427 }
jpayne@68 428 set myObj [uplevel 1 set this]
jpayne@68 429 #puts stderr "myObj!$myObj!"
jpayne@68 430 set ::itcl::internal::variables::${myObj}::itcl_options($opt) $val
jpayne@68 431 set ::itcl::internal::variables::${myObj}::__itcl_option_infos($opt) [list $resource $class $default_val]
jpayne@68 432 #puts stderr "OPT1!$opt!$val!"
jpayne@68 433 uplevel 1 [list set itcl_options($opt) [list $val]]
jpayne@68 434 # if {[catch {uplevel 1 $myObj configure $opt [list $val]} msg]} {
jpayne@68 435 #puts stderr "initoptions ERR!$msg!$my_class!$my_win!configure!$opt!$val!"
jpayne@68 436 # }
jpayne@68 437 }
jpayne@68 438 }
jpayne@68 439 # uplevel 1 $opt_lst
jpayne@68 440 }
jpayne@68 441
jpayne@68 442 # ========================= keepcomponentoption ======================
jpayne@68 443 # Invoked by Tcl during evaluating constructor whenever
jpayne@68 444 # the "keepcomponentoption" command is invoked to list the options
jpayne@68 445 # to be kept when an ::itcl::extendedclass component has been setup
jpayne@68 446 # for an object.
jpayne@68 447 #
jpayne@68 448 # It checks, for all arguments, if the opt is an option of that class
jpayne@68 449 # and of that component. If that is the case it adds the component name
jpayne@68 450 # to the list of components for that option.
jpayne@68 451 # The variable is the object variable: itcl_option_components($opt)
jpayne@68 452 #
jpayne@68 453 # Handles the following syntax:
jpayne@68 454 #
jpayne@68 455 # keepcomponentoption <componentName> <optionName> ?<optionName> ...?
jpayne@68 456 #
jpayne@68 457 # ======================================================================
jpayne@68 458
jpayne@68 459
jpayne@68 460 proc keepcomponentoption {args} {
jpayne@68 461 upvar win win
jpayne@68 462 upvar itcl_hull itcl_hull
jpayne@68 463
jpayne@68 464 set usage "wrong # args, should be: keepcomponentoption componentName optionName ?optionName ...?"
jpayne@68 465
jpayne@68 466 #puts stderr "KEEP!$args![uplevel 1 namespace current]!"
jpayne@68 467 if {[llength $args] < 2} {
jpayne@68 468 puts stderr $usage
jpayne@68 469 return -code error
jpayne@68 470 }
jpayne@68 471 set my_hull [uplevel 1 set itcl_hull]
jpayne@68 472 set my_class [uplevel 1 namespace current]
jpayne@68 473 set comp [lindex $args 0]
jpayne@68 474 set args [lrange $args 1 end]
jpayne@68 475 set class_info_dict [dict get $::itcl::internal::dicts::classComponents $my_class]
jpayne@68 476 if {![dict exists $class_info_dict $comp]} {
jpayne@68 477 puts stderr "keepcomponentoption cannot find component \"$comp\""
jpayne@68 478 return -code error
jpayne@68 479 }
jpayne@68 480 set class_comp_dict [dict get $class_info_dict $comp]
jpayne@68 481 if {![dict exists $class_comp_dict -keptoptions]} {
jpayne@68 482 dict set class_comp_dict -keptoptions [list]
jpayne@68 483 }
jpayne@68 484 foreach opt $args {
jpayne@68 485 #puts stderr "KEEP!$opt!"
jpayne@68 486 if {[string range $opt 0 0] ne "-"} {
jpayne@68 487 puts stderr "keepcomponentoption: option must begin with a \"-\"!"
jpayne@68 488 return -code error
jpayne@68 489 }
jpayne@68 490 if {[lsearch [dict get $class_comp_dict -keptoptions] $opt] < 0} {
jpayne@68 491 dict lappend class_comp_dict -keptoptions $opt
jpayne@68 492 }
jpayne@68 493 }
jpayne@68 494 if {![info exists ::itcl::internal::component_objects([lindex [uplevel 1 info context] 1])]} {
jpayne@68 495 set comp_object $::itcl::internal::component_objects([lindex [uplevel 1 info context] 1])
jpayne@68 496 } else {
jpayne@68 497 set comp_object "unknown_comp_obj_$comp!"
jpayne@68 498 }
jpayne@68 499 dict set class_info_dict $comp $class_comp_dict
jpayne@68 500 dict set ::itcl::internal::dicts::classComponents $my_class $class_info_dict
jpayne@68 501 puts stderr "CLDI!$class_comp_dict!"
jpayne@68 502 addToItclOptions $my_class $comp_object $args [list]
jpayne@68 503 }
jpayne@68 504
jpayne@68 505 proc ignorecomponentoption {args} {
jpayne@68 506 puts stderr "IGNORE_COMPONENT_OPTION!$args!"
jpayne@68 507 }
jpayne@68 508
jpayne@68 509 proc renamecomponentoption {args} {
jpayne@68 510 puts stderr "rename_COMPONENT_OPTION!$args!"
jpayne@68 511 }
jpayne@68 512
jpayne@68 513 proc addoptioncomponent {args} {
jpayne@68 514 puts stderr "ADD_OPTION_COMPONENT!$args!"
jpayne@68 515 }
jpayne@68 516
jpayne@68 517 proc ignoreoptioncomponent {args} {
jpayne@68 518 puts stderr "IGNORE_OPTION_COMPONENT!$args!"
jpayne@68 519 }
jpayne@68 520
jpayne@68 521 proc renameoptioncomponent {args} {
jpayne@68 522 puts stderr "RENAME_OPTION_COMPONENT!$args!"
jpayne@68 523 }
jpayne@68 524
jpayne@68 525 proc getEclassOptions {args} {
jpayne@68 526 upvar win win
jpayne@68 527
jpayne@68 528 #puts stderr "getEclassOptions!$args!$win![uplevel 1 namespace current]!"
jpayne@68 529 #parray ::itcl::internal::variables::${win}::itcl_options
jpayne@68 530 set result [list]
jpayne@68 531 foreach opt [array names ::itcl::internal::variables::${win}::itcl_options] {
jpayne@68 532 if {[catch {
jpayne@68 533 foreach {res cls def} [set ::itcl::internal::variables::${win}::__itcl_option_infos($opt)] break
jpayne@68 534 lappend result [list $opt $res $cls $def [set ::itcl::internal::variables::${win}::itcl_options($opt)]]
jpayne@68 535 } msg]} {
jpayne@68 536 }
jpayne@68 537 }
jpayne@68 538 return $result
jpayne@68 539 }
jpayne@68 540
jpayne@68 541 proc eclassConfigure {args} {
jpayne@68 542 upvar win win
jpayne@68 543
jpayne@68 544 #puts stderr "+++ eclassConfigure!$args!"
jpayne@68 545 if {[llength $args] > 1} {
jpayne@68 546 foreach {opt val} $args break
jpayne@68 547 if {[::info exists ::itcl::internal::variables::${win}::itcl_options($opt)]} {
jpayne@68 548 set ::itcl::internal::variables::${win}::itcl_options($opt) $val
jpayne@68 549 return
jpayne@68 550 }
jpayne@68 551 } else {
jpayne@68 552 foreach {opt} $args break
jpayne@68 553 if {[::info exists ::itcl::internal::variables::${win}::itcl_options($opt)]} {
jpayne@68 554 #puts stderr "OP![set ::itcl::internal::variables::${win}::itcl_options($opt)]!"
jpayne@68 555 foreach {res cls def} [set ::itcl::internal::variables::${win}::__itcl_option_infos($opt)] break
jpayne@68 556 return [list $opt $res $cls $def [set ::itcl::internal::variables::${win}::itcl_options($opt)]]
jpayne@68 557 }
jpayne@68 558 }
jpayne@68 559 return -code error
jpayne@68 560 }
jpayne@68 561
jpayne@68 562 }