Debian Codegraph @

scratcher~.tcl

raw
1 ############ scratcher procedures -- [email protected] #########
2
3 proc scratcher_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
12 set cmd [concat $id dialog \
13 [eval concat $$var_graph_width] \
14 [eval concat $$var_graph_height] \
15 \;]
16 #puts stderr $cmd
17 pdsend $cmd
18 }
19
20 proc scratcher_cancel {id} {
21 set cmd [concat $id cancel \;]
22 #puts stderr $cmd
23 pdsend $cmd
24 }
25
26 proc scratcher_ok {id} {
27 scratcher_apply $id
28 scratcher_cancel $id
29 }
30
31 proc pdtk_scratcher_dialog {id width height} {
32 set vid [string trimleft $id .]
33 set var_graph_width [concat graph_width_$vid]
34 global $var_graph_width
35 set var_graph_height [concat graph_height_$vid]
36 global $var_graph_height
37
38 set $var_graph_width $width
39 set $var_graph_height $height
40
41 toplevel $id
42 wm title $id {scratcher}
43 wm protocol $id WM_DELETE_WINDOW [concat scratcher_cancel $id]
44
45 label $id.label -text {SCRATCHER PROPERTIES}
46 pack $id.label -side top
47
48 frame $id.buttonframe
49 pack $id.buttonframe -side bottom -fill x -pady 2m
50 button $id.buttonframe.cancel -text {Cancel}\
51 -command "scratcher_cancel $id"
52 button $id.buttonframe.apply -text {Apply}\
53 -command "scratcher_apply $id"
54 button $id.buttonframe.ok -text {OK}\
55 -command "scratcher_ok $id"
56 pack $id.buttonframe.cancel -side left -expand 1
57 pack $id.buttonframe.apply -side left -expand 1
58 pack $id.buttonframe.ok -side left -expand 1
59
60 frame $id.1rangef
61 pack $id.1rangef -side top
62 label $id.1rangef.lwidth -text "Width :"
63 entry $id.1rangef.width -textvariable $var_graph_width -width 7
64 pack $id.1rangef.lwidth $id.1rangef.width -side left
65
66 frame $id.2rangef
67 pack $id.2rangef -side top
68 label $id.2rangef.lheight -text "Height :"
69 entry $id.2rangef.height -textvariable $var_graph_height -width 7
70 pack $id.2rangef.lheight $id.2rangef.height -side left
71
72 bind $id.1rangef.name <KeyPress-Return> [concat scratcher_ok $id]
73 bind $id.2rangef.height <KeyPress-Return> [concat scratcher_ok $id]
74 focus $id.1rangef.name
75 }
76
77 ############ scratcher procedures END -- [email protected] #########