1delegation(n)                     [incr Tcl]                     delegation(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       itcl::delegation - delegate methods, procs or options to other objects
9
10       Parts  of this description are "borrowed" from Tcl extension [snit], as
11       the functionality is mostly identical.
12

WARNING!

14       This is new functionality  in  [incr  Tcl]  where  the  API  can  still
15       change!!
16

SYNOPSIS

18       delegate method methodName to componentName ?as targetName?
19       delegate method methodName ?to componentName? using pattern
20       delegate method * ?to componentName? ?using pattern? ?except methodName methodName ...?
21
22       delegate proc procName to componentName ?as targetName?
23       delegate proc procName ?to componentName? using pattern
24       delegate proc * ?to componentName? ?using pattern? ?except procName procName ...?
25
26       delegate option optionSpec to componentName
27       delegate option optionSpec to componentName as targetname?
28       delegate option * to componentName
29       delegate option * to componentName except optionName optionname ...
30______________________________________________________________________________
31
32

DESCRIPTION

34       The  delegate  command  is used inside an [incr Tcl] extendedclass/wid‐
35       get/widgetadaptor definition to delegate methods/procs/options to other
36       objects for handling.
37
38       delegate method methodName to componentName ?as targetName?
39              This form of delegate method delegates method methodName to com‐
40              ponent componentName. That  is,  when  method  methdoNameame  is
41              called on an instance of this type, the method and its arguments
42              will be passed to the named component's  command  instead.  That
43              is, the following statement
44
45                     delegate method wag to tail
46
47              is roughly equivalent to this explicitly defined method:
48
49                     method wag {args} {
50                         uplevel $tail wag $args
51                     }
52
53              The  optional  as  clause  allows  you  to specify the delegated
54              method name and possibly add some arguments:
55
56                     delegate method wagtail to tail as "wag briskly"
57
58              A method cannot be both locally defined and delegated.
59
60       delegate method methodName ?to componentName? using pattern
61              In this form of the delegate statement, the using clause is used
62              to  specify the precise form of the command to which method name
63              name is delegated.  The to clause is optional, since the  chosen
64              command might not involve any particular component.
65
66              The  value of the using clause is a list that may contain any or
67              all of the following substitution codes; these codes are substi‐
68              tuted  with  the  described value to build the delegated command
69              prefix. Note that the following two statements are equivalent:
70
71                     delegate method wag to tail
72                     delegate method wag to tail using "%c %m"
73
74              Each element of the list becomes a single element of  the  dele‐
75              gated command --it is never reparsed as a string.
76
77              Substitutions:
78
79              %%     This  is  replaced  with  a single "%". Thus, to pass the
80                     string "%c" to the command as an  argument,  you'd  write
81                     "%%c".
82
83              %c     This is replaced with the named component's command.
84
85              %j     This is replaced by the method name; if the name consists
86                     of multiple tokens, they are joined by underscores ("_").
87
88              %m     This is replaced with the final token of the method name;
89                     if  the  method  name has one token, this is identical to
90                     %M.
91
92              %M     This is replaced by the method name; if the name consists
93                     of multiple tokens, they are joined by space characters.
94
95              %n     This  is replaced with the name of the instance's private
96                     namespace.
97
98              %s     This is replaced with the name of the instance command.
99
100              %t     This is replaced with the fully qualified type name.
101
102              %w     This is replaced with the original name of  the  instance
103                     command; for Itcl widgets and widget adaptors, it will be
104                     the Tk window name. It  remains  constant,  even  if  the
105                     instance command is renamed.
106
107       delegate method * ?to componentName? ?using pattern? ?except methodName
108       methodName ...?
109              In this form all unknown method names are delegeted to the spec‐
110              ified component. The except clause can be used to specify a list
111              of exceptions, i.e., method names that will not be so delegated.
112              The  using  clause  is defined as given above. In this form, the
113              statement must contain the to clause, the using clause, or both.
114
115              In fact, the "*" can be a list of two or more tokens whose  last
116              element is "*", as in the following example:
117
118                     delegate method {tail *} to tail
119
120              This  implicitly  defines the method tail whose subcommands will
121              be delegated to the tail component.
122
123              The definitions for delegate  proc  ...  are  the  same  as  for
124              method, the only difference being, that this is for procs.
125
126       delegate option namespec to comp
127
128       delegate option namespec to comp as target
129
130       delegate option * to comp
131
132       delegate option * to comp except exceptions
133              Defines  a  delegated option; the namespec is defined as for the
134              option statement. When the  configure,  configurelist,  or  cget
135              instance  method  is used to set or retrieve the option's value,
136              the equivalent configure or cget command will be applied to  the
137              component  as  though  the option was defined with the following
138              -configuremethod and -cgetmethod:
139
140                     method ConfigureMethod {option value} {
141                         $comp configure $option $value
142                     }
143
144                     method CgetMethod {option} {
145                         return [$comp cget $option]
146                     }
147
148              Note that delegated options never  appear  in  the  itcl_options
149              array.   If  the  as clause is specified, then the target option
150              name is used in place of name.
151
152       delegate option * ?except optionName optionName ...?
153              This form delegates all unknown options to the specified  compo‐
154              nent.  The except clause can be used to specify a list of excep‐
155              tions, i.e., option names that will not be so delegated.
156
157              Warning: options can only be delegated to a component if it sup‐
158              ports the configure and cget instance methods.
159
160              An  option  cannot  be  both locally defined and delegated. TBD:
161              Continue from here.
162

KEYWORDS

164       delegation, option, method, proc
165
166
167
168itcl                                  4.0                        delegation(n)
Impressum