subsection3_4_3.html
subsection3_4_2.html
subsection3_4_2.html
tableofcontents3_1.html
Next:
subsection3_4_3.html
Writing Methods
Up:
subsection3_4_2.html
Widget Class Declaration
Previous:
subsection3_4_2.html
Widget Class Declaration
Using the tixWidgetClass Command
We can use the
tixWidgetClass
command to declare a new
class. The syntax is:
tixWidgetClass classCommandName {
-switch value
-switch value
....
}
For example, the following is the declaration section of
TixArrowButton
:
tixWidgetClass tixArrowButton {
-classname  TixArrowButton
-superclass tixPrimitive
-method {
flash invoke invert
}
-flag {
-direction -state
}
-configspec {
{-direction direction Direction e}
{-state state State normal}
}
-alias {
{-dir -direction}
}
-default {
{*Button.anchor         c}
{*Button.padX           5}
}
}
We'll look at what each option means as the command is described in the
following sections. The first argument for
tixWidgetClass
is the
command name for the widget class (
tixArrowButton
). Command names are
used to create widgets of this class. For example, the code:
tixArrowButton .arrow
creates a widget instance
.arrow
of the class
TixArrowButton
.
Also, the command name is used as a prefix of all the methods of this
class. For example, the
Foo
and
Bar
methods of the class
TixArrowButton
will be written as
tixArrowButton:Foo
and
tixArrowButton:Bar
.
The class name of the class (
TixArrowButton
) is specified by the
-classname
switch inside the main body of the declaration. The class
name is used only to specify options in the TK option database.
Notice the difference in the capitalization of the class name and the
command name of the
TixArrowButton
class: both of them have the
individual words capitalized, but the command name
(
tixArrowButton
) starts with a lower case letter while the class name
(
TixArrowButton
) starts with an upper case letter. When you create
your own classes, you should follow this naming convention.
The
-superclass
switch specifies the superclass of the new widget. In
our example, we have set it to
tixPrimitive
.
http://tix.sourceforge.net
http://tix.sourceforge.net
