Documentation generated from CVS HEAD
itcl::delegation -
delegate methods, procs or options to other objects
Parts of this description are "borrowed" from Tcl extension [snit], as the functionality is mostly identical.
This is new functionality in [incr Tcl] where the API can still change!!
delegate method methodName to componentName ?as targetName? delegate method methodName ?to componentName? using pattern delegate method * ?to componentName? ?using pattern? ?except methodName methodName ...? delegate proc procName to componentName ?as targetName? delegate proc procName ?to componentName? using pattern delegate proc * ?to componentName? ?using pattern? ?except procName procName ...? delegate option optionSpec to componentName delegate option optionSpec to componentName as targetname? delegate option * to componentName delegate option * to componentName except optionName optionname ...
The delegate command is used inside an [incr Tcl] extendedclass/widget/widgetadaptor definition to delegate methods/procs/options to other objects for handling.
delegate method wag to tail
is roughly equivalent to this explicitly defined method:
method wag {args} { uplevel $tail wag $args }
The optional as clause allows you to specify the delegated method name and possibly add some arguments:
delegate method wagtail to tail as "wag briskly"
A method cannot be both locally defined and delegated.
The value of the using clause is a list that may contain any or all of the following substitution codes; these codes are substituted with the described value to build the delegated command prefix. Note that the following two statements are equivalent:
delegate method wag to tail delegate method wag to tail using "%c %m"
Each element of the list becomes a single element of the delegated command --it is never reparsed as a string.
Substitutions:
In fact, the "*" can be a list of two or more tokens whose last element is "*", as in the following example:
delegate method {tail *} to tail
This implicitly defines the method tail whose subcommands will be delegated to the tail component.
The definitions for delegate proc ... are the same as for method, the only difference being, that this is for procs.
method ConfigureMethod {option value} { $comp configure $option $value } method CgetMethod {option} { return [$comp cget $option] }
Note that delegated options never appear in the itcl_options array. If the as clause is specified, then the target option name is used in place of name.
Warning: options can only be delegated to a component if it supports the configure and cget instance methods.
An option cannot be both locally defined and delegated. TBD: Continue from here.