1# Copyright (C) 1987-2015 by Jeffery P. Hansen 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 2 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License along 14# with this program; if not, write to the Free Software Foundation, Inc., 15# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16# 17# Last edit by hansen on Sat Feb 21 16:28:03 2009 18# 19 20######################################################################## 21# 22# Popup flag meanings: 23# r Use label directly without a messages file lookup 24# R Do not prepend "Action::" to command name 25# I Prepend a "PopupMenu::inpop " to command. 26# 27 28namespace eval PopupMenu { 29 # 30 # 31 # Tag Label Name Action Image Sel. Image Var./Cascade Flags 32 variable menuEntryData { 33 {libraries library.mgr loadLibrary file_lib - - - } 34 {libname library.mgr loadLibrary file_lib - - - } 35 {libname library.close unloadSelectedLibrary file_unlib - - - } 36 37 {wire wire.prop popupWireProps i_wireprops - - - } 38 {wire wire.addseg popupWireAddStub emptytool - - - } 39 40 {wirelabel wire.showlabel popupWireShowLabel emptytool - - - } 41 {wirelabel wire.hidealllabel popupWireHideAllLabel emptytool - - - } 42 {wirelabel wire.clearalllabel popupWireClearAllLabel emptytool - - - } 43 44 {wireunlabel wire.hidelabel popupWireHideLabel emptytool - - - } 45 {wireunlabel wire.hidealllabel popupWireHideAllLabel emptytool - - - } 46 {wireunlabel wire.clearalllabel popupWireClearAllLabel emptytool - - - } 47 48 {wiresize wire.showsize popupWireShowSize emptytool - - - } 49 50 {wireunsize wire.hidesize popupWireHideSize emptytool - - - } 51 52 {gateport gate.addport addPort addport - - - } 53 54 {gateprop gate.prop editProps i_gateprops - - - } 55 {portprop gate.prop editProps i_portprops - - - } 56 57 {gate gate.anchor popupAnchor anchor unanchor pop_anchor - } 58 {gate gate.settech -cascade emptytool - settech - } 59 {gate gate.delete delete delgate - - - } 60 61 {gatebase gate.anchor popupAnchor anchor unanchor pop_anchor - } 62 {gatebase gate.delete delete delgate - - - } 63 64 {joint3 gate.anchor popupAnchor anchor unanchor pop_anchor - } 65 {joint3 wire.addseg popupWireAddStub emptytool - - - } 66 67 {joint4 gate.anchor popupAnchor anchor unanchor pop_anchor - } 68 69 {block gate.open openMod blk_open - - - } 70 {block interface -cascade editintr - int=block.int - } 71 {block module.prop blockPropCanvas i_modprops - - - } 72 {block.int interface.edit openInterface - - - - } 73 {block.int interface.set setBlockDesc - - - - } 74 {block.int interface.update updateInterface - - - - } 75 {block.int interface.updateall updateAllInterfaces - - - - } 76 {block.int interface.auto autoGenerateCanvas - - - - } 77 78 {blockedge gate.addin popupBlockAddIn emptytool - - - } 79 {blockedge gate.addout popupBlockAddOut emptytool - - - } 80 {blockedge gate.addinout popupBlockAddInOut emptytool - - - } 81 82 {blockport igen.type -cascade emptytool - ioset=blockport.type - } 83 {blockport igen.size -cascade emptytool - iosize=blockport.size - } 84 {blockport igen.delete popupDeletePort emptytool - - - } 85 86 {blockport.type port.in popupPortMakeIn emptytool - - - } 87 {blockport.type port.out popupPortMakeOut emptytool - - - } 88 {blockport.type port.inout popupPortMakeInOut emptytool - - - } 89 90 {blockport.size 1 "popupPortSize 1" - - - r } 91 {blockport.size 2 "popupPortSize 2" - - - r } 92 {blockport.size 4 "popupPortSize 4" - - - r } 93 {blockport.size 8 "popupPortSize 8" - - - r } 94 {blockport.size 16 "popupPortSize 16" - - - r } 95 {blockport.size 32 "popupPortSize 32" - - - r } 96 97 98 {canv make -cascade emptytool - make=@make - } 99 {canv tool -cascade emptytool - tool=@tool - } 100 {canv - -separator - - - - } 101 {canv gate.close closeMod blk_close - - - } 102 103 {notmove tool -cascade - - tool=@tool - } 104 105 {simu gate.close closeMod blk_close - - - } 106 {simu - -separator - - - - } 107 {simu simulate.end endSimulator sim_stop - - - } 108 {simu - -separator - - - - } 109 {simu simulate.run simRun sim_go - - - } 110 {simu simulate.pause simPause sim_pause - - - } 111 {simu simulate.step simStep sim_step - - - } 112 {simu simulate.cycle simCycle sim_clock - - - } 113 {simu simulate.break editBreakpoints sim_break - - - } 114 {simu simulate.script doSimScript sim_script - - - } 115 {simu - -separator - - - - } 116 {simu simulate.load simLoadMem sim_load - - - } 117 {simu simulate.dump simDumpMem sim_dump - - - } 118 {simu simulate.view simViewMem sim_view - - - } 119 120 {wiresimu simulate.addprobe toggleProbe net_probe - - I } 121 122 {scopetrace simulate.delprobe delScopeProbe net_probe - - I } 123 124 {close gate.close closeMod blk_close - - - } 125 126 {open gate.open openMod blk_open - - - } 127 128 {modlist module.new blockNew blk_new - - - } 129 {modlist module.del blockDelete blk_delete - - - } 130 {modlist module.copy blockCopy blk_copy - - - } 131 {modlist module.rename blockRename blk_rename - - - } 132 {modlist module.claim blockClaim blk_claim - - - } 133 {modlist module.setroot blockSetRoot blk_root - - - } 134 {modlist module.prop blockProp i_modprops - - - } 135 {modlist interface -cascade editintr - int=modlist.int - } 136 137 {modlist.int interface.edit openInterface - - - - } 138 {modlist.int interface.updateall updateAllInterfaces - - - - } 139 {modlist.int interface.auto autoGenerateSelected - - - - } 140 141 142 {ipanports igen.type -cascade - - type=ipanports.type - } 143 {ipanports igen.size -cascade - - size=ipanports.size - } 144 {ipanports igen.side -cascade - - side=ipanports.side - } 145 {ipanports igen.delete "PortEntry::inpopup delete" - - - R } 146 147 {ipanports.type igen.in "PortEntry::inpopup setType in" - - - R } 148 {ipanports.type igen.out "PortEntry::inpopup setType out" - - - R } 149 {ipanports.type igen.inout "PortEntry::inpopup setType inout" - - - R } 150 151 {ipanports.size 1 "PortEntry::inpopup setSize 1" - - - Rr } 152 {ipanports.size 2 "PortEntry::inpopup setSize 2" - - - Rr } 153 {ipanports.size 4 "PortEntry::inpopup setSize 4" - - - Rr } 154 {ipanports.size 8 "PortEntry::inpopup setSize 8" - - - Rr } 155 {ipanports.size 16 "PortEntry::inpopup setSize 16" - - - Rr } 156 {ipanports.size 32 "PortEntry::inpopup setSize 32" - - - Rr } 157 158 {ipanports.side igen.left "PortEntry::inpopup setSide left" - - - R } 159 {ipanports.side igen.right "PortEntry::inpopup setSide right" - - - R } 160 {ipanports.side igen.top "PortEntry::inpopup setSide top" - - - R } 161 {ipanports.side igen.bottom "PortEntry::inpopup setSide bottom" - - - R } 162 163 {paste edit.paste yankFromBuf edit_paste - - - } 164 165 {hdledit gate.close closeMod blk_close - - - } 166 {hdledit gate.open HdlEditor::openModule blk_open - - R } 167 168 {cut edit.copy copyToBuf edit_copy - - - } 169 {cut edit.cut cutToBuf edit_cut - - - } 170 171 {hdlsimu simulate.addprobe HdlEditor::toggleProbe net_probe - - R } 172 } 173 174 proc inpop {cmd} { 175 gat_popupSetState 1 176 eval $cmd 177 gat_popupSetState 0 178 } 179 180 ############################################################################# 181 # 182 # Make the menu for $tag in the menu $w 183 # 184 proc make {m args} { 185 variable menuEntryData 186 187 menu $m -tearoff 0 188 189 set isfirst 1 190 foreach context $args { 191 192 if { $context == "-nosep" } { 193 set isfirst 1 194 continue 195 } 196 # 197 # Add separators between blocks 198 # 199 if {!$isfirst} { 200 $m add separator 201 } 202 set isfirst 0 203 204 # 205 # Create the menu entries 206 # 207 foreach entry $menuEntryData { 208 set tag "" 209 set name "" 210 set action "" 211 set image "" 212 set simage "" 213 set varval "" 214 set gflags "" 215 lscan $entry tag name action image simage varval gflags 216 217 if { $tag != $context } continue 218 219 if {$image != "" && $image != "-"} { set image [gifI $image.gif]} { set image "" } 220 if {$simage != "" && $simage != "-"} { set simage [gifI $simage.gif]} { set simage "" } 221 222 set index "" 223 224 if { [string first r $gflags] < 0 } { 225 set name [m pop.$name] 226 } 227 228 if { $action == "-separator" } { 229 # This is a spearator entry 230 $m add separator 231 set index [$m index last] 232 } elseif { $action == "-cascade" } { 233 234 235 if { [scan $varval "%\[^=\]=%s" var val] == 2 } { 236 safeeval $::menu_forbidden $m add cascade -image $image -compound left -label $name -menu $m.$var 237 if { [string index $val 0] == "@" } { 238 Menu::makeMenu $m.$var [string range $val 1 end] 239 $m.$var configure -tearoff 0 240 } else { 241 PopupMenu::make $m.$var $val 242 } 243 } else { 244 safeeval $::menu_forbidden $m add cascade -image $image -compound left -label $name -menu $m.$varval 245 } 246 247 } else { 248 249 if { [string first R $gflags] < 0 } { 250 set action "Action::$action" 251 } 252 253 if { [string first I $gflags] >= 0 } { 254 set action "PopupMenu::inpop $action" 255 } 256 257 if { $varval != "-"} { 258 set var "" 259 set val "" 260 261 if { [scan $varval "%\[^=\]=%s" var val] == 2 } { 262 safeeval $::menu_forbidden $m add command -command $action -radio 1 -variable $var -value $val -image $image -selectimage $simage -compound left -indicatoron 0 -label $name 263 } else { 264 safeeval $::menu_forbidden $m add checkbutton -command $action -variable $var -image $image -selectimage $simage -compound left -indicatoron 0 -label $name 265 } 266 } else { 267 # This is a normal command entry 268 safeeval $::menu_forbidden $m add command -command $action -image $image -compound left -label $name 269 } 270 } 271 } 272 } 273 } 274 275 276 proc post {w x y s Px Py} { 277 global pop_anchor pop_tech main_w 278 279 tkg_buttonPress $main_w $x $y $s 3 280 set ptype [gat_setpop $x $y] 281 set pop_anchor [gat_anchor] 282 set pop_tech [gat_getTech] 283 tkg_buttonRelease $main_w $x $y $s 284 285 catch { tk_popup .pop_$ptype $Px $Py } 286 } 287 288 proc scopePost {Px Py} { 289 catch { tk_popup .pop_scopetrace $Px $Py } 290 } 291} 292 293############################################################################# 294############################################################################# 295# 296# Create the popup menus 297# 298proc makePopups {} { 299 PopupMenu::make .pop_wire wire wirelabel 300 PopupMenu::make .pop_wireL wire wireunlabel 301 PopupMenu::make .pop_mbwire wire wiresize wirelabel 302 PopupMenu::make .pop_mbwireL wire wiresize wireunlabel 303 PopupMenu::make .pop_mbwireS wire wireunsize wirelabel 304 PopupMenu::make .pop_mbwireLS wire wireunsize wireunlabel 305 PopupMenu::make .pop_MIgate gateport gateprop gate cut 306 PopupMenu::make .pop_gate gateprop gate cut 307 PopupMenu::make .pop_joint3 joint3 308 PopupMenu::make .pop_joint4 joint4 309 PopupMenu::make .pop_multi gate cut 310 PopupMenu::make .pop_block block gateprop gatebase 311 PopupMenu::make .pop_blockedge blockedge block gateprop gatebase 312 PopupMenu::make .pop_blockport blockport block portprop gatebase 313 PopupMenu::make .pop_canv canv paste 314 PopupMenu::make .pop_simu simu 315 PopupMenu::make .pop_blksimu open -nosep simu 316 PopupMenu::make .pop_wiresimu wiresimu simu 317 PopupMenu::make .pop_anal close 318 PopupMenu::make .pop_blkanal open -nosep close 319 PopupMenu::make .pop_intf close 320 PopupMenu::make .pop_intfblock open -nosep close 321 PopupMenu::make .pop_intfblockport blockport open -nosep close 322 PopupMenu::make .pop_intfblockedge blockedge open -nosep 323 PopupMenu::make .pop_notmove notmove close 324 PopupMenu::make .pop_modlist modlist 325 PopupMenu::make .pop_ipanports ipanports 326 PopupMenu::make .pop_hdleditp paste hdledit 327 PopupMenu::make .pop_hdledit hdledit 328 PopupMenu::make .pop_hdleditsel cut hdledit 329 PopupMenu::make .pop_hdlsimu hdlsimu hdledit 330 PopupMenu::make .pop_scopetrace scopetrace 331 PopupMenu::make .pop_libraries libraries 332 PopupMenu::make .pop_libname libname 333} 334 335