Bwidget Source Code
Check-in [3c515a19e2]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:* tree.tcl: Added "range" subcommand to selection. Given two visible nodes, node1 and node2, it will set the selection to the visible nodes between (and including) node1 and node2.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3c515a19e23dda95ba63f782f573337d1bb5f430
User & Date: ericm 2000-02-11 00:07:50
Context
2000-02-11
00:16
Slight modification to algorithm to handle non-visible nodes. check-in: 6bdb5e8a71 user: ericm tags: trunk
00:07
* tree.tcl: Added "range" subcommand to selection. Given two visible nodes, node1 and node2, it will set the selection to the visible nodes between (and including) node1 and node2. check-in: 3c515a19e2 user: ericm tags: trunk
2000-02-08
17:48
Added support to the Entry widget for the -validate {none focus focusin focusout key all} -invalidcommand -validatecommand -invcmd and -vcmd flags to support the validation features of the entry widget. These flags simply are passed down to the underlying entry widget if they are specified. They work identically to the flag descriptions given in the entry man page. check-in: 9f740baa74 user: kuchler tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tree.tcl.

1
2
3
4
5
6
7
8
9
10
11
...
456
457
458
459
460
461
462

463
464
465
466
467
468






































469
470
471
472
473
474
475
# ------------------------------------------------------------------------------
#  tree.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: tree.tcl,v 1.5 1999/11/05 03:38:55 ericm Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - Tree::create
#     - Tree::configure
#     - Tree::cget
#     - Tree::insert
#     - Tree::itemconfigure
................................................................................
		    uplevel \#0 $selectcmd
		}
	    }
        }
        add {
            foreach node $args {
                if { [info exists data($node)] } {

                    if { [lsearch $data(selnodes) $node] == -1 } {
                        lappend data(selnodes) $node
                    }
                }
            }
        }






































        remove {
            foreach node $args {
                if { [set idx [lsearch $data(selnodes) $node]] != -1 } {
                    set data(selnodes) [lreplace $data(selnodes) $idx $idx]
                }
            }
        }


|







 







>
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
...
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# ------------------------------------------------------------------------------
#  tree.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: tree.tcl,v 1.6 2000/02/11 00:07:50 ericm Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - Tree::create
#     - Tree::configure
#     - Tree::cget
#     - Tree::insert
#     - Tree::itemconfigure
................................................................................
		    uplevel \#0 $selectcmd
		}
	    }
        }
        add {
            foreach node $args {
                if { [info exists data($node)] } {
		    if { [Widget::getoption $path.$node -selectable] } {
			if { [lsearch $data(selnodes) $node] == -1 } {
			    lappend data(selnodes) $node
			}
		    }
                }
            }
        }
	range {
	    # Here's our algorithm:
	    #   make a list of all nodes, then take the range from node1
	    #       to node2 and select those nodes
	    # This works because of how this widget handles redraws:
	    # the tree is always completely redraw, always from top to bottom.
	    # So the list of visible nodes *is* the list of nodes, and we can
	    # use that to decide which nodes to select.  NOTE:  if node1
	    # is not actually drawn on the canvas (for example, it is in an
	    # unexpanded branch), this will NOT WORK because we will get
	    # a bogus index in the nodelist for that node.  The question is,
	    # what can we do about it?  Probably the right thing to do is
	    # to not rely on canvas visibility and _really_ do the range on
	    # the tree.  That's hard though.
	    foreach {node1 node2} $args break
	    if { [info exists data($node1)] && [info exists data($node2)] } {
		set nodes {}
		foreach nodeItem [$path:cmd find withtag node] {
		    set node [string range \
			    [lindex [$path:cmd gettags $nodeItem] 1] 2 end]
		    if { [Widget::getoption $path.$node -selectable] } {
			lappend nodes $node
		    }
		}

		set index1 [lsearch -exact $nodes $node1]
		set index2 [lsearch -exact $nodes $node2]
		# If the nodes were given in backwards order, flip the
		# indices now
		if { $index2 < $index1 } {
		    incr index1 $index2
		    set index2 [expr {$index1 - $index2}]
		    set index1 [expr {$index1 - $index2}]
		}
		set data(selnodes) [lrange $nodes $index1 $index2]
	    }
	}
        remove {
            foreach node $args {
                if { [set idx [lsearch $data(selnodes) $node]] != -1 } {
                    set data(selnodes) [lreplace $data(selnodes) $idx $idx]
                }
            }
        }