📄 mainwin.tcl
字号:
# you change these. Legend_Create $w.legend $mainwin($w,log) $widget_width set labeltitle [ $log creator ] #puts stdout "$labeltitle"# frame $w.titlelegend canvas $w.titlelegend label $w.titlelegend.label -text "Logfile title:"# label $w.titlelegend.val -text "$labeltitle" text $w.titlelegend.val -height 1 $w.titlelegend.val insert 1.0 "$labeltitle" pack $w.titlelegend.label $w.titlelegend.val -fill x -side left frame $w.bottom # these names are assumed int SetScrollsLeft and SetScrollsSpan # if you change the names here, change them there # attach time labels and a scrollbar to the whole mess time_lbl $w.bottom.tlbl [$log starttime] [$log endtime] # -font $font scrollbar $w.bottom.xscroll -command "SetXview $w" -orient horiz # create list of windows that are scrollable set mainwin($w,scrollers) [list $w.bottom.tlbl $w.bottom.xscroll] # set mainwin($w,scrollers) {} # Let's hope this doesn't change much set scroll_width 19 set right_gap $scroll_width frame $w.bottom.left_gap -width $left_gap frame $w.bottom.right_gap -width $right_gap pack $w.bottom.left_gap -side left -fill y pack $w.bottom.right_gap -side right -fill y pack $w.bottom.tlbl $w.bottom.xscroll -fill x # might want to throw in a static scale for the scrollbar pack $w.controls -fill x # pack $w.sep -fill x -padx 15 -pady 4 pack $w.legend -fill x pack $w.titlelegend -fill x pack $w.bottom -side bottom -fill x # why did I put this here? Ah, so the reqheight's and stuff # will work. update idletasks set maxheight [expr ([winfo screenheight .] - \ [winfo reqheight $w.menu] - \ [winfo reqheight $w.controls] - \ [winfo reqheight $w.legend] - \ [winfo reqheight $w.titlelegend] - \ [winfo reqheight $w.bottom] - 40) / [llength $displays]] # fudge factor of 40 for the window manager's border # What to do if this is really small? # xscrollcommand - command that everyone should call to update the scrollbar # -xscrollcommand "ScrollDisplays $w" # * removed * # timevar - variable that everyone should set to represent the current time # the cursor is hovering over # setzoomptcmd - command that anyone can call if the user selects # a new zoom point (in time) # maxheight - maximum height for any of the displays # scan - command that every should call to update the horizontal # position of other displays if the display gets scanned # Open a display widget display $w.displays $w $log \ -timevar "ptrtime($w)" \ -setzoomptcmd "Zoom_SetTime $w" \ -maxheight $maxheight \ -scan "SetLeft $w" # open up each display and pack 'em into the display widget foreach display $displays { # have each display send scroll commands to a central # point, attach to the same log, and tell a certain # 'ptrtime($w)' variable what time the pointer # is over $w.displays add $display end {} } pack $w.displays -fill both -expand 1 if $mainwin($w,is_root_win) { set win . } else { set win $w } #wm minsize $win [winfo reqwidth $win] [winfo reqheight $win] wm minsize $win \ [maximum [list [winfo reqwidth $w.menu] \ [winfo reqwidth $w.controls]]] \ [expr [winfo reqheight $w.menu] + \ [winfo reqheight $w.controls] + \ [winfo reqheight $w.legend] + \ [winfo reqheight $w.titlelegend] + \ [winfo reqheight $w.bottom]] set mainwin($w,totalTime) [expr [$log endtime] - [$log starttime]] set mainwin($w,span) $mainwin($w,totalTime) set mainwin($w,left) [$log starttime] set mainwin($w,windowUnits) [expr [winfo reqwidth $w.displays]/10+1] set mainwin($w,totalUnits) [expr $mainwin($w,windowUnits) * \ $mainwin($w,totalTime) / $mainwin($w,span)] # not empty anymore set mainwin($w,empty) 0 # this command sets the horizontal scrollbar, time labels, # and the position of each of the displays, in units of # seconds SetView $w $mainwin($w,left) $mainwin($w,span) # go back to normal cursor LookBored $w update idletasks}proc SetXview {win xview} { global mainwin # The scrollbars have this funny notion that every is speaking in terms # of 10000 units. Change their words around to seconds before anyone # think the scrollbars are loony. Then tell everyone else the new # left edge. if {$xview < 0} {set xview 0} if {$xview > 10000-$mainwin($win,windowUnits)} { set xview [expr 10000-$mainwin($win,windowUnits)] } set left [expr $xview*$mainwin($win,totalTime)/10000.0+ \ $mainwin($win,startTime)] SetLeft $win $left}proc SetLeft {win left} { global mainwin set mainwin($win,left) $left SetScrollsLeft $win $left foreach disp [$win.displays list] { $disp setleft $left } $win.bottom.tlbl setview $left $mainwin($win,span)}proc SetView {win left span} { global mainwin set mainwin($win,left) $left set mainwin($win,span) $span SetScrollsView $win $left $span foreach disp [$win.displays list] { $disp setview $left $span } $win.bottom.tlbl setview $left $span}proc SetScrollsLeft {win x} { global mainwin set log $mainwin($win,log) set l [expr int(10000.0*($x-$mainwin($win,startTime)) / \ ($mainwin($win,totalTime)))] set r [expr $l+$mainwin($win,windowUnits)] # puts "telling the scrollbars 10000 $mainwin($win,windowUnits) $l $r" $win.bottom.xscroll set 10000 $mainwin($win,windowUnits) $l $r}proc SetScrollsView {win left span} { global mainwin # always set totalUnits to 10000 if 0 { set w [expr int([winfo width $win]/10)+1] set t [expr int($w*$mainwin($win,totalTime)/$span)] } set mainwin($win,windowUnits) \ [expr int(10000.0*$span/$mainwin($win,totalTime))] set l [expr int(10000.0*($left-$mainwin($win,startTime)) / \ ($mainwin($win,totalTime)))] set r [expr $l+$mainwin($win,windowUnits)] # puts "telling the scrollbars 10000 $mainwin($win,windowUnits) $l $r" $win.bottom.xscroll set 10000 $mainwin($win,windowUnits) $l $r}## send an 'xview' command to each of the display widgets, keeping# them all in sync## mainwin($id,ndisplays) should be set to the number of displays# The displays should be the windows $id.display.[0 -> (n-1)]#proc XviewAll {id xview} { global mainwin foreach disp [$id.displays list] { # puts "$disp xview $xview" $disp xview $xview }} # send a 'set' command to all the x-scrolling widgets on this windowproc ScrollDisplays {id t w l r} { global mainwin foreach scroller $mainwin($id,scrollers) { # puts "$scroller set $t $w $l $r" $scroller set $t $w $l $r }}proc OpenDisplay {frame cmd log} { # separate out the widget command and the arguments set args [lrange $cmd 1 end] set widget [lindex $cmd 0] # puts "OpenDisplay $frame $cmd $log" eval $widget $frame $log $args}proc ExitUpshot {} { exit}proc CloseFile win { # Where did these come from?! # displays, display_left_gap, display widget width destroy $win}proc AddLogManipulationButtons {win} { AddZoomMenu $win $win.menu.zoom AddDisplayMenu $win $win.menu.display pack $win.menu.display $win.menu.zoom -side left}proc Create_Controls {frame win log} { frame $frame # display of the time the pointer is currently at frame $frame.time label $frame.time.lbl -text "Pointer: " entry $frame.time.val -relief sunken -textvariable ptrtime($win) label $frame.units -text "(in seconds)" pack $frame.time.lbl $frame.time.val -side left # zoom buttons frame $frame.z button $frame.z.ih -bitmap zoom_in_horiz -command \ "Zoom $win $win.displays horiz 2" button $frame.z.oh -bitmap zoom_out_horiz -command \ "Zoom $win $win.displays horiz .5" # button $frame.z.iv -bitmap zoom_in_vert -command \ "Zoom $win $win.displays vert 2" # button $frame.z.ov -bitmap zoom_out_vert -command \ "Zoom $win $win.displays vert .5" # pack $frame.z.ih $frame.z.oh $frame.z.iv $frame.z.ov -side left button $frame.z.r -text "Reset view" -command \ "Zoom $win $win.displays reset" pack $frame.z.ih $frame.z.oh -side left -padx 5 pack $frame.z.r -side left -padx 5 pack $frame.time $frame.units $frame.z -side left -padx 5 -pady 3}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -