Product Documentation

ActiveTcl 8.4 Documentation


[ Main table Of Contents | Tktreectrl Table Of Contents | Tktreectrl Index ]

treectrl(n) 2.2.7 "Tk Commands"

Name

treectrl - Create and manipulate hierarchical multicolumn widgets

Synopsis

  • package require treectrl 2.2.7

Description

treectrl pathName ?options?

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 in a one- or two-dimensional arrangement. Items have a parent-child relationship with other items. Items have a set of states, which are boolean properties. Items 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 taking into account 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.

STANDARD OPTIONS

-background
-borderwidth
-cursor
-font
-highlightbackground
-highlightcolor
-highlightthickness
-orient
-relief
-takefocus
-xscrollcommand
-yscrollcommand
-foreground

See the option manual entry for details on the standard options.

WIDGET SPECIFIC OPTIONS

Command-Line Switch: -backgroundimage
Database Name: backgroundImage
Database Class: BackgroundImage

Specifies the name of an image to draw as the list background. The image is tiled horizontally and vertically to fill the content area of the list. If the image is transparent it is drawn on top of the background color(s).

Command-Line Switch: -backgroundmode
Database Name: backgroundMode
Database Class: BackgroundMode

Specifies how the background color of items is chosen in each column. The value should be one of row, column, order, or ordervisible. The default is row. This option has only an effect for columns which have -itembackground defined as list of two or more colors (see section COLUMNS below for more on this). If row or column is specified, the background color is chosen based on the location of the item in the 1- or 2-dimensional grid of items as layed out on the screen; this layout of items is affected by the -orient and -wrap options as well as item visibility. When order or ordervisible is specified, the background color is chosen based on the result of the item order command, regardless of the layout of items.

Command-Line Switch: -buttonbitmap
Database Name: buttonBitmap
Database Class: ButtonBitmap

Specifies the bitmap to be used as the expand/collapse button to the left of an item. This is a per-state option. If a bitmap is specified for a certain item state, it overrides the effects of -usetheme.

Command-Line Switch: -buttoncolor
Database Name: buttonColor
Database Class: ButtonColor

Specifies the foreground color which should be used for drawing the outline and the plus or minus sign of the button to the left of an item.

Command-Line Switch: -buttonimage
Database Name: buttonImage
Database Class: ButtonImage

Specifies the image to be used as the expand/collapse button to the left of an item. This is a per-state option. If an image is specified for a certain item state, it overrides the effects of -buttonbitmap and -usetheme.

Command-Line Switch: -buttonsize
Database Name: buttonSize
Database Class: ButtonSize

Specifies the width and height of the button drawn to the left of an item in any of the forms acceptable to Tk_GetPixels.

Command-Line Switch: -buttonthickness
Database Name: buttonThickness
Database Class: ButtonThickness

Specifies the width of the outline and the plus or minus sign of the button to the left of an item in any of the forms acceptable to Tk_GetPixels.

Command-Line Switch: -columnprefix
Database Name: columnPrefix
Database Class: ColumnPrefix

Specifies an ascii string that changes the way column ids are reported and processed. If this option is a non-empty string, the usual integer value of a column id is prefixed with the given string. This can aid debugging but it is important your code doesn't assume column ids are integers if you use it.

Command-Line Switch: -columnproxy
Database Name: columnProxy
Database Class: ColumnProxy

If this option specifies a non empty value, it should be a screen distance in any of the forms acceptable to Tk_GetPixels. Then a 1 pixel thick vertical line will be drawn at the specified screen distance from the left edge of the treectrl widget, which reaches from top to bottom of the treectrl widget and uses an inverting color (i.e black on lighter background, white on darker background). This line can be used to give the user a visual feedback during column resizing.

Command-Line Switch: -columnresizemode
Database Name: columnResizeMode
Database Class: ColumnResizeMode

Specifies the visual feedback used when resizing columns. The value should be one of proxy or realtime. For proxy, a 1-pixel thick vertical line is drawn representing where the right edge of the column will be after resizing. For realtime, the column's size is changed while the user is dragging the right edge of the column.

Command-Line Switch: -columntagexpr
Database Name: columnTagExpr
Database Class: ColumnTagExpr

Specifies a boolean that enables or disables tag expressions in column descriptions. See ITEM AND COLUMN TAGS.

Command-Line Switch: -defaultstyle
Database Name: defaultStyle
Database Class: DefaultStyle

This option is deprecated; use the column option -itemstyle instead. Specifies a list of styles, one per column, to apply to each item created by the item create command. The number of styles in the list can be different from the number of tree columns. Each list element should be a valid style name or an empty string to indicate no style should be applied to a specific column. The list of styles is updated if a style is deleted or if a column is moved.

Command-Line Switch: -doublebuffer
Database Name: doubleBuffer
Database Class: DoubleBuffer

Specifies if double-buffering should be used to improve displaying. The value should be one of none, window, or item. For none no double-buffering is used at all, which may be most memory efficient, but will probably generate some flickering on the screen. For window the complete tree is double-buffered, which requires a buffer big enough to contain the complete widget. For item, which is the default, every item is separately double-buffered, so it works with a buffer size as big as the biggest item.

Command-Line Switch: -height
Database Name: height
Database Class: Height

Specifies the desired height for the window in any of the forms acceptable to Tk_GetPixels. The default is 200 pixels. If this option is less than or equal to zero then the window will not request any size at all.

Command-Line Switch: -indent
Database Name: indent
Database Class: Indent

Specifies the screen distance an item is indented relative to its parent item in any of the forms acceptable to Tk_GetPixels. The default is 19 pixels.

Command-Line Switch: -itemheight
Database Name: itemHeight
Database Class: ItemHeight

Specifies a fixed height for every item in any of the forms acceptable to Tk_GetPixels. If non-zero, this option overrides the requested height of an item and the -minitemheight option. The default is 0, which means that every item has the height requested by the arrangement of elements in each column. Items are never shorter than the maximum height of a button.

Command-Line Switch: -itemprefix
Database Name: itemPrefix
Database Class: ItemPrefix

Specifies an ascii string that changes the way item ids are reported and processed. If this option is a non-empty string, the usual integer value of an item id is prefixed with the given string. This can aid debugging but it is important your code doesn't assume item ids are integers if you use it.

Command-Line Switch: -itemtagexpr
Database Name: itemTagExpr
Database Class: ItemTagExpr

Specifies a boolean that enables or disables tag expressions in item descriptions. See ITEM AND COLUMN TAGS.

Command-Line Switch: -itemwidth
Database Name: itemWidth
Database Class: ItemWidth

Specifies a fixed width for every item in any of the forms acceptable to Tk_GetPixels. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column).

Command-Line Switch: -itemwidthequal
Database Name: itemWidthEqual
Database Class: ItemWidthEqual

Specifies a boolean that says whether all items should have the same width. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column). If the -itemwidth option is specified, then this option has no effect.

Command-Line Switch: -itemwidthmultiple
Database Name: itemWidthMultiple
Database Class: ItemWidthMultiple

Specifies a screen distance that every item's width will be evenly divisible by in any of the forms acceptable to Tk_GetPixels. If more than one column is visible, then this option has no effect. If the -orient option is vertical, and the -wrap option is unspecified, then this option has no effect (in that case all items are as wide as the column). If the -itemwidth option is specified, then this option has no effect.

Command-Line Switch: -linecolor
Database Name: lineColor
Database Class: LineColor

Specifies the color which should be used for drawing the connecting lines between related items.

Command-Line Switch: -linestyle
Database Name: lineStyle
Database Class: LineStyle

Specifies the style of the connecting lines between related items, should be dot which is the default, or solid.

Command-Line Switch: -linethickness
Database Name: lineThickness
Database Class: LineThickness

Specifies the thickness of the connecting lines between related items in any of the forms acceptable to Tk_GetPixels.

Command-Line Switch: -minitemheight
Database Name: minItemHeight
Database Class: MinItemHeight

Specifies a minimum height for every item in any of the forms acceptable to Tk_GetPixels. The default is 0, which means that every item has the height requested by the arrangement of elements in each column. This option has no effect if the -itemheight option is specified. Items are never shorter than the maximum height of a button.

Command-Line Switch: -rowproxy
Database Name: rowProxy
Database Class: RowProxy

If this option specifies a non empty value, it should be a screen distance in any of the forms acceptable to Tk_GetPixels. Then a 1 pixel thick horizontal line will be drawn at the specified screen distance from the top edge of the treectrl widget, which reaches from left to right of the treectrl widget and uses an inverting color (i.e black on lighter background, white on darker background). This line can be used to give the user a visual feedback during row resizing.

Command-Line Switch: -scrollmargin
Database Name: scrollMargin
Database Class: ScrollMargin

Specifies a positive screen distance in any of the forms acceptable to Tk_GetPixels. This option is used by the default bindings to determine how close to the edges of the contentbox the mouse pointer must be before scrolling occurs. Specifying a positive value is useful when items may be drag-and-dropped. Defaults to 0.

Command-Line Switch: -selectmode
Database Name: selectMode
Database Class: SelectMode

Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either single, browse, multiple, or extended; the default value is browse.

Command-Line Switch: -showbuttons
Database Name: showButtons
Database Class: ShowButtons

Specifies a boolean value that determines whether this widget leaves indentation space to display the expand/collapse buttons next to items. The default value is true. The item option -button determines whether any item has a button. See also the treectrl option -showrootbutton.

Command-Line Switch: -showheader
Database Name: showHeader
Database Class: ShowHeader

Specifies a boolean value that determines whether this widget should display the header line with the column names at the top of the widget. The default value is true.

Command-Line Switch: -showlines
Database Name: showLines
Database Class: ShowLines

Specifies a boolean value that determines whether this widget should draw the connecting lines between related items. The default value is true.

Command-Line Switch: -showroot
Database Name: showRoot
Database Class: ShowRoot

Specifies a boolean value that determines whether this widget should draw the root item. By suppressing the drawing of the root item the widget can have multiple items that appear as toplevel items. The default value is true.

Command-Line Switch: -showrootbutton
Database Name: showRootButton
Database Class: ShowRootButton

Specifies a boolean value that determines whether this widget leaves indentation space to display the expand/collapse button next to the root item. The default value is false. The item option -button determines whether the root item has a button.

Command-Line Switch: -showrootchildbuttons
Database Name: showRootChildButtons
Database Class: ShowRootChildButtons

Specifies a boolean value that determines whether this widget should draw the expand/collapse buttons next to children of the root item. The default value is true.

Command-Line Switch: -showrootlines
Database Name: showRootLines
Database Class: ShowRootLines

Specifies a boolean value that determines whether this widget should draw the connecting lines between children of the root item. The default value is true.

Command-Line Switch: -treecolumn
Database Name: treeColumn
Database Class: TreeColumn

Specifies a column description that determines which column displays the buttons and lines. The default is unspecified.

Command-Line Switch: -usetheme
Database Name: useTheme
Database Class: UseTheme

Specifies a boolean value that determines whether this widget should draw parts of itself using a platform-specific theme manager. The default is false.

Command-Line Switch: -width
Database Name: width
Database Class: Width

Specifies the desired width for the window in any of the forms acceptable to Tk_GetPixels. The default is 200 pixel. If this option is less than or equal to zero then the window will not request any size at all.

Command-Line Switch: -wrap
Database Name: wrap
Database Class: Wrap

Specifies whether items are arranged in a 1- or 2-dimensional layout. If the value is an empty string (the default), then items are arranged from top to bottom (-orient vertical) or from left to right (-orient horizontal) in a 1-dimensional layout. If the value is "N items", then a no more than N items will appear in a vertical group (-orient vertical) or horizontal group (-orient horizontal). If the value is "N pixels", then a no vertical group of items will be taller than N pixels (-orient vertical) or no horizontal group of items will be wider than N pixels (-orient horizontal). If the value is window, then a no vertical group of items will be taller than the window (-orient vertical) or no horizontal group of items will be wider than the window (-orient horizontal).

Command-Line Switch: -xscrolldelay
Database Name: xScrollDelay
Database Class: ScrollDelay

This option controls how quickly horizontal scrolling occurs while dragging the mouse with button 1 pressed. The value should be a list of 1 or 2 integers interpreted as microseconds. If 2 values are specified, then the first value determines the intial delay after the first scroll, and the second value determines the delay for all scrolling after the first. If only 1 value is specified, each scroll takes place after that delay.

Command-Line Switch: -xscrollincrement
Database Name: xScrollIncrement
Database Class: ScrollIncrement

Specifies an increment for horizontal scrolling, in any of the usual forms permitted for screen distances. If the value of this option is greater than zero, the horizontal view in the window will be constrained so that the x coordinate at the left edge of the window is always an even multiple of -xscrollincrement; furthermore, the units for scrolling (e.g., the change in view when the left and right arrows of a scrollbar are selected) will also be -xscrollincrement. If the value of this option is less than or equal to zero, then horizontal scrolling snaps to the left of an item, or part of an item if items are wider than the contentbox.

Command-Line Switch: -yscrolldelay
Database Name: yScrollDelay
Database Class: ScrollDelay

This option controls how quickly vertical scrolling occurs while dragging the mouse with button 1 pressed. The value should be a list of 1 or 2 integers interpreted as microseconds. If 2 values are specified, then the first value determines the intial delay after the first scroll, and the second value determines the delay for all scrolling after the first. If only 1 value is specified, each scroll takes place after that delay.

Command-Line Switch: -yscrollincrement
Database Name: yScrollIncrement
Database Class: ScrollIncrement

Specifies an increment for vertical scrolling, in any of the usual forms permitted for screen distances. If the value of this option is greater than zero, the vertical view in the window will be constrained so that the y coordinate at the top edge of the window is always an even multiple of -yscrollincrement; furthermore, the units for scrolling (e.g., the change in view when the top and bottom arrows of a scrollbar are selected) will also be -yscrollincrement. If the value of this option is less than or equal to zero, then vertical scrolling snaps to the top of an item, or part of an item if items are taller than the contentbox.

ITEM AND COLUMN TAGS

Columns and items may have any number of tags associated with them. A tag is just a string of characters, and it may take any form, including that of an integer, although the characters '(', ')', '&', '|', '^' and '!' should be avoided.

The same tag may be associated with many columns or items. This is commonly done to group items in various interesting ways; for example, in a file browser all directories might be given the tag "directory".

Tag expressions are used in column descriptions and item descriptions to specify which columns and items to operate on. A tag expression can be a single tag name or a logical expression of tags using operators '&&', '||', '^' and '!', and parenthesized subexpressions. For example:

.t item id "tag {(a && !b) || (!a && b)}"

or equivalently:

.t item id "tag {a ^ b}"

will return the unique ids of any items with either "a" or "b" tags, but not both.

Within a tag expression a tag name may be enclosed in double quotes to avoid special processing of the operator characters. For example:

.t item id {tag {"a&&b"||c}}

will return the unique ids of any items with either "a&&b" or "c" tags; in this example the && is not treated as an operator. A double-quote may be escaped within a quoted tag name using a backslash '\'.

Tag operators may be bypassed completely by setting the -columntagexpr and -itemtagexpr options. This can be useful if your application has column or item tags containing arbitrary text.

.t configure -itemtagexpr false
.t item delete "tag a&&b"

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:

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:

pathName activate itemDesc

Sets the active item to the one described by itemDesc, and switches on the state active for this item. From now on the item can be retrieved with the item description active. An <ActiveItem> event is generated.

pathName bbox ?area?

Returns a list with four elements giving the bounding box (left, top, right and bottom) of an area of the window. If area is not specified, then the result is the bounding box of the entire window. If area is content, then the result is the part of the window not including borders, headers, or locked columns. If area is header, then the result is the part of the window not including borders where column titles are displayed. If area is left, then the result is the part of the window not including borders or headers where left-locked columns are displayed. If area is right, then the result is the part of the window not including borders or headers where right-locked columns are displayed. An empty string is returned if the display area has no height or width, which can be true for various reasons such as the window is too small, or the header is not displayed, or there aren't any locked columns.

pathName canvasx screenx

Given a window x-coordinate in the treectrl screenx, this command returns the treectrl x-coordinate that is displayed at that location.

pathName canvasy screeny

Given a window y-coordinate in the treectrl screeny, this command returns the treectrl y-coordinate that is displayed at that location.

pathName cget option

Returns the current value of the configuration option given by option. Option may have any of the values accepted by the tree command.

pathName collapse ?-recurse? ?itemDesc ...?

Use item collapse instead.

pathName column option column ?arg ...?

This command is used to manipulate the columns of the treectrl widget (see section COLUMNS below). The exact behavior of the command depends on the option argument that follows the column argument. The following forms of the command are supported:

pathName column bbox columnDesc

Returns a list with four elements giving the bounding box of the header of the column specified by the column description columnDesc. If the treectrl is configured not to display the column headers by means of the -showheader option, then an empty list is returned instead.

pathName column cget columnDesc option

This command returns the current value of the option named option for the column specified by the column description columnDesc, ColumnDesc may also be the string tail to specify the tail column. Option may have any of the values accepted by the column configure widget command.

pathName column configure columnDesc ?option? ?value? ?option value ...?

This command is similar to the configure widget command except that it modifies options associated with the columns specified by the column description columnDesc instead of modifying options for the overall treectrl widget. ColumnDesc may be the string tail to specify the tail column. If columnDesc refers to more than one column, then at least one option-value pair must be given. If no option is specified, the command returns a list describing all of the available options for columnDesc (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) for columnDesc; in this case the command returns an empty string.

See COLUMNS below for details on the options available for columns.

pathName column compare column1 op column2

For both column descriptions column1 and column2 the index is retrieved (as returned from the column order widget command). Then these indexes are compared using the operator op, which must be either <, <=, ==, >=, >, or !=. The return value of this command is 1 if the comparison evaluated to true, 0 otherwise.

pathName column count ?columnDesc?

If no additional arguments are given, the result is a decimal string giving the number of columns created by the column create widget command which haven't been deleted by the column delete widget command; in this case the tail column is not counted. If columnDesc is given, then the result is the number of columns that match that column description.

pathName column create ?option value ...?

This command creates a new column in the treectrl widget. The new column is placed to the right of all other columns (except the tail column). Any option-value arguments configure the new column according to the column configure command. The return value is the unique identifier of the new column.

pathName column delete first ?last?

Deletes the specified column(s). First and last must be valid column descriptions. If both first and last are specified, then they may refer to a single column only. The tail column cannot be deleted and it is an error to specify it. The order of first and last doesn't matter, and first may be equal to last.

pathName column dragcget option
pathName column dragconfigure ?option? ?value? ?option value ...?

The user can move a column within a treectrl by drag-and-drop. Feedback consists of a semi-transparent photo image of the header of the column being dragged and a 2-pixel-thick vertical line to indicate where the column may be dropped. The drag image consists of a colored background rectangle plus the image and/or text displayed in the column header. The 2-pixel-thick line will be drawn over the left edge of the column before which the dragged column may be dropped.

The library scripts generate a <ColumnDrag-accept> event when the user has successfully drag-and-drop'd a column. You will have to bind a script to this event if you want to move the dragged column.

The following configuration options are supported:

-enable boolean

Controls whether the user is allowed to rearrange columns by drag-and-drop.

-imagealpha alpha

Alpha is an integer from 0 (invisible) to 255 (opaque) controlling the transparency of the drag image. Any value outside this range is clipped.

-imagecolor background

Background is the color of the drag image background rectangle.

-imagecolumn column

Column specifies the column to create the drag image from.

-imageoffset offset

Offset is the horizontal screen distance the drag image is offset from its starting position.

-indicatorcolor color

Color is the color of the 2-pixel-thick line.

-indicatorcolumn column

The 2-pixel-thick line will be drawn over the left or right edge of column.

-indicatorside side

Specifies whether the 2-pixel-thick line will be drawn over the left or right edge of the column specified by -indicatorcolumn.

pathName column index columnDesc

Deprecated. Use column id instead.

pathName column id columnDesc

This command resolves the column description columnDesc into a list of unique column identifiers. If the column(s) described by columnDesc don't exist, this command returns an empty list.

pathName column list ?-visible?

This command returns a list of identifiers for every column (except the tail) from left to right. If -visible is given, only columns whose -visible option is true are returned.

pathName column move columnDesc beforeDesc

Moves the column specified by columnDesc to the left of the column specified by beforeDesc. Both columnDesc and beforeDesc must be valid column descriptions. If beforeDesc is the string tail, the column columnDesc will become the last column.

pathName column neededwidth columnDesc

This command returns a decimal string giving the needed width of the column specified by the column description columnDesc. The needed width is the maximum of the width of the column header and the width of the widest style in any visible item.

pathName column order columnDesc ?-visible?

This command returns a decimal string giving the position of the column specified by the column description columnDesc in the list of columns starting from zero for the leftmost column. If -visible is given, only columns whose -visible option is true are considered, and -1 is returned if columnDesc's -visible option is false.

pathName column tag option ?arg arg ...?

This command is used to manipulate tags on columns. The exact behavior of the command depends on the option argument that follows the column tag argument. The following forms of the command are supported:

pathName column tag add columnDesc tagList

Adds each tag in tagList to the columns specified by the column description columnDesc. Duplicate tags are ignored. The list of tags for a column can also be changed via a column's -tags option.

pathName column tag expr columnDesc tagExpr

Evaluates the tag expression tagExpr against every column specified by the column description columnDesc. The result is 1 if the tag expression evaluates to true for every column, 0 otherwise.

pathName column tag names columnDesc

Returns a list of tag names assigned to the columns specified by the column description columnDesc. The result is the union of any tags assigned to the columns.

pathName column tag remove columnDesc tagList

Removes each tag in tagList from the columns specified by the column description columnDesc. It is not an error if any of the columns do not use any of the tags. The list of tags for a column can also be changed via a column's -tags option.

pathName column width columnDesc

This command returns a decimal string giving the width in pixels of the column specified by the column description columnDesc, even if the treectrl is configured to not display the column headers by means of the -showheader option.

pathName compare itemDesc1 op itemDesc2

Deprecated. Use the item compare command instead.

pathName configure ?option? ?value option value ...?

Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the treectrl command.

pathName contentbox

Returns a list with four elements giving the bounding box of the screen area used to display items. This is the area of the window not including borders, column headers, or locked columns. An empty string is returned if the display area has no height or width, which can happen if the window is too small.

pathName debug option ?arg arg ...?

This command is used to facilitate debugging of the treectrl widget. The exact behavior of the command depends on the option argument that follows the debug argument. The following forms of the command are supported:

pathName debug alloc

Returns a string giving partial statistics on memory allocations, if the package was built with TREECTRL_DEBUG defined.

pathName debug cget option

This command returns the current value of the debugging option named option. Option may have any of the values accepted by the debug configure widget command.

pathName debug configure ?option? ?value? ?option value ...?

This command is similar to the configure widget command except that it modifies debugging options instead of modifying options for the overall treectrl widget. If no option is specified, the command returns a list describing all of the available debugging options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given debugging option(s) to have the given value(s); in this case the command returns an empty string.

The following debugging options are supported:

-displaydelay millis

Specifies a time duration in milliseconds, which should be waited after something has been drawn to the screen. Setting this option has only an effect, if the debugging options -enable and -display are switched on.

-data boolean

If this option is switched on (together with the debugging option -enable), at various places a consistence check on the internal data structure is made (e.g. for every item is checked, if the registered number of children is equal to the number of child items). If an inconsistency was found, a Tcl background error is raised.

-display boolean

If this option is switched on (together with the debugging option -enable), at varios places additional debugging output is printed to stdout.

-drawcolor color

When specified, areas of the window are painted with this color when drawing in those areas is about to occur. Setting this option has only an effect if the debugging options -enable and -display are switched on.

-enable boolean

All other debugging options only take effect if this option is also switched on.

-erasecolor color

When specified, areas of the window which have been marked as "invalid" (for example, when part of the window is exposed) are painted with this color. If you use an unusual color for this option (like pink), superflous screen redraws can be spotted more easily. Setting this option has only an effect if the debugging options -enable and -display are switched on.

-span boolean

Debugging related to column spanning.

-textlayout boolean

Debugging related to text-element layout.

pathName debug dinfo option

Returns a string describing display-related stuff. Option must be one of alloc, ditem, onscreen or range.

pathName debug expose x1 y1 x2 y2

Causes the area of the window bounded by the given window-coords to be marked as invalid. This simulates uncovering part of the window.

pathName debug scroll

Returns a string useful for debugging vertical scrolling.

pathName depth ?itemDesc?

If the additional argument itemDesc is given, then the result is a decimal string giving the depth of the item described by itemDesc. If no itemDesc is specified, then the maximum depth of all items in the treectrl widget is returned instead. Depth is defined as the number of ancestors an item has.

pathName dragimage option ?arg ...?

This command is used to manipulate the dragimage, one or more dotted lines around rectangular regions of the treectrl widget. The exact behavior of the command depends on the option argument that follows the dragimage argument. The following forms of the command are supported:

pathName dragimage add itemDesc ?column? ?element?

Adds the shapes of the item described by itemDesc to the shapes of the dragimage. Specifying additional arguments reduces the number of rectangles that are added to the dragimage. If no additional arguments is specified, for every element of the item in every column a dotted rectangles is added. If column is specified, all elements in other columns are ignored. If also element is specified, only a rectangle for this one element of the specified item in the given column is added.

pathName dragimage cget option

This command returns the current value of the dragimage option named option. Option may have any of the values accepted by the dragimage configure widget command.

pathName dragimage clear

Removes all shapes (if there are any) from the dragimage. This command does not modify the dragimage offset.

pathName dragimage configure ?option? ?value? ?option value ...?

This command is similar to the configure widget command except that it modifies the dragimage options instead of modifying options for the overall treectrl widget. If no option is specified, the command returns a list describing all of the available dragimage options (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named dragimage option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given dragimage option(s) to have the given value(s); in this case the command returns an empty string.

The following dragimage options are supported:

-visible boolean

Specifies a boolean value which determines whether the dragimage should currently be visible.

pathName dragimage offset ?x y?

Returns a list containing the x and y offsets of the dragimage, if no additional arguments are specified. The dragimage offset is the screen distance, the image is displayed relative to the item its shape is derived from. If two coordinates are specified, sets the dragimage offset to the given coordinates x and y.

pathName element option ?element? ?arg arg ...?

This command is used to manipulate elements (see ELEMENTS below). The exact behavior of the command depends on the option argument that follows the element argument. The following forms of the command are supported:

pathName element cget element option

This command returns the current value of the option named option associated with the element given by element. Option may have any of the values accepted by the element configure widget command.

pathName element configure element ?option? ?value? ?option value ...?

This command is similar to the configure widget command except that it modifies options associated with the element given by element instead of modifying options for the overall treectrl widget. If no option is specified, the command returns a list describing all of the available options for element (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) in element; in this case the command returns an empty string. See ELEMENTS below for details on the options available for elements.

pathName element create element type ?option value ...?

Create a new elememt in pathName of type type with name element. The exact format of the arguments after type depends on type, but generally consist of specifications for zero or more element options. See the subsections on individual element types below for more on the syntax of this command. This command returns the name for the new element.

pathName element delete ?element ...?

Deletes each of the named elements and returns an empty string. If an element is deleted while it is still configured as an element of one or more styles by means of the style elements widget command, it is also removed from the element lists of these styles.

pathName element names

Returns a list containing the names of all existing elements.

pathName element perstate element option stateList

This command returns the value of the per-state option named option for element for a certain state. StateList is a list of state names (static and dynamic, see STATES) which specifies the state to use.

pathName element type element

Returns the type of the element given by element, such as rect or text.

pathName expand ?-recurse? ?itemDesc ...?

Use item expand instead.

pathName identify x y

Returns a list describing what is displayed at the given window coordinates x and y. If the coordinates are outside the window, over the borders, or over any whitespace in the window, then the result is an empty string; otherwise the first word of the result is header or item.

If the coordinates are over a column header, then the first word of the result is header, followed by the unique id of the column (or the string tail). If the x coordinate is near the left or right end of a column, then a third word left or right is appended to the result.

If the coordinates are over an item, then the first word of the result is item followed by the unique id of that item. If the coordinates are not over the area for displaying buttons and lines, then column and a unique column id are the 3rd and 4th words of the result. If the coordinates are over an element within that column, then element and an element name are the 5th and 6th words of the result.

If the coordinates are over a button, then the first word of the result is item, followed by the unique id of that item, followed by the word button.

If the coordinates are over a line descending from an ancestor of an item (but not the parent of that item), then the first word of the result is item, followed by the unique id of that item, followed by the word line, followed by the unique id of the item the line is coming from. This is used to collapse the ancestor when the line is clicked on.

pathName index itemDesc

Deprecated. Use item id instead.

pathName item option ?arg ...?

This command is used to manipulate items. The exact behavior of the command depends on the option argument that follows the item argument. The following forms of the command are supported:

pathName item ancestors itemDesc

Returns a list containing the item ids of the ancestors of the item specified by itemDesc. The first list value is the parent, the second is the parent's parent, an so on. The last list value will be the root item if itemDesc is a descendant of the root item.

pathName item bbox itemDesc ?column? ?element?

Returns a list with four elements giving the bounding box of the item described by itemDesc. If no further argument is specified, the bbox spans the area of the item over all non-locked columns. If a column is specified, only the area of the item in this column is considered. If an additional element is specified, the area of this element in column of the specified item is returned.

pathName item cget itemDesc option

Returns the current value of the configuration option for the item specified by itemDesc whose name is option. Option may have any of the values accepted by the item configure command.

pathName item children itemDesc

Returns a list containing the item ids of all children of the item specified by itemDesc in the correct order from the first child to the last child.

pathName item collapse itemDesc ?-recurse?

Switches off the open state of the item(s) described by itemDesc. If an item has descendants, then they are no longer displayed. If an item is already closed, then this command has no effect on that item. If -recurse is specified, then all descendants of the items described by itemDesc will also be collapsed. For every item that actually will be collapsed, two events are generated: a <Collapse-before> event before the item state is changed, and a <Collapse-after> event after the item state was changed.

pathName item compare itemDesc1 op itemDesc2

From both items described by the itemDescs the index is retrieved (as returned from the item order widget command). Then these indexes are compared using the operator op, which must be either <, <=, ==, >=, >, or !=. The return value of this command is 1 if the comparison evaluated to true, 0 otherwise.

pathName item complex itemDesc ?list...?

This horrible command is now deprecated. Use item element configure instead. For every column of the treectrl there may be specified one list. Each list should look like this:

{ {element option value ...} {element option value ...} ...}

Every option must be known by the element's type (see ELEMENTS below). Each option will be set to value for the element in this one column in this item.

pathName item configure itemDesc ?option? ?value? ?option value ...?

If no option is specified, returns a list describing all of the available options for the item given by itemDesc (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).

If one or more option-value pairs are specified, then the command modifies the given item option(s) to have the given value(s); in this case the command returns an empty string. This is the only case where itemDesc may refer to multiple items.

The following options are supported by this command (see item create for the meaning of each option):

-button boolean|auto
-height height
-tags tagList
-visible boolean
pathName item count ?itemDesc?

If no additional arguments are given, the result is a decimal string giving the number of items created by the item create widget command which haven't been deleted by the item delete widget command, plus 1 for the ever-present root item. If the optional argument itemDesc is given, then the result is the number of items that match that item description.

pathName item create ?option value ...?

Creates some new items and optionally returns a list of unique identifiers for those items. The new items have the states open and enabled set by default. If the treectrl widget currently has the focus, the state focus is also set.

The following options are supported by this command:

-button boolean|auto

The value of this option must have one of the forms accepted by Tcl_GetBoolean or be the word auto (or any abbreviation of it). It indicates whether or not an expand/collapse button should be drawn next to the item, typically to indicate that the item has children. If the value of this option is auto, then a button is displayed next to the item whenever the item has any children whose item option -visible is true. The button will only be displayed if:

  1. the column specified by the treectrl option -treecolumn is visible, and

  2. the treectrl option -showbuttons is true, and

  3. for the root item, the treectrl option -showrootbutton is true.

-count numItems

Specifies the number of items to create. Must be >= 0. Defaults to 1.

-height height

Specifies a fixed height in any of the forms acceptable to Tk_GetPixels. Must be >= 0. If height is zero then the item's height is unspecified. Defaults to 0.

-nextsibling itemDesc

Specifies the item before which the new items will be inserted. The new items will have the same parent as itemDesc.

-open boolean

Specifies whether the items should be open or closed. Default is true.

-parent itemDesc

Specifies the item which the new items will be the children of. The new items will be appended to the list of children of itemDesc.

-prevsibling itemDesc

Specifies the item after which the new items will be inserted. The new items will have the same parent as itemDesc.

-returnid boolean

Specifies whether or not to return a list of item identifiers for the newly created items. Specifying false is useful when creating a large number of items in the console or to improve performance. Default is true.

-tags tagList

TagList is a list of tag names to be added to the new items.

-visible boolean

Boolean must have one of the forms accepted by Tcl_GetBoolean. It indicates that the item should be displayed in the list. The item will only be displayed if: a) each ancestor is a descendant of the root item (not an orphan); and b) each ancestor's -visible option is true

pathName item delete first ?last?

Deletes the specified item(s). First and last must be valid item descriptions. If last isn't specified, then first may specify multiple items. If both first and last are specified, they must each decribe a single item with a common ancestor; then the range of items between first and last is deleted. The order of first and last doesn't matter.

Deleting an item deletes any child items of the deleted item recursively. If the current active item is deleted, the root item becomes the new active item. If the current selection anchor item is deleted, the root item becomes the new anchor item. There is no way to delete the root item of the treectrl widget; in all cases the specification of the root item is ignored.

For each call to this command, two events may be generated. If any of the deleted items are selected, then a <Selection> event is generated just before the items are deleted. If any items are going to be deleted, then an <ItemDelete> event event is generated just before the items are deleted.

pathName item descendants itemDesc

Returns a list containing the item ids of the descendants of the item specified by itemDesc, i.e. the children, grandchildren, great-grandchildren etc, of the item.

pathName item dump itemDesc

Returns a list with 4 words in the form index index indexVis indexVis.

pathName item element command itemDesc column element ?arg ...?

This command is used to manipulate elements of the item. The exact behavior of the command depends on the command argument that follows the element argument. The following forms of the command are supported:

pathName item element actual itemDesc column element option

Deprecated. Use item element perstate instead.

pathName item element cget itemDesc column element option

This command returns the value of the option named option associated with element inside column of the item described by itemDesc, if it was already configured for the actual item. Option may have any of the values accepted by the type of the specified element (see ELEMENTS below)

pathName item element configure itemDesc column element ?option? ?value? ?option value ...?

This command modifies configuration options for an element in a column of an item. If no option is specified, the command returns a list describing all of the available options for the element (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified).

If one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s) in the element inside column of the item(s) described by itemDesc; in this case the command returns an empty string. This is the only case where itemDesc may refer to multiple items.

It is possible to configure multiple elements in multiple columns with a single call. To configure another element in the same column, append a '+' argument followed by the element name. To configure elements in another column, append a ',' argument followed by the column. For example:

.t item element configure $I \
    $C1 $E1 -text "hello" + $E2 -text "world" , \
    $C2 $E3 -fill Blue , \
    $C3 $E1 -text "apples and oranges"

Each of the column description arguments to this command may refer to multiple columns if at least one option-value pair is given.

pathName item element perstate itemDesc column element option ?stateList?

This command returns the current value of the per-state option named option for element inside column of the item described by itemDesc. If stateList is specified, the list of state names (static and dynamic, see STATES) is used in place of the current state for item and column.

pathName item enabled itemDesc ?boolean?

Returns 1 if the item described by itemDesc has the state enabled switched on, 0 otherwise. If boolean is specified, then the enabled state of every item described by the item description itemDesc is set accordingly. All items are enabled when first created. Disabled items cannot be selected, and are ignored by the default key-navigation and mouse bindings.

pathName item expand itemDesc ?-recurse?

Switches on the open state of the item(s) described by itemDesc. If an item has descendants, then they are now displayed. If an item is already open, then this command has no effect on that item. If -recurse is specified, then all descendants of the items described by itemDesc will also be expanded. For every item that actually will be expanded, two events are generated: an <Expand-before> event before the item state is changed, and an <Expand-after> event after the item state was changed.

pathName item firstchild parent ?child?

If child is not specified, returns the item id of the first child of the item described by parent. If child is specified, it must describe an item that is neither the root item nor an ancestor of parent. Then it will become the new first child of parent.

pathName item id itemDesc

This command resolves the item description itemDesc into a list of unique item identifiers. If itemDesc doesn't refer to any existing items, then this command returns an empty list.

pathName item image itemDesc ?column? ?image? ?column image ...?

This command sets or retrieves the value of the per-state -image option for the first image element in one or more columns. If no column is specified, this command returns a list of values, one per column. If no image is specified, this command returns the value for column.

If one or more column-image pairs is specified, then the value of the -image option in each column is set to image. In this case itemDesc may refer to multiple items and each column may refer to multiple columns.

Note that this command is provided as a convenience. Use the item element configure or item element cget commands if you want to set or retrieve the value of the -image option for a specific image element.

pathName item isancestor itemDesc descendant

Returns 1 if the item described by itemDesc is a direct or indirect parent of the item decribed by descendant, 0 otherwise.

pathName item isopen itemDesc

Returns 1 if the item described by itemDesc has the state open switched on, 0 otherwise.

pathName item lastchild parent ?child?

If child is not specified, returns the item id of the last child of the item described by parent. If child is specified, it must describe an item that is not an ancestor of parent. Then it will become the new last child of parent.

pathName item nextsibling sibling ?next?

If next is not specified, returns the item id of the next sibling of the item described by sibling. If next is specified, it must describe an item that is not an ancestor of sibling. Then it will become the new next sibling of sibling.

pathName item numchildren itemDesc

Returns the number of children of the item described by itemDesc.

pathName item order itemDesc ?-visible?

This command returns the position of the item itemDesc relative to its toplevel ancestor (usually the root item, unless the ancestor is an orphan). If you imagine all the items flattened into a vertical list, the result of this command is the row the item falls in. If the optional argument -visible is given, only the items whose ancestors are expanded, and whose -visible option is true, get counted; in this case -1 is returned if the item is not visible.

pathName item parent itemDesc

Returns the item id of the parent of the item described by itemDesc.

pathName item prevsibling sibling ?prev?

If prev is not specified, returns the item id of the previous sibling of the item described by sibling. If prev is specified, it must describe an item that is not an ancestor of sibling. Then it will become the new previous sibling of sibling.

pathName item range first last

Returns a list containing the item ids of all items in the range between first and last, inclusive. The order between first and last doesn't matter, and the result is always sorted by the increasing order of the items (as returned by the item order command). The items specified by first and last must share a common ancestor.

pathName item remove itemDesc

Removes the item described by itemDesc from the list of children of its parent, so that it will become an orphan.

pathName item rnc itemDesc

Returns a list of two integers, which corresponds to the row and column of the item described by itemDesc. The row and column corresponds to the on-screen arrangement of items as determined by the -orient and -wrap options. If the item is not displayed, this command returns an empty string.

pathName item sort itemDesc ?option ...?

Sorts the children of the item described by itemDesc, and redisplays the tree with the items in the new order.

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 multicolumn 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. Any of the following options may be specified to control the sorting process of the previously specified column (unique abbreviations are accepted):

-ascii

Use string comparison with ASCII collation order. This is the default.

-command command

Use command as a comparison command. To compare two items, evaluate a Tcl script consisting of command with the numerical ids of the two items appended as additional arguments. The script should return an integer less than, equal to, or greater than zero if the first item is to be considered less than, equal to, or greater than the second, respectively.

-decreasing

Sort the items in decreasing order ("largest" items first).

-dictionary

Use dictionary-style comparison. This is the same as -ascii except (a) case is ignored except as a tie-breaker and (b) if two strings contain embedded numbers, the numbers compare as integers, not characters. For example, in -dictionary mode, bigBoy sorts between bigbang and bigboy, and x10y sorts between x9y and x11y.

-increasing

Sort the items in increasing order ("smallest" items first). This is the default.

-integer

Convert to integers and use integer comparison.

-real

Convert to floating-point values and use floating comparison.

pathName item span itemDesc ?column? ?numColumns? ?column numColumns ...?

This command sets or retrieves the number of columns that a style covers. If no column is specified, the return value is a list of spans, one per column. If no numColumns is specified, the return value is the span for column.

If one or more column-numColumns pairs is specified, the span for each column is set to numColumns. In this case itemDesc may refer to multiple items and each column may refer to multiple columns.

pathName item state command itemDesc ?arg ...?

This command is used to manipulate the states of an item. The exact behavior of the command depends on the command argument that follows the style argument. The following forms of the command are supported:

pathName item state forcolumn itemDesc column ?stateDescList?

Just like item state set but manipulates dynamic states for a single item column, not the item as a whole. If stateDescList is unspecified, this command returns a list containing the names of all the dynamic states which are switched on in column.

If stateDescList is specified, then itemDesc may refer to multiple items and column may refer to multiple columns.

pathName item state get itemDesc ?stateName?

If no stateName is specified, returns a list containing the names of all (static and dynamic) states which are currently switched on for the item described by itemDesc. If a stateName is specified, 1 is returned if the specified s