treectrl - Create and manipulate hierarchical multicolumn widgets
SYNOPSIS
package require treectrl 1.0
|
The treectrl command creates a new window (given by the pathName argument) and makes it into a treectrl widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the treectrl such as its background color and relief. The treectrl command returns the path name of the new window. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.
A treectrl is a widget which displays items one per line. Every item has a set of states, which are boolean properties. The item may be spread about one or more columns. For each column of an item there is a style associated, which determines how to display the item's column respecting the item's current state set. One column can be defined to display the data in a hierarchical structure.
Normally the origin of the coordinate system is at the upper-left corner of the window containing the treectrl. It is possible to adjust the origin of the coordinate system relative to the origin of the window using the xview and yview widget commands; this is typically used for scrolling.
A treectrl widget can be horizontal or vertical oriented
like many other Tk widgets.
For displaying hierarchical data only vertical orientation is useful,
since only then the children of an item
are displayed directly below their parent.
If the treectrl widget is used only
to display data in a multicolumn listbox,
the specification of an orientation will give useful results.
pathName option ?arg arg ...?
PathName is the name of the command, which is the same as
the treectrl widget's path name. Option and the args
determine the exact behavior of the command. The following
commands are possible for treectrl widgets:
Many of the widget commands for a treectrl take as one argument an
indicator of which column of the treectrl to operate on. These
indicators are called columns and may be specified
as numerical index as given by the first column configure
widget command which created the column or by its name,
which can be configured my means of the -tag column option.
There is always one special column, the tail column, which fills
all space to the right of the last ordinary column.
This column has no number;
it can only be specified by its tag tail, which cannot be modified.
It is explicitely mentioned for a widget command,
if its column argument can also specify the tail column.
The following options are supported for columns:
By means of the state define widget command
upto 27 additional stateNames can be defined.
Some widget commands expect a stateDesc argument,
which is a stateName
optionally preceded by an exclamation mark (!).
If the stateName has no leading !
it describes a currently switched on state,
if it has a leading ! it describes a currently switched off state.
Some widget commands expect a statePattern argument,
which should be a non empty list of stateDescs.
The pattern matches, if for every element of the list
the stateDesc describes the same state as the item currently has.
There are some options which can be configured to get different values
dependent on the state of the item in which their element is included.
The values of these options are basically a list.
If the list has one element, the value is valid regardless of the item state.
A list with an even number of elements (value-statePattern pairs)
specifies different values for different states.
For acceptable values of statePattern
see the section STATES above.
The last statePattern can be empty,
implementing a sort of otherwise clause.
The options with this behaviour are called per state options.
The itemDesc may be followed by one or more modifiers.
A modifier changes the item described by the itemDesc relative to
the description upto this point.
It may be specified in any of the following forms,
all optionally followed by visible:
By means of the notify bind widget command Tcl scripts can
be specified,
which will be executed whenever the event triggers.
The command will be executed in the same interpreter that the
notify bind command was executed in, and it will run at global
level (only global variables will be accessible).
If the script contains any % characters,
then the script will not be executed directly.
Instead, a new script will be
generated by replacing each %,
and the character following it,
with information from the current event.
The replacement depends on the character following the %,
as defined in the list below.
Unless otherwise indicated,
Some of the substitutions are only valid for certain types of events;
if they are used for other types of events
the value substituted is undefined.
STANDARD OPTIONS
See the option manual entry for details on the standard options.
WIDGET SPECIFIC OPTIONS
Database Name: backgroundMode
Database Class: BackgroundMode
Database Name: buttonColor
Database Class: ButtonColor
Database Name: buttonSize
Database Class: ButtonSize
Database Name: buttonThickness
Database Class: ButtonThickness
Database Name: closedButtonBitmap
Database Class: ClosedButtonBitmap
Database Name: closedButtonImage
Database Class: ClosedButtonImage
Database Name: columnProxy
Database Class: ColumnProxy
Database Name: doubleBuffer
Database Class: DoubleBuffer
Database Name: height
Database Class: Height
Database Name: indent
Database Class: Indent
Database Name: itemHeight
Database Class: ItemHeight
Database Name: lineColor
Database Class: LineColor
Database Name: lineStyle
Database Class: LineStyle
Database Name: lineThickness
Database Class: LineThickness
Database Name: openButtonBitmap
Database Class: OpenButtonBitmap
Database Name: openButtonImage
Database Class: OpenButtonImage
Database Name: scrollMargin
Database Class: ScrollMargin
Database Name: selectMode
Database Class: SelectMode
Database Name: showButtons
Database Class: ShowButtons
Database Name: showHeader
Database Class: ShowHeader
Database Name: showLines
Database Class: ShowLines
Database Name: showRoot
Database Class: ShowRoot
Database Name: showRootButton
Database Class: ShowRootButton
Database Name: treeColumn
Database Class: TreeColumn
Database Name: width
Database Class: Width
Database Name: wrap
Database Class: Wrap
Database Name: xScrollDelay
Database Class: ScrollDelay
Database Name: xScrollIncrement
Database Class: ScrollIncrement
Database Name: yScrollDelay
Database Class: ScrollDelay
Database Name: yScrollIncrement
Database Class: ScrollIncrement
WIDGET COMMAND
The treectrl command creates a new Tcl command whose
name is the same as the path name of the treectrl's window.
This command may be used to invoke various
operations on the widget. It has the following general form:
The specified column is created, if it not already exists
and if at least one option-value pair is specified.
See COLUMNS below for details on the options available for columns.
The following debugging options are supported:
The following dragimage options are supported:
If the coordinates are in the header area
and thus the first element of the result is header,
the number of the column or the string tail
is the second element in the resulting list;
if the x coordinate is near the left or right end of the header,
a third element left or right is added respectively.
If the coordinates are below the header area
and thus the first element of the result is item,
the numerical id of the item
is the second element in the resulting list.
If the x coordinate doesn't fall into the column
displaying the hierarchical structure,
the elements column and the column number are added.
If the x coordinate if above the column
displaying the hierarchical structure,
the following elements are added to the resulting list:
line and the numerical id of the item the line comes from,
if the x coordinate is above an item connecting line;
button, if the x coordinate is above a button;
column, the column number, elem, and the element name,
if the x coordinate is above an element of the item;
column and the column number,
if the x coordinate is to the right of the elements;
nothing otherwise.
The range of items which should be sorted can be restricted
by means of the -first and/or -last options,
which should be children of the item described by itemDesc;
the order between these two limiting items doesn't matter.
The sort column can be specified by means of the -column option;
this option can be used repeatedly to define a multi column sort.
The sorting is done by looking at the text
of the element specified by the -element option,
which must be a text element defined in the style of the sorting column,
by default the first text element is used.
If the -notreally option is specified,
no rearranging of the items is done;
instead the sorted items are returned as result of the command.
By default ASCII sorting is used with the result returned in increasing order.
The order can be modified by means of the -increasing (the default)
or -decreasing flag.
Any of the following options may be specified to control
the sorting process of the previously specified column
(unique abbreviations are accepted):
The following marquee options are supported:
The exact behavior of the command depends on the option argument
that follows the notify argument.
The following forms of the command are supported:
The following event options are supported:
The optional charMap is a list of key-value pairs
as in the form returned by array get;
each key has to be exactly one character.
If this argument is specified,
the following substitution will be done in the script
registered for the generated event
before it will be evaluated:
every occurence of a percent character (%) followed by a key
will be replaced with its corresponding value.
The optional percentsCommand will be called
before the event is triggered
for every two character sequence
starting with a percent character (%).
The script is called with at least four additional arguments:
the second character of the sequence,
the window for which the event is triggered,
eventName and detail,
and finally the field-value pairs specified
as arguments in the notify generate call to generate the event
(the leading dash is dropped from the fields).
The two character sequence of the command will be replaced by
the returning string, or by an empty string
if the command returns with a returnCode other than 0.
The options of a style have effect on all elements managed by the style.
The following options are supported:
If the elementList argument is not specified, a list is returned
containing the currently defined elements of style.
The options of a layout have effect on exactly the one element element
managed by style.
The following options are supported:
COLUMNS
A treectrl widget is capable of displaying multiple columns next to each
other.
An item can be considered as a row, which reaches over all columns.
STATES
A state consists basically of just a string: its stateName.
For every item a set of these states is managed,
which means that every item can have every state switched on or off.
The following states are predefined for every item:
ELEMENTS
Elements are the smallest building block
which are handled by a treectrl widget.
One or more elements together can be combined to a style,
which can be considered as a blueprint for an item.
They can also be used to create an item directly
by means of the item complex widget command.
An element can be of type bitmap, border, image,
rect, or text.
For each element type there is a section below describing all options
which can modify the behaviour of an element of this type.
BITMAP ELEMENT
An element of type bitmap can be used to display a bitmap in an item.
The following options are supported for bitmap elements:
BORDER ELEMENT
An element of type border can be used to add a border to an item.
The following options are supported for border elements:
IMAGE ELEMENT
An element of type image can be used to display an image in an item.
The following options are supported for image elements:
RECTANGLE ELEMENT
An element of type rect can be used to display a rectangle in an item.
The following options are supported for rectangle elements:
TEXT ELEMENT
An element of type text can be used to display a text in an item.
The following options are supported for text elements:
ITEM DESCRIPTION
Many of the widget commands for a treectrl take as one argument an
indicator of which item of the treectrl to operate on. These
indicators are called itemDescs and may be specified in
any of the following forms:
EVENTS AND SCRIPT SUBSTITUTIONS
Beside of all the normal Tk events, which are generated as reaction
of e.g. mouse movements or key presses,
the treectrl widget generates at various places
events created by treectrl widget:
DEFAULT BINDINGS
Tk automatically creates class bindings for treectrls that give them
the following default behavior.
SEE ALSO
listbox(n), image(n), bitmap(n), bind(n), options(n)
KEYWORDS
tree, widget