Delegation
You may by now have lost track of
how delegation within a compound
widget takes place.
Perhaps a brief look at the implementation
will clarify this.
Each eval, configure or bind
function call for a widget
results in a command addressed to
the path of the widget.
By redirecting the command to a different path,
the instructions may be delegated to
the appropriate (component) widget.
Delegation occurs, in other words,
by directing the commands to the widget's virtual
path, which is obtained by the protected
function .
In contrast, the function delivers
the path of the widget's outer component.
Indirection takes place by invoking the function
, which relies on an instance variable
{\em _self} that may be set by the redirect
function.
}
\fslide{f-self}{Dereferencing }{
- \hspace*{-2cm}
\begin{mfpic}[25][12]{-2}{10}{0}{10}
\rect{(1,1),(9,9)}
\rect{(3,1.4),(8.8,6)}
\rect{(4.5,1.8),(8.6,4)}
\cdisk{(1.5,2.3),0.2}
\cdisk{(3.5,2.3),0.2}
\cdisk{(5.0,2.3),0.2}
\curvedarrow{(1.7,2.3),(2.3,2.0), (3.0,2.3)}
\curvedarrow{(3.7,2.3),(4.0,2.0),(4.5,2.3)}
\curvedarrow{(5.2,2.3),(5.5,2.0), (5.7,2.3), (5.5,2.6), (5.3,2.3)}
\label[tl]{1.2}{8.5}{drawtool}
\label[tl]{3.2}{5.5}{tablet}
\label[tl]{4.7}{3.5}{canvas}
\end{mfpic}
}{
\begin{mfpic}[25][8]{0}{10}{0}{10}
\rect{(1,1),(9,9)}
\rect{(3,1.4),(8.8,6)}
\rect{(4.5,1.8),(8.6,4)}
\cdisk{(1.5,2.3),0.2}
\cdisk{(3.5,2.3),0.2}
\cdisk{(5.0,2.3),0.2}
\curvedarrow{(1.7,2.3),(2.3,2.0), (3.0,2.3)}
\curvedarrow{(3.7,2.3),(4.0,2.0),(4.5,2.3)}
\curvedarrow{(5.2,2.3),(5.5,2.0), (5.7,2.3), (5.5,2.6), (5.3,2.3)}
\label[tl]{1.2}{8.5}{drawtool}
\label[tl]{3.2}{5.5}{tablet}
\label[tl]{4.7}{3.5}{canvas}
\end{mfpic}
}
}
The implementation of and is
simply:
char* thepath() { return self()->path(); }
widget* self() { return _self?_self->self():this; }
Hence, resolving a compound widget's
primary inner component relies on simple pointer chasing,
which may be applied recursively to an
arbitrary depth at acceptable costs.