- NAME
- Widget - The Widget base class for BWidget
- DESCRIPTION
- COMMANDS
- Slab::Widget::addmap
class
subclass
subpath
options
- Slab::Widget::bwinclude
class
subclass
subpath
?arg...?
- Slab::Widget::cget
path
option
- Slab::Widget::configure
path
options
- Slab::Widget::create
class
path
?rename?
- Slab::Widget::declare
class
optlist
- Slab::Widget::define
class
filename
?class ...?
- Slab::Widget::destroy
path
- Slab::Widget::getoption
path
option
- Slab::Widget::getVariable
path
varName
?myVarName?
- Slab::Widget::hasChanged
path
option
pvalue
- Slab::Widget::init
class
path
options
- Slab::Widget::setoption
path
option
value
- Slab::Widget::subcget
path
subwidget
- Slab::Widget::tkinclude
class
tkwidget
subpath
?arg...?
- OTHER COMMANDS in the Slab::Widget namespace, documented on the Utilities page.
- Slab::Widget::focusNext
w
- Slab::Widget::focusOK
w
- Slab::Widget::focusPrev
w
- Slab::Widget::traverseTo
w
- Slab::Widget::theme
?bool?
NAME
Widget - The Widget base class for BWidget
DESCRIPTION
Under construction ...
The Slab::Widget namespace handles data associated to all BWidgets
and provides commands to easily define a BWidget. It is retained in Slab for
use by the widgets that have not yet been ported to Snit. It also includes
general-purpose Utilities that are used by Slab widgets that have been ported to Snit.
Four commands can be used to define a BWidget:
tkinclude, bwinclude, declare, and addmap.
Here is the definition of ComboBox widget:
namespace eval ComboBox {
# We're using ArrowButton, Entry and LabelFrame
ArrowButton::use
Entry::use
LabelFrame::use
# Include resources of LabelFrame
Slab::Widget::bwinclude ComboBox LabelFrame .labf \
rename {-text -label} \
remove {-focus} \
prefix {label -justify -width -anchor -height -font} \
initialize {-relief sunken -borderwidth 2}
# Include resources of Entry
Slab::Widget::bwinclude ComboBox Entry .e \
remove {-relief -bd -borderwidth -bg -fg} \
rename {-foreground -entryfg -background -entrybg}
# Declare new resources
Slab::Widget::declare ComboBox {
{-height TkResource 0 0 listbox}
{-values String "" 0}
{-modifycmd String "" 0}
{-postcommand String "" 0}
}
# Map resources to subwidget
Slab::Widget::addmap ComboBox "" :cmd {-background {}}
Slab::Widget::addmap ComboBox ArrowButton .a \
{-foreground {} -background {} -disabledforeground {} -state {}}
proc use {} {}
}
- Slab::Widget::addmap
class
subclass
subpath
options
-
This command map some resources to subwidget.
Mapped resources automatically configure subwidget when widget is configured.
- class is the class of the new BWidget
- subclass is the class the subwidget (BWidget class, e.g Entry, or empty for Tk widget)
- subpath is the path of the subwidget
- options is the list {option realres ...} of options to map to subwidget
- Slab::Widget::bwinclude
class
subclass
subpath
?arg...?
-
This command includes into a new BWidget the resources of another BWidget.
Arguments are:
- class class of the new widget
- subclass class name of the BWidget to be included
- subpath path of the widget to configure when BWidget is configured
- options is:
- include {option option ...}
list of options to include (all if not defined)
- remove {option option ...}
list of options to remove
- rename {option name option name ...}
list of options to rename
- prefix {prefix option option ...}
pefix all option by prefix
- initialize {option value option value ...}
default value of options
- readonly {option value option value ...}
new readonly flag
- Slab::Widget::cget
path
option
-
Returns the value of option of BWidget path. cget tests the option
existence and takes care of synchronization with subwidget.
Typically called by the BWidget cget command.
- Slab::Widget::configure
path
options
-
Description text
- Slab::Widget::create
class
path
?rename?
-
The standard method for creating a BWidget. The real widget path
is renamed to $path:cmd, and a new proc is created to replace the
path which points to the BWidget's commands.
If rename is false, the path will not be renamed, but the
proc will still be created. This is useful when inheriting another
BWidget who will already have renamed the widget.
The command returns the widget path. This command is usually the
last command executed in the ::create command for the widget.
- Slab::Widget::declare
class
optlist
-
This command declare new resources for a BWidget.
- class is class of the new widget
- options is the list describing new options. Each new option is a list
{option type value ro ?args?} where:
- option is the name of the option
- type is the type of the option
- value is the default value of the option
- ro is the readonly flag of the option
- args depends on type
type can be:
- TkResource
-
value of option denotes a resource of a Tk widget. args must be class or
{class realoption}. class is the creation command of the Tk widget, e.g.
entry.
The second form must be used if option has not the same name in Tk widget,
but realoption.
If value is empty, it is initialized to the default value of the Tk widget.
- BwResource
-
value of option denotes a resource of a BWidget. args must be class or
{class realoption}. class is the name of the namespace of the BWidget, e.g.
LabelFrame.
The second form must be used if option has not the same name in BWidget,
but realoption.
If value is empty, it is initialized to the default value of the BWidget.
- Int
- value of option is an integer.
args can be {?min? ?max?} to force it to be in a range. The test is
[expr $option > $min] && [expr $option < $max] so
if args is {0 10}, value must be beetween 0 and 10 exclude,
if args is {=0 =10} , value must be beetween 0 and 10 include.
- Boolean
- value of option is a boolean. True values can be 1, true or yes.
False values can be 0, false or no. Slab::Widget::cget always return
0 or 1.
- Enum
-
value of option is a element of a enumeration. args must be the list
of enumeration, e.g. {top left bottom right}.
- Flag
-
value of option is a combination of a set of chars. args must be a
string defining the set.
- String
-
- value of option is any uncontrolled string.
- Synonym
-
- option is a synonym of option args. value has no effect here.
- Slab::Widget::define
class
filename
?class ...?
-
This command is used to define a new BWidget class. It is
usually the first command executed in a new widget definition.
- class is the name of the new widget class.
- filename is the name of the file (without extension) in the
BWidget distribution that defines this class.
- ?-classonly? If present, the class is not setup.
- ?-namespace ns? The namespace where the widget's procedures live
in; defaults to the class name.
Each class defined after the filename is a class that this widget
depends on. The ::use command will be called for each of these
classes after the new widget has been defined.
If -classonly option is not given this command does several things to
setup the new class. First, it creates an alias in the global namespace for
the name of the class that points to the class's ::create subcommand.
Second, it defines a ::use subcommand for the class which other classes can
use to load this class on the fly. Lastly, it creates a default binding to
the <Destroy> event for the class that calls Slab::Widget::destroy on the
path. This is the default setup for almost all widgets in the BWidget
package.
- Slab::Widget::destroy
path
-
Description text
- Slab::Widget::getoption
path
option
-
Returns the value of option of BWidget path. This command does not test
option existence, does not handle synonym and does not take care of synchronization with
subwidget.
- Slab::Widget::getVariable
path
varName
?myVarName?
-
Make the variable varName relational to path accessible in
the current procedure. The variable will be created in the widget namespace
for path and can be used for storing widget-specific information.
When path is destroyed, any variable accessed in this manner will be
destroyed with it.
If myVarName is specified, the variable will be accessible in the
current procedure as that name.
- Slab::Widget::hasChanged
path
option
pvalue
-
Description text
- Slab::Widget::init
class
path
options
-
Description text
- Slab::Widget::setoption
path
option
value
-
Set the value of option of BWidget path without option test, subwidget mapping,
synonym handling and does not set the modification flag.
- Slab::Widget::subcget
path
subwidget
-
Returns the list of all option/value of BWidget path that are mapped to subwidget.
- Slab::Widget::tkinclude
class
tkwidget
subpath
?arg...?
-
This command includes into a new BWidget the resources of a Tk widget.
Arguments are:
- class class of the new widget
- tkwidget command name of the Tk widget to be included
- subpath path of the widget to configure when BWidget is configured
- options is:
- include {option option ...}
list of options to include (all if not defined)
- remove {option option ...}
list of options to remove
- rename {option name option name ...}
list of options to rename
- prefix {prefix option option ...}
pefix all option by prefix
- initialize {option value option value ...}
default value of options
- readonly {option value option value ...}
new readonly flag
Copyright © 1998-1999 UNIFIX.
Copyright © 2001-2002 ActiveState Corp.
Copyright © 2017-2025 CitizenEarth Internet Ltd.