Debian Codegraph @

pianoroll.tcl

raw
1 ############ pianoroll procedures -- [email protected] #########
2
3 proc pianoroll_apply {id} {
4 # strip "." from the TK id to make a variable name suffix
5 set vid [string trimleft $id .]
6 # for each variable, make a local variable to hold its name...
7 set var_graph_name [concat graph_name_$vid]
8 global $var_graph_name
9 set var_graph_width [concat graph_width_$vid]
10 global $var_graph_width
11 set var_graph_height [concat graph_height_$vid]
12 global $var_graph_height
13 set var_graph_pmin [concat graph_pmin_$vid]
14 global $var_graph_pmin
15 set var_graph_pmax [concat graph_pmax_$vid]
16 global $var_graph_pmax
17 set var_graph_nbgrades [concat graph_nbgrades_$vid]
18 global $var_graph_nbgrades
19 set var_graph_nbsteps [concat graph_nbsteps_$vid]
20 global $var_graph_nbsteps
21 set var_graph_defvalue [concat graph_defvalue_$vid]
22 global $var_graph_defvalue
23 set var_graph_save [concat graph_save_$vid]
24 global $var_graph_save
25
26 set cmd [concat $id dialog \
27 [eval concat $$var_graph_name] \
28 [eval concat $$var_graph_width] \
29 [eval concat $$var_graph_height] \
30 [eval concat $$var_graph_pmin] \
31 [eval concat $$var_graph_pmax] \
32 [eval concat $$var_graph_nbgrades] \
33 [eval concat $$var_graph_nbsteps] \
34 [eval concat $$var_graph_defvalue] \
35 [eval concat $$var_graph_save] \;]
36 #puts stderr $cmd
37 pdsend $cmd
38 }
39
40 proc pianoroll_cancel {id} {
41 set cmd [concat $id cancel \;]
42 #puts stderr $cmd
43 pdsend $cmd
44 }
45
46 proc pianoroll_ok {id} {
47 pianoroll_apply $id
48 pianoroll_cancel $id
49 }
50
51 proc pdtk_pianoroll_dialog {id name width height pmin pmax nbgrades nbsteps defvalue save } {
52 set vid [string trimleft $id .]
53 set var_graph_name [concat graph_name_$vid]
54 global $var_graph_name
55 set var_graph_width [concat graph_width_$vid]
56 global $var_graph_width
57 set var_graph_height [concat graph_height_$vid]
58 global $var_graph_height
59 set var_graph_pmin [concat graph_pmin_$vid]
60 global $var_graph_pmin
61 set var_graph_pmax [concat graph_pmax_$vid]
62 global $var_graph_pmax
63 set var_graph_nbgrades [concat graph_nbgrades_$vid]
64 global $var_graph_nbgrades
65 set var_graph_nbsteps [concat graph_nbsteps_$vid]
66 global $var_graph_nbsteps
67 set var_graph_defvalue [concat graph_defvalue_$vid]
68 global $var_graph_defvalue
69 set var_graph_save [concat graph_save_$vid]
70 global $var_graph_save
71
72 set $var_graph_name $name
73 set $var_graph_width $width
74 set $var_graph_height $height
75 set $var_graph_pmin $pmin
76 set $var_graph_pmax $pmax
77 set $var_graph_nbgrades $nbgrades
78 set $var_graph_nbsteps $nbsteps
79 set $var_graph_defvalue $defvalue
80 set $var_graph_save $save
81
82 toplevel $id
83 wm title $id {pianoroll}
84 wm protocol $id WM_DELETE_WINDOW [concat pianoroll_cancel $id]
85
86 label $id.label -text {PIANOROLL PROPERTIES}
87 pack $id.label -side top
88
89 frame $id.buttonframe
90 pack $id.buttonframe -side bottom -fill x -pady 2m
91 button $id.buttonframe.cancel -text {Cancel}\
92 -command "pianoroll_cancel $id"
93 button $id.buttonframe.apply -text {Apply}\
94 -command "pianoroll_apply $id"
95 button $id.buttonframe.ok -text {OK}\
96 -command "pianoroll_ok $id"
97 pack $id.buttonframe.cancel -side left -expand 1
98 pack $id.buttonframe.apply -side left -expand 1
99 pack $id.buttonframe.ok -side left -expand 1
100
101 frame $id.1rangef
102 pack $id.1rangef -side top
103 label $id.1rangef.lname -text "Name :"
104 entry $id.1rangef.name -textvariable $var_graph_name -width 15
105 pack $id.1rangef.lname $id.1rangef.name -side left
106
107 frame $id.2rangef
108 pack $id.2rangef -side top
109 label $id.2rangef.lwidth -text "Width :"
110 entry $id.2rangef.width -textvariable $var_graph_width -width 7
111 pack $id.2rangef.lwidth $id.2rangef.width -side left
112
113 frame $id.3rangef
114 pack $id.3rangef -side top
115 label $id.3rangef.lheight -text "Height :"
116 entry $id.3rangef.height -textvariable $var_graph_height -width 7
117 pack $id.3rangef.lheight $id.3rangef.height -side left
118
119 frame $id.4rangef
120 pack $id.4rangef -side top
121 label $id.4rangef.lpmin -text "Pitch low :"
122 entry $id.4rangef.pmin -textvariable $var_graph_pmin -width 7
123 pack $id.4rangef.lpmin $id.4rangef.pmin -side left
124
125 frame $id.5rangef
126 pack $id.5rangef -side top
127 label $id.5rangef.lpmax -text "Pitch high :"
128 entry $id.5rangef.pmax -textvariable $var_graph_pmax -width 7
129 pack $id.5rangef.lpmax $id.5rangef.pmax -side left
130
131 frame $id.6rangef
132 pack $id.6rangef -side top
133 label $id.6rangef.lnbgrades -text "Grades :"
134 entry $id.6rangef.nbgrades -textvariable $var_graph_nbgrades -width 7
135 pack $id.6rangef.lnbgrades $id.6rangef.nbgrades -side left
136
137 frame $id.7rangef
138 pack $id.7rangef -side top
139 label $id.7rangef.lnbsteps -text "Steps :"
140 entry $id.7rangef.nbsteps -textvariable $var_graph_nbsteps -width 7
141 pack $id.7rangef.lnbsteps $id.7rangef.nbsteps -side left
142
143 frame $id.8rangef
144 pack $id.8rangef -side top
145 label $id.8rangef.ldefvalue -text "Default Value :"
146 entry $id.8rangef.defvalue -textvariable $var_graph_defvalue -width 7
147 pack $id.8rangef.ldefvalue $id.8rangef.defvalue -side left
148
149 checkbutton $id.save -text {Save contents} -variable $var_graph_save \
150 -anchor w
151 pack $id.save -side top
152
153 bind $id.1rangef.name <KeyPress-Return> [concat pianoroll_ok $id]
154 bind $id.2rangef.width <KeyPress-Return> [concat pianoroll_ok $id]
155 bind $id.3rangef.height <KeyPress-Return> [concat pianoroll_ok $id]
156 bind $id.4rangef.pmin <KeyPress-Return> [concat pianoroll_ok $id]
157 bind $id.5rangef.pmax <KeyPress-Return> [concat pianoroll_ok $id]
158 bind $id.6rangef.nbgrades <KeyPress-Return> [concat pianoroll_ok $id]
159 bind $id.7rangef.nbsteps <KeyPress-Return> [concat pianoroll_ok $id]
160 bind $id.8rangef.defvalue <KeyPress-Return> [concat pianoroll_ok $id]
161 focus $id.1rangef.name
162 }
163
164 ############ pianoroll procedures END -- [email protected] #########