Debian Codegraph @

audience~.tcl

raw
1 ############ audience procedures -- [email protected] #########
2
3 proc audience_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_width [concat graph_width_$vid]
8 global $var_graph_width
9 set var_graph_height [concat graph_height_$vid]
10 global $var_graph_height
11 set var_graph_nboutputs [concat graph_nboutputs_$vid]
12 global $var_graph_nboutputs
13
14 set cmd [concat $id dialog \
15 [eval concat $$var_graph_width] \
16 [eval concat $$var_graph_height] \
17 [eval concat $$var_graph_nboutputs] \
18 \;]
19 #puts stderr $cmd
20 pdsend $cmd
21 }
22
23 proc audience_cancel {id} {
24 set cmd [concat $id cancel \;]
25 #puts stderr $cmd
26 pdsend $cmd
27 }
28
29 proc audience_ok {id} {
30 audience_apply $id
31 audience_cancel $id
32 }
33
34 proc pdtk_audience_dialog {id width height nboutputs} {
35 set vid [string trimleft $id .]
36 set var_graph_width [concat graph_width_$vid]
37 global $var_graph_width
38 set var_graph_height [concat graph_height_$vid]
39 global $var_graph_height
40 set var_graph_nboutputs [concat graph_nboutputs_$vid]
41 global $var_graph_nboutputs
42
43 set $var_graph_width $width
44 set $var_graph_height $height
45 set $var_graph_nboutputs $nboutputs
46
47 toplevel $id
48 wm title $id {audience}
49 wm protocol $id WM_DELETE_WINDOW [concat audience_cancel $id]
50
51 label $id.label -text {2$ SPACE PROPERTIES}
52 pack $id.label -side top
53
54 frame $id.buttonframe
55 pack $id.buttonframe -side bottom -fill x -pady 2m
56 button $id.buttonframe.cancel -text {Cancel}\
57 -command "audience_cancel $id"
58 button $id.buttonframe.apply -text {Apply}\
59 -command "audience_apply $id"
60 button $id.buttonframe.ok -text {OK}\
61 -command "audience_ok $id"
62 pack $id.buttonframe.cancel -side left -expand 1
63 pack $id.buttonframe.apply -side left -expand 1
64 pack $id.buttonframe.ok -side left -expand 1
65
66 frame $id.1rangef
67 pack $id.1rangef -side top
68 label $id.1rangef.lwidth -text "Width :"
69 entry $id.1rangef.width -textvariable $var_graph_width -width 7
70 pack $id.1rangef.lwidth $id.1rangef.width -side left
71
72 frame $id.2rangef
73 pack $id.2rangef -side top
74 label $id.2rangef.lheight -text "Height :"
75 entry $id.2rangef.height -textvariable $var_graph_height -width 7
76 pack $id.2rangef.lheight $id.2rangef.height -side left
77
78 frame $id.3rangef
79 pack $id.3rangef -side top
80 label $id.3rangef.lnboutputs -text "Nb Listeners :"
81 entry $id.3rangef.nboutputs -textvariable $var_graph_nboutputs -width 7
82 pack $id.3rangef.lnboutputs $id.3rangef.nboutputs -side left
83
84 bind $id.1rangef.width <KeyPress-Return> [concat audience_ok $id]
85 bind $id.2rangef.height <KeyPress-Return> [concat audience_ok $id]
86 bind $id.3rangef.nboutputs <KeyPress-Return> [concat audience_ok $id]
87 focus $id.1rangef.width
88 }
89
90 ############ audience procedures END -- [email protected] #########