File: portlist.tcl

package info (click to toggle)
tkgate 2.1%2Brepack-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,384 kB
  • sloc: ansic: 62,300; tcl: 20,345; xml: 2,731; yacc: 1,177; lex: 839; sh: 664; makefile: 180; perl: 39
file content (147 lines) | stat: -rw-r--r-- 4,082 bytes parent folder | download | duplicates (5)
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
#   Copyright (C) 1987-2015 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.,
#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Last edit by hansen on Fri Jan  9 20:06:58 2009
#

namespace eval PortList {
  variable typeimages
  variable typeimagehelp
  variable portbits
  variable port_w

  proc setupImages {} {
    variable typeimages
    variable typeimagehelp

    set typeimages(in) [gifI [m @portlist.in]]
    set typeimages(out) [gifI [m @portlist.out]]
    set typeimages(inout) [gifI [m @portlist.inout]]
    set typeimages(in2) [gifI [m @portlist.in2]]
    set typeimages(out2) [gifI [m @portlist.out2]]
    set typeimages(inout2) [gifI [m @portlist.inout2]]

    set typeimagehelp(in) [m ho.net.in]
    set typeimagehelp(out) [m ho.net.out]
    set typeimagehelp(inout) [m ho.net.inout]
    set typeimagehelp(in2) [m ho.net.in2]
    set typeimagehelp(out2) [m ho.net.out2]
    set typeimagehelp(inout2) [m ho.net.inout2]
  }

  proc flush {} {
    variable port_w
    Tree::delitem $port_w.t /
  }

  proc replace {mod args} {
    del $mod
    eval "add $mod $args"
  }

  proc del {mod} {
    variable port_w
    Tree::delitem $port_w.t /$mod
  }


  proc add {name args} {
    variable netl_w
    variable typeimages
    variable typeimagehelp
    variable portbits
    variable port_w

    set bits 1
    set type "in"
    parseargs $args {-bits -type}

    #
    # Ignore duplicate entries.
    #
    if {[Tree::exists $port_w.t /$name]} {
      return
    }

    if {$bits == 1} {
      set portbits($name) ""
    } else {
      set portbits($name) "\[[expr $bits-1]:0\]"
      set type "${type}2"
    }

    Tree::newitem $port_w.t /$name -image $typeimages($type) -imagehelp $typeimagehelp($type)
  }

  proc seeB1Press {w x y X Y} {
    action -Unselect { tkg_undoSelections nets }
    set lbl [Tree::labelat $w $x $y]
    setselection $lbl
  }
  proc seeB3Press {w x y X Y} {
    action -Unselect { tkg_undoSelections nets }
    set lbl [Tree::labelat $w $x $y]
    setselection $lbl
  }
  proc seeDoubleB1 {w x y X Y} {
    action -Unselect { tkg_undoSelections nets }
    set lbl [Tree::labelat $w $x $y]
    setselection $lbl
    if { $lbl != "" } {
      continueAction EditNet { gat_editNet [PortList::getselection] }
    }
  }

  proc setselection {name} {
    variable port_w

    Tree::setselection $port_w.t $name
    action -Select { gat_selectNet [string range $name 1 end] }
  }

  proc getselection {args} {
    variable port_w

    set path [Tree::getselection $port_w.t]
    return [string trimleft $path  "/" ]
  }

  proc create {w} {
    variable port_w

    setupImages

    frame $w
    set port_w $w

    Tree::create $w.t -width 50 -height 50 -bd 2 -relief sunken \
	-yscrollcommand "$w.vb set" -xscrollcommand "$w.hb set" -nolines 1
    scrollbar $w.vb -orient vertical -command "$w.t yview" -takefocus 0
    scrollbar $w.hb -orient horizontal -command "$w.t xview" -takefocus 0

    grid rowconfigure $w 0 -weight 1
    grid columnconfigure $w 0 -weight 1
    grid $w.t  -row 0 -column 0 -sticky nsew -padx 1 -pady 1
    grid $w.vb -row 0 -column 1 -sticky ns -padx 1 -pady 1
    grid $w.hb -row 1 -column 0 -sticky ew -padx 1 -pady 1

    bind $w.t <1> { PortList::seeB1Press %W %x %y %X %Y }
    bind $w.t <3> { PortList::seeB3Press %W %x %y %X %Y }
    bind $w.t <Double-ButtonPress-1> { PortList::seeDoubleB1 %W %x %y %X %Y }

    Tree::setsuparray $w.t PortList::portbits
  }
}