subsubsection3_8_5_1.html
section3_8.html
subsubsection3_8_4_5.html
tableofcontents3_1.html
Next:
subsubsection3_8_5_1.html
Initialization of Public
Up:
section3_8.html
Tix Object Oriented
Previous:
subsubsection3_8_4_5.html
The SetBindings Method
Declaring and Using Variables
The private variables of a widget class do not need to be
declared. In fact they can be initialized and used anywhere by any
method. Usually, however, general purpose private variables are
initialized by the
InitWidgetRec
method and subwidget
variables are initialized in the
ConstructWidget
method.
We have seen in the
tixArrowButton:InitWidgetRec
example that
the private variable
data(count)
was initialized there. Also,
the private variable
data(w:button)
was initialized in
tixArrowButton:ConstructWidget
and subsequently used in
tixArrowButton:SetBindings
.
In contrast, public variables must be declared inside the class
declaration. The following arguments are used to declare the public
variables and specify various options for them:
-flag
: As shown in the class declaration in figure
6-2, the
-flag
argument declares all the public
variables of the TixArrowButton class,
-direction
and
-state
-configspec
: We can use the
-configspec
argument to
specify the details of each public variable. For example, the
following declaration
-configspec {
{-direction direction Direction e}
{-state state State normal}
}
specifies that the
-direction
variable has the resource
name
direction
and resource class
Direction
; its default
value is
e
. The application programmer can assign value to
this variable by using the
-direction
option in the command
line or by specifying resources in the Tk option database with its
resource name or class. The declaration of
-state
installs
similar definitions for that variable.
-alias
: The
-alias
argument is used to specify
alternative names for public variables. In our example, the setting
-alias {
{-dir -direction}
}
specifies that
-dir
is the same variable as
-direction
. Therefore, when the application issue the command
.up config -dir w
it is the same as issuing
.up config -direction w
The
-alias
option provides only an alternative name for
the application programmer. Inside the widget's implementation code,
the variable is still accessed as
data(-direction)
,
not
data(-dir)
.
subsubsection3_8_5_1.html#SECTION00085100000000000000
Initialization of Public Variables
subsubsectionstar3_8_5_2.html#SECTION00085200000000000000
Type Checker
subsubsection3_8_5_3.html#SECTION00085300000000000000
Public Variable Configuration Methods
subsubsectionstar3_8_5_4.html#SECTION00085400000000000000
Configuration Methods and Public Variable Initialization
http://tix.sourceforge.net
http://tix.sourceforge.net
