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

📄 displays.tcl

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 TCL
📖 第 1 页 / 共 2 页
字号:
         # destroy the spacer      destroy [lindex $display($win,spclist) $spcidx]         # remove the spacer from the spacer list      set display($win,spclist) [lreplace $display($win,spclist) \	    $spcidx $spcidx]   }   set display($win,list) [lreplace $displist $idx $idx]}      ## Create a spacer bar between display widgets.  The cursor will change# over this bar to an up-arrow/down-arrow, signifying that the user can# drag the space bar to stretch and shrink the display widgets#proc display_spacer {win spc_win} {   frame $spc_win -borderwidth 2 -relief raised -height 4 \	 -cursor double_arrow}   ## Bring up display control dialog.  A list of the window names of the# current displays will be provided.  The dialog will have the option of# adding or removing displays, configuring the displays directly, and# repacking them in a different order.## display_dialog structure:#   prefix: dialog toplevel window name##   <n> - window name of display #<n>#   ndisplays - # of displays represented#   drag - name of window being dragged#   selected - # of the selected display#proc Display_Dialog {win} {   global display display_dialog   set dlg .[GetUniqueWindowID]   toplevel $dlg   wm title $dlg "Display Configuration"   frame $dlg.list -relief ridge -borderwidth 3   pack $dlg.list   set i 0      # go through the list of displays being shown   foreach disp $display($win,list) {      set name [$disp name]      Display_Dialog_AddButton $win $dlg $disp $name end      # puts "disp = $name"      set display_dialog($dlg,$i) $disp      incr i   }   if {$i > 0} {      set display_dialog($dlg,selected) 0      $dlg.list.0 config -relief ridge   }   set display_dialog($dlg,ndisplays) $i   set display_dialog($dlg,drag) ""   label $dlg.help -text "Drag with button 2 to reorder displays."   pack $dlg.help   frame $dlg.controls   set menu $dlg.controls.add.menu   menubutton $dlg.controls.add -text "Add" -menu $menu   menu $menu   foreach type $display(_list) {      $menu add command -label $type \	    -command "Display_Dialog_Add $win $dlg {$type}"   }   # button $dlg.controls.config -text "Config" -command \	 "Display_Dialog_Config $dlg"   button $dlg.controls.remove -text "Remove" -command \	 "Display_Dialog_Remove $win $dlg"   # pack $dlg.controls.add $dlg.controls.config $dlg.controls.remove \	 -side left -fill x -expand 1 -padx 5 -pady 5   pack $dlg.controls.add $dlg.controls.remove \	 -side left -fill x -expand 1 -padx 5 -pady 5   pack $dlg.controls -fill x -expand 1   button $dlg.ok -text "OK" -command "destroy $dlg"   pack $dlg.ok   # displayprint $win $dlg      # wait until the window is destroyed   tkwait window $dlgif 0 {   set result {}      # unpack all the displays   eval pack forget [pack slaves $win]      # repack them in the new order   set ndisplays $display_dialog($dlg,ndisplays)   for {set i 0} {$i < [expr $ndisplays - 1]} {incr i} {      pack $display_dialog($dlg,$i) -expand 1 -fill both      pack [lindex $display($win,spclist) $i] -fill x      lappend result $display_dialog($dlg,$i)   }      # if there is at least one more, pack it (no spacer) on the end   if $ndisplays {      pack $display_dialog($dlg,$i) -expand 1 -fill both   }}   # Woah, it works!}## Select one of the displays in the display dialog#proc Display_Dialog_Select {win i} {   global display_dialog      # reset the previously selected frame   $win.list.$display_dialog($win,selected) config -relief flat      # set the newly selected frame   $win.list.$i config -relief ridge   set display_dialog($win,selected) $i}## Start the drag of one of the display names, so they can be reordered## Dragging uses a few new members of the display_dialog structure:#   drag_offx, drag_offy - offset (from the center of the name being#                          dragged) where the mouse button was clicked#   drag - name of the toplevel window being dragged#proc Display_StartDrag {win i x y X Y} {   global display_dialog   set disp_win $display_dialog($win,$i)   set disp_btn $win.list.$i.b      # set drag_offx and drag_offy as the offsets from the center of      # the name being dragged   set display_dialog($win,drag_offx) \	 [expr $x - [winfo width $disp_btn] / 2 + 1]   set display_dialog($win,drag_offy) \	 [expr $y - [winfo height $disp_btn] / 2 + 1]   # sometimes you need it, sometimes you don't!!   #set X [expr $X+[winfo vrootx .] - $x - 3]   #set Y [expr $Y+[winfo vrooty .] - $y - 3]   set X [expr $X - $x - 3]   set Y [expr $Y - $y - 3]      # make floating window   set display_dialog($win,drag) $win.drag   toplevel $win.drag   frame $win.drag.f -width [expr [winfo width $disp_btn]+4] \	 -height [expr [winfo height $disp_btn]+4] -borderwidth 2 \	 -relief raised   label $win.drag.f.l -text [$disp_win name]   pack $win.drag.f   place $win.drag.f.l -x [expr [winfo width $disp_btn]/2] \	 -y [expr [winfo height $disp_btn]/2] -anchor center   wm overrideredirect $win.drag 1   wm geometry $win.drag +$X+$Y}## Do the actual 'drag' of the display name#proc Display_DoDrag {win i x y X Y} {   global display_dialog   if {$display_dialog($win,drag) == ""} return   # check if I'm over one of the other guys   set n $display_dialog($win,ndisplays)   for {set i 0} {$i<$n} {incr i} {      if [in_window $win.list.$i $X $Y] {	 if {$i != $display_dialog($win,selected)} {	    Display_Dialog_Select $win $i	 }      }   }   set drag_win $display_dialog($win,drag)   set X [expr $X+[winfo vrootx .] - [winfo width $drag_win]/2 - \	 $display_dialog($win,drag_offx)]   set Y [expr $Y+[winfo vrooty .] - [winfo height $drag_win]/2 - \	 $display_dialog($win,drag_offy)]   wm geometry $win.drag +$X+$Y}## End of the drag#proc Display_EndDrag {win dlg i x y X Y} {   global display_dialog   if {$display_dialog($dlg,drag) == ""} return   destroy $dlg.drag      # if the display selected has been dragged to a different slot,      # repack my list of windows   set j $display_dialog($dlg,selected)   if {$i == $j} return   # i is the previous slot, j is the new slot   if {$i < $j} {      # moving down the list      set temp $display_dialog($dlg,$i)      for {set n $i} {$n < $j} {incr n} {	 set display_dialog($dlg,$n) \	       $display_dialog($dlg,[expr $n+1])      }      set start $i      set end $j      display_move $win $i [expr $j+1]   } else {      # moving up the list      set temp $display_dialog($dlg,$i)      for {set n $i} {$n > $j} {incr n -1} {	 set display_dialog($dlg,$n) \	       $display_dialog($dlg,[expr $n-1])      }      set start $j      set end $i      display_move $win $i $j   }   set display_dialog($dlg,$j) $temp   # rename the buttons to match their new masters   for {set n $start} {$n <= $end} {incr n} {      $dlg.list.$n.b config -text [$display_dialog($dlg,$n) name]   }   set display_dialog($dlg,drag) ""   # displayprint $win $dlg}## Add a button representing a display to the dialog window## disp - name of window this button is representing# name - name to put on the button# idx - index where to insert the button.  "end" is recognized.proc Display_Dialog_AddButton {win dlg disp name idx} {   global display_dialog   # puts "AddButton $win $dlg (win)$disp (name)$name $idx"   upvar #0 display_dialog($dlg,ndisplays) ndisplays   if ![info exists ndisplays] {      set ndisplays 0   }      if {$idx == "end"} {      set idx $ndisplays   }   if {$idx > $ndisplays || $idx < 0} {      error "out of range index -- $idx"   }      # create the button for this display   frame $dlg.list.$ndisplays -relief flat -borderwidth 4   set button $dlg.list.$ndisplays.b   button $button -command "Display_Dialog_Select $dlg $ndisplays"   bind $button <2> \	 "Display_StartDrag $dlg $ndisplays %x %y %X %Y"   bind $button <B2-Motion> \	 "Display_DoDrag $dlg $ndisplays %x %y %X %Y"   bind $button <B2-ButtonRelease> \	 "Display_EndDrag $win $dlg $ndisplays %x %y %X %Y"   pack $button -fill x -padx 2   pack $dlg.list.$ndisplays -fill x -padx 2 -pady 2      # insert the window name for this display in the dialog list   if {$idx == "end"} {      set display_dialog($dlg,$ndisplays) $disp   } else {      for {set i $ndisplays} {$i > $idx} {incr i -1} {	 set new_win $display_dialog($dlg,[expr $i-1])	 set display_dialog($dlg,$i) $new_win	 $dlg.list.$i.b config -text [$new_win name]      }      set display_dialog($dlg,$idx) $disp      $dlg.list.$idx.b config -text [$disp name]   }      # increment the # of displays in the dialog   incr ndisplays}## Remove a button representing a display from the dialog window##  dlg - name of dialog window#  idx - index of button to removeproc Display_Dialog_RemoveButton {dlg idx} {   global display_dialog   upvar #0 display_dialog($dlg,ndisplays) ndisplays   if {$idx < 0 || $idx >= $ndisplays} {      error "invalid index"   }      for {set i $idx} {$i < [expr $ndisplays-1]} {incr i} {      set new_win $display_dialog($dlg,[expr $i+1])         # shift the names of the displays in the dialog's list      set display_dialog($dlg,$i) $new_win         # shift the names of the buttons      $dlg.list.$i.b config -text [$new_win name]   }      # destroy the last button's frame, which will destroy the button too   destroy $dlg.list.$i      # clear the array entry, like it would make a difference   unset display_dialog($dlg,$i)   incr ndisplays -1   }if 0 {proc displayprint {win dlg} {   global display display_dialog   puts "from the dialog:"   for {set i 0} {$i < $display_dialog($dlg,ndisplays)} {incr i} {      puts "  $display_dialog($dlg,$i)"   }   puts "from the window:"   foreach disp $display($win,list) {      puts "  $disp"   }}  }## Use the display dialog 'add' button to add displays.#  win - display window#  dlg - display dialog window#  type - type of display to add#proc Display_Dialog_Add {win dlg type} {   global display display_dialog   set insert_idx $display_dialog($dlg,selected)   set new_disp [display_add $win $type $insert_idx {}]      Display_Dialog_AddButton $win $dlg $new_disp $type $insert_idx   # displayprint $win $dlg}## Use the display dialog 'remove' button to remove displays.#  win - display window#  dlg - display dialog window#proc Display_Dialog_Remove {win dlg} {   global display display_dialog   set idx $display_dialog($dlg,selected)   display_remove $win $idx   Display_Dialog_RemoveButton $dlg $idx   # displayprint $win $dlg}

⌨️ 快捷键说明

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