⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hierarchy.itk

📁 linux 下的源代码分析阅读器 red hat公司新版
💻 ITK
📖 第 1 页 / 共 5 页
字号:
# ----------------------------------------------------------------------# PUBLIC METHOD: refresh node## Performs a redraw of a specific node.  If that node is currently # not visible, then no action is taken.# ----------------------------------------------------------------------body iwidgets::Hierarchy::refresh {node} {    if {! [info exists _nodes($node)]} {	error "bad refresh node argument: \"$node\", the node doesn't exist"    }        if {! $_states($node)} {return}    foreach parent [_getHeritage $node] {	if {! $_states($parent)} {return}    }    $itk_component(list) configure -state normal -cursor watch    $itk_component(list) delete $node:start $node:end    set _markers ""    $itk_component(list) mark set insert "$node:start"    set indent $_indents($node)    _drawLevel $node $indent    foreach {name index} $_markers {        $itk_component(list) mark set $name $index    }    $itk_component(list) configure -state disabled -cursor $itk_option(-cursor)}# ------------------------------------------------------------------# THIN WRAPPED TEXT METHODS:## The following methods are thin wraps of standard text methods.# Consult the Tk text man pages for functionallity and argument# documentation.# ------------------------------------------------------------------# ------------------------------------------------------------------# PUBLIC METHOD: bbox index## Returns four element list describing the bounding box for the list# item at index# ------------------------------------------------------------------body iwidgets::Hierarchy::bbox {index} {    return [$itk_component(list) bbox $index]}# ------------------------------------------------------------------# PUBLIC METHOD compare index1 op index2## Compare indices according to relational operator.# ------------------------------------------------------------------body iwidgets::Hierarchy::compare {index1 op index2} {    return [$itk_component(list) compare $index1 $op $index2]}# ------------------------------------------------------------------# PUBLIC METHOD delete first ?last?## Delete a range of characters from the text.# ------------------------------------------------------------------body iwidgets::Hierarchy::delete {first {last {}}} {    $itk_component(list) configure -state normal -cursor watch    $itk_component(list) delete $first $last    $itk_component(list) configure -state disabled -cursor $itk_option(-cursor)}# ------------------------------------------------------------------# PUBLIC METHOD dump ?switches? index1 ?index2?## Returns information about the contents of the text widget from # index1 to index2.# ------------------------------------------------------------------body iwidgets::Hierarchy::dump {args} {    return [eval $itk_component(list) dump $args]}# ------------------------------------------------------------------# PUBLIC METHOD dlineinfo index## Returns a five element list describing the area occupied by the# display line containing index.# ------------------------------------------------------------------body iwidgets::Hierarchy::dlineinfo {index} {    return [$itk_component(list) dlineinfo $index]}# ------------------------------------------------------------------# PUBLIC METHOD get index1 ?index2?## Return text from start index to end index.# ------------------------------------------------------------------body iwidgets::Hierarchy::get {index1 {index2 {}}} {    return [$itk_component(list) get $index1 $index2]}# ------------------------------------------------------------------# PUBLIC METHOD index index## Return position corresponding to index.# ------------------------------------------------------------------body iwidgets::Hierarchy::index {index} {    return [$itk_component(list) index $index]}# ------------------------------------------------------------------# PUBLIC METHOD insert index chars ?tagList?## Insert text at index.# ------------------------------------------------------------------body iwidgets::Hierarchy::insert {args} {    $itk_component(list) configure -state normal -cursor watch    eval $itk_component(list) insert $args    $itk_component(list) configure -state disabled -cursor $itk_option(-cursor)}# ------------------------------------------------------------------# PUBLIC METHOD scan option args## Implements scanning on texts.# ------------------------------------------------------------------body iwidgets::Hierarchy::scan {option args} {    eval $itk_component(list) scan $option $args}# ------------------------------------------------------------------# PUBLIC METHOD search ?switches? pattern index ?varName?## Searches the text for characters matching a pattern.# ------------------------------------------------------------------body iwidgets::Hierarchy::search {args} {    return [eval $itk_component(list) search $args]}# ------------------------------------------------------------------# PUBLIC METHOD see index## Adjusts the view in the window so the character at index is # visible.# ------------------------------------------------------------------body iwidgets::Hierarchy::see {index} {    $itk_component(list) see $index}# ------------------------------------------------------------------# PUBLIC METHOD tag option ?arg arg ...?## Manipulate tags dependent on options.# ------------------------------------------------------------------body iwidgets::Hierarchy::tag {op args} {    return [eval $itk_component(list) tag $op $args]}# ------------------------------------------------------------------# PUBLIC METHOD window option ?arg arg ...?## Manipulate embedded windows.# ------------------------------------------------------------------body iwidgets::Hierarchy::window {option args} {    return [eval $itk_component(list) window $option $args]}# ----------------------------------------------------------------------# PUBLIC METHOD: xview args## Thin wrap of the text widget's xview command.# ----------------------------------------------------------------------body iwidgets::Hierarchy::xview {args} {    return [eval itk_component(list) xview $args]}# ----------------------------------------------------------------------# PUBLIC METHOD: yview args## Thin wrap of the text widget's yview command.# ----------------------------------------------------------------------body iwidgets::Hierarchy::yview {args} {    return [eval $itk_component(list) yview $args]}# ----------------------------------------------------------------------# PUBLIC METHOD: expanded node## Tells if a node is expanded or collapsed## Douglas R. Howard, Jr.# ----------------------------------------------------------------------body iwidgets::Hierarchy::expanded {node} {    if {! [info exists _states($node)]} {	error "bad collapse node argument: \"$node\", the node doesn't exist"    }        return $_states($node)}# ----------------------------------------------------------------------# PUBLIC METHOD: expState## Returns a list of all expanded nodes## Douglas R. Howard, Jr.# ----------------------------------------------------------------------body iwidgets::Hierarchy::expState {} {    set nodes [_contents ""]    set open ""    set i 0    while {1} {	if {[info exists _states([lindex $nodes $i])] &&	$_states([lindex $nodes $i])} {	    lappend open [lindex $nodes $i]	    foreach child [_contents [lindex $nodes $i]] {		lappend nodes $child	    }	}	incr i	if {$i >= [llength $nodes]} {break}    }        return $open}# ------------------------------------------------------------------#                       PROTECTED METHODS# ------------------------------------------------------------------# ----------------------------------------------------------------------# PROTECTED METHOD: _drawLevel node indent## Used internally by draw to draw one level of the hierarchy.# Draws all of the nodes under node, using the indent string to# indent nodes.# ----------------------------------------------------------------------body iwidgets::Hierarchy::_drawLevel {node indent} {    lappend _markers "$node:start" [$itk_component(list) index insert]    set bg [$itk_component(list) cget -background]    #    # Obtain the list of subnodes for this node and cycle through    # each one displaying it in the hierarchy.    #    foreach child [_contents $node] {	set _images($child) "$itk_component(list).hicon[incr _hcounter]"        if {![info exists _states($child)]} {            set _states($child) $itk_option(-expanded)        }	#	# Check the user tags to see if they have been kind enough	# to tell us ahead of time what type of node we are dealing	# with branch or leaf.  If they neglected to do so, then	# get the contents of the child node to see if it has children	# itself.	#	set display 0	if {[lsearch $_tags($child) leaf] != -1} {	    set type leaf	} elseif {[lsearch $_tags($child) branch] != -1} {	    set type branch	} else {	    if {[llength [_contents $child]] == 0} {		set type leaf	    } else {		set type branch	    }	}	#	# Now that we know the type of node, branch or leaf, we know	# the type of icon to use.	#	if {$type == "leaf"} {            set icon $itk_option(-nodeicon)            eval $_filterCode	} else {            if {$_states($child)} {                set icon $itk_option(-openicon)            } else {                set icon $itk_option(-closedicon)            }            set display 1	}	#	# If display is set then we're going to be drawing this node.	# Save off the indentation level for this node and do the indent.	#	if {$display} {	    set _indents($child) "$indent\t"	    $itk_component(list) insert insert $indent	    #	    # Add the branch or leaf icon and setup a binding to toggle	    # its expanded/collapsed state.	    #	    label $_images($child) -image $icon -background $bg 	    # DRH - enhanced and added features that handle image clicking,	    # double clicking, and right clicking behavior	    bind $_images($child) <ButtonPress-1> \	      "[code $this toggle $child]; [code $this _imageSelect $child]"	    bind $_images($child) <Double-1> [code $this _imageDblClick $child]	    bind $_images($child) <ButtonPress-3> \	      [code $this _imagePost $child $_images($child) $type %x %y]	    $itk_component(list) window create insert -window $_images($child)	    #	    # If any user icons exist then draw them as well.  The little	    # regexp is just to check and see if they've passed in a	    # command which needs to be evaluated as opposed to just	    # a variable.  Also, attach a binding to call them if their	    # icon is selected.	    #	    if {[info exists _icons($child)]} {		foreach image $_icons($child) {		    set wid "$itk_component(list).uicon[incr _ucounter]"		    if {[regexp {\[.*\]} $image]} {			eval label $wid -image $image -background $bg 		    } else {			label $wid -image $image -background $bg 		    }		    # DRH - this will bind events to the icons to allow		    # clicking, double clicking, and right clicking actions.		    bind $wid <ButtonPress-1> \			    [code $this _iconSelect $child $image]		    bind $wid <Double-1> \			    [code $this _iconDblSelect $child $image]		    bind $wid <ButtonPress-3> \			    [code $this _imagePost $child $wid $type %x %y]		    $itk_component(list) window create insert -window $wid		}	    }	    #	    # Create the list of tags to be applied to the text.  Start	    # out with a tag of "info" and append "hilite" if the node	    # is currently selected, finally add the tags given by the	    # user.	    #	    set texttags [list "info" $child]	    if {[info exists _selected($child)]} {		lappend texttags hilite	    } 	    foreach tag $_tags($child) {		lappend texttags $tag	    }	    #	    # Insert the text for the node along with the tags and 	    # append to the markers the start of this node.  The text	    # has been broken at newlines into a list.  We'll make sure	    # that each line is at the same indentation position.	    #	    set firstline 1	    foreach line $_text($child) {		if {$firstline} {		    $itk_component(list) insert insert " "		} else {		    $itk_component(list) insert insert "$indent\t"		}		$itk_component(list) insert insert $line $texttags "\n"		set firstline 0	    }	    lappend _markers "$child:start" [$itk_component(list) index insert]	    #	    # If the state of the node is open, proceed to draw the next 	    # node below it in the hierarchy.	    #	    if {$_states($child)} {		_drawLevel $child "$indent\t"	    }	}    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -