📄 node.tk
字号:
set xpos [lindex $pos 0] set ypos [lindex $pos 3] } } else { set previd [nodeLineGet $nodeframe $lineno [expr $groupno - 1]] set pos [$ncanv bbox $previd] set xpos [lindex $pos 2] set ypos [lindex $pos 1] } set textid [$ncanv create text $xpos $ypos -anchor nw \ -text $text -tags "text $nodeframe" \ -font $text_font \ -fill $canvas(bigFg) -justify left] nodeLinePut $nodeframe $lineno $groupno $textid}proc nodeAddLineText { nodeframe lineno listOfText } { if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set g 0 foreach text $listOfText { nodeAddText $nodeframe $lineno $g $text incr g }}proc nodeMatchItemTag {nodeframe itemid tag} { if {[string compare $nodeframe ""] == 0 || \ [string compare $itemid ""] == 0} { return 0 } set canv [nodeCanvasGet $nodeframe] set tags [lindex [$canv itemconfigure $itemid -tags] end] if {[lsearch -exact $tags $tag] != -1} { return 1 } return 0}proc nodeModText { nodeframe lineno groupno text } { if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set textid [nodeLineGet $nodeframe $lineno $groupno] if [nodeMatchItemTag $nodeframe $textid text] { set oldtext [lindex [$ncanv itemconfigure $textid -text] end] if {[string compare $text $oldtext] != 0} { $ncanv itemconfigure $textid -text $text return 1 } } else { catch {$ncanv delete $textid} nodeAddText $nodeframe $lineno $groupno $text return 1 } return 0}proc nodeRemLineEntry { nodeframe lineno groupno } { global canvas if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set array [string trimleft $nodeframe .] global $array set j $groupno set item [nodeLineGet $nodeframe $lineno $j] while {[string compare $item ""] != 0} { $ncanv delete $item catch {unset ${array}(line,$lineno,$j)} incr j set item [nodeLineGet $nodeframe $lineno $j] }}proc nodeModLineText { nodeframe lineno listOfText } { if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set g 0 foreach text $listOfText { nodeModText $nodeframe $lineno $g $text incr g } nodeRemLineEntry $nodeframe $lineno $g}proc nodeRemLines { nodeframe lineno } { global canvas if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set array [string trimleft $nodeframe .] global $array set i $lineno set item [nodeLineGet $nodeframe $i 0] while {[string compare $item ""] != 0} { nodeRemLineEntry $nodeframe $i 0 incr i set item [nodeLineGet $nodeframe $i 0] }}proc nodeScaleCreate {nodeframe lineno groupno value} { global canvas if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set vtype [nodeViewTypeGet $nodeframe] switch -exact -- $vtype { MIRROR { set scale_factor $canvas(mirrorScaleFactor) set text_font $canvas(bigTextFont) set text_width $canvas(bigTextFontWidth) set text_height $canvas(bigTextFontHeight) } default { set scale_factor $canvas(nodeScaleFactor) set text_font $canvas(smallTextFont) set text_width $canvas(smallTextFontWidth) set text_height $canvas(smallTextFontHeight) } } if {$groupno == 0} { set xpos $text_width set ypos $text_height if {$lineno > 0} { set previd [nodeLineGet $nodeframe \ [expr $lineno - 1] 0] set pos [$ncanv bbox $previd] set xpos [lindex $pos 0] set ypos [lindex $pos 3] } } else { set previd [nodeLineGet $nodeframe $lineno [expr $groupno - 1]] set pos [$ncanv bbox $previd] set xpos [lindex $pos 2] set ypos [lindex $pos 1] } set valabel "$value%" set vlen [string length $valabel] for {set i [string length $valabel]} {$i < 10} {incr i} { set valabel "$valabel " } if [catch {expr $value * $scale_factor} val] { InfoBox_sendmsg "nodeScaleCreate: Received val: $val" 2 return "" } set textid [$ncanv create text $xpos $ypos -anchor nw \ -text "$valabel" -tags [list scale \ $lineno$groupno$nodeframe \ text.$lineno$groupno$nodeframe] \ -fill $canvas(smallFg) -justify left \ -font $text_font -justify right] if [catch {expr 101 * $scale_factor} width] { InfoBox_sendmsg "nodeScaleCreate: Received width: $width" 2 return "" } set pos [$ncanv bbox $textid] set x1pos [lindex $pos 2] set y1pos [lindex $pos 1] set y2pos [expr ($y1pos + $text_height) - 3] set x2pos [expr $x1pos + $width] set trid [$ncanv create rect $x1pos $y1pos $x2pos $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorTrough)] if {$val > $width} { set diff [expr ($val - $width) + 1] set slid [$ncanv create rect $x1pos $y1pos $x2pos $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorSlider)] set textd [$ncanv create rect $x2pos $y1pos \ [expr $x2pos + $diff] $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorExtendedTrough)] } else { set slid [$ncanv create rect $x1pos $y1pos \ [expr $x1pos + $val] $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorSlider)] } nodeLinePut $nodeframe $lineno $groupno $lineno$groupno$nodeframe}proc nodeScaleReCreate {nodeframe lineno groupno newvalue} { global canvas if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set vtype [nodeViewTypeGet $nodeframe] switch -exact -- $vtype { MIRROR { set scale_factor $canvas(mirrorScaleFactor) set text_font $canvas(bigTextFont) set text_width $canvas(bigTextFontWidth) set text_height $canvas(bigTextFontHeight) } default { set scale_factor $canvas(nodeScaleFactor) set text_font $canvas(smallTextFont) set text_width $canvas(smallTextFontWidth) set text_height $canvas(smallTextFontHeight) } } set valabel "$newvalue%" set vlen [string length $valabel] for {set i [string length $valabel]} {$i < 10} {incr i} { set valabel "$valabel " } set oldlabel \ [lindex [$ncanv itemconfigure text.$lineno$groupno$nodeframe -text] end] if {[string compare $valabel $oldlabel] != 0} { if [catch {expr $newvalue * $scale_factor} val] { InfoBox_sendmsg "nodeScaleReCreate: Received val: $val" 2 return "" } catch {$ncanv delete scale.$lineno$groupno$nodeframe} if [catch {expr 101 * $scale_factor} width] { InfoBox_sendmsg "nodeScaleReCreate: Received width: $width" 2 return "" } $ncanv itemconfigure text.$lineno$groupno$nodeframe \ -text $valabel set pos [$ncanv bbox text.$lineno$groupno$nodeframe] set x1pos [lindex $pos 2] set y1pos [lindex $pos 1] set y2pos [expr ($y1pos + $text_height) - 3] set x2pos [expr $x1pos + $width] set trid [$ncanv create rect $x1pos $y1pos $x2pos $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorTrough)] if {$val > $width} { set diff [expr ($val - $width) + 1] set slid [$ncanv create rect $x1pos $y1pos \ $x2pos $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorSlider)] set textd [$ncanv create rect $x2pos $y1pos \ [expr $x2pos + $diff] $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorExtendedTrough)] } else { set slid [$ncanv create rect $x1pos $y1pos \ [expr $x1pos + $val] $y2pos \ -tags [list scale \ $lineno$groupno$nodeframe \ scale.$lineno$groupno$nodeframe] \ -fill $canvas(nodeColorSlider)] } }}proc nodeAddLineScale { nodeframe lineno param } { if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set label [lindex $param 0] set valabel [lindex $param 1] nodeAddText $nodeframe $lineno 0 $label if {[string compare $valabel ""] != 0} { nodeScaleCreate $nodeframe $lineno 1 $valabel }}proc nodeModLineScale { nodeframe lineno newContent } { if {[string compare $nodeframe ""] == 0} { return } set ncanv [nodeCanvasGet $nodeframe] set label [lindex $newContent 0] set valabel [lindex $newContent 1] nodeModText $nodeframe $lineno 0 $label if {[string compare $valabel ""] != 0} { if { [string compare [nodeLineGet $nodeframe $lineno 1] \ ${lineno}1${nodeframe}] == 0 } { nodeScaleReCreate $nodeframe $lineno 1 $valabel nodeRemLineEntry $nodeframe $lineno 2 } else { nodeRemLineEntry $nodeframe $lineno 1 nodeScaleCreate $nodeframe $lineno 1 $valabel } } else { nodeRemLineEntry $nodeframe $lineno 1 }}proc nodeFindXCs {nodeframe startl endl} { if {[string compare $nodeframe ""] == 0} { return } set canv [nodeCanvasGet $nodeframe] set i $startl set j 0 set item [nodeLineGet $nodeframe $i $j] while {[string compare $item ""] != 0} { while {[string compare $item ""] != 0} { set coords [$canv bbox $item] set x1 [lindex $coords 0]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -