📄 mainwin.tcl
字号:
## Main window control for Upshot## Ed Karrels# Argonne National Laboratory### mainwin structure:## index format: <id>,<fieldName># id: the window name of the toplevel window# fieldName: one of the following:## log - logfile widget this window is associated with# needs_menus - whether this window needs menus to be created yet# empty - whether this window is currently empty; without a# logfile or display# is_root_win - whether this is the main window, which must remain# open through the life of the program. If it is, the# last option in the <logfile> menu will be 'Exit Nupshot',# as opposed to 'Close frame' for all other toplevel windows.# scrollers - list of all the windows that need to be sent# horizontal scroll information# displays - list of displays currently visible. For example,# {timeline mtn {msgq recv 3}}# endTime, startTime - from the logfile# totalTime - legth of the logfile: endTime - startTime# span - time span of the current visible range# left - time displayed at the far left of the current visible range# * note * these are referred to in # totalUnits, windowUnits - saved for scrollbars, these depict the# ratio between the time span visible and the total length of the# logfile# procWidth - width of process names widgetproc NewWin {win is_root_win {logfile {}}} { # $logfile will be the default file open global mainwin color # initialize data for this window if [info exists mainwin($win,log)] { unset mainwin($win,log) } set mainwin($win,empty) 1 set mainwin($win,needs_menus) 1 set mainwin($win,is_root_win) $is_root_win if {$logfile == ""} { set title "Nupshot" } else { set title "Nupshot - $logfile" } if !$is_root_win { toplevel $win wm title $win $title } # create funky colored background frame frame $win.menu -relief raised -border 3 -back $color(menubar) # create main menus AddLogfileMenu $win $win.menu.logfile # AddOptionsMenu $win $win.menu.options # just to see the background color... # frame $win.menu.junk -width 50 pack $win.menu -fill x # pack $win.menu.logfile $win.menu.options -side left pack $win.menu.logfile -side left # if a logfile was specified, load it if {$logfile != ""} { OpenFile $win $logfile [GuessFormat $logfile] \ [GetDefault displays Timelines] }}proc AddLogfileMenu {id win} { global mainwin # id is the index id for any neccessary data # win the the window to create menubutton $win -text "Logfile" -menu $win.menu # menu options set logmenu $win.menu menu $logmenu $logmenu add command -label "New frame" -command \ {NewWin .[GetUniqueWindowID] 0} # load a new logfile $logmenu add command -label "Open..." -command "SelectFile $id" # print the current view $logmenu add command \ -label "Print..." \ -state disabled # pick one of two exit options. If this is the main window, # the user should know that destroying it will close the app if $mainwin($id,is_root_win) { $logmenu add command -label "Exit Nupshot" -command ExitUpshot } else { $logmenu add command -label "Close frame" -command "CloseFile $id" }}proc EnablePrintMenu {log w} { global mainwin # be sure to adjust this if the menus get moved $w.menu.logfile.menu entryconfigure 2 \ -state normal -command "Print_MainWin_Dialog $log $w"}proc AddOptionsMenu {id win} { # id is the index id for any neccessary data # win the the window to create # create menu button menubutton $win -text "Options" -menu $win.menu # add menu items menu $win.menu $win.menu add command -label "Colors..." -command ColorOptions $win.menu add command -label "Print..." -command PrintOptions}proc AddZoomMenu {id win} { # id is the index id for any neccessary data # win the the window to create # create menu button menubutton $win -text "Zoom" -menu $win.menu # add menu items menu $win.menu set menu $win.menu $win.menu add command -label "Zoom in horiz" -command \ "Zoom $id $id.displays horiz 2" $menu add command -label "Zoom out horiz" -command \ "Zoom $id $id.displays horiz .5" $menu add command -label "Reset view" -command \ "Zoom $id $id.displays reset" # These should not be here. They should be on each widget. # $menu add command -label "Zoom in vert" -command \ "Zoom $id $id.displays vert 2" # $menu add command -label "Zoom out vert" -command \ "Zoom $id $id.displays vert .5"}proc AddDisplayMenu {id win} { # id is the index id in mainwin() for any neccessary data # win the the window to create # create menu button menubutton $win -text "Display" -menu $win.menu # add menu items menu $win.menu set menu $win.menu proc bill {name} { return Bill } proc joe {name} { return Joe } proc ed {name} { return Ed } $menu add command -label "Configure" -command \ "Display_Dialog $id.displays" # $menu add command -label "Add" -command \ "Display_Add $id" # $menu add command -label "Remove" -command \ "Display_Remove $id"}proc SelectFile {win} { # Call fileselect and select something. On 'OK' call OpenFile. fileselect "SelectedFile $win" "Open Logfile:" $win.selectfile}proc SelectedFile {win filename format} { OpenFile $win $filename $format [GetDefault displays Timelines]}proc OpenFile {w logfile format displays} { global mainwin # puts "OpenFile $w $logfile $format $displays" # w is used to index into mainwin(), as well as the toplevel window name # display is a list of display widgets that should be used to display # this file. For example: # { {timeline} {msgq in 3} } # would specify that two displays are to be opened: timeline and # msgq (input queue on process 3) # left_gap is the width of the gap to leave to leave on the left # side for whatever various widgets wish to do with it # Better way to do this? set left_gap [GetDefault display_left_gap 40] # reset zoom point if [info exists mainwin($w,zoom_time)] {unset mainwin($w,zoom_time)} # if a logfile hasn't already been loaded in this window if {$mainwin($w,needs_menus)} { AddLogManipulationButtons $w set mainwin($w,needs_menus) 0 } if {!$mainwin($w,empty)} { # be sure to close the controls and stuff before closing the logfile # destroy the displays first, since if the other stuff is destroyed # first, the displays will notice they have more space, a # <Configure> event will be triggered, and they will waste time # recalculating to fill the new space. Grrr... destroy $w.displays destroy $w.controls destroy $w.legend destroy $w.titlelegend destroy $w.bottom update idletasks } # close the old logfile if {[info exists mainwin($w,log)]} { $mainwin($w,log) close unset mainwin($w,log) } # turn on hourglass cursor LookBusy $w # open the new logfile set openStatus [catch "logfile $w.log $logfile $format" err] if {$openStatus} { # if there was an error, let the user know set errwin .[GetUniqueWindowID] toplevel $errwin wm title $errwin "Error" message $errwin.m -aspect 400 -text "Error opening logfile: \ $err" button $errwin.b -text "Cancel" -command "destroy $errwin" pack $errwin.m $errwin.b return -1 } set mainwin($w,log) $w.log set log $mainwin($w,log) set mainwin($w,startTime) [$log starttime] set mainwin($w,endTime) [$log endtime] set mainwin($w,totalTime) [expr [$log endtime] - [$log starttime]] # set initial visible range set mainwin($w,left) $mainwin($w,startTime) set mainwin($w,span) $mainwin($w,totalTime) # set the title of the window to the name of the logfile if $mainwin($w,is_root_win) { wm title . "nupshot - $logfile" } else { wm title $w "nupshot - $logfile" } # set font [option get $w font Font] EnablePrintMenu $mainwin($w,log) $w # get the requested display widget width and height set widget_width [GetDefault "display widget width" 700] # set widget_height [GetDefault "display widget height" 300] Create_Controls $w.controls $w $mainwin($w,log) # frame $w.sep -height 4 -relief raised -borderwidth 2 # The names of the windows used in this procedure are highly # depended on by stuff in print.tcl. Change those if
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -