option



option

NAME
WARNING!
SYNOPSIS
DESCRIPTION
KEYWORDS

___________________________

NAME

itcl::option − define options for extendedclass, widget or widgetadaptor

Parts of this description are "borrowed" from Tcl extension [snit], as the functionality is mostly identical.

WARNING!

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

SYNOPSIS

option optionSpec ?defaultValue?
option
optionSpec ?options? ___________________________

DESCRIPTION

The option command is used inside an [incr Tcl] extendedclass/widget/widgetadaptor definition to define options.

In the first form defines an option for instances of this type, and optionally gives it an initial value. The initial value defaults to the empty string if no defaultValue is specified.

An option defined in this way is said to be locally defined. The optionSpec is a list defining the option’s name, resource name, and class name, e.g.:

option {-font font Font} {Courier 12}

The option name must begin with a hyphen, and must not contain any upper case letters. The resource name and class name are optional; if not specified, the resource name defaults to the option name, minus the hyphen, and the class name defaults to the resource name with the first letter capitalized. Thus, the following statement is equivalent to the previous example:

option -font {Courier 12}

See The Tk Option Database for more information about resource and class names.

Options are normally set and retrieved using the standard instance methods configure and cget; within instance code (method bodies, etc.), option values are available through the options array:

set myfont $itcl_options(-font)

In the second form you can define option handlers (e.g., -configuremethod), then it should probably use configure and cget to access its options to avoid subtle errors.

The option statement may include the following options:
-default
defvalue

Defines the option’s default value; the option’s default value will be "" otherwise.

-readonly

The option is handled read-only -- it can only be set using configure at creation time, i.e., in the type’s constructor.

-cgetmethod methodName

Every locally-defined option may define a -cgetmethod; it is called when the option’s value is retrieved using the cget method. Whatever the method’s body returns will be the return value of the call to cget.

The named method must take one argument, the option name. For example, this code is equivalent to (though slower than) Itcl’s default handling of cget:

option -font -cgetmethod GetOption
method GetOption {option} {
return $itcl_options($option)
}

Note that it’s possible for any number of options to share a -cgetmethod.

-cgetmethodvar varName

That is very similar to -cgetmethod, the only difference is, one can define a variable, where to find the cgetmethod during runtime.

-configuremethod methodName

Every locally-defined option may define a -configuremethod; it is called when the option’s value is set using the configure or configurelist methods. It is the named method’s responsibility to save the option’s value; in other words, the value will not be saved to the itcl_options() array unless the method saves it there.

The named method must take two arguments, the option name and its new value. For example, this code is equivalent to (though slower than) Itcl’s default handling of configure:

option -font -configuremethod SetOption
method SetOption {option value} {
set itcl_options($option) $value
}

Note that it’s possible for any number of options to share a single -configuremethod.

-configuremethodvar varName

That is very similar to -configuremethod, the only difference is, one can define a variable, where to find the configuremethod during runtime.

-validatemethod methodName

Every locally-defined option may define a -validatemethod; it is called when the option’s value is set using the configure or configurelist methods, just before the -configuremethod (if any). It is the named method’s responsibility to validate the option’s new value, and to throw an error if the value is invalid.

The named method must take two arguments, the option name and its new value. For example, this code verifies that -flag’s value is a valid Boolean value:

option -font -validatemethod CheckBoolean
method CheckBoolean {option value} {
if {![string is boolean -strict $value]} {
error "option $option must have a boolean value."
}
}

Note that it’s possible for any number of options to share a single -validatemethod.

-validatemethodvar varName

That is very similar to -validatemethod, the only difference is, one can define a variable, where to find the validatemethod during runtime.

KEYWORDS

option, widget, widgetadaptor, extendedclass




More Linux Commands

manpages/latin7.7.html
latin7(7) - ISO 8859-13 character set encoded in octal, deci
The ISO 8859 standard includes several 8-bit extensions to the ASCII character set (also known as ISO 646-IRV). ISO 8859-13 encodes the characters used in Balti

manpages/XFreeEventData.3.html
XFreeEventData(3) - retrieve and free additional event data
Some extension XGenericEvents require additional memory to store information. For these events, the library returns a XGenericEventCookie with a token (cookie)

manpages/gcj.1.html
gcj(1) - Ahead-of-time compiler for the Java language.......
As gcj is just another front end to gcc, it supports many of the same options as gcc. This manual only documents the options specific to gcj. OPTIONS Input and

manpages/git-log.1.html
git-log(1) - Show commit logs (Commands - Linux man page)...
Shows the commit logs. The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git diff

manpages/field_userptr.3form.html
field_userptr(3form) - associate application data with a for
Every form field has a field that can be used to hold application-specific data (that is, the form-driver code leaves it alone). These functions get and set tha

manpages/XAllocStandardColormap.3.html
XAllocStandardColormap(3) - allocate, set, or read a standar
XAllocStandardColormap.3 - The XAllocStandardColormap function allocates and returns a pointer to a XStandardColormap structure. Note that all fields in the XSt

manpages/true.1.html
true(1) - do nothing, successfully - Linux manual page......
Exit with a status code indicating success. --help display this help and exit --version output version information and exit NOTE: your shell may have its own ve

manpages/HUGE_VALF.3.html
HUGE_VALF(3) - floating-point constants - Linux manual page
The macro INFINITY expands to a float constant representing positive infinity. The macro NAN expands to a float constant representing a quiet NaN (when supporte

manpages/logwtmp.3.html
logwtmp(3) - append an entry to the wtmp file (Man Page)....
logwtmp.3 - updwtmp() appends the utmp structure ut to the wtmp file. logwtmp() constructs a utmp structure using line, name, host, current time and current pro

manpages/ldap_controls_dup.3.html
ldap_controls_dup(3) - LDAP control manipulation routines...
These routines are used to manipulate structures used for LDAP controls. ldap_control_create() creates a control with the specified OID using the contents of th

manpages/clock.3.html
clock(3) - Determine processor time - Linux manual page.....
The clock() function returns an approximation of processor time used by the program. RETURN VALUE The value returned is the CPU time used so far as a clock_t; t

manpages/slk_attr_sp.3ncurses.html
slk_attr_sp(3ncurses) - curses screen-pointer extension.....
This implementation can be configured to provide a set of functions which improve the ability to manage multiple screens. This feature can be added to any of th





We can't live, work or learn in freedom unless the software we use is free.