subsubsectionstar3_8_4_3.html
subsection3_8_4.html
subsubsection3_8_4_1.html
tableofcontents3_1.html
Next:
subsubsectionstar3_8_4_3.html
The tixChainMethod call
Up:
subsection3_8_4.html
Standard Initialization Methods
Previous:
subsubsection3_8_4_1.html
The InitWidgetRec Method
Chaining Methods
The above implementation is not sufficient because our
TixArrowButton class is derived from TixPrimitive. The class
derivation in Tix is basically an
is-a
relationship:
TixArrowButton
is a
TixPrimitive. TixPrimitive defines the
method
tixPrimitive:InitWidgetRec
which sets up the instance
variables of every instance of TixPrimitive. Since an instance of
TixArrowButton is also an instance of TixPrimitive, we need to make
sure that the instance variables defined by TixPrimitive are also
properly initialized. The technique of calling a method defined in a
superclass is called the
chaining
of a method. The following
implementation does this correctly:
proc tixArrowButton:InitWidgetRec {w} {
upvar #0 $w data
tixPrimitive:InitWidgetRec $w
set data(count) 0
}
Notice that
tixPrimitive:InitWidgetRec
is called before anything
else is done. This way, we can define new classes by means of
successive refinement: we can first ask the superclass to set up the
instance variables, then we can modify some of those variables when
necessary and also define new variables.
http://tix.sourceforge.net
http://tix.sourceforge.net
