|
From: Joe E. <jen...@fl...> - 2006-09-21 18:22:38
|
Now in CVS: treeview item tags.
Treeview tags are inspired by the core [text] and [canvas] widgets;
they're used to associate event binding scripts with items and
to configure the item appearance. Updated manpage here:
<URL: http://tktable.sourceforge.net/tile/doc/treeview.html >
In the [text] widget, each character has a set of tags; configuration
options are set on tags; and tag precedence order is global to the whole
widget. In the [canvas] widget, each item has a list of tags; and
configuration options are set on *items* and modified *through* tags
(i.e., [$canvas tag configure foo ...] only applies to items that currently
have tag 'foo').
The treeview widget takes yet a third approach: each item has
an ordered list of tags, specified by the '-tags' item option;
configuration options are stored on tags, and are applied to
items dynamically; tag precedence order is per-item, determined
by the -tags option list order.
There are two new tag-related commands:
$tv tag bind _tag_ ?<sequence> ?script....??
Specifies an event binding script for the specified tag.
When an event is delivered to an item, matching binding scripts
for each of the item's tags are evaluated in order
as per bindtags(n).
<KeyPress>, <KeyRelease>, and virtual events are sent
to the focus item. <ButtonPress>, <ButtonRelease>,
and <Motion> events are sent to the item under the mouse pointer.
No other event types are supported.
$tv tag configure _tag_ ?-option ?value ...??
Query or modify tag options. Available options are:
-foreground, -background, -font; and possibly -image,
-text, and -anchor.
There are still some kinks to work out with [$tv tag configure ...],
mostly related to the order of precedence relative to style options,
style dynamic settings, item options, and column options.
[$tv tag bind ...] works pretty well though.
Possible future enhancements:
* Column names are tags.
Automatically apply an additional tag to each data cell corresponding
to its column name. This would allow bindings and configuration options
to be applied to individual columns.
* $tv tag map -option ?statespec value ...?
Specify state-specific option settings for tags, analogous
to [style map ...].
* Convenience methods for tag modification:
[$tv tag ...] subcommands to add, remove, raise, lower, and/or otherwise
reorder item tags, either globally or for a specified list of items.
* Convenience methods for searching:
[$tv tag ...] subcommand to return a list of all items having
a specified tag or set of tags.
* -rowtags and -columntags widget options.
Right now, you get "zebra stripes" in the treeview widget
whether you want them or not. "-rowtags" would specify
a cyclic list of tags to apply to each display row in
order (if -rowtags is an $n-element list, then tag
($i % $n) is applied to display row $i). So for example
the current zebra-stripe effect could be achieved with:
$tv configure -rowtags [list even odd]
$tv tag configure even -background #EEEEEE
The -rowtags list can contain any number of elements,
so longer repeating patterns are possible.
-columntags would work the same way.
* %I (current item), %C (current column), and %T (current tag)
substitutions in tag binding scripts. This isn't strictly
necessary since the same information is available with
[$tv identify ...] and [$tv focus]; and I'd rather not
have to do it if possible as this involves pretty much
completely rewriting Tk_BindEvent() and related functions;
but it might end up being necessary for:
* Support <Enter>/<Leave> and <FocusIn>/<FocusOut> events
Send <Leave>/<Enter> events (resp Focus events) when the
active item (resp focus item) changes.
Coming up next: treeview -selectmode option.
--Joe English
jen...@fl...
|