The Widget namespace handle data associated to all BWidget and provide commands
to easily define BWidget.
For commands can be used to define a BWidget:
tkinclude, bwinclude, declare, addmap and syncoptions.
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
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
Widget::bwinclude ComboBox Entry .e \
remove {-relief -bd -borderwidth -bg -fg} \
rename {-foreground -entryfg -background -entrybg}
# Declare new resources
Widget::declare ComboBox {
{-height TkResource 0 0 listbox}
{-values String "" 0}
{-modifycmd String "" 0}
{-postcommand String "" 0}
}
# Map resources to subwidget
Widget::addmap ComboBox "" :cmd {-background {}}
Widget::addmap ComboBox ArrowButton .a \
{-foreground {} -background {} -disabledforeground {} -state {}}
# Synchronize subwidget options
Widget::syncoptions ComboBox Entry .e {-text {}}
Widget::syncoptions ComboBox LabelFrame .labf {-label -text -underline {}}
proc use {} {}
}
|