Bwidget Source Code
Check-in [6bdb5e8a71]
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:Slight modification to algorithm to handle non-visible nodes.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6bdb5e8a71f5feb9875c9812528504332182d676
User & Date: ericm 2000-02-11 00:16:30
Context
2000-02-11
22:54
* tree.tcl: Integrated changes from Eric Boudaillier: [itemconfigure -open ...] optimized to only call redraw_idle 3 if node has subnodes. _cross_event: itemconfigure -open called before -opencmd/closecmd; no more call to _redraw_idle (handled by other procedures) _over_cmd: allow position {root 0} when tree is empty new [find] command: [find @x,y ?confine?] if confine is "confine" returns the node at window coordinate x,y (x,y must be inside the bbox of the node) else returns the node found on the line (in pixel) pixel y [find line] returns the node on the line $line (in -deltay coords) new [line] command: [line node] returns the line where node is drawn -selectfill option added: if true, selection is draw on full width of tree (instead of just highlighting the bbox of the selected nodes)

* combobox.tcl: Integrated changes from Eric Boudaillier: internal widget restructuring.

* tree.tcl: Added "range" subcommand to selection. Given two nodes, node1 and node2, it will set the selection to the visible nodes between (and including) node1 and node2. If node1 or node2 is not visible, it will find the first visible ancestor of the node and use that as the start/end point instead.

* listbox.tcl: Integrated changes from Eric Boudaillier: _over_cmd: allow position 0 when listbox is empty find command, similar to tree find command.

* spinbox.tcl: Integrated changes from Eric Boudaillier: cosmetic changes.

* color.tcl: Integrated changes from Eric Boudaillier: split widget into two commands: SelectColor::menu and SelectColor::dialog.

* progressbar.tcl: Integrated changes from Eric Boudaillier: added -idle option to prevent call to update in case where task is done in idle (ie, fileevents)

* scrollview.tcl: Integrated changes from Eric Boudaillier: bindings changed.

* scrollw.tcl: Integrated changes from Eric Boudaillier: -managed option: if true, scrollbar are managed during creation, so their size are included in the requested size of the ScrolledWindow. If false, they are not. -sides option: specifies the side of the scrollbar. -size option: specifies size of scrollbar. -ipad option: specifies pad between scrollbar and scrolled widget.

* mainframe.tcl: Integrated changes from Eric Boudaillier: support for function keys in accelerators, support for no modifier in accelerators.

* notebook.tcl: Integrated changes from Eric Boudaillier: -internalborderwidth (-ibd) option specifies pad around pages; -foreground, -background, -activeforeground, -activebackground, -disabledforeground options for each tab. Code cleanup. check-in: 651774cb09 user: ericm tags: trunk

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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tree.tcl.

1
2
3
4
5
6
7
8
9
10
11
...
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
# ------------------------------------------------------------------------------
#  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
................................................................................
	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}]
		}


|







 







|
<
<
<
<
<
<











>
|
>
>
>
|
>
>







1
2
3
4
5
6
7
8
9
10
11
...
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
# ------------------------------------------------------------------------------
#  tree.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: tree.tcl,v 1.7 2000/02/11 00:16:30 ericm Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - Tree::create
#     - Tree::configure
#     - Tree::cget
#     - Tree::insert
#     - Tree::itemconfigure
................................................................................
	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.






	    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
		    }
		}

		# Find the first visible ancestor of node1, starting with node1
		while {[set index1 [lsearch -exact $nodes $node1]] == -1} {
		    set node1 [lindex $data($node1) 0]
		}
		# Find the first visible ancestor of node2, starting with node2
		while {[set index2 [lsearch -exact $nodes $node2]] == -1} {
		    set node2 [lindex $data($node2) 0]
		}
		# 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}]
		}