tx-tool/menu.tcl
1:
2: set MAX_ENTRY 10
3:
4: proc smenu_loop {widget line} {
5: global VERSION
6: global SYSINFO
7: global MAX_ENTRY
8: if {[string match "SYSINFO:*" $line]} {
9: set SYSINFO [lrange [split $line ":"] 1 end]
10: set VERSION [lindex [split $SYSINFO "/"] 3]
11: wm title . "RCOPEN24 Serial-Menu ($SYSINFO)"
12:
13: catch {eval $widget.bl configure -text \"$SYSINFO\"}
14:
15: } elseif {[string match "MT:*:*" $line]} {
16: set STAT [lindex [split $line ":"] 1]
17: set TITLE [lindex [split $line ":"] 2]
18: eval $widget.frame_list.space configure -text \"TX: $TITLE ($STAT)\"
19:
20: set N [expr $MAX_ENTRY + 1]
21: while {$N < 10} {
22: catch {
23: eval $widget.frame_list.me$N.n configure -text \"\"
24: eval $widget.frame_list.me$N.v configure -text \"\"
25: eval $widget.frame_list.me$N.n configure -relief flat
26: eval $widget.frame_list.me$N.s configure -relief flat
27: eval $widget.frame_list.me$N.v configure -relief flat
28: }
29: incr N
30: }
31: set MAX_ENTRY 0
32:
33: } elseif {[string match "RMT:*:*" $line]} {
34: set STAT [lindex [split $line ":"] 1]
35: set TITLE [lindex [split $line ":"] 2]
36: eval $widget.frame_list.space configure -text \"RX: $TITLE ($STAT)\"
37:
38: set N [expr $MAX_ENTRY + 1]
39: while {$N < 10} {
40: catch {
41: eval $widget.frame_list.me$N.n configure -text \"\"
42: eval $widget.frame_list.me$N.v configure -text \"\"
43: eval $widget.frame_list.me$N.n configure -relief flat
44: eval $widget.frame_list.me$N.s configure -relief flat
45: eval $widget.frame_list.me$N.v configure -relief flat
46: }
47: incr N
48: }
49: set MAX_ENTRY 0
50:
51: } elseif {[string match "ME:*:*" $line]} {
52: set TEXT [lindex [split [lrange [split $line ":"] 2 end] "="] 0]
53: set VALUE [lrange [split [lrange [split $line ":"] 2 end] "="] 1 end]
54: set ID [lindex [split $line ":"] 1]
55: set MAX_ENTRY $ID
56: if {[lindex $TEXT 0] == " "} {
57: set TEXT "";
58: }
59: catch {
60: eval $widget.frame_list.me$ID.n configure -text \"$TEXT\"
61: eval $widget.frame_list.me$ID.v configure -text \"$VALUE\"
62: }
63:
64: # .mainframe.a.menu.screen itemconfigure a.menu[expr $ID + 1] -text "$TEXT $VALUE"
65:
66: if {[string match ">*" $TEXT]} {
67: set N 0
68: while {$N < 10} {
69: catch {
70: eval $widget.frame_list.me$N.n configure -relief flat
71: eval $widget.frame_list.me$N.s configure -relief flat
72: eval $widget.frame_list.me$N.v configure -relief flat
73: }
74: incr N
75: }
76: catch {
77: eval $widget.frame_list.me$ID.n configure -relief raised
78: eval $widget.frame_list.me$ID.s configure -relief raised
79: eval $widget.frame_list.me$ID.v configure -relief raised
80: }
81: }
82: }
83: }
84:
85:
86: proc smenu_init {widget} {
87:
88: frame $widget -border 5 -relief sunken
89: pack $widget -side top -fill none -expand no
90:
91: frame $widget.frame_list
92: pack $widget.frame_list -side top -fill x
93:
94: label $widget.frame_list.space -text ""
95: pack $widget.frame_list.space -side top -fill x -expand yes
96:
97: set N 0
98: while {$N < 10} {
99: frame $widget.frame_list.me$N
100: pack $widget.frame_list.me$N -side top -fill x
101:
102: label $widget.frame_list.me$N.n -text "" -border 1
103: pack $widget.frame_list.me$N.n -side left -fill x -expand no
104:
105: label $widget.frame_list.me$N.s -text "" -border 1
106: pack $widget.frame_list.me$N.s -side left -fill x -expand yes
107:
108: label $widget.frame_list.me$N.v -text "" -border 1
109: pack $widget.frame_list.me$N.v -side right -fill x -expand no
110:
111: incr N
112: }
113:
114: frame $widget.frameB
115: pack $widget.frameB -side top -fill both -expand yes
116:
117: button $widget.frameB.m -text "Left" -border 1 -command {
118: send_cmd "1"
119: }
120: pack $widget.frameB.m -side left -fill both -expand yes
121:
122: frame $widget.frameB.frame3
123: pack $widget.frameB.frame3 -side left -fill both -expand yes
124:
125: button $widget.frameB.frame3.up -text "Up" -border 1 -command {
126: send_cmd "8"
127: }
128: pack $widget.frameB.frame3.up -side top -fill both -expand yes
129:
130: button $widget.frameB.frame3.down -text "Down" -border 1 -command {
131: send_cmd "2"
132: }
133: pack $widget.frameB.frame3.down -side bottom -fill both -expand yes
134:
135: button $widget.frameB.frame3.left -text "-" -border 1 -command {
136: send_cmd "4"
137: }
138: pack $widget.frameB.frame3.left -side left -fill x -expand yes
139:
140: button $widget.frameB.frame3.lr -text "L/R" -border 1 -command {
141: send_cmd "5"
142: }
143: pack $widget.frameB.frame3.lr -side left -fill x -expand yes
144:
145: button $widget.frameB.frame3.right -text "+" -border 1 -command {
146: send_cmd "6"
147: }
148: pack $widget.frameB.frame3.right -side right -fill x -expand yes
149:
150: button $widget.frameB.p -text "Right" -border 1 -command {
151: send_cmd "3"
152: }
153: pack $widget.frameB.p -side right -fill both -expand yes
154:
155: label $widget.bl -text "--" -border 1 -relief sunken
156: pack $widget.bl -side bottom -fill both -expand yes
157:
158: }
159: