/usr/share/tkgate/scripts/blockops.tcl is in tkgate-data 2.0~b10-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | # Copyright (C) 1987-2004 by Jeffery P. Hansen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Last edit by hansen on Mon Jan 19 19:52:13 2009
#
#############################################################################
#
# Get the selected block (from list or tree)
#
proc tkg_getSelectedBlock {} {
set name [BlockList::getselection]
if { $name != "" } { return $name }
set name [BlockTree::getselection]
if { $name != "" } { return $name }
set name [gat_getSelected module]
return $name
}
proc tkg_moduleSelector {w args} {
set width 10
set height 10
set command ""
set value ""
set variable ""
set entry ""
set libraryonly 0
set nomain 0
parseargs $args {-width -height -command -value -variable -entry -libraryonly -nomain}
set block_list {}
foreach m [BlockList::getallmodules] {
set add_ok 1
if { $libraryonly && ![BlockList::isLibrary $m]} {
set add_ok 0
}
if { $nomain && [BlockList::getType $m] == "root" } {
set add_ok 0
}
if { $add_ok } {
lappend block_list $m
}
}
if { $value == "" } {
set value [lindex $block_list 0]
}
Dropbox::new $w -width $width -height $height -command $command -value $value -variable $variable -entry $entry
foreach m $block_list {
Dropbox::itemadd $w $m
}
return [llength $block_list]
}
#############################################################################
#
# This is the dialog box to define new module types
#
namespace eval BlockOp {
variable props
variable srcModule ""
variable dstModule ""
proc delete {} {
baseDlg -title [m blklst.delete.title] -srcprompt "[m blklst.name]:" -command gat_deleteBlock \
-image [gifI module_del.gif] -caption [m blklst.del.cap] -explaination [m blklst.del.exp]
}
proc copy {} {
baseDlg -title [m blklst.copy.title] -srcprompt "[m blklst.from]:" -dstprompt "[m blklst.to]:" -command gat_copyBlock \
-image [gifI module_copy.gif] -caption [m blklst.copy.cap] -explaination [m blklst.copy.exp]
}
proc rename {} {
baseDlg -title [m blklst.rename.title] -srcprompt "[m blklst.from]:" -dstprompt "[m blklst.to]:" \
-command gat_renameBlock \
-image [gifI module_rename.gif] -caption [m blklst.rename.cap] -explaination [m blklst.rename.exp]
}
proc claim {} {
baseDlg -title [m blklst.claim.title] -srcprompt "[m blklst.name]:" -command gat_claimBlock \
-image [gifI module_claim.gif] -caption [m blklst.claim.cap] -libraryonly 1 -explaination [m blklst.claim.exp]
}
proc setroot {} {
baseDlg -title [m blklst.setroot.title] -srcprompt "[m blklst.name]:" -command gat_reroot \
-image [gifI module_root.gif] -caption [m blklst.setroot.cap] -libraryonly 0 -explaination [m blklst.setroot.exp]
}
#############################################################################
#
# Base dialog for block operations
#
proc baseDlg args {
variable srcModule
variable dstModule
global tkg_currentModule
set title ""
set srcprompt ""
set dstprompt ""
set command ""
set image ""
set caption ""
set explaination ""
set libraryonly 0
set w .blk
parseargs $args {-title -srcprompt -dstprompt -command -image -caption -libraryonly -explaination}
if { [catch { toplevel $w } ] } { return }
wm title $w $title
wm geometry $w [offsetgeometry . 50 50 ]
wm transient $w .
set srcModule [tkg_getSelectedBlock]
set dstModule ""
frame $w.top -bd 2 -relief raised
frame $w.top.t
#
# If no selected module, use the current module.
#
if { $srcModule == "" } {
set srcModule $tkg_currentModule
}
if { $srcprompt != "" } {
label $w.top.t.tsrc -text $srcprompt
if { $libraryonly } {
set count [tkg_moduleSelector $w.top.t.esrc -width 20 -variable BlockOp::srcModule -entry 0 -libraryonly 1]
} else {
set count [tkg_moduleSelector $w.top.t.esrc -width 20 -variable BlockOp::srcModule -value $srcModule -entry 0 -libraryonly 0]
}
if { $count == 0 } {
destroy $w
errmsg [m err.nomodop]
return
}
append command { $BlockOp::srcModule }
grid $w.top.t.tsrc -row 0 -column 0 -sticky e -padx 3 -pady 3
grid $w.top.t.esrc -row 0 -column 1 -sticky w -padx 3 -pady 3
bind $w.top.t.esrc <Return> $command
bind $w.top.t.esrc <Return> "+ destroy $w"
set mod_list [Dropbox::getcontents $w.top.t.esrc]
if {[lsearch $mod_list $srcModule] < 0 } {
set srcModule [lindex $mod_list 0]
}
}
if { $dstprompt != "" } {
label $w.top.t.tdst -text $dstprompt
entry $w.top.t.edst -textvariable BlockOp::dstModule -bg white
grid $w.top.t.tdst -row 1 -column 0 -sticky e -padx 3 -pady 3
grid $w.top.t.edst -row 1 -column 1 -sticky ew -padx 3 -pady 3
append command { $BlockOp::dstModule }
bind $w.top.t.edst <Return> $command
bind $w.top.t.edst <Return> "+ destroy $w"
}
pack $w.top.t -padx 10 -pady 10 -fill both -expand 1 -side right
if { $explaination != "" } {
label $w.top.t.exp -text $explaination -justify left -wraplength 200 -font dialogExpFont
grid $w.top.t.exp -padx 10 -pady 10 -row 2 -column 0 -columnspan 2
}
okcancel $w.b -okcommand "$command; destroy $w" -cancelcommand "destroy $w"
pack $w.b -fill x -side bottom
if { $image != "" } {
dialogImage $w.top.icpad -image $image -caption $caption
pack $w.top.icpad -fill both -side left
}
pack $w.top -fill both -expand 1
if { $srcprompt != "" } {
focus $w.top.t.esrc
} else {
focus $w.top.t.edst
}
dialogWait $w
# BlockTree::rebuild
}
#############################################################################
#
# Confirm property settings for a new module.
#
proc newConfirm {w} {
variable props
if { $props(name) != "" } {
set props(ok) 1
gat_newBlock BlockOp::props
}
destroy $w
}
#############################################################################
#
# Frame with property flags
#
proc flagFrame {w args} {
labelframe $w [m db.mod.flags]
frame $w.pad -height 5
pack $w.pad
set array BlockOp::props
parseargs $args {-array}
checkbutton $w.prot -variable ${array}(prot) -text [m db.mod.dataprot]
pack $w.prot -anchor w -pady 3 -padx 5
checkbutton $w.protint -variable ${array}(protint) -text [m db.mod.intfprot]
pack $w.protint -anchor w -pady 3 -padx 5
checkbutton $w.proted -variable ${array}(proted) -text [m db.mod.edprot]
pack $w.proted -anchor w -pady 3 -padx 5
label $w.ppos -text [m ipanel.ppos.label]
pack $w.ppos -anchor w -pady 3 -padx 5
set IPanel::props(ppos) scale
frame $w.grid
radiobutton $w.grid.grid -text [m ipanel.ppos.scale] -variable ${array}(ppos) -value scale
frame $w.grid.pad -width 5
radiobutton $w.grid.free -text [m ipanel.ppos.fix] -variable ${array}(ppos) -value fix
pack $w.grid.grid $w.grid.pad $w.grid.free -side left
pack $w.grid -anchor w -pady 3 -padx 5
}
#############################################################################
#
# Respond to a change in the type by updating image and label.
#
proc seeTypeChanged {w args} {
if { $BlockOp::props(type) == "netlist" } {
$w.image.i configure -image [gifI type_netlist.gif]
$w.image.l configure -text [m db.mod.netexpl]
} else {
$w.image.i configure -image [gifI type_hdl.gif]
$w.image.l configure -text [m db.mod.hdlexpl]
}
}
#############################################################################
#
# Select the type (netlist vs. HDL) for a module
#
proc typeSelector {w} {
global tkg_pastelHighlight
labelframe $w [m db.mod.type]
frame $w.pad -height 5
pack $w.pad
frame $w.button
radiobutton $w.button.netlist -variable BlockOp::props(type) -value netlist -text [m db.mod.netlist]
radiobutton $w.button.hdl -variable BlockOp::props(type) -value hdl -text [m db.mod.hdl]
pack $w.button.netlist $w.button.hdl -padx 3 -pady 3 -anchor nw
frame $w.image
label $w.image.i -image [gifI type_netlist.gif]
label $w.image.l -text [m db.mod.netexpl] -justify left -anchor n
pack $w.image.i $w.image.l -padx 5 -pady 5 -side left -anchor nw
pack $w.button -side left -anchor nw
pack $w.image -side left -anchor center -fill x -expand 1
trace variable BlockOp::props(type) w "BlockOp::seeTypeChanged $w"
bind $w <Destroy> "trace vdelete BlockOp::props(type) w \"BlockOp::seeTypeChanged $w\""
seeTypeChanged $w
# -image [gifI type_Uhdl.gif] -selectimage [gifI type_hdl.gif]
}
#############################################################################
#
# Post dialog box for defining a new module.
#
proc new args {
variable props
global tkg_currentModule
set parent .
parseargs $args {-parent}
set w .blk
if { [catch { toplevel $w } ] } { return }
wm title $w [m blklst.new.title]
wm geometry $w [offsetgeometry $parent 50 50 ]
wm transient $w $parent
set props(ok) 0
set props(name) ""
set props(type) netlist
set props(prot) 0
set props(protint) 0
set props(proted) 1
set props(ppos) scale
okcancel $w.ok -okcommand "BlockOp::newConfirm $w" -cancelcommand "destroy $w"
pack $w.ok -fill x -side bottom
frame $w.top -bd 2 -relief raised
pack $w.top -fill both -expand 1
dialogImage $w.top.icpad -image [gifI module_new.gif] -caption [m blklst.new.cap] -explaination [m blklst.new.exp]
pack $w.top.icpad -fill both -side left
frame $w.top.strut -height 300
pack $w.top.strut -side left
set pw $w.top.props
frame $pw
pack $pw -padx 10 -pady 10 -anchor n -side right
frame $pw.name
label $pw.name.l -text [m blklst.name]:
entry $pw.name.e -textvariable BlockOp::props(name) -bg white -width 40
pack $pw.name.l -padx 5 -pady 10 -side left
pack $pw.name.e -padx 5 -pady 10 -side left -fill x -expand 1
typeSelector $pw.type
flagFrame $pw.flags
pack $pw.name $pw.type $pw.flags -pady 5 -fill x -anchor w
bind $pw.name.e <Return> "BlockOp::newConfirm $w"
update
focus -force $pw.name.e
dialogWait $w
}
}
namespace eval ModuleProps {
variable props
#############################################################################
#
# Initialize all of the interface/module properties
#
proc mpropInit {} {
variable props
set props(shortfile) ""
set props(file) ""
set props(type) ""
set props(prot) "0"
set props(protint) "0"
set props(proted) "0"
set props(inuse) "0"
set props(modload) "0"
set props(modsave) "0"
set props(libname) ""
set props(wantclaim) "0"
set props(grid) "grid"
}
proc postSelected {args} {
set which modlist
parseargs $args {-which}
if { $which == "canvas" } {
set name [gat_getSelected module]
if { $name == "" } {
set name [tkg_getSelectedBlock]
}
} else {
set name [tkg_getSelectedBlock]
if { $name == "" } {
set name [gat_getSelected module]
}
}
if {$name != ""} {
post $name
} else {
errmsg [m err.nomodule]
}
}
proc update {w name} {
variable props
gat_editModProps save ModuleProps::props $name
destroy $w
catch {
set IPanel::props(prot) $props(prot)
set IPanel::props(protint) $props(protint)
set IPanel::props(proted) $props(proted)
set IPanel::props(ppos) $props(ppos)
}
}
#############################################################################
#
# Create the framed list of module property options
#
proc moduleFlags {w args} {
variable props
set array ModuleProps::props
parseargs $args {-array}
frame $w
checkbutton $w.prot -variable ${array}(prot) -text [m db.mod.dataprot]
pack $w.prot -anchor w -pady 3
checkbutton $w.protint -variable ${array}(protint) -text [m db.mod.intfprot]
pack $w.protint -anchor w -pady 3
checkbutton $w.proted -variable ${array}(proted) -text [m db.mod.edprot]
pack $w.proted -anchor w -pady 3
frame $w.ppos
pack $w.ppos -anchor w -pady 3
label $w.ppos.l -text [m ipanel.ppos.label]
radiobutton $w.ppos.scale -text [m ipanel.ppos.scale] -variable ${array}(ppos) -value scale
radiobutton $w.ppos.fix -text [m ipanel.ppos.fix] -variable ${array}(ppos) -value fix
pack $w.ppos.l -anchor w
pack $w.ppos.scale -side left -padx 10
pack $w.ppos.fix -side left
if { $props(itype) == "symbol" } {
$w.ppos.scale configure -state disabled
$w.ppos.fix configure -state disabled
$w.ppos.l configure -fg [$w.ppos.fix cget -disabledforeground]
} else {
$w.ppos.l configure -fg black
$w.ppos.scale configure -state normal
$w.ppos.fix configure -state normal
}
helpon $w.prot [m ho.ipanel.prot]
helpon $w.protint [m ho.ipanel.protint]
helpon $w.proted [m ho.ipanel.proted]
helpon $w.ppos.scale [m ho.ipanel.scale]
helpon $w.ppos.fix [m ho.ipanel.fix]
}
proc post {name} {
variable props
set w .mprops
if { [catch { toplevel $w } ] } { return }
wm title $w [m module.props.title]
wm geometry $w [offsetgeometry . 50 50 ]
wm transient $w .
#
# Get properties about this module
#
gat_editModProps load ModuleProps::props $name
okcancel $w.okc -okcommand "ModuleProps::update $w $name" -cancelcommand "destroy $w"
pack $w.okc -side bottom -fill x
frame $w.main -bd 2 -relief raised
dialogImage $w.main.typeimg -image [gifI type_$props(type).gif] -imgbd 2 -imgrelief raised -caption [m module.props]
grid $w.main.typeimg -row 0 -column 0 -rowspan 4 -padx 5 -pady 5
grid rowconfigure $w.main 3 -weight 1
label $w.main.lname -text [m db.mod.name]:
label $w.main.name -text $name
grid $w.main.lname -row 0 -column 1 -padx 5 -pady 3 -sticky e
grid $w.main.name -row 0 -column 2 -padx 5 -pady 3 -sticky w
label $w.main.lfile -text [m db.mod.file]:
entry $w.main.file -textvariable ModuleProps::props(shortfile) -state disabled -width 25 -relief flat
catch { $w.main.file configure -disabledforeground black }
grid $w.main.lfile -row 1 -column 1 -padx 5 -pady 3 -sticky e
grid $w.main.file -row 1 -column 2 -padx 5 -pady 3 -sticky w
label $w.main.ltype -text [m db.mod.type]:
label $w.main.type -text [m db.mod.$props(type)]
grid $w.main.ltype -row 2 -column 1 -padx 5 -pady 3 -sticky e
grid $w.main.type -row 2 -column 2 -padx 5 -pady 3 -sticky w
# frame $w.main.pad
# grid $w.main.pad -row
moduleFlags $w.main.flags -array ModuleProps::props
grid $w.main.flags -row 3 -column 1 -columnspan 2 -sticky nw
pack $w.main
dialogWait $w
}
}
|