ZTWHHH commited on
Commit
8079b12
·
verified ·
1 Parent(s): 763ce52

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. janus/lib/itcl4.2.4/libitcl4.2.4.so +3 -0
  3. janus/lib/pkgconfig/python-3.10.pc +13 -0
  4. janus/lib/sqlite3.44.2/libsqlite3.44.2.so +3 -0
  5. janus/lib/tk8.6/demos/aniwave.tcl +104 -0
  6. janus/lib/tk8.6/demos/arrow.tcl +241 -0
  7. janus/lib/tk8.6/demos/bind.tcl +78 -0
  8. janus/lib/tk8.6/demos/bitmap.tcl +52 -0
  9. janus/lib/tk8.6/demos/browse +66 -0
  10. janus/lib/tk8.6/demos/check.tcl +71 -0
  11. janus/lib/tk8.6/demos/colors.tcl +99 -0
  12. janus/lib/tk8.6/demos/combo.tcl +61 -0
  13. janus/lib/tk8.6/demos/cscroll.tcl +172 -0
  14. janus/lib/tk8.6/demos/ctext.tcl +176 -0
  15. janus/lib/tk8.6/demos/en.msg +97 -0
  16. janus/lib/tk8.6/demos/entry3.tcl +185 -0
  17. janus/lib/tk8.6/demos/fontchoose.tcl +67 -0
  18. janus/lib/tk8.6/demos/hello +22 -0
  19. janus/lib/tk8.6/demos/hscale.tcl +45 -0
  20. janus/lib/tk8.6/demos/images/earthris.gif +3 -0
  21. janus/lib/tk8.6/demos/images/flagdown.xbm +27 -0
  22. janus/lib/tk8.6/demos/images/flagup.xbm +27 -0
  23. janus/lib/tk8.6/demos/images/gray25.xbm +6 -0
  24. janus/lib/tk8.6/demos/images/letters.xbm +27 -0
  25. janus/lib/tk8.6/demos/images/noletter.xbm +27 -0
  26. janus/lib/tk8.6/demos/images/pattern.xbm +6 -0
  27. janus/lib/tk8.6/demos/items.tcl +302 -0
  28. janus/lib/tk8.6/demos/ixset +328 -0
  29. janus/lib/tk8.6/demos/knightstour.tcl +268 -0
  30. janus/lib/tk8.6/demos/labelframe.tcl +76 -0
  31. janus/lib/tk8.6/demos/menu.tcl +177 -0
  32. janus/lib/tk8.6/demos/msgbox.tcl +62 -0
  33. janus/lib/tk8.6/demos/nl.msg +125 -0
  34. janus/lib/tk8.6/demos/paned1.tcl +32 -0
  35. janus/lib/tk8.6/demos/paned2.tcl +74 -0
  36. janus/lib/tk8.6/demos/pendulum.tcl +197 -0
  37. janus/lib/tk8.6/demos/plot.tcl +97 -0
  38. janus/lib/tk8.6/demos/puzzle.tcl +82 -0
  39. janus/lib/tk8.6/demos/radio.tcl +66 -0
  40. janus/lib/tk8.6/demos/rmt +210 -0
  41. janus/lib/tk8.6/demos/rolodex +204 -0
  42. janus/lib/tk8.6/demos/ruler.tcl +175 -0
  43. janus/lib/tk8.6/demos/search.tcl +139 -0
  44. janus/lib/tk8.6/demos/spin.tcl +53 -0
  45. janus/lib/tk8.6/demos/states.tcl +54 -0
  46. janus/lib/tk8.6/demos/style.tcl +155 -0
  47. janus/lib/tk8.6/demos/tclIndex +67 -0
  48. janus/lib/tk8.6/demos/tcolor +358 -0
  49. janus/lib/tk8.6/demos/text.tcl +113 -0
  50. janus/lib/tk8.6/demos/timer +47 -0
.gitattributes CHANGED
@@ -526,3 +526,5 @@ janus/lib/python3.10/site-packages/numpy/random/_bounded_integers.cpython-310-x8
526
  janus/lib/python3.10/lib-dynload/_codecs_tw.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
527
  janus/lib/ossl-modules/legacy.so filter=lfs diff=lfs merge=lfs -text
528
  janus/lib/python3.10/lib-dynload/_decimal.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
 
526
  janus/lib/python3.10/lib-dynload/_codecs_tw.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
527
  janus/lib/ossl-modules/legacy.so filter=lfs diff=lfs merge=lfs -text
528
  janus/lib/python3.10/lib-dynload/_decimal.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
529
+ janus/lib/sqlite3.44.2/libsqlite3.44.2.so filter=lfs diff=lfs merge=lfs -text
530
+ janus/lib/itcl4.2.4/libitcl4.2.4.so filter=lfs diff=lfs merge=lfs -text
janus/lib/itcl4.2.4/libitcl4.2.4.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4dec209d072b6ea25863993f95c4fcf0023974e0d01d06a5705173db1313379
3
+ size 318912
janus/lib/pkgconfig/python-3.10.pc ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See: man pkg-config
2
+ prefix=/root/envs/janus
3
+ exec_prefix=${prefix}
4
+ libdir=${exec_prefix}/lib
5
+ includedir=${prefix}/include
6
+
7
+ Name: Python
8
+ Description: Build a C extension for Python
9
+ Requires:
10
+ Version: 3.10
11
+ Libs.private: -lcrypt -lpthread -ldl -lutil -lm
12
+ Libs:
13
+ Cflags: -I${includedir}/python3.10
janus/lib/sqlite3.44.2/libsqlite3.44.2.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ccfe88e9e8b573a4d312a3cf85f51de60783ab649a4ca9a4ae69b13c3f87ef1
3
+ size 1596704
janus/lib/tk8.6/demos/aniwave.tcl ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # aniwave.tcl --
2
+ #
3
+ # This demonstration script illustrates how to adjust canvas item
4
+ # coordinates in a way that does something fairly similar to waveform
5
+ # display.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .aniwave
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Animated Wave Demonstration"
17
+ wm iconname $w "aniwave"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration contains a canvas widget with a line item inside it. The animation routines work by adjusting the coordinates list of the line; a trace on a variable is used so updates to the variable result in a change of position of the line."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ # Create a canvas large enough to hold the wave. In fact, the wave
28
+ # sticks off both sides of the canvas to prevent visual glitches.
29
+ pack [canvas $w.c -width 300 -height 200 -background black] -padx 10 -pady 10 -expand yes
30
+
31
+ # Ensure that this this is an array
32
+ array set animationCallbacks {}
33
+
34
+ # Creates a coordinates list of a wave. This code does a very sketchy
35
+ # job and relies on Tk's line smoothing to make things look better.
36
+ set waveCoords {}
37
+ for {set x -10} {$x<=300} {incr x 5} {
38
+ lappend waveCoords $x 100
39
+ }
40
+ lappend waveCoords $x 0 [incr x 5] 200
41
+
42
+ # Create a smoothed line and arrange for its coordinates to be the
43
+ # contents of the variable waveCoords.
44
+ $w.c create line $waveCoords -tags wave -width 1 -fill green -smooth 1
45
+ proc waveCoordsTracer {w args} {
46
+ global waveCoords
47
+ # Actual visual update will wait until we have finished
48
+ # processing; Tk does that for us automatically.
49
+ $w.c coords wave $waveCoords
50
+ }
51
+ trace add variable waveCoords write [list waveCoordsTracer $w]
52
+
53
+ # Basic motion handler. Given what direction the wave is travelling
54
+ # in, it advances the y coordinates in the coordinate-list one step in
55
+ # that direction.
56
+ proc basicMotion {} {
57
+ global waveCoords direction
58
+ set oc $waveCoords
59
+ for {set i 1} {$i<[llength $oc]} {incr i 2} {
60
+ if {$direction eq "left"} {
61
+ lset waveCoords $i [lindex $oc \
62
+ [expr {$i+2>[llength $oc] ? 1 : $i+2}]]
63
+ } else {
64
+ lset waveCoords $i \
65
+ [lindex $oc [expr {$i-2<0 ? "end" : $i-2}]]
66
+ }
67
+ }
68
+ }
69
+
70
+ # Oscillation handler. This detects whether to reverse the direction
71
+ # of the wave by checking to see if the peak of the wave has moved off
72
+ # the screen (whose size we know already.)
73
+ proc reverser {} {
74
+ global waveCoords direction
75
+ if {[lindex $waveCoords 1] < 10} {
76
+ set direction "right"
77
+ } elseif {[lindex $waveCoords end] < 10} {
78
+ set direction "left"
79
+ }
80
+ }
81
+
82
+ # Main animation "loop". This calls the two procedures that handle the
83
+ # movement repeatedly by scheduling asynchronous calls back to itself
84
+ # using the [after] command. This procedure is the fundamental basis
85
+ # for all animated effect handling in Tk.
86
+ proc move {} {
87
+ basicMotion
88
+ reverser
89
+
90
+ # Theoretically 100 frames-per-second (==10ms between frames)
91
+ global animationCallbacks
92
+ set animationCallbacks(simpleWave) [after 10 move]
93
+ }
94
+
95
+ # Initialise our remaining animation variables
96
+ set direction "left"
97
+ set animateAfterCallback {}
98
+ # Arrange for the animation loop to stop when the canvas is deleted
99
+ bind $w.c <Destroy> {
100
+ after cancel $animationCallbacks(simpleWave)
101
+ unset animationCallbacks(simpleWave)
102
+ }
103
+ # Start the animation processing
104
+ move
janus/lib/tk8.6/demos/arrow.tcl ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # arrow.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget that displays a
4
+ # large line with an arrowhead whose shape can be edited interactively.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # arrowSetup --
13
+ # This procedure regenerates all the text and graphics in the canvas
14
+ # window. It's called when the canvas is initially created, and also
15
+ # whenever any of the parameters of the arrow head are changed
16
+ # interactively.
17
+ #
18
+ # Arguments:
19
+ # c - Name of the canvas widget.
20
+
21
+ proc arrowSetup c {
22
+ upvar #0 demo_arrowInfo v
23
+
24
+ # Remember the current box, if there is one.
25
+
26
+ set tags [$c gettags current]
27
+ if {$tags != ""} {
28
+ set cur [lindex $tags [lsearch -glob $tags box?]]
29
+ } else {
30
+ set cur ""
31
+ }
32
+
33
+ # Create the arrow and outline.
34
+
35
+ $c delete all
36
+ eval {$c create line $v(x1) $v(y) $v(x2) $v(y) -arrow last \
37
+ -width [expr {10*$v(width)}] -arrowshape [list \
38
+ [expr {10*$v(a)}] [expr {10*$v(b)}] [expr {10*$v(c)}]]} \
39
+ $v(bigLineStyle)
40
+ set xtip [expr {$v(x2)-10*$v(b)}]
41
+ set deltaY [expr {10*$v(c)+5*$v(width)}]
42
+ $c create line $v(x2) $v(y) $xtip [expr {$v(y)+$deltaY}] \
43
+ [expr {$v(x2)-10*$v(a)}] $v(y) $xtip [expr {$v(y)-$deltaY}] \
44
+ $v(x2) $v(y) -width 2 -capstyle round -joinstyle round
45
+
46
+ # Create the boxes for reshaping the line and arrowhead.
47
+
48
+ eval {$c create rect [expr {$v(x2)-10*$v(a)-5}] [expr {$v(y)-5}] \
49
+ [expr {$v(x2)-10*$v(a)+5}] [expr {$v(y)+5}] \
50
+ -tags {box1 box}} $v(boxStyle)
51
+ eval {$c create rect [expr {$xtip-5}] [expr {$v(y)-$deltaY-5}] \
52
+ [expr {$xtip+5}] [expr {$v(y)-$deltaY+5}] \
53
+ -tags {box2 box}} $v(boxStyle)
54
+ eval {$c create rect [expr {$v(x1)-5}] [expr {$v(y)-5*$v(width)-5}] \
55
+ [expr {$v(x1)+5}] [expr {$v(y)-5*$v(width)+5}] \
56
+ -tags {box3 box}} $v(boxStyle)
57
+ if {$cur != ""} {
58
+ eval $c itemconfigure $cur $v(activeStyle)
59
+ }
60
+
61
+ # Create three arrows in actual size with the same parameters
62
+
63
+ $c create line [expr {$v(x2)+50}] 0 [expr {$v(x2)+50}] 1000 \
64
+ -width 2
65
+ set tmp [expr {$v(x2)+100}]
66
+ $c create line $tmp [expr {$v(y)-125}] $tmp [expr {$v(y)-75}] \
67
+ -width $v(width) \
68
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
69
+ $c create line [expr {$tmp-25}] $v(y) [expr {$tmp+25}] $v(y) \
70
+ -width $v(width) \
71
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
72
+ $c create line [expr {$tmp-25}] [expr {$v(y)+75}] [expr {$tmp+25}] \
73
+ [expr {$v(y)+125}] -width $v(width) \
74
+ -arrow both -arrowshape "$v(a) $v(b) $v(c)"
75
+
76
+ # Create a bunch of other arrows and text items showing the
77
+ # current dimensions.
78
+
79
+ set tmp [expr {$v(x2)+10}]
80
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
81
+ $tmp [expr {$v(y)-$deltaY}] \
82
+ -arrow both -arrowshape $v(smallTips)
83
+ $c create text [expr {$v(x2)+15}] [expr {$v(y)-$deltaY+5*$v(c)}] \
84
+ -text $v(c) -anchor w
85
+ set tmp [expr {$v(x1)-10}]
86
+ $c create line $tmp [expr {$v(y)-5*$v(width)}] \
87
+ $tmp [expr {$v(y)+5*$v(width)}] \
88
+ -arrow both -arrowshape $v(smallTips)
89
+ $c create text [expr {$v(x1)-15}] $v(y) -text $v(width) -anchor e
90
+ set tmp [expr {$v(y)+5*$v(width)+10*$v(c)+10}]
91
+ $c create line [expr {$v(x2)-10*$v(a)}] $tmp $v(x2) $tmp \
92
+ -arrow both -arrowshape $v(smallTips)
93
+ $c create text [expr {$v(x2)-5*$v(a)}] [expr {$tmp+5}] \
94
+ -text $v(a) -anchor n
95
+ set tmp [expr {$tmp+25}]
96
+ $c create line [expr {$v(x2)-10*$v(b)}] $tmp $v(x2) $tmp \
97
+ -arrow both -arrowshape $v(smallTips)
98
+ $c create text [expr {$v(x2)-5*$v(b)}] [expr {$tmp+5}] \
99
+ -text $v(b) -anchor n
100
+
101
+ $c create text $v(x1) 310 -text "-width $v(width)" \
102
+ -anchor w -font {Helvetica 18}
103
+ $c create text $v(x1) 330 -text "-arrowshape {$v(a) $v(b) $v(c)}" \
104
+ -anchor w -font {Helvetica 18}
105
+
106
+ incr v(count)
107
+ }
108
+
109
+ set w .arrow
110
+ catch {destroy $w}
111
+ toplevel $w
112
+ wm title $w "Arrowhead Editor Demonstration"
113
+ wm iconname $w "arrow"
114
+ positionWindow $w
115
+ set c $w.c
116
+
117
+ label $w.msg -font $font -wraplength 5i -justify left -text "This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."
118
+ pack $w.msg -side top
119
+
120
+ ## See Code / Dismiss buttons
121
+ set btns [addSeeDismiss $w.buttons $w]
122
+ pack $btns -side bottom -fill x
123
+
124
+ canvas $c -width 500 -height 350 -relief sunken -borderwidth 2
125
+ pack $c -expand yes -fill both
126
+
127
+ set demo_arrowInfo(a) 8
128
+ set demo_arrowInfo(b) 10
129
+ set demo_arrowInfo(c) 3
130
+ set demo_arrowInfo(width) 2
131
+ set demo_arrowInfo(motionProc) arrowMoveNull
132
+ set demo_arrowInfo(x1) 40
133
+ set demo_arrowInfo(x2) 350
134
+ set demo_arrowInfo(y) 150
135
+ set demo_arrowInfo(smallTips) {5 5 2}
136
+ set demo_arrowInfo(count) 0
137
+ if {[winfo depth $c] > 1} {
138
+ if {[tk windowingsystem] eq "aqua"} {
139
+ set demo_arrowInfo(bigLineStyle) "-fill systemSelectedTextBackgroundColor"
140
+ } else {
141
+ set demo_arrowInfo(bigLineStyle) "-fill LightSeaGreen"
142
+ }
143
+ set demo_arrowInfo(boxStyle) "-fill {} -width 1"
144
+ set demo_arrowInfo(activeStyle) "-fill red -width 1"
145
+ } else {
146
+ # Main widget program sets variable tk_demoDirectory
147
+ set demo_arrowInfo(bigLineStyle) "-fill black \
148
+ -stipple @[file join $tk_demoDirectory images grey.25]"
149
+ set demo_arrowInfo(boxStyle) "-fill {} -outline black -width 1"
150
+ set demo_arrowInfo(activeStyle) "-fill black -outline black -width 1"
151
+ }
152
+ arrowSetup $c
153
+ $c bind box <Enter> "$c itemconfigure current $demo_arrowInfo(activeStyle)"
154
+ $c bind box <Leave> "$c itemconfigure current $demo_arrowInfo(boxStyle)"
155
+ $c bind box <B1-Enter> " "
156
+ $c bind box <B1-Leave> " "
157
+ $c bind box1 <Button-1> {set demo_arrowInfo(motionProc) arrowMove1}
158
+ $c bind box2 <Button-1> {set demo_arrowInfo(motionProc) arrowMove2}
159
+ $c bind box3 <Button-1> {set demo_arrowInfo(motionProc) arrowMove3}
160
+ $c bind box <B1-Motion> "\$demo_arrowInfo(motionProc) $c %x %y"
161
+ bind $c <ButtonRelease-1> "arrowSetup $c"
162
+
163
+ # arrowMove1 --
164
+ # This procedure is called for each mouse motion event on box1 (the
165
+ # one at the vertex of the arrow). It updates the controlling parameters
166
+ # for the line and arrowhead.
167
+ #
168
+ # Arguments:
169
+ # c - The name of the canvas window.
170
+ # x, y - The coordinates of the mouse.
171
+
172
+ proc arrowMove1 {c x y} {
173
+ upvar #0 demo_arrowInfo v
174
+ set newA [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
175
+ if {$newA < 0} {
176
+ set newA 0
177
+ }
178
+ if {$newA > 25} {
179
+ set newA 25
180
+ }
181
+ if {$newA != $v(a)} {
182
+ $c move box1 [expr {10*($v(a)-$newA)}] 0
183
+ set v(a) $newA
184
+ }
185
+ }
186
+
187
+ # arrowMove2 --
188
+ # This procedure is called for each mouse motion event on box2 (the
189
+ # one at the trailing tip of the arrowhead). It updates the controlling
190
+ # parameters for the line and arrowhead.
191
+ #
192
+ # Arguments:
193
+ # c - The name of the canvas window.
194
+ # x, y - The coordinates of the mouse.
195
+
196
+ proc arrowMove2 {c x y} {
197
+ upvar #0 demo_arrowInfo v
198
+ set newB [expr {($v(x2)+5-round([$c canvasx $x]))/10}]
199
+ if {$newB < 0} {
200
+ set newB 0
201
+ }
202
+ if {$newB > 25} {
203
+ set newB 25
204
+ }
205
+ set newC [expr {($v(y)+5-round([$c canvasy $y])-5*$v(width))/10}]
206
+ if {$newC < 0} {
207
+ set newC 0
208
+ }
209
+ if {$newC > 20} {
210
+ set newC 20
211
+ }
212
+ if {($newB != $v(b)) || ($newC != $v(c))} {
213
+ $c move box2 [expr {10*($v(b)-$newB)}] [expr {10*($v(c)-$newC)}]
214
+ set v(b) $newB
215
+ set v(c) $newC
216
+ }
217
+ }
218
+
219
+ # arrowMove3 --
220
+ # This procedure is called for each mouse motion event on box3 (the
221
+ # one that controls the thickness of the line). It updates the
222
+ # controlling parameters for the line and arrowhead.
223
+ #
224
+ # Arguments:
225
+ # c - The name of the canvas window.
226
+ # x, y - The coordinates of the mouse.
227
+
228
+ proc arrowMove3 {c x y} {
229
+ upvar #0 demo_arrowInfo v
230
+ set newWidth [expr {($v(y)+2-round([$c canvasy $y]))/5}]
231
+ if {$newWidth < 0} {
232
+ set newWidth 0
233
+ }
234
+ if {$newWidth > 20} {
235
+ set newWidth 20
236
+ }
237
+ if {$newWidth != $v(width)} {
238
+ $c move box3 0 [expr {5*($v(width)-$newWidth)}]
239
+ set v(width) $newWidth
240
+ }
241
+ }
janus/lib/tk8.6/demos/bind.tcl ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bind.tcl --
2
+ #
3
+ # This demonstration script creates a text widget with bindings set
4
+ # up for hypertext-like effects.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .bind
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Text Demonstration - Tag Bindings"
16
+ wm iconname $w "bind"
17
+ positionWindow $w
18
+
19
+ ## See Code / Dismiss buttons
20
+ set btns [addSeeDismiss $w.buttons $w]
21
+ pack $btns -side bottom -fill x
22
+
23
+ text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
24
+ -width 60 -height 24 -font $font -wrap word
25
+ ttk::scrollbar $w.scroll -command "$w.text yview"
26
+ pack $w.scroll -side right -fill y
27
+ pack $w.text -expand yes -fill both
28
+
29
+ # Set up display styles.
30
+
31
+ if {[winfo depth $w] > 1} {
32
+ set bold "-background #43ce80 -relief raised -borderwidth 1"
33
+ set normal "-background {} -relief flat"
34
+ } else {
35
+ set bold "-foreground white -background black"
36
+ set normal "-foreground {} -background {}"
37
+ }
38
+
39
+ # Add text to widget.
40
+
41
+ $w.text insert 0.0 {\
42
+ The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked.
43
+
44
+ }
45
+ $w.text insert end \
46
+ {1. Samples of all the different types of items that can be created in canvas widgets.} d1
47
+ $w.text insert end \n\n
48
+ $w.text insert end \
49
+ {2. A simple two-dimensional plot that allows you to adjust the positions of the data points.} d2
50
+ $w.text insert end \n\n
51
+ $w.text insert end \
52
+ {3. Anchoring and justification modes for text items.} d3
53
+ $w.text insert end \n\n
54
+ $w.text insert end \
55
+ {4. An editor for arrow-head shapes for line items.} d4
56
+ $w.text insert end \n\n
57
+ $w.text insert end \
58
+ {5. A ruler with facilities for editing tab stops.} d5
59
+ $w.text insert end \n\n
60
+ $w.text insert end \
61
+ {6. A grid that demonstrates how canvases can be scrolled.} d6
62
+
63
+ # Create bindings for tags.
64
+
65
+ foreach tag {d1 d2 d3 d4 d5 d6} {
66
+ $w.text tag bind $tag <Enter> "$w.text tag configure $tag $bold"
67
+ $w.text tag bind $tag <Leave> "$w.text tag configure $tag $normal"
68
+ }
69
+ # Main widget program sets variable tk_demoDirectory
70
+ $w.text tag bind d1 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory items.tcl]}
71
+ $w.text tag bind d2 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory plot.tcl]}
72
+ $w.text tag bind d3 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ctext.tcl]}
73
+ $w.text tag bind d4 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory arrow.tcl]}
74
+ $w.text tag bind d5 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory ruler.tcl]}
75
+ $w.text tag bind d6 <Button-1> {source -encoding utf-8 [file join $tk_demoDirectory cscroll.tcl]}
76
+
77
+ $w.text mark set insert 0.0
78
+ $w.text configure -state disabled
janus/lib/tk8.6/demos/bitmap.tcl ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bitmap.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window that displays
4
+ # all of Tk's built-in bitmaps.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # bitmapRow --
13
+ # Create a row of bitmap items in a window.
14
+ #
15
+ # Arguments:
16
+ # w - The window that is to contain the row.
17
+ # args - The names of one or more bitmaps, which will be displayed
18
+ # in a new row across the bottom of w along with their
19
+ # names.
20
+
21
+ proc bitmapRow {w args} {
22
+ frame $w
23
+ pack $w -side top -fill both
24
+ set i 0
25
+ foreach bitmap $args {
26
+ frame $w.$i
27
+ pack $w.$i -side left -fill both -pady .25c -padx .25c
28
+ label $w.$i.bitmap -bitmap $bitmap
29
+ label $w.$i.label -text $bitmap -width 9
30
+ pack $w.$i.label $w.$i.bitmap -side bottom
31
+ incr i
32
+ }
33
+ }
34
+
35
+ set w .bitmap
36
+ catch {destroy $w}
37
+ toplevel $w
38
+ wm title $w "Bitmap Demonstration"
39
+ wm iconname $w "bitmap"
40
+ positionWindow $w
41
+
42
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."
43
+ pack $w.msg -side top
44
+
45
+ ## See Code / Dismiss buttons
46
+ set btns [addSeeDismiss $w.buttons $w]
47
+ pack $btns -side bottom -fill x
48
+
49
+ frame $w.frame
50
+ bitmapRow $w.frame.0 error gray12 gray25 gray50 gray75
51
+ bitmapRow $w.frame.1 hourglass info question questhead warning
52
+ pack $w.frame -side top -expand yes -fill both
janus/lib/tk8.6/demos/browse ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # browse --
6
+ # This script generates a directory browser, which lists the working
7
+ # directory and allows you to open files or subdirectories by
8
+ # double-clicking.
9
+
10
+ package require Tk
11
+
12
+ # Create a scrollbar on the right side of the main window and a listbox
13
+ # on the left side.
14
+
15
+ scrollbar .scroll -command ".list yview"
16
+ pack .scroll -side right -fill y
17
+ listbox .list -yscroll ".scroll set" -relief sunken -width 20 -height 20 \
18
+ -setgrid yes
19
+ pack .list -side left -fill both -expand yes
20
+ wm minsize . 1 1
21
+
22
+ # The procedure below is invoked to open a browser on a given file; if the
23
+ # file is a directory then another instance of this program is invoked; if
24
+ # the file is a regular file then the Mx editor is invoked to display
25
+ # the file.
26
+
27
+ set browseScript [file join [pwd] $argv0]
28
+ proc browse {dir file} {
29
+ global env browseScript
30
+ if {[string compare $dir "."] != 0} {set file $dir/$file}
31
+ switch [file type $file] {
32
+ directory {
33
+ exec [info nameofexecutable] $browseScript $file &
34
+ }
35
+ file {
36
+ if {[info exists env(EDITOR)]} {
37
+ eval exec $env(EDITOR) $file &
38
+ } else {
39
+ exec xedit $file &
40
+ }
41
+ }
42
+ default {
43
+ puts stdout "\"$file\" isn't a directory or regular file"
44
+ }
45
+ }
46
+ }
47
+
48
+ # Fill the listbox with a list of all the files in the directory.
49
+
50
+ if {$argc>0} {set dir [lindex $argv 0]} else {set dir "."}
51
+ foreach i [lsort [glob * .* *.*]] {
52
+ if {[file type $i] eq "directory"} {
53
+ # Safe to do since it is still a directory.
54
+ append i /
55
+ }
56
+ .list insert end $i
57
+ }
58
+
59
+ # Set up bindings for the browser.
60
+
61
+ bind all <Control-c> {destroy .}
62
+ bind .list <Double-Button-1> {foreach i [selection get] {browse $dir $i}}
63
+
64
+ # Local Variables:
65
+ # mode: tcl
66
+ # End:
janus/lib/tk8.6/demos/check.tcl ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # check.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several checkbuttons.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .check
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Checkbutton Demonstration"
16
+ wm iconname $w "check"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "Four checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. The first button also follows the state of the other three. If only some of the three are checked, the first button will display the tri-state mode. Click the \"See Variables\" button to see the current values of the variables."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w [list safety wipers brakes sober]]
24
+ pack $btns -side bottom -fill x
25
+
26
+ checkbutton $w.b0 -text "Safety Check" -variable safety -relief flat \
27
+ -onvalue "all" \
28
+ -offvalue "none" \
29
+ -tristatevalue "partial"
30
+ checkbutton $w.b1 -text "Wipers OK" -variable wipers -relief flat
31
+ checkbutton $w.b2 -text "Brakes OK" -variable brakes -relief flat
32
+ checkbutton $w.b3 -text "Driver Sober" -variable sober -relief flat
33
+ pack $w.b0 -side top -pady 2 -anchor w
34
+ pack $w.b1 $w.b2 $w.b3 -side top -pady 2 -anchor w -padx 15
35
+
36
+ ## This code makes $w.b0 function as a tri-state button; it's not
37
+ ## needed at all for just straight yes/no buttons.
38
+
39
+ set in_check 0
40
+ proc tristate_check {n1 n2 op} {
41
+ global safety wipers brakes sober in_check
42
+ if {$in_check} {
43
+ return
44
+ }
45
+ set in_check 1
46
+ if {$n1 eq "safety"} {
47
+ if {$safety eq "none"} {
48
+ set wipers 0
49
+ set brakes 0
50
+ set sober 0
51
+ } elseif {$safety eq "all"} {
52
+ set wipers 1
53
+ set brakes 1
54
+ set sober 1
55
+ }
56
+ } else {
57
+ if {$wipers == 1 && $brakes == 1 && $sober == 1} {
58
+ set safety all
59
+ } elseif {$wipers == 1 || $brakes == 1 || $sober == 1} {
60
+ set safety partial
61
+ } else {
62
+ set safety none
63
+ }
64
+ }
65
+ set in_check 0
66
+ }
67
+
68
+ trace add variable wipers write tristate_check
69
+ trace add variable brakes write tristate_check
70
+ trace add variable sober write tristate_check
71
+ trace add variable safety write tristate_check
janus/lib/tk8.6/demos/colors.tcl ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # colors.tcl --
2
+ #
3
+ # This demonstration script creates a listbox widget that displays
4
+ # many of the colors from the X color database. You can click on
5
+ # a color to change the application's palette.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .colors
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Listbox Demonstration (colors)"
17
+ wm iconname $w "Listbox"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing several color names is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by dragging in the listbox window with button 2 pressed. If you double-click button 1 on a color, then the application's color palette will be set to match that color"
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ frame $w.frame -borderwidth 10
28
+ pack $w.frame -side top -expand yes -fill y
29
+
30
+ scrollbar $w.frame.scroll -command "$w.frame.list yview"
31
+ listbox $w.frame.list -yscroll "$w.frame.scroll set" \
32
+ -width 20 -height 16 -setgrid 1
33
+ pack $w.frame.list $w.frame.scroll -side left -fill y -expand 1
34
+
35
+ bind $w.frame.list <Double-Button-1> {
36
+ tk_setPalette [selection get]
37
+ }
38
+ $w.frame.list insert 0 gray60 gray70 gray80 gray85 gray90 gray95 \
39
+ snow1 snow2 snow3 snow4 seashell1 seashell2 \
40
+ seashell3 seashell4 AntiqueWhite1 AntiqueWhite2 AntiqueWhite3 \
41
+ AntiqueWhite4 bisque1 bisque2 bisque3 bisque4 PeachPuff1 \
42
+ PeachPuff2 PeachPuff3 PeachPuff4 NavajoWhite1 NavajoWhite2 \
43
+ NavajoWhite3 NavajoWhite4 LemonChiffon1 LemonChiffon2 \
44
+ LemonChiffon3 LemonChiffon4 cornsilk1 cornsilk2 cornsilk3 \
45
+ cornsilk4 ivory1 ivory2 ivory3 ivory4 honeydew1 honeydew2 \
46
+ honeydew3 honeydew4 LavenderBlush1 LavenderBlush2 \
47
+ LavenderBlush3 LavenderBlush4 MistyRose1 MistyRose2 \
48
+ MistyRose3 MistyRose4 azure1 azure2 azure3 azure4 \
49
+ SlateBlue1 SlateBlue2 SlateBlue3 SlateBlue4 RoyalBlue1 \
50
+ RoyalBlue2 RoyalBlue3 RoyalBlue4 blue1 blue2 blue3 blue4 \
51
+ DodgerBlue1 DodgerBlue2 DodgerBlue3 DodgerBlue4 SteelBlue1 \
52
+ SteelBlue2 SteelBlue3 SteelBlue4 DeepSkyBlue1 DeepSkyBlue2 \
53
+ DeepSkyBlue3 DeepSkyBlue4 SkyBlue1 SkyBlue2 SkyBlue3 \
54
+ SkyBlue4 LightSkyBlue1 LightSkyBlue2 LightSkyBlue3 \
55
+ LightSkyBlue4 SlateGray1 SlateGray2 SlateGray3 SlateGray4 \
56
+ LightSteelBlue1 LightSteelBlue2 LightSteelBlue3 \
57
+ LightSteelBlue4 LightBlue1 LightBlue2 LightBlue3 \
58
+ LightBlue4 LightCyan1 LightCyan2 LightCyan3 LightCyan4 \
59
+ PaleTurquoise1 PaleTurquoise2 PaleTurquoise3 PaleTurquoise4 \
60
+ CadetBlue1 CadetBlue2 CadetBlue3 CadetBlue4 turquoise1 \
61
+ turquoise2 turquoise3 turquoise4 cyan1 cyan2 cyan3 cyan4 \
62
+ DarkSlateGray1 DarkSlateGray2 DarkSlateGray3 \
63
+ DarkSlateGray4 aquamarine1 aquamarine2 aquamarine3 \
64
+ aquamarine4 DarkSeaGreen1 DarkSeaGreen2 DarkSeaGreen3 \
65
+ DarkSeaGreen4 SeaGreen1 SeaGreen2 SeaGreen3 SeaGreen4 \
66
+ PaleGreen1 PaleGreen2 PaleGreen3 PaleGreen4 SpringGreen1 \
67
+ SpringGreen2 SpringGreen3 SpringGreen4 green1 green2 \
68
+ green3 green4 chartreuse1 chartreuse2 chartreuse3 \
69
+ chartreuse4 OliveDrab1 OliveDrab2 OliveDrab3 OliveDrab4 \
70
+ DarkOliveGreen1 DarkOliveGreen2 DarkOliveGreen3 \
71
+ DarkOliveGreen4 khaki1 khaki2 khaki3 khaki4 \
72
+ LightGoldenrod1 LightGoldenrod2 LightGoldenrod3 \
73
+ LightGoldenrod4 LightYellow1 LightYellow2 LightYellow3 \
74
+ LightYellow4 yellow1 yellow2 yellow3 yellow4 gold1 gold2 \
75
+ gold3 gold4 goldenrod1 goldenrod2 goldenrod3 goldenrod4 \
76
+ DarkGoldenrod1 DarkGoldenrod2 DarkGoldenrod3 DarkGoldenrod4 \
77
+ RosyBrown1 RosyBrown2 RosyBrown3 RosyBrown4 IndianRed1 \
78
+ IndianRed2 IndianRed3 IndianRed4 sienna1 sienna2 sienna3 \
79
+ sienna4 burlywood1 burlywood2 burlywood3 burlywood4 wheat1 \
80
+ wheat2 wheat3 wheat4 tan1 tan2 tan3 tan4 chocolate1 \
81
+ chocolate2 chocolate3 chocolate4 firebrick1 firebrick2 \
82
+ firebrick3 firebrick4 brown1 brown2 brown3 brown4 salmon1 \
83
+ salmon2 salmon3 salmon4 LightSalmon1 LightSalmon2 \
84
+ LightSalmon3 LightSalmon4 orange1 orange2 orange3 orange4 \
85
+ DarkOrange1 DarkOrange2 DarkOrange3 DarkOrange4 coral1 \
86
+ coral2 coral3 coral4 tomato1 tomato2 tomato3 tomato4 \
87
+ OrangeRed1 OrangeRed2 OrangeRed3 OrangeRed4 red1 red2 red3 \
88
+ red4 DeepPink1 DeepPink2 DeepPink3 DeepPink4 HotPink1 \
89
+ HotPink2 HotPink3 HotPink4 pink1 pink2 pink3 pink4 \
90
+ LightPink1 LightPink2 LightPink3 LightPink4 PaleVioletRed1 \
91
+ PaleVioletRed2 PaleVioletRed3 PaleVioletRed4 maroon1 \
92
+ maroon2 maroon3 maroon4 VioletRed1 VioletRed2 VioletRed3 \
93
+ VioletRed4 magenta1 magenta2 magenta3 magenta4 orchid1 \
94
+ orchid2 orchid3 orchid4 plum1 plum2 plum3 plum4 \
95
+ MediumOrchid1 MediumOrchid2 MediumOrchid3 MediumOrchid4 \
96
+ DarkOrchid1 DarkOrchid2 DarkOrchid3 DarkOrchid4 purple1 \
97
+ purple2 purple3 purple4 MediumPurple1 MediumPurple2 \
98
+ MediumPurple3 MediumPurple4 thistle1 thistle2 thistle3 \
99
+ thistle4
janus/lib/tk8.6/demos/combo.tcl ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # combo.tcl --
2
+ #
3
+ # This demonstration script creates several combobox widgets.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .combo
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Combobox Demonstration"
15
+ wm iconname $w "combo"
16
+ positionWindow $w
17
+
18
+ ttk::label $w.msg -font $font -wraplength 5i -justify left -text "Three different\
19
+ combo-boxes are displayed below. You can add characters to the first\
20
+ one by pointing, clicking and typing, just as with an entry; pressing\
21
+ Return will cause the current value to be added to the list that is\
22
+ selectable from the drop-down list, and you can choose other values\
23
+ by pressing the Down key, using the arrow keys to pick another one,\
24
+ and pressing Return again. The second combo-box is fixed to a\
25
+ particular value, and cannot be modified at all. The third one only\
26
+ allows you to select values from its drop-down list of Australian\
27
+ cities."
28
+ pack $w.msg -side top -fill x
29
+
30
+ ## See Code / Dismiss buttons
31
+ set btns [addSeeDismiss $w.buttons $w {firstValue secondValue ozCity}]
32
+ pack $btns -side bottom -fill x
33
+
34
+ ttk::frame $w.f
35
+ pack $w.f -fill both -expand 1
36
+ set w $w.f
37
+
38
+ set australianCities {
39
+ Canberra Sydney Melbourne Perth Adelaide Brisbane
40
+ Hobart Darwin "Alice Springs"
41
+ }
42
+ set secondValue unchangable
43
+ set ozCity Sydney
44
+
45
+ ttk::labelframe $w.c1 -text "Fully Editable"
46
+ ttk::combobox $w.c1.c -textvariable firstValue
47
+ ttk::labelframe $w.c2 -text Disabled
48
+ ttk::combobox $w.c2.c -textvariable secondValue -state disabled
49
+ ttk::labelframe $w.c3 -text "Defined List Only"
50
+ ttk::combobox $w.c3.c -textvariable ozCity -state readonly \
51
+ -values $australianCities
52
+ bind $w.c1.c <Return> {
53
+ if {[%W get] ni [%W cget -values]} {
54
+ %W configure -values [concat [%W cget -values] [list [%W get]]]
55
+ }
56
+ }
57
+
58
+ pack $w.c1 $w.c2 $w.c3 -side top -pady 5 -padx 10
59
+ pack $w.c1.c -pady 5 -padx 10
60
+ pack $w.c2.c -pady 5 -padx 10
61
+ pack $w.c3.c -pady 5 -padx 10
janus/lib/tk8.6/demos/cscroll.tcl ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # cscroll.tcl --
2
+ #
3
+ # This demonstration script creates a simple canvas that can be
4
+ # scrolled in two dimensions.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .cscroll
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Scrollable Canvas Demonstration"
16
+ wm iconname $w "cscroll"
17
+ positionWindow $w
18
+ set c $w.c
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ frame $w.grid
28
+ scrollbar $w.hscroll -orient horizontal -command "$c xview"
29
+ scrollbar $w.vscroll -command "$c yview"
30
+ canvas $c -relief sunken -borderwidth 2 -scrollregion {-11c -11c 50c 20c} \
31
+ -xscrollcommand "$w.hscroll set" \
32
+ -yscrollcommand "$w.vscroll set"
33
+ pack $w.grid -expand yes -fill both -padx 1 -pady 1
34
+ grid rowconfig $w.grid 0 -weight 1 -minsize 0
35
+ grid columnconfig $w.grid 0 -weight 1 -minsize 0
36
+
37
+ grid $c -padx 1 -in $w.grid -pady 1 \
38
+ -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
39
+ grid $w.vscroll -in $w.grid -padx 1 -pady 1 \
40
+ -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
41
+ grid $w.hscroll -in $w.grid -padx 1 -pady 1 \
42
+ -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
43
+
44
+
45
+ set bg [lindex [$c config -bg] 4]
46
+ for {set i 0} {$i < 20} {incr i} {
47
+ set x [expr {-10 + 3*$i}]
48
+ for {set j 0; set y -10} {$j < 10} {incr j; incr y 3} {
49
+ $c create rect ${x}c ${y}c [expr {$x+2}]c [expr {$y+2}]c \
50
+ -fill $bg -tags rect
51
+ $c create text [expr {$x+1}]c [expr {$y+1}]c -text "$i,$j" \
52
+ -anchor center -tags text
53
+ }
54
+ }
55
+
56
+ $c bind all <Enter> "scrollEnter $c"
57
+ $c bind all <Leave> "scrollLeave $c"
58
+ $c bind all <Button-1> "scrollButton $c"
59
+ if {([tk windowingsystem] eq "aqua") && ![package vsatisfies [package provide Tk] 8.7-]} {
60
+ bind $c <Button-3> "$c scan mark %x %y"
61
+ bind $c <B3-Motion> "$c scan dragto %x %y"
62
+ bind $c <MouseWheel> {
63
+ %W yview scroll [expr {-%D}] units
64
+ }
65
+ bind $c <Option-MouseWheel> {
66
+ %W yview scroll [expr {-10*%D}] units
67
+ }
68
+ bind $c <Shift-MouseWheel> {
69
+ %W xview scroll [expr {-%D}] units
70
+ }
71
+ bind $c <Shift-Option-MouseWheel> {
72
+ %W xview scroll [expr {-10*%D}] units
73
+ }
74
+ } else {
75
+ bind $c <Button-2> "$c scan mark %x %y"
76
+ bind $c <B2-Motion> "$c scan dragto %x %y"
77
+ # We must make sure that positive and negative movements are rounded
78
+ # equally to integers, avoiding the problem that
79
+ # (int)1/-30 = -1,
80
+ # but
81
+ # (int)-1/-30 = 0
82
+ # The following code ensure equal +/- behaviour.
83
+ bind $c <MouseWheel> {
84
+ if {%D >= 0} {
85
+ %W yview scroll [expr {%D/-30}] units
86
+ } else {
87
+ %W yview scroll [expr {(%D-29)/-30}] units
88
+ }
89
+ }
90
+ bind $c <Option-MouseWheel> {
91
+ if {%D >= 0} {
92
+ %W yview scroll [expr {%D/-3}] units
93
+ } else {
94
+ %W yview scroll [expr {(%D-2)/-3}] units
95
+ }
96
+ }
97
+ bind $c <Shift-MouseWheel> {
98
+ if {%D >= 0} {
99
+ %W xview scroll [expr {%D/-30}] units
100
+ } else {
101
+ %W xview scroll [expr {(%D-29)/-30}] units
102
+ }
103
+ }
104
+ bind $c <Shift-Option-MouseWheel> {
105
+ if {%D >= 0} {
106
+ %W xview scroll [expr {%D/-3}] units
107
+ } else {
108
+ %W xview scroll [expr {(%D-2)/-3}] units
109
+ }
110
+ }
111
+ }
112
+
113
+ if {[tk windowingsystem] eq "x11" && ![package vsatisfies [package provide Tk] 8.7-]} {
114
+ # Support for mousewheels on Linux/Unix commonly comes through mapping
115
+ # the wheel to the extended buttons. If you have a mousewheel, find
116
+ # Linux configuration info at:
117
+ # https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X
118
+ bind $c <Button-4> {
119
+ if {!$tk_strictMotif} {
120
+ %W yview scroll -5 units
121
+ }
122
+ }
123
+ bind $c <Shift-Button-4> {
124
+ if {!$tk_strictMotif} {
125
+ %W xview scroll -5 units
126
+ }
127
+ }
128
+ bind $c <Button-5> {
129
+ if {!$tk_strictMotif} {
130
+ %W yview scroll 5 units
131
+ }
132
+ }
133
+ bind $c <Shift-Button-5> {
134
+ if {!$tk_strictMotif} {
135
+ %W xview scroll 5 units
136
+ }
137
+ }
138
+ }
139
+
140
+
141
+ proc scrollEnter canvas {
142
+ global oldFill
143
+ set id [$canvas find withtag current]
144
+ if {[lsearch [$canvas gettags current] text] >= 0} {
145
+ set id [expr {$id-1}]
146
+ }
147
+ set oldFill [lindex [$canvas itemconfig $id -fill] 4]
148
+ if {[winfo depth $canvas] > 1} {
149
+ if {[tk windowingsystem] eq "aqua"} {
150
+ $canvas itemconfigure $id -fill systemSelectedTextBackgroundColor
151
+ } else {
152
+ $canvas itemconfigure $id -fill LightSeaGreen
153
+ }
154
+ }
155
+ }
156
+
157
+ proc scrollLeave canvas {
158
+ global oldFill
159
+ set id [$canvas find withtag current]
160
+ if {[lsearch [$canvas gettags current] text] >= 0} {
161
+ set id [expr {$id-1}]
162
+ }
163
+ $canvas itemconfigure $id -fill $oldFill
164
+ }
165
+
166
+ proc scrollButton canvas {
167
+ set id [$canvas find withtag current]
168
+ if {[lsearch [$canvas gettags current] text] < 0} {
169
+ set id [expr {$id+1}]
170
+ }
171
+ puts stdout "You buttoned at [lindex [$canvas itemconf $id -text] 4]"
172
+ }
janus/lib/tk8.6/demos/ctext.tcl ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ctext.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget with a text
4
+ # item that can be edited and reconfigured in various ways.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .ctext
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Canvas Text Demonstration"
16
+ wm iconname $w "Text"
17
+ positionWindow $w
18
+ set c $w.c
19
+
20
+ label $w.msg -font $font -wraplength 5i -justify left -text "This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification, and on a pie slice to change its angle. The text also supports the following simple bindings for editing:
21
+ 1. You can point, click, and type.
22
+ 2. You can also select with button 1.
23
+ 3. You can copy the selection to the mouse position with button 2.
24
+ 4. Backspace and Control+h delete the selection if there is one;
25
+ otherwise they delete the character just before the insertion cursor.
26
+ 5. Delete deletes the selection if there is one; otherwise it deletes
27
+ the character just after the insertion cursor."
28
+ pack $w.msg -side top
29
+
30
+ ## See Code / Dismiss buttons
31
+ set btns [addSeeDismiss $w.buttons $w]
32
+ pack $btns -side bottom -fill x
33
+
34
+ canvas $c -relief flat -borderwidth 0 -width 500 -height 350
35
+ pack $w.c -side top -expand yes -fill both
36
+
37
+ set textFont {Helvetica 24}
38
+
39
+ $c create rectangle 245 195 255 205 -outline black -fill red
40
+
41
+ # First, create the text item and give it bindings so it can be edited.
42
+
43
+ $c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left]
44
+ $c bind text <Button-1> "textB1Press $c %x %y"
45
+ $c bind text <B1-Motion> "textB1Move $c %x %y"
46
+ $c bind text <Shift-Button-1> "$c select adjust current @%x,%y"
47
+ $c bind text <Shift-B1-Motion> "textB1Move $c %x %y"
48
+ $c bind text <Key> "textInsert $c %A"
49
+ $c bind text <Return> "textInsert $c \\n"
50
+ $c bind text <Control-h> "textBs $c"
51
+ $c bind text <BackSpace> "textBs $c"
52
+ $c bind text <Delete> "textDel $c"
53
+ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
54
+ $c bind text <Button-3> "textPaste $c @%x,%y"
55
+ } else {
56
+ $c bind text <Button-2> "textPaste $c @%x,%y"
57
+ }
58
+
59
+ # Next, create some items that allow the text's anchor position
60
+ # to be edited.
61
+
62
+ proc mkTextConfigBox {w x y option value color} {
63
+ set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \
64
+ -outline black -fill $color -width 1]
65
+ $w bind $item <Button-1> "$w itemconf text $option $value"
66
+ $w addtag config withtag $item
67
+ }
68
+ proc mkTextConfigPie {w x y a option value color} {
69
+ set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \
70
+ -start [expr {$a-15}] -extent 30 -outline black -fill $color \
71
+ -width 1]
72
+ $w bind $item <Button-1> "$w itemconf text $option $value"
73
+ $w addtag config withtag $item
74
+ }
75
+
76
+ set x 50
77
+ set y 50
78
+ set color LightSkyBlue1
79
+ mkTextConfigBox $c $x $y -anchor se $color
80
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y }] -anchor s $color
81
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y }] -anchor sw $color
82
+ mkTextConfigBox $c [expr {$x }] [expr {$y+30}] -anchor e $color
83
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y+30}] -anchor center $color
84
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y+30}] -anchor w $color
85
+ mkTextConfigBox $c [expr {$x }] [expr {$y+60}] -anchor ne $color
86
+ mkTextConfigBox $c [expr {$x+30}] [expr {$y+60}] -anchor n $color
87
+ mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color
88
+ set item [$c create rect \
89
+ [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \
90
+ -outline black -fill red]
91
+ $c bind $item <Button-1> "$c itemconf text -anchor center"
92
+ $c create text [expr {$x+45}] [expr {$y-5}] \
93
+ -text {Text Position} -anchor s -font {Times 20} -fill brown
94
+
95
+ # Now create some items that allow the text's angle to be changed.
96
+
97
+ set x 205
98
+ set y 50
99
+ set color Yellow
100
+ mkTextConfigPie $c $x $y 0 -angle 90 $color
101
+ mkTextConfigPie $c $x $y 30 -angle 120 $color
102
+ mkTextConfigPie $c $x $y 60 -angle 150 $color
103
+ mkTextConfigPie $c $x $y 90 -angle 180 $color
104
+ mkTextConfigPie $c $x $y 120 -angle 210 $color
105
+ mkTextConfigPie $c $x $y 150 -angle 240 $color
106
+ mkTextConfigPie $c $x $y 180 -angle 270 $color
107
+ mkTextConfigPie $c $x $y 210 -angle 300 $color
108
+ mkTextConfigPie $c $x $y 240 -angle 330 $color
109
+ mkTextConfigPie $c $x $y 270 -angle 0 $color
110
+ mkTextConfigPie $c $x $y 300 -angle 30 $color
111
+ mkTextConfigPie $c $x $y 330 -angle 60 $color
112
+ $c create text [expr {$x+45}] [expr {$y-5}] \
113
+ -text {Text Angle} -anchor s -font {Times 20} -fill brown
114
+
115
+ # Lastly, create some items that allow the text's justification to be
116
+ # changed.
117
+
118
+ set x 350
119
+ set y 50
120
+ set color SeaGreen2
121
+ mkTextConfigBox $c $x $y -justify left $color
122
+ mkTextConfigBox $c [expr {$x+30}] $y -justify center $color
123
+ mkTextConfigBox $c [expr {$x+60}] $y -justify right $color
124
+ $c create text [expr {$x+45}] [expr {$y-5}] \
125
+ -text {Justification} -anchor s -font {Times 20} -fill brown
126
+
127
+ $c bind config <Enter> "textEnter $c"
128
+ $c bind config <Leave> "$c itemconf current -fill \$textConfigFill"
129
+
130
+ set textConfigFill {}
131
+
132
+ proc textEnter {w} {
133
+ global textConfigFill
134
+ set textConfigFill [lindex [$w itemconfig current -fill] 4]
135
+ $w itemconfig current -fill black
136
+ }
137
+
138
+ proc textInsert {w string} {
139
+ if {$string == ""} {
140
+ return
141
+ }
142
+ catch {$w dchars text sel.first sel.last}
143
+ $w insert text insert $string
144
+ }
145
+
146
+ proc textPaste {w pos} {
147
+ catch {
148
+ $w insert text $pos [selection get]
149
+ }
150
+ }
151
+
152
+ proc textB1Press {w x y} {
153
+ $w icursor current @$x,$y
154
+ $w focus current
155
+ focus $w
156
+ $w select from current @$x,$y
157
+ }
158
+
159
+ proc textB1Move {w x y} {
160
+ $w select to current @$x,$y
161
+ }
162
+
163
+ proc textBs {w} {
164
+ if {![catch {$w dchars text sel.first sel.last}]} {
165
+ return
166
+ }
167
+ set char [expr {[$w index text insert] - 1}]
168
+ if {$char >= 0} {$w dchar text $char}
169
+ }
170
+
171
+ proc textDel {w} {
172
+ if {![catch {$w dchars text sel.first sel.last}]} {
173
+ return
174
+ }
175
+ $w dchars text insert
176
+ }
janus/lib/tk8.6/demos/en.msg ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ::msgcat::mcset en "Widget Demonstration"
2
+ ::msgcat::mcset en "tkWidgetDemo"
3
+ ::msgcat::mcset en "&File"
4
+ ::msgcat::mcset en "About..."
5
+ ::msgcat::mcset en "&About..."
6
+ ::msgcat::mcset en "<F1>"
7
+ ::msgcat::mcset en "&Quit"
8
+ ::msgcat::mcset en "Meta+Q" ;# Displayed hotkey
9
+ ::msgcat::mcset en "Meta-q" ;# Actual binding sequence
10
+ ::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey
11
+ ::msgcat::mcset en "Control-q" ;# Actual binding sequence
12
+ ::msgcat::mcset en "Variable values"
13
+ ::msgcat::mcset en "Variable values:"
14
+ ::msgcat::mcset en "OK"
15
+ ::msgcat::mcset en "Run the \"%s\" sample program"
16
+ ::msgcat::mcset en "Dismiss"
17
+ ::msgcat::mcset en "Rerun Demo"
18
+ ::msgcat::mcset en "Demo code: %s"
19
+ ::msgcat::mcset en "About Widget Demo"
20
+ ::msgcat::mcset en "Tk widget demonstration application"
21
+ ::msgcat::mcset en "Copyright © %s"
22
+ ::msgcat::mcset en "
23
+ @@title
24
+ Tk Widget Demonstrations
25
+ @@newline
26
+ @@normal
27
+ @@newline
28
+
29
+ This application provides a front end for several short scripts
30
+ that demonstrate what you can do with Tk widgets. Each of the
31
+ numbered lines below describes a demonstration; you can click on
32
+ it to invoke the demonstration. Once the demonstration window
33
+ appears, you can click the
34
+ @@bold
35
+ See Code
36
+ @@normal
37
+ button to see the Tcl/Tk code that created the demonstration. If
38
+ you wish, you can edit the code and click the
39
+ @@bold
40
+ Rerun Demo
41
+ @@normal
42
+ button in the code window to reinvoke the demonstration with the
43
+ modified code.
44
+ @@newline
45
+ "
46
+ ::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons"
47
+ ::msgcat::mcset en "Labels (text and bitmaps)"
48
+ ::msgcat::mcset en "Labels and UNICODE text"
49
+ ::msgcat::mcset en "Buttons"
50
+ ::msgcat::mcset en "Check-buttons (select any of a group)"
51
+ ::msgcat::mcset en "Radio-buttons (select one of a group)"
52
+ ::msgcat::mcset en "A 15-puzzle game made out of buttons"
53
+ ::msgcat::mcset en "Iconic buttons that use bitmaps"
54
+ ::msgcat::mcset en "Two labels displaying images"
55
+ ::msgcat::mcset en "A simple user interface for viewing images"
56
+ ::msgcat::mcset en "Labelled frames"
57
+ ::msgcat::mcset en "Listboxes"
58
+ ::msgcat::mcset en "The 50 states"
59
+ ::msgcat::mcset en "Colors: change the color scheme for the application"
60
+ ::msgcat::mcset en "A collection of famous and infamous sayings"
61
+ ::msgcat::mcset en "Entries and Spin-boxes"
62
+ ::msgcat::mcset en "Entries without scrollbars"
63
+ ::msgcat::mcset en "Entries with scrollbars"
64
+ ::msgcat::mcset en "Validated entries and password fields"
65
+ ::msgcat::mcset en "Spin-boxes"
66
+ ::msgcat::mcset en "Simple Rolodex-like form"
67
+ ::msgcat::mcset en "Text"
68
+ ::msgcat::mcset en "Basic editable text"
69
+ ::msgcat::mcset en "Text display styles"
70
+ ::msgcat::mcset en "Hypertext (tag bindings)"
71
+ ::msgcat::mcset en "A text widget with embedded windows"
72
+ ::msgcat::mcset en "A search tool built with a text widget"
73
+ ::msgcat::mcset en "Canvases"
74
+ ::msgcat::mcset en "The canvas item types"
75
+ ::msgcat::mcset en "A simple 2-D plot"
76
+ ::msgcat::mcset en "Text items in canvases"
77
+ ::msgcat::mcset en "An editor for arrowheads on canvas lines"
78
+ ::msgcat::mcset en "A ruler with adjustable tab stops"
79
+ ::msgcat::mcset en "A building floor plan"
80
+ ::msgcat::mcset en "A simple scrollable canvas"
81
+ ::msgcat::mcset en "Scales"
82
+ ::msgcat::mcset en "Horizontal scale"
83
+ ::msgcat::mcset en "Vertical scale"
84
+ ::msgcat::mcset en "Paned Windows"
85
+ ::msgcat::mcset en "Horizontal paned window"
86
+ ::msgcat::mcset en "Vertical paned window"
87
+ ::msgcat::mcset en "Menus"
88
+ ::msgcat::mcset en "Menus and cascades (sub-menus)"
89
+ ::msgcat::mcset en "Menu-buttons"
90
+ ::msgcat::mcset en "Common Dialogs"
91
+ ::msgcat::mcset en "Message boxes"
92
+ ::msgcat::mcset en "File selection dialog"
93
+ ::msgcat::mcset en "Color picker"
94
+ ::msgcat::mcset en "Miscellaneous"
95
+ ::msgcat::mcset en "The built-in bitmaps"
96
+ ::msgcat::mcset en "A dialog box with a local grab"
97
+ ::msgcat::mcset en "A dialog box with a global grab"
janus/lib/tk8.6/demos/entry3.tcl ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry3.tcl --
2
+ #
3
+ # This demonstration script creates several entry widgets whose
4
+ # permitted input is constrained in some way. It also shows off a
5
+ # password entry.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ set w .entry3
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Constrained Entry Demonstration"
17
+ wm iconname $w "entry3"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 5i -justify left -text "Four different\
21
+ entries are displayed below. You can add characters by pointing,\
22
+ clicking and typing, though each is constrained in what it will\
23
+ accept. The first only accepts 32-bit integers or the empty string\
24
+ (checking when focus leaves it) and will flash to indicate any\
25
+ problem. The second only accepts strings with fewer than ten\
26
+ characters and sounds the bell when an attempt to go over the limit\
27
+ is made. The third accepts US phone numbers, mapping letters to\
28
+ their digit equivalent and sounding the bell on encountering an\
29
+ illegal character or if trying to type over a character that is not\
30
+ a digit. The fourth is a password field that accepts up to eight\
31
+ characters (silently ignoring further ones), and displaying them as\
32
+ asterisk characters."
33
+
34
+ ## See Code / Dismiss buttons
35
+ set btns [addSeeDismiss $w.buttons $w]
36
+ pack $btns -side bottom -fill x
37
+
38
+ # focusAndFlash --
39
+ # Error handler for entry widgets that forces the focus onto the
40
+ # widget and makes the widget flash by exchanging the foreground and
41
+ # background colours at intervals of 200ms (i.e. at approximately
42
+ # 2.5Hz).
43
+ #
44
+ # Arguments:
45
+ # W - Name of entry widget to flash
46
+ # fg - Initial foreground colour
47
+ # bg - Initial background colour
48
+ # count - Counter to control the number of times flashed
49
+
50
+ proc focusAndFlash {W fg bg {count 9}} {
51
+ focus -force $W
52
+ if {$count<1} {
53
+ $W configure -foreground $fg -background $bg
54
+ } else {
55
+ if {$count%2} {
56
+ $W configure -foreground $bg -background $fg
57
+ } else {
58
+ $W configure -foreground $fg -background $bg
59
+ }
60
+ after 200 [list focusAndFlash $W $fg $bg [expr {$count-1}]]
61
+ }
62
+ }
63
+
64
+ labelframe $w.l1 -text "Integer Entry"
65
+ # Alternatively try using {string is digit} for arbitrary length numbers,
66
+ # and not just 32-bit ones.
67
+ entry $w.l1.e -validate focus -vcmd {string is integer %P}
68
+ $w.l1.e configure -invalidcommand \
69
+ "focusAndFlash %W [$w.l1.e cget -fg] [$w.l1.e cget -bg]"
70
+ pack $w.l1.e -fill x -expand 1 -padx 1m -pady 1m
71
+
72
+ labelframe $w.l2 -text "Length-Constrained Entry"
73
+ entry $w.l2.e -validate key -invcmd bell -vcmd {expr {[string length %P]<10}}
74
+ pack $w.l2.e -fill x -expand 1 -padx 1m -pady 1m
75
+
76
+ ### PHONE NUMBER ENTRY ###
77
+ # Note that the source to this is quite a bit longer as the behaviour
78
+ # demonstrated is a lot more ambitious than with the others.
79
+
80
+ # Initial content for the third entry widget
81
+ set entry3content "1-(000)-000-0000"
82
+ # Mapping from alphabetic characters to numbers. This is probably
83
+ # wrong, but it is the only mapping I have; the UK doesn't really go
84
+ # for associating letters with digits for some reason.
85
+ set phoneNumberMap {}
86
+ foreach {chars digit} {abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9} {
87
+ foreach char [split $chars ""] {
88
+ lappend phoneNumberMap $char $digit [string toupper $char] $digit
89
+ }
90
+ }
91
+
92
+ # validatePhoneChange --
93
+ # Checks that the replacement (mapped to a digit) of the given
94
+ # character in an entry widget at the given position will leave a
95
+ # valid phone number in the widget.
96
+ #
97
+ # W - The entry widget to validate
98
+ # vmode - The widget's validation mode
99
+ # idx - The index where replacement is to occur
100
+ # char - The character (or string, though that will always be
101
+ # refused) to be overwritten at that point.
102
+
103
+ proc validatePhoneChange {W vmode idx char} {
104
+ global phoneNumberMap entry3content
105
+ if {$idx < 0} {return 1}
106
+ after idle [list $W configure -validate $vmode -invcmd bell]
107
+ if {
108
+ !($idx<3 || $idx==6 || $idx==7 || $idx==11 || $idx>15) &&
109
+ [string match {[0-9A-Za-z]} $char]
110
+ } then {
111
+ $W delete $idx
112
+ $W insert $idx [string map $phoneNumberMap $char]
113
+ after idle [list phoneSkipRight $W -1]
114
+ return 1
115
+ }
116
+ return 0
117
+ }
118
+
119
+ # phoneSkipLeft --
120
+ # Skip over fixed characters in a phone-number string when moving left.
121
+ #
122
+ # Arguments:
123
+ # W - The entry widget containing the phone-number.
124
+
125
+ proc phoneSkipLeft {W} {
126
+ set idx [$W index insert]
127
+ if {$idx == 8} {
128
+ # Skip back two extra characters
129
+ $W icursor [incr idx -2]
130
+ } elseif {$idx == 7 || $idx == 12} {
131
+ # Skip back one extra character
132
+ $W icursor [incr idx -1]
133
+ } elseif {$idx <= 3} {
134
+ # Can't move any further
135
+ bell
136
+ return -code break
137
+ }
138
+ }
139
+
140
+ # phoneSkipRight --
141
+ # Skip over fixed characters in a phone-number string when moving right.
142
+ #
143
+ # Arguments:
144
+ # W - The entry widget containing the phone-number.
145
+ # add - Offset to add to index before calculation (used by validation.)
146
+
147
+ proc phoneSkipRight {W {add 0}} {
148
+ set idx [$W index insert]
149
+ if {$idx+$add == 5} {
150
+ # Skip forward two extra characters
151
+ $W icursor [incr idx 2]
152
+ } elseif {$idx+$add == 6 || $idx+$add == 10} {
153
+ # Skip forward one extra character
154
+ $W icursor [incr idx]
155
+ } elseif {$idx+$add == 15 && !$add} {
156
+ # Can't move any further
157
+ bell
158
+ return -code break
159
+ }
160
+ }
161
+
162
+ labelframe $w.l3 -text "US Phone-Number Entry"
163
+ entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \
164
+ -vcmd {validatePhoneChange %W %v %i %S}
165
+ # Click to focus goes to the first editable character...
166
+ bind $w.l3.e <FocusIn> {
167
+ if {"%d" ne "NotifyAncestor"} {
168
+ %W icursor 3
169
+ after idle {%W selection clear}
170
+ }
171
+ }
172
+ bind $w.l3.e <<PrevChar>> {phoneSkipLeft %W}
173
+ bind $w.l3.e <<NextChar>> {phoneSkipRight %W}
174
+ pack $w.l3.e -fill x -expand 1 -padx 1m -pady 1m
175
+
176
+ labelframe $w.l4 -text "Password Entry"
177
+ entry $w.l4.e -validate key -show "*" -vcmd {expr {[string length %P]<=8}}
178
+ pack $w.l4.e -fill x -expand 1 -padx 1m -pady 1m
179
+
180
+ lower [frame $w.mid]
181
+ grid $w.l1 $w.l2 -in $w.mid -padx 3m -pady 1m -sticky ew
182
+ grid $w.l3 $w.l4 -in $w.mid -padx 3m -pady 1m -sticky ew
183
+ grid columnconfigure $w.mid {0 1} -uniform 1
184
+ pack $w.msg -side top
185
+ pack $w.mid -fill both -expand 1
janus/lib/tk8.6/demos/fontchoose.tcl ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fontchoose.tcl --
2
+ #
3
+ # Show off the stock font selector dialog
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .fontchoose
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Font Selection Dialog"
15
+ wm iconname $w "fontchooser"
16
+ positionWindow $w
17
+
18
+ catch {font create FontchooseDemoFont {*}[font actual TkDefaultFont]}
19
+
20
+ # The font chooser needs to be configured and then shown.
21
+ proc SelectFont {parent} {
22
+ tk fontchooser configure -font FontchooseDemoFont \
23
+ -command ApplyFont -parent $parent
24
+ tk fontchooser show
25
+ }
26
+
27
+ proc ApplyFont {font} {
28
+ font configure FontchooseDemoFont {*}[font actual $font]
29
+ }
30
+
31
+ # When the visibility of the fontchooser changes, the following event is fired
32
+ # to the parent widget.
33
+ #
34
+ bind $w <<TkFontchooserVisibility>> {
35
+ if {[tk fontchooser configure -visible]} {
36
+ %W.f.font state disabled
37
+ } else {
38
+ %W.f.font state !disabled
39
+ }
40
+ }
41
+
42
+
43
+ set f [ttk::frame $w.f -relief sunken -padding 2]
44
+
45
+ text $f.msg -font FontchooseDemoFont -width 40 -height 6 -borderwidth 0 \
46
+ -yscrollcommand [list $f.vs set]
47
+ ttk::scrollbar $f.vs -command [list $f.msg yview]
48
+
49
+ $f.msg insert end "Press the buttons below to choose a new font for the\
50
+ text shown in this window.\n" {}
51
+
52
+ ttk::button $f.font -text "Set font ..." -command [list SelectFont $w]
53
+
54
+ grid $f.msg $f.vs -sticky news
55
+ grid $f.font - -sticky e
56
+ grid columnconfigure $f 0 -weight 1
57
+ grid rowconfigure $f 0 -weight 1
58
+
59
+ ## See Code / Dismiss buttons
60
+ set btns [addSeeDismiss $w.buttons $w]
61
+
62
+ grid $f -sticky news
63
+ grid $btns -sticky ew
64
+ grid columnconfigure $w 0 -weight 1
65
+ grid rowconfigure $w 0 -weight 1
66
+ update idletasks
67
+ grid propagate $f 0
janus/lib/tk8.6/demos/hello ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # hello --
6
+ # Simple Tk script to create a button that prints "Hello, world".
7
+ # Click on the button to terminate the program.
8
+
9
+ package require Tk
10
+
11
+ # The first line below creates the button, and the second line
12
+ # asks the packer to shrink-wrap the application's main window
13
+ # around the button.
14
+
15
+ button .hello -text "Hello, world" -command {
16
+ puts stdout "Hello, world"; destroy .
17
+ }
18
+ pack .hello
19
+
20
+ # Local Variables:
21
+ # mode: tcl
22
+ # End:
janus/lib/tk8.6/demos/hscale.tcl ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # hscale.tcl --
2
+ #
3
+ # This demonstration script shows an example with a horizontal scale.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .hscale
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Horizontal Scale Demonstration"
15
+ wm iconname $w "hscale"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 3.5i -justify left -text "An arrow and a horizontal scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the length of the arrow."
19
+ pack $w.msg -side top -padx .5c
20
+
21
+ ## See Code / Dismiss buttons
22
+ set btns [addSeeDismiss $w.buttons $w]
23
+ pack $btns -side bottom -fill x
24
+
25
+ frame $w.frame -borderwidth 10
26
+ pack $w.frame -side top -fill x
27
+
28
+ canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0
29
+ $w.frame.canvas create polygon 0 0 1 1 2 2 -fill DeepSkyBlue3 -tags poly
30
+ $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
31
+ scale $w.frame.scale -orient horizontal -length 284 -from 0 -to 250 \
32
+ -command "setWidth $w.frame.canvas" -tickinterval 50
33
+ pack $w.frame.canvas -side top -expand yes -anchor s -fill x -padx 15
34
+ pack $w.frame.scale -side bottom -expand yes -anchor n
35
+ $w.frame.scale set 75
36
+
37
+ proc setWidth {w width} {
38
+ incr width 21
39
+ set x2 [expr {$width - 30}]
40
+ if {$x2 < 21} {
41
+ set x2 21
42
+ }
43
+ $w coords poly 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
44
+ $w coords line 20 15 20 35 $x2 35 $x2 45 $width 25 $x2 5 $x2 15 20 15
45
+ }
janus/lib/tk8.6/demos/images/earthris.gif ADDED

Git LFS Details

  • SHA256: c2da473e55d8317bd1f983638adb729bff1461de590d76f99d8b3430c71e0f6e
  • Pointer size: 129 Bytes
  • Size of remote file: 6.34 kB
janus/lib/tk8.6/demos/images/flagdown.xbm ADDED
janus/lib/tk8.6/demos/images/flagup.xbm ADDED
janus/lib/tk8.6/demos/images/gray25.xbm ADDED
janus/lib/tk8.6/demos/images/letters.xbm ADDED
janus/lib/tk8.6/demos/images/noletter.xbm ADDED
janus/lib/tk8.6/demos/images/pattern.xbm ADDED
janus/lib/tk8.6/demos/items.tcl ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # items.tcl --
2
+ #
3
+ # This demonstration script creates a canvas that displays the
4
+ # canvas item types.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .items
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Canvas Item Demonstration"
16
+ wm iconname $w "Items"
17
+ positionWindow $w
18
+ set c $w.frame.c
19
+
20
+ label $w.msg -font $font -wraplength 5i -justify left -text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Left-Button drag:\tmoves item under pointer.\n Middle-Button drag:\trepositions view.\n Right-Button drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ frame $w.frame
28
+ pack $w.frame -side top -fill both -expand yes
29
+
30
+ canvas $c -scrollregion {0c 0c 30c 24c} -width 15c -height 10c \
31
+ -relief sunken -borderwidth 2 \
32
+ -xscrollcommand "$w.frame.hscroll set" \
33
+ -yscrollcommand "$w.frame.vscroll set"
34
+ ttk::scrollbar $w.frame.vscroll -command "$c yview"
35
+ ttk::scrollbar $w.frame.hscroll -orient horizontal -command "$c xview"
36
+
37
+ grid $c -in $w.frame \
38
+ -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
39
+ grid $w.frame.vscroll \
40
+ -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
41
+ grid $w.frame.hscroll \
42
+ -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
43
+ grid rowconfig $w.frame 0 -weight 1 -minsize 0
44
+ grid columnconfig $w.frame 0 -weight 1 -minsize 0
45
+
46
+ # Display a 3x3 rectangular grid.
47
+
48
+ $c create rect 0c 0c 30c 24c -width 2
49
+ $c create line 0c 8c 30c 8c -width 2
50
+ $c create line 0c 16c 30c 16c -width 2
51
+ $c create line 10c 0c 10c 24c -width 2
52
+ $c create line 20c 0c 20c 24c -width 2
53
+
54
+ set font1 {Helvetica 12}
55
+ set font2 {Helvetica 24 bold}
56
+ if {[winfo depth $c] > 1} {
57
+ set blue DeepSkyBlue3
58
+ set red red
59
+ set bisque bisque3
60
+ set green SeaGreen3
61
+ } else {
62
+ set blue black
63
+ set red black
64
+ set bisque black
65
+ set green black
66
+ }
67
+
68
+ # Set up demos within each of the areas of the grid.
69
+
70
+ $c create text 5c .2c -text Lines -anchor n
71
+ $c create line 1c 1c 3c 1c 1c 4c 3c 4c -width 2m -fill $blue \
72
+ -cap butt -join miter -tags item
73
+ $c create line 4.67c 1c 4.67c 4c -arrow last -tags item
74
+ $c create line 6.33c 1c 6.33c 4c -arrow both -tags item
75
+ $c create line 5c 6c 9c 6c 9c 1c 8c 1c 8c 4.8c 8.8c 4.8c 8.8c 1.2c \
76
+ 8.2c 1.2c 8.2c 4.6c 8.6c 4.6c 8.6c 1.4c 8.4c 1.4c 8.4c 4.4c \
77
+ -width 3 -fill $red -tags item
78
+ # Main widget program sets variable tk_demoDirectory
79
+ $c create line 1c 5c 7c 5c 7c 7c 9c 7c -width .5c \
80
+ -stipple @[file join $tk_demoDirectory images gray25.xbm] \
81
+ -arrow both -arrowshape {15 15 7} -tags item
82
+ $c create line 1c 7c 1.75c 5.8c 2.5c 7c 3.25c 5.8c 4c 7c -width .5c \
83
+ -cap round -join round -tags item
84
+
85
+ $c create text 15c .2c -text "Curves (smoothed lines)" -anchor n
86
+ $c create line 11c 4c 11.5c 1c 13.5c 1c 14c 4c -smooth on \
87
+ -fill $blue -tags item
88
+ $c create line 15.5c 1c 19.5c 1.5c 15.5c 4.5c 19.5c 4c -smooth on \
89
+ -arrow both -width 3 -tags item
90
+ $c create line 12c 6c 13.5c 4.5c 16.5c 7.5c 18c 6c \
91
+ 16.5c 4.5c 13.5c 7.5c 12c 6c -smooth on -width 3m -cap round \
92
+ -stipple @[file join $tk_demoDirectory images gray25.xbm] \
93
+ -fill $red -tags item
94
+
95
+ $c create text 25c .2c -text Polygons -anchor n
96
+ $c create polygon 21c 1.0c 22.5c 1.75c 24c 1.0c 23.25c 2.5c \
97
+ 24c 4.0c 22.5c 3.25c 21c 4.0c 21.75c 2.5c -fill $green \
98
+ -outline {} -width 4 -tags item
99
+ $c create polygon 25c 4c 25c 4c 25c 1c 26c 1c 27c 4c 28c 1c \
100
+ 29c 1c 29c 4c 29c 4c -fill $red -outline {} -smooth on -tags item
101
+ $c create polygon 22c 4.5c 25c 4.5c 25c 6.75c 28c 6.75c \
102
+ 28c 5.25c 24c 5.25c 24c 6.0c 26c 6c 26c 7.5c 22c 7.5c \
103
+ -stipple @[file join $tk_demoDirectory images gray25.xbm] \
104
+ -fill $blue -outline {} -tags item
105
+
106
+ $c create text 5c 8.2c -text Rectangles -anchor n
107
+ $c create rectangle 1c 9.5c 4c 12.5c -outline $red -width 3m -tags item
108
+ $c create rectangle 0.5c 13.5c 4.5c 15.5c -fill $green -tags item
109
+ $c create rectangle 6c 10c 9c 15c -outline {} \
110
+ -stipple @[file join $tk_demoDirectory images gray25.xbm] \
111
+ -fill $blue -tags item
112
+
113
+ $c create text 15c 8.2c -text Ovals -anchor n
114
+ $c create oval 11c 9.5c 14c 12.5c -outline $red -width 3m -tags item
115
+ $c create oval 10.5c 13.5c 14.5c 15.5c -fill $green -tags item
116
+ $c create oval 16c 10c 19c 15c -outline {} \
117
+ -stipple @[file join $tk_demoDirectory images gray25.xbm] \
118
+ -fill $blue -tags item
119
+
120
+ $c create text 25c 8.2c -text Text -anchor n
121
+ $c create rectangle 22.4c 8.9c 22.6c 9.1c
122
+ $c create text 22.5c 9c -anchor n -font $font1 -width 4c \
123
+ -text "A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text." -tags item
124
+ $c create rectangle 25.4c 10.9c 25.6c 11.1c
125
+ $c create text 25.5c 11c -anchor w -font $font1 -fill $blue \
126
+ -text "Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge." \
127
+ -justify center -tags item
128
+ $c create rectangle 24.9c 13.9c 25.1c 14.1c
129
+ catch {
130
+ $c create text 25c 14c -font $font2 -anchor c -fill $red -angle 15 \
131
+ -text "Angled characters" -tags item
132
+ }
133
+
134
+ $c create text 5c 16.2c -text Arcs -anchor n
135
+ $c create arc 0.5c 17c 7c 20c -fill $green -outline black \
136
+ -start 45 -extent 270 -style pieslice -tags item
137
+ $c create arc 6.5c 17c 9.5c 20c -width 4m -style arc \
138
+ -outline $blue -start -135 -extent 270 -tags item \
139
+ -outlinestipple @[file join $tk_demoDirectory images gray25.xbm]
140
+ $c create arc 0.5c 20c 9.5c 24c -width 4m -style pieslice \
141
+ -fill {} -outline $red -start 225 -extent -90 -tags item
142
+ $c create arc 5.5c 20.5c 9.5c 23.5c -width 4m -style chord \
143
+ -fill $blue -outline {} -start 45 -extent 270 -tags item
144
+
145
+ $c create text 15c 16.2c -text "Bitmaps and Images" -anchor n
146
+ catch {
147
+ image create photo items.ousterhout \
148
+ -file [file join $tk_demoDirectory images ouster.png]
149
+ image create photo items.ousterhout.active -format "png -alpha 0.5" \
150
+ -file [file join $tk_demoDirectory images ouster.png]
151
+ $c create image 13c 20c -tags item -image items.ousterhout \
152
+ -activeimage items.ousterhout.active
153
+ }
154
+ $c create bitmap 17c 18.5c -tags item \
155
+ -bitmap @[file join $tk_demoDirectory images noletter.xbm]
156
+ $c create bitmap 17c 21.5c -tags item \
157
+ -bitmap @[file join $tk_demoDirectory images letters.xbm]
158
+
159
+ $c create text 25c 16.2c -text Windows -anchor n
160
+ button $c.button -text "Press Me" -command "butPress $c $red"
161
+ $c create window 21c 18c -window $c.button -anchor nw -tags item
162
+ entry $c.entry -width 20 -relief sunken
163
+ $c.entry insert end "Edit this text"
164
+ $c create window 21c 21c -window $c.entry -anchor nw -tags item
165
+ scale $c.scale -from 0 -to 100 -length 6c -sliderlength .4c \
166
+ -width .5c -tickinterval 0
167
+ $c create window 28.5c 17.5c -window $c.scale -anchor n -tags item
168
+ $c create text 21c 17.9c -text Button: -anchor sw
169
+ $c create text 21c 20.9c -text Entry: -anchor sw
170
+ $c create text 28.5c 17.4c -text Scale: -anchor s
171
+
172
+ # Set up event bindings for canvas:
173
+
174
+ $c bind item <Enter> "itemEnter $c"
175
+ $c bind item <Leave> "itemLeave $c"
176
+ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
177
+ bind $c <Button-2> "itemMark $c %x %y"
178
+ bind $c <B2-Motion> "itemStroke $c %x %y"
179
+ bind $c <Button-3> "$c scan mark %x %y"
180
+ bind $c <B3-Motion> "$c scan dragto %x %y"
181
+ } else {
182
+ bind $c <Button-2> "$c scan mark %x %y"
183
+ bind $c <B2-Motion> "$c scan dragto %x %y"
184
+ bind $c <Button-3> "itemMark $c %x %y"
185
+ bind $c <B3-Motion> "itemStroke $c %x %y"
186
+ }
187
+ bind $c <<NextChar>> "itemsUnderArea $c"
188
+ bind $c <Button-1> "itemStartDrag $c %x %y"
189
+ bind $c <B1-Motion> "itemDrag $c %x %y"
190
+
191
+ # Utility procedures for highlighting the item under the pointer:
192
+
193
+ proc itemEnter {c} {
194
+ global restoreCmd
195
+
196
+ if {[winfo depth $c] == 1} {
197
+ set restoreCmd {}
198
+ return
199
+ }
200
+ set type [$c type current]
201
+ if {$type == "window" || $type == "image"} {
202
+ set restoreCmd {}
203
+ return
204
+ } elseif {$type == "bitmap"} {
205
+ set bg [lindex [$c itemconf current -background] 4]
206
+ set restoreCmd [list $c itemconfig current -background $bg]
207
+ $c itemconfig current -background SteelBlue2
208
+ return
209
+ } elseif {$type == "image"} {
210
+ set restoreCmd [list $c itemconfig current -state normal]
211
+ $c itemconfig current -state active
212
+ return
213
+ }
214
+ set fill [lindex [$c itemconfig current -fill] 4]
215
+ if {(($type == "rectangle") || ($type == "oval") || ($type == "arc"))
216
+ && ($fill == "")} {
217
+ set outline [lindex [$c itemconfig current -outline] 4]
218
+ set restoreCmd "$c itemconfig current -outline $outline"
219
+ $c itemconfig current -outline SteelBlue2
220
+ } else {
221
+ set restoreCmd "$c itemconfig current -fill $fill"
222
+ $c itemconfig current -fill SteelBlue2
223
+ }
224
+ }
225
+
226
+ proc itemLeave {c} {
227
+ global restoreCmd
228
+
229
+ eval $restoreCmd
230
+ }
231
+
232
+ # Utility procedures for stroking out a rectangle and printing what's
233
+ # underneath the rectangle's area.
234
+
235
+ proc itemMark {c x y} {
236
+ global areaX1 areaY1
237
+ set areaX1 [$c canvasx $x]
238
+ set areaY1 [$c canvasy $y]
239
+ $c delete area
240
+ }
241
+
242
+ proc itemStroke {c x y} {
243
+ global areaX1 areaY1 areaX2 areaY2
244
+ set x [$c canvasx $x]
245
+ set y [$c canvasy $y]
246
+ if {($areaX1 != $x) && ($areaY1 != $y)} {
247
+ $c delete area
248
+ $c addtag area withtag [$c create rect $areaX1 $areaY1 $x $y \
249
+ -outline black]
250
+ set areaX2 $x
251
+ set areaY2 $y
252
+ }
253
+ }
254
+
255
+ proc itemsUnderArea {c} {
256
+ global areaX1 areaY1 areaX2 areaY2
257
+ set area [$c find withtag area]
258
+ set items ""
259
+ foreach i [$c find enclosed $areaX1 $areaY1 $areaX2 $areaY2] {
260
+ if {[lsearch [$c gettags $i] item] >= 0} {
261
+ lappend items $i
262
+ }
263
+ }
264
+ puts stdout "Items enclosed by area: $items"
265
+ set items ""
266
+ foreach i [$c find overlapping $areaX1 $areaY1 $areaX2 $areaY2] {
267
+ if {[lsearch [$c gettags $i] item] >= 0} {
268
+ lappend items $i
269
+ }
270
+ }
271
+ puts stdout "Items overlapping area: $items"
272
+ }
273
+
274
+ set areaX1 0
275
+ set areaY1 0
276
+ set areaX2 0
277
+ set areaY2 0
278
+
279
+ # Utility procedures to support dragging of items.
280
+
281
+ proc itemStartDrag {c x y} {
282
+ global lastX lastY
283
+ set lastX [$c canvasx $x]
284
+ set lastY [$c canvasy $y]
285
+ }
286
+
287
+ proc itemDrag {c x y} {
288
+ global lastX lastY
289
+ set x [$c canvasx $x]
290
+ set y [$c canvasy $y]
291
+ $c move current [expr {$x-$lastX}] [expr {$y-$lastY}]
292
+ set lastX $x
293
+ set lastY $y
294
+ }
295
+
296
+ # Procedure that's invoked when the button embedded in the canvas
297
+ # is invoked.
298
+
299
+ proc butPress {w color} {
300
+ set i [$w create text 25c 18.1c -text "Oooohhh!!" -fill $color -anchor n]
301
+ after 500 "$w delete $i"
302
+ }
janus/lib/tk8.6/demos/ixset ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # ixset --
6
+ # A nice interface to "xset" to change X server settings
7
+ #
8
+ # History :
9
+ # 91/11/23 : pda@masi.ibp.fr, jt@ratp.fr : design
10
+ # 92/08/01 : pda@masi.ibp.fr : cleaning
11
+
12
+ package require Tk
13
+
14
+ #
15
+ # Button actions
16
+ #
17
+
18
+ proc quit {} {
19
+ destroy .
20
+ }
21
+
22
+ proc ok {} {
23
+ writesettings
24
+ quit
25
+ }
26
+
27
+ proc cancel {} {
28
+ readsettings
29
+ dispsettings
30
+ .buttons.apply configure -state disabled
31
+ .buttons.cancel configure -state disabled
32
+ }
33
+
34
+ proc apply {} {
35
+ writesettings
36
+ .buttons.apply configure -state disabled
37
+ .buttons.cancel configure -state disabled
38
+ }
39
+
40
+ #
41
+ # Read current settings
42
+ #
43
+
44
+ proc readsettings {} {
45
+ global kbdrep ; set kbdrep "on"
46
+ global kbdcli ; set kbdcli 0
47
+ global bellvol ; set bellvol 100
48
+ global bellpit ; set bellpit 440
49
+ global belldur ; set belldur 100
50
+ global mouseacc ; set mouseacc "3/1"
51
+ global mousethr ; set mousethr 4
52
+ global screenbla ; set screenbla "blank"
53
+ global screentim ; set screentim 600
54
+ global screencyc ; set screencyc 600
55
+
56
+ set xfd [open "|xset q" r]
57
+ while {[gets $xfd line] >= 0} {
58
+ switch -- [lindex $line 0] {
59
+ auto {
60
+ set rpt [lindex $line 1]
61
+ if {$rpt eq "repeat:"} {
62
+ set kbdrep [lindex $line 2]
63
+ set kbdcli [lindex $line 6]
64
+ }
65
+ }
66
+ bell {
67
+ set bellvol [lindex $line 2]
68
+ set bellpit [lindex $line 5]
69
+ set belldur [lindex $line 8]
70
+ }
71
+ acceleration: {
72
+ set mouseacc [lindex $line 1]
73
+ set mousethr [lindex $line 3]
74
+ }
75
+ prefer {
76
+ set bla [lindex $line 2]
77
+ set screenbla [expr {$bla eq "yes" ? "blank" : "noblank"}]
78
+ }
79
+ timeout: {
80
+ set screentim [lindex $line 1]
81
+ set screencyc [lindex $line 3]
82
+ }
83
+ }
84
+ }
85
+ close $xfd
86
+
87
+ # puts stdout [format "Key REPEAT = %s\n" $kbdrep]
88
+ # puts stdout [format "Key CLICK = %s\n" $kbdcli]
89
+ # puts stdout [format "Bell VOLUME = %s\n" $bellvol]
90
+ # puts stdout [format "Bell PITCH = %s\n" $bellpit]
91
+ # puts stdout [format "Bell DURATION = %s\n" $belldur]
92
+ # puts stdout [format "Mouse ACCELERATION = %s\n" $mouseacc]
93
+ # puts stdout [format "Mouse THRESHOLD = %s\n" $mousethr]
94
+ # puts stdout [format "Screen BLANCK = %s\n" $screenbla]
95
+ # puts stdout [format "Screen TIMEOUT = %s\n" $screentim]
96
+ # puts stdout [format "Screen CYCLE = %s\n" $screencyc]
97
+ }
98
+
99
+
100
+ #
101
+ # Write settings into the X server
102
+ #
103
+
104
+ proc writesettings {} {
105
+ global kbdrep kbdcli bellvol bellpit belldur
106
+ global mouseacc mousethr screenbla screentim screencyc
107
+
108
+ set bellvol [.bell.vol get]
109
+ set bellpit [.bell.val.pit.entry get]
110
+ set belldur [.bell.val.dur.entry get]
111
+
112
+ if {$kbdrep eq "on"} {
113
+ set kbdcli [.kbd.val.cli get]
114
+ } else {
115
+ set kbdcli "off"
116
+ }
117
+
118
+ set mouseacc [.mouse.hor.acc.entry get]
119
+ set mousethr [.mouse.hor.thr.entry get]
120
+
121
+ set screentim [.screen.tim.entry get]
122
+ set screencyc [.screen.cyc.entry get]
123
+
124
+ exec xset \
125
+ b $bellvol $bellpit $belldur \
126
+ c $kbdcli \
127
+ r $kbdrep \
128
+ m $mouseacc $mousethr \
129
+ s $screentim $screencyc \
130
+ s $screenbla
131
+ }
132
+
133
+
134
+ #
135
+ # Sends all settings to the window
136
+ #
137
+
138
+ proc dispsettings {} {
139
+ global kbdrep kbdcli bellvol bellpit belldur
140
+ global mouseacc mousethr screenbla screentim screencyc
141
+
142
+ .bell.vol set $bellvol
143
+ .bell.val.pit.entry delete 0 end
144
+ .bell.val.pit.entry insert 0 $bellpit
145
+ .bell.val.dur.entry delete 0 end
146
+ .bell.val.dur.entry insert 0 $belldur
147
+
148
+ .kbd.val.onoff [expr {$kbdrep eq "on" ? "select" : "deselect"}]
149
+ .kbd.val.cli set $kbdcli
150
+
151
+ .mouse.hor.acc.entry delete 0 end
152
+ .mouse.hor.acc.entry insert 0 $mouseacc
153
+ .mouse.hor.thr.entry delete 0 end
154
+ .mouse.hor.thr.entry insert 0 $mousethr
155
+
156
+ .screen.blank [expr {$screenbla eq "blank" ? "select" : "deselect"}]
157
+ .screen.pat [expr {$screenbla ne "blank" ? "select" : "deselect"}]
158
+ .screen.tim.entry delete 0 end
159
+ .screen.tim.entry insert 0 $screentim
160
+ .screen.cyc.entry delete 0 end
161
+ .screen.cyc.entry insert 0 $screencyc
162
+ }
163
+
164
+
165
+ #
166
+ # Create all windows, and pack them
167
+ #
168
+
169
+ proc labelentry {path text length {range {}}} {
170
+ frame $path
171
+ label $path.label -text $text
172
+ if {[llength $range]} {
173
+ spinbox $path.entry -width $length -relief sunken \
174
+ -from [lindex $range 0] -to [lindex $range 1]
175
+ } else {
176
+ entry $path.entry -width $length -relief sunken
177
+ }
178
+ pack $path.label -side left
179
+ pack $path.entry -side right -expand y -fill x
180
+ }
181
+
182
+ proc createwindows {} {
183
+ #
184
+ # Buttons
185
+ #
186
+
187
+ frame .buttons
188
+ button .buttons.ok -default active -command ok -text "Ok"
189
+ button .buttons.apply -default normal -command apply -text "Apply" \
190
+ -state disabled
191
+ button .buttons.cancel -default normal -command cancel -text "Cancel" \
192
+ -state disabled
193
+ button .buttons.quit -default normal -command quit -text "Quit"
194
+
195
+ pack .buttons.ok .buttons.apply .buttons.cancel .buttons.quit \
196
+ -side left -expand yes -pady 5
197
+
198
+ bind . <Return> {.buttons.ok flash; .buttons.ok invoke}
199
+ bind . <Escape> {.buttons.quit flash; .buttons.quit invoke}
200
+ bind . <Button-1> {
201
+ if {![string match .buttons* %W]} {
202
+ .buttons.apply configure -state normal
203
+ .buttons.cancel configure -state normal
204
+ }
205
+ }
206
+ bind . <Key> {
207
+ if {![string match .buttons* %W]} {
208
+ switch -glob %K {
209
+ Return - Escape - Tab - *Shift* {}
210
+ default {
211
+ .buttons.apply configure -state normal
212
+ .buttons.cancel configure -state normal
213
+ }
214
+ }
215
+ }
216
+ }
217
+
218
+ #
219
+ # Bell settings
220
+ #
221
+
222
+ labelframe .bell -text "Bell Settings" -padx 1.5m -pady 1.5m
223
+ scale .bell.vol \
224
+ -from 0 -to 100 -length 200 -tickinterval 20 \
225
+ -label "Volume (%)" -orient horizontal
226
+
227
+ frame .bell.val
228
+ labelentry .bell.val.pit "Pitch (Hz)" 6 {25 20000}
229
+ labelentry .bell.val.dur "Duration (ms)" 6 {1 10000}
230
+ pack .bell.val.pit -side left -padx 5
231
+ pack .bell.val.dur -side right -padx 5
232
+ pack .bell.vol .bell.val -side top -expand yes
233
+
234
+ #
235
+ # Keyboard settings
236
+ #
237
+
238
+ labelframe .kbd -text "Keyboard Repeat Settings" -padx 1.5m -pady 1.5m
239
+
240
+ frame .kbd.val
241
+ checkbutton .kbd.val.onoff \
242
+ -text "On" \
243
+ -onvalue "on" -offvalue "off" -variable kbdrep \
244
+ -relief flat
245
+ scale .kbd.val.cli \
246
+ -from 0 -to 100 -length 200 -tickinterval 20 \
247
+ -label "Click Volume (%)" -orient horizontal
248
+ pack .kbd.val.onoff -side left -fill x -expand yes -padx {0 1m}
249
+ pack .kbd.val.cli -side left -expand yes -fill x -padx {1m 0}
250
+
251
+ pack .kbd.val -side top -expand yes -pady 2 -fill x
252
+
253
+ #
254
+ # Mouse settings
255
+ #
256
+
257
+ labelframe .mouse -text "Mouse Settings" -padx 1.5m -pady 1.5m
258
+
259
+ frame .mouse.hor
260
+ labelentry .mouse.hor.acc "Acceleration" 5
261
+ labelentry .mouse.hor.thr "Threshold (pixels)" 3 {1 2000}
262
+
263
+ pack .mouse.hor.acc -side left -padx {0 1m}
264
+ pack .mouse.hor.thr -side right -padx {1m 0}
265
+
266
+ pack .mouse.hor -side top -expand yes
267
+
268
+ #
269
+ # Screen Saver settings
270
+ #
271
+
272
+ labelframe .screen -text "Screen-saver Settings" -padx 1.5m -pady 1.5m
273
+
274
+ radiobutton .screen.blank \
275
+ -variable screenblank -text "Blank" -relief flat \
276
+ -value "blank" -variable screenbla -anchor w
277
+ radiobutton .screen.pat \
278
+ -variable screenblank -text "Pattern" -relief flat \
279
+ -value "noblank" -variable screenbla -anchor w
280
+ labelentry .screen.tim "Timeout (s)" 5 {1 100000}
281
+ labelentry .screen.cyc "Cycle (s)" 5 {1 100000}
282
+
283
+ grid .screen.blank .screen.tim -sticky e
284
+ grid .screen.pat .screen.cyc -sticky e
285
+ grid configure .screen.blank .screen.pat -sticky ew
286
+
287
+ #
288
+ # Main window
289
+ #
290
+
291
+ pack .buttons -side top -fill both
292
+ pack .bell .kbd .mouse .screen -side top -fill both -expand yes \
293
+ -padx 1m -pady 1m
294
+
295
+ #
296
+ # Let the user resize our window
297
+ #
298
+ wm minsize . 10 10
299
+ }
300
+
301
+ ##############################################################################
302
+ # Main program
303
+
304
+ #
305
+ # Listen what "xset" tells us...
306
+ #
307
+
308
+ readsettings
309
+
310
+ #
311
+ # Create all windows
312
+ #
313
+
314
+ createwindows
315
+
316
+ #
317
+ # Write xset parameters
318
+ #
319
+
320
+ dispsettings
321
+
322
+ #
323
+ # Now, wait for user actions...
324
+ #
325
+
326
+ # Local Variables:
327
+ # mode: tcl
328
+ # End:
janus/lib/tk8.6/demos/knightstour.tcl ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
2
+ #
3
+ # Calculate a Knight's tour of a chessboard.
4
+ #
5
+ # This uses Warnsdorff's rule to calculate the next square each
6
+ # time. This specifies that the next square should be the one that
7
+ # has the least number of available moves.
8
+ #
9
+ # Using this rule it is possible to get to a position where
10
+ # there are no squares available to move into. In this implementation
11
+ # this occurs when the starting square is d6.
12
+ #
13
+ # To solve this fault an enhancement to the rule is that if we
14
+ # have a choice of squares with an equal score, we should choose
15
+ # the one nearest the edge of the board.
16
+ #
17
+ # If the call to the Edgemost function is commented out you can see
18
+ # this occur.
19
+ #
20
+ # You can drag the knight to a specific square to start if you wish.
21
+ # If you let it repeat then it will choose random start positions
22
+ # for each new tour.
23
+
24
+ package require Tk
25
+
26
+ # Return a list of accessible squares from a given square
27
+ proc ValidMoves {square} {
28
+ set moves {}
29
+ foreach pair {{-1 -2} {-2 -1} {-2 1} {-1 2} {1 2} {2 1} {2 -1} {1 -2}} {
30
+ set col [expr {($square % 8) + [lindex $pair 0]}]
31
+ set row [expr {($square / 8) + [lindex $pair 1]}]
32
+ if {$row >= 0 && $row < 8 && $col >= 0 && $col < 8} {
33
+ lappend moves [expr {$row * 8 + $col}]
34
+ }
35
+ }
36
+ return $moves
37
+ }
38
+
39
+ # Return the number of available moves for this square
40
+ proc CheckSquare {square} {
41
+ variable visited
42
+ set moves 0
43
+ foreach test [ValidMoves $square] {
44
+ if {[lsearch -exact -integer $visited $test] < 0} {
45
+ incr moves
46
+ }
47
+ }
48
+ return $moves
49
+ }
50
+
51
+ # Select the next square to move to. Returns -1 if there are no available
52
+ # squares remaining that we can move to.
53
+ proc Next {square} {
54
+ variable visited
55
+ set minimum 9
56
+ set nextSquare -1
57
+ foreach testSquare [ValidMoves $square] {
58
+ if {[lsearch -exact -integer $visited $testSquare] < 0} {
59
+ set count [CheckSquare $testSquare]
60
+ if {$count < $minimum} {
61
+ set minimum $count
62
+ set nextSquare $testSquare
63
+ } elseif {$count == $minimum} {
64
+ # to remove the enhancement to Warnsdorff's rule
65
+ # remove the next line:
66
+ set nextSquare [Edgemost $nextSquare $testSquare]
67
+ }
68
+ }
69
+ }
70
+ return $nextSquare
71
+ }
72
+
73
+ # Select the square nearest the edge of the board
74
+ proc Edgemost {a b} {
75
+ set colA [expr {3-int(abs(3.5-($a%8)))}]
76
+ set colB [expr {3-int(abs(3.5-($b%8)))}]
77
+ set rowA [expr {3-int(abs(3.5-($a/8)))}]
78
+ set rowB [expr {3-int(abs(3.5-($b/8)))}]
79
+ return [expr {($colA * $rowA) < ($colB * $rowB) ? $a : $b}]
80
+ }
81
+
82
+ # Display a square number as a standard chess square notation.
83
+ proc N {square} {
84
+ return [format %c%d [expr {97 + $square % 8}] \
85
+ [expr {$square / 8 + 1}]]
86
+ }
87
+
88
+ # Perform a Knight's move and schedule the next move.
89
+ proc MovePiece {dlg last square} {
90
+ variable visited
91
+ variable delay
92
+ variable continuous
93
+ $dlg.f.txt insert end "[llength $visited]. [N $last] .. [N $square]\n" {}
94
+ $dlg.f.txt see end
95
+ $dlg.f.c itemconfigure [expr {1+$last}] -state normal -outline black
96
+ $dlg.f.c itemconfigure [expr {1+$square}] -state normal -outline red
97
+ $dlg.f.c moveto knight {*}[lrange [$dlg.f.c coords [expr {1+$square}]] 0 1]
98
+ lappend visited $square
99
+ set next [Next $square]
100
+ if {$next ne -1} {
101
+ variable aid [after $delay [list MovePiece $dlg $square $next]]
102
+ } else {
103
+ $dlg.tf.b1 configure -state normal
104
+ if {[llength $visited] == 64} {
105
+ variable initial
106
+ if {$initial == $square} {
107
+ $dlg.f.txt insert end "Closed tour!"
108
+ } else {
109
+ $dlg.f.txt insert end "Success\n" {}
110
+ if {$continuous} {
111
+ after [expr {$delay * 2}] [namespace code \
112
+ [list Tour $dlg [expr {int(rand() * 64)}]]]
113
+ }
114
+ }
115
+ } else {
116
+ $dlg.f.txt insert end "FAILED!\n" {}
117
+ }
118
+ }
119
+ }
120
+
121
+ # Begin a new tour of the board given a random start position
122
+ proc Tour {dlg {square {}}} {
123
+ variable visited {}
124
+ $dlg.f.txt delete 1.0 end
125
+ $dlg.tf.b1 configure -state disabled
126
+ for {set n 0} {$n < 64} {incr n} {
127
+ $dlg.f.c itemconfigure $n -state disabled -outline black
128
+ }
129
+ if {$square eq {}} {
130
+ set coords [lrange [$dlg.f.c coords knight] 0 1]
131
+ set square [expr {[$dlg.f.c find closest {*}$coords 0 65]-1}]
132
+ }
133
+ variable initial $square
134
+ after idle [list MovePiece $dlg $initial $initial]
135
+ }
136
+
137
+ proc Stop {} {
138
+ variable aid
139
+ catch {after cancel $aid}
140
+ }
141
+
142
+ proc Exit {dlg} {
143
+ Stop
144
+ destroy $dlg
145
+ }
146
+
147
+ proc SetDelay {new} {
148
+ variable delay [expr {int($new)}]
149
+ }
150
+
151
+ proc DragStart {w x y} {
152
+ $w dtag selected
153
+ $w addtag selected withtag current
154
+ variable dragging [list $x $y]
155
+ }
156
+ proc DragMotion {w x y} {
157
+ variable dragging
158
+ if {[info exists dragging]} {
159
+ $w move selected [expr {$x - [lindex $dragging 0]}] \
160
+ [expr {$y - [lindex $dragging 1]}]
161
+ variable dragging [list $x $y]
162
+ }
163
+ }
164
+ proc DragEnd {w x y} {
165
+ set square [$w find closest $x $y 0 65]
166
+ $w moveto selected {*}[lrange [$w coords $square] 0 1]
167
+ $w dtag selected
168
+ variable dragging ; unset dragging
169
+ }
170
+
171
+ proc CreateGUI {} {
172
+ catch {destroy .knightstour}
173
+ set dlg [toplevel .knightstour]
174
+ wm title $dlg "Knights tour"
175
+ wm withdraw $dlg
176
+ set f [ttk::frame $dlg.f]
177
+ set c [canvas $f.c -width 240 -height 240]
178
+ text $f.txt -width 10 -height 1 \
179
+ -yscrollcommand [list $f.vs set] -font {Arial 8}
180
+ ttk::scrollbar $f.vs -command [list $f.txt yview]
181
+
182
+ variable delay 600
183
+ variable continuous 0
184
+ ttk::frame $dlg.tf
185
+ ttk::label $dlg.tf.ls -text Speed
186
+ ttk::scale $dlg.tf.sc -from 8 -to 2000 -command [list SetDelay] \
187
+ -variable [namespace which -variable delay]
188
+ ttk::checkbutton $dlg.tf.cc -text Repeat \
189
+ -variable [namespace which -variable continuous]
190
+ ttk::button $dlg.tf.b1 -text Start -command [list Tour $dlg]
191
+ ttk::button $dlg.tf.b2 -text Exit -command [list Exit $dlg]
192
+ set square 0
193
+ for {set row 7} {$row >= 0} {incr row -1} {
194
+ for {set col 0} {$col < 8} {incr col} {
195
+ if {(($col & 1) ^ ($row & 1))} {
196
+ set fill tan3 ; set dfill tan4
197
+ } else {
198
+ set fill bisque ; set dfill bisque3
199
+ }
200
+ set coords [list [expr {$col * 30 + 4}] [expr {$row * 30 + 4}] \
201
+ [expr {$col * 30 + 30}] [expr {$row * 30 + 30}]]
202
+ $c create rectangle $coords -fill $fill -disabledfill $dfill \
203
+ -width 2 -state disabled -outline black
204
+ }
205
+ }
206
+ if {[tk windowingsystem] ne "x11"} {
207
+ catch {eval font create KnightFont -size -24}
208
+ $c create text 0 0 -font KnightFont -text "\u265e" \
209
+ -anchor nw -tags knight -fill black -activefill "#600000"
210
+ } else {
211
+ # On X11 we cannot reliably tell if the \u265e glyph is available
212
+ # so just use a polygon
213
+ set pts {
214
+ 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16
215
+ 2 17 4 14 5 15 3 17 5 17 9 14 10 15 5 21
216
+ }
217
+ $c create polygon $pts -tag knight -offset 8 \
218
+ -fill black -activefill "#600000"
219
+ }
220
+ $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1]
221
+ $c bind knight <Button-1> [namespace code [list DragStart %W %x %y]]
222
+ $c bind knight <Motion> [namespace code [list DragMotion %W %x %y]]
223
+ $c bind knight <ButtonRelease-1> [namespace code [list DragEnd %W %x %y]]
224
+
225
+ grid $c $f.txt $f.vs -sticky news
226
+ grid rowconfigure $f 0 -weight 1
227
+ grid columnconfigure $f 1 -weight 1
228
+
229
+ grid $f - - - - - -sticky news
230
+ set things [list $dlg.tf.ls $dlg.tf.sc $dlg.tf.cc $dlg.tf.b1]
231
+ if {![info exists ::widgetDemo]} {
232
+ lappend things $dlg.tf.b2
233
+ if {[tk windowingsystem] ne "aqua"} {
234
+ set things [linsert $things 0 [ttk::sizegrip $dlg.tf.sg]]
235
+ }
236
+ }
237
+ pack {*}$things -side right
238
+ if {[tk windowingsystem] eq "aqua"} {
239
+ pack configure {*}$things -padx {4 4} -pady {12 12}
240
+ pack configure [lindex $things 0] -padx {4 24}
241
+ pack configure [lindex $things end] -padx {16 4}
242
+ }
243
+ grid $dlg.tf - - - - - -sticky ew
244
+ if {[info exists ::widgetDemo]} {
245
+ grid [addSeeDismiss $dlg.buttons $dlg] - - - - - -sticky ew
246
+ }
247
+
248
+ grid rowconfigure $dlg 0 -weight 1
249
+ grid columnconfigure $dlg 0 -weight 1
250
+
251
+ bind $dlg <Control-F2> {console show}
252
+ bind $dlg <Return> [list $dlg.tf.b1 invoke]
253
+ bind $dlg <Escape> [list $dlg.tf.b2 invoke]
254
+ bind $dlg <Destroy> [namespace code [list Stop]]
255
+ wm protocol $dlg WM_DELETE_WINDOW [namespace code [list Exit $dlg]]
256
+
257
+ wm deiconify $dlg
258
+ tkwait window $dlg
259
+ }
260
+
261
+ if {![winfo exists .knightstour]} {
262
+ if {![info exists widgetDemo]} { wm withdraw . }
263
+ set r [catch [linsert $argv 0 CreateGUI] err]
264
+ if {$r} {
265
+ tk_messageBox -icon error -title "Error" -message $err
266
+ }
267
+ if {![info exists widgetDemo]} { exit $r }
268
+ }
janus/lib/tk8.6/demos/labelframe.tcl ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # labelframe.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several labelframe widgets.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .labelframe
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Labelframe Demonstration"
16
+ wm iconname $w "labelframe"
17
+ positionWindow $w
18
+
19
+ # Some information
20
+
21
+ label $w.msg -font $font -wraplength 4i -justify left -text "Labelframes are\
22
+ used to group related widgets together. The label may be either \
23
+ plain text or another widget."
24
+ pack $w.msg -side top
25
+
26
+ ## See Code / Dismiss buttons
27
+ set btns [addSeeDismiss $w.buttons $w]
28
+ pack $btns -side bottom -fill x
29
+
30
+ # Demo area
31
+
32
+ frame $w.f
33
+ pack $w.f -side bottom -fill both -expand 1
34
+ set w $w.f
35
+
36
+ # A group of radiobuttons in a labelframe
37
+
38
+ labelframe $w.f -text "Value" -padx 2 -pady 2
39
+ grid $w.f -row 0 -column 0 -pady 2m -padx 2m
40
+
41
+ foreach value {1 2 3 4} {
42
+ radiobutton $w.f.b$value -text "This is value $value" \
43
+ -variable lfdummy -value $value
44
+ pack $w.f.b$value -side top -fill x -pady 2
45
+ }
46
+
47
+
48
+ # Using a label window to control a group of options.
49
+
50
+ proc lfEnableButtons {w} {
51
+ foreach child [winfo children $w] {
52
+ if {$child == "$w.cb"} continue
53
+ if {$::lfdummy2} {
54
+ $child configure -state normal
55
+ } else {
56
+ $child configure -state disabled
57
+ }
58
+ }
59
+ }
60
+
61
+ labelframe $w.f2 -pady 2 -padx 2
62
+ checkbutton $w.f2.cb -text "Use this option." -variable lfdummy2 \
63
+ -command "lfEnableButtons $w.f2" -padx 0
64
+ $w.f2 configure -labelwidget $w.f2.cb
65
+ grid $w.f2 -row 0 -column 1 -pady 2m -padx 2m
66
+
67
+ set t 0
68
+ foreach str {Option1 Option2 Option3} {
69
+ checkbutton $w.f2.b$t -text $str
70
+ pack $w.f2.b$t -side top -fill x -pady 2
71
+ incr t
72
+ }
73
+ lfEnableButtons $w.f2
74
+
75
+
76
+ grid columnconfigure $w {0 1} -weight 1
janus/lib/tk8.6/demos/menu.tcl ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # menu.tcl --
2
+ #
3
+ # This demonstration script creates a window with a bunch of menus
4
+ # and cascaded menus using menubars.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .menu
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Menu Demonstration"
16
+ wm iconname $w "menu"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left
20
+ if {[tk windowingsystem] eq "aqua"} {
21
+ $w.msg configure -text "This window has a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by selecting the first item in the menu."
22
+ } else {
23
+ $w.msg configure -text "This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu."
24
+ }
25
+ pack $w.msg -side top
26
+
27
+ set menustatus " "
28
+ frame $w.statusBar
29
+ label $w.statusBar.label -textvariable menustatus -relief sunken -bd 1 -font "Helvetica 10" -anchor w
30
+ pack $w.statusBar.label -side left -padx 2 -expand yes -fill both
31
+ pack $w.statusBar -side bottom -fill x -pady 2
32
+
33
+ ## See Code / Dismiss buttons
34
+ set btns [addSeeDismiss $w.buttons $w]
35
+ pack $btns -side bottom -fill x
36
+
37
+ menu $w.menu -tearoff 0
38
+
39
+ set m $w.menu.file
40
+ menu $m -tearoff 0
41
+ $w.menu add cascade -label "File" -menu $m -underline 0
42
+ $m add command -label "Open..." -command {error "this is just a demo: no action has been defined for the \"Open...\" entry"}
43
+ $m add command -label "New" -command {error "this is just a demo: no action has been defined for the \"New\" entry"}
44
+ $m add command -label "Save" -command {error "this is just a demo: no action has been defined for the \"Save\" entry"}
45
+ $m add command -label "Save As..." -command {error "this is just a demo: no action has been defined for the \"Save As...\" entry"}
46
+ $m add separator
47
+ $m add command -label "Print Setup..." -command {error "this is just a demo: no action has been defined for the \"Print Setup...\" entry"}
48
+ $m add command -label "Print..." -command {error "this is just a demo: no action has been defined for the \"Print...\" entry"}
49
+ $m add separator
50
+ $m add command -label "Dismiss Menus Demo" -command "destroy $w"
51
+
52
+ set m $w.menu.basic
53
+ $w.menu add cascade -label "Basic" -menu $m -underline 0
54
+ menu $m -tearoff 0
55
+ $m add command -label "Long entry that does nothing"
56
+ if {[tk windowingsystem] eq "aqua"} {
57
+ set modifier Command
58
+ } elseif {[tk windowingsystem] eq "win32"} {
59
+ set modifier Control
60
+ } else {
61
+ set modifier Meta
62
+ }
63
+ foreach i {A B C D E F} {
64
+ $m add command -label "Print letter \"$i\"" -underline 14 \
65
+ -accelerator $modifier+$i -command "puts $i"
66
+ bind $w <$modifier-[string tolower $i]> "puts $i"
67
+ }
68
+
69
+ set m $w.menu.cascade
70
+ $w.menu add cascade -label "Cascades" -menu $m -underline 0
71
+ menu $m -tearoff 0
72
+ $m add command -label "Print hello" \
73
+ -command {puts stdout "Hello"} -accelerator $modifier+H -underline 6
74
+ bind $w <$modifier-h> {puts stdout "Hello"}
75
+ $m add command -label "Print goodbye" -command {\
76
+ puts stdout "Goodbye"} -accelerator $modifier+G -underline 6
77
+ bind $w <$modifier-g> {puts stdout "Goodbye"}
78
+ $m add cascade -label "Check buttons" \
79
+ -menu $w.menu.cascade.check -underline 0
80
+ $m add cascade -label "Radio buttons" \
81
+ -menu $w.menu.cascade.radio -underline 0
82
+
83
+ set m $w.menu.cascade.check
84
+ menu $m -tearoff 0
85
+ $m add check -label "Oil checked" -variable oil
86
+ $m add check -label "Transmission checked" -variable trans
87
+ $m add check -label "Brakes checked" -variable brakes
88
+ $m add check -label "Lights checked" -variable lights
89
+ $m add separator
90
+ $m add command -label "Show current values" \
91
+ -command "showVars $w.menu.cascade.dialog oil trans brakes lights"
92
+ $m invoke 1
93
+ $m invoke 3
94
+
95
+ set m $w.menu.cascade.radio
96
+ menu $m -tearoff 0
97
+ $m add radio -label "10 point" -variable pointSize -value 10
98
+ $m add radio -label "14 point" -variable pointSize -value 14
99
+ $m add radio -label "18 point" -variable pointSize -value 18
100
+ $m add radio -label "24 point" -variable pointSize -value 24
101
+ $m add radio -label "32 point" -variable pointSize -value 32
102
+ $m add sep
103
+ $m add radio -label "Roman" -variable style -value roman
104
+ $m add radio -label "Bold" -variable style -value bold
105
+ $m add radio -label "Italic" -variable style -value italic
106
+ $m add sep
107
+ $m add command -label "Show current values" \
108
+ -command "showVars $w.menu.cascade.dialog pointSize style"
109
+ $m invoke 1
110
+ $m invoke 7
111
+
112
+ set m $w.menu.icon
113
+ $w.menu add cascade -label "Icons" -menu $m -underline 0
114
+ menu $m -tearoff 0
115
+ # Main widget program sets variable tk_demoDirectory
116
+ image create photo lilearth -file [file join $tk_demoDirectory \
117
+ images earthmenu.png]
118
+ $m add command -image lilearth \
119
+ -hidemargin 1 -command [list \
120
+ tk_dialog $w.pattern {Bitmap Menu Entry} \
121
+ "The menu entry you invoked displays a photoimage rather than\
122
+ a text string. Other than this, it is just like any other\
123
+ menu entry." {} 0 OK ]
124
+ foreach i {info questhead error} {
125
+ $m add command -bitmap $i -hidemargin 1 -command [list \
126
+ puts "You invoked the $i bitmap" ]
127
+ }
128
+ $m entryconfigure 2 -columnbreak 1
129
+
130
+ set m $w.menu.more
131
+ $w.menu add cascade -label "More" -menu $m -underline 0
132
+ menu $m -tearoff 0
133
+ foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Make life meaningful}} {
134
+ $m add command -label $i -command [list puts "You invoked \"$i\""]
135
+ }
136
+ set emojiLabel [encoding convertfrom utf-8 "\xF0\x9F\x98\x8D Make friends"]
137
+ $m add command -label $emojiLabel -command [list puts "Menu labels can include non-BMP characters."]
138
+ $m entryconfigure "Does almost nothing" -bitmap questhead -compound left \
139
+ -command [list \
140
+ tk_dialog $w.compound {Compound Menu Entry} \
141
+ "The menu entry you invoked displays both a bitmap and a\
142
+ text string. Other than this, it is just like any other\
143
+ menu entry." {} 0 OK ]
144
+
145
+ set m $w.menu.colors
146
+ $w.menu add cascade -label "Colors" -menu $m -underline 1
147
+ menu $m -tearoff 1
148
+ if {[tk windowingsystem] eq "aqua"} {
149
+ # Aqua ignores the -background and -foreground options, but a compound
150
+ # button can be used for selecting colors.
151
+ foreach i {red orange yellow green blue} {
152
+ image create photo image_$i -height 16 -width 16
153
+ image_$i put black -to 0 0 16 1
154
+ image_$i put black -to 0 1 1 16
155
+ image_$i put black -to 0 15 16 16
156
+ image_$i put black -to 15 1 16 16
157
+ image_$i put $i -to 1 1 15 15
158
+ $m add command -label $i -image image_$i -compound left -command [list \
159
+ puts "You invoked \"$i\"" ]
160
+ }
161
+ } else {
162
+ foreach i {red orange yellow green blue} {
163
+ $m add command -label $i -background $i -command [list \
164
+ puts "You invoked \"$i\"" ]
165
+ }
166
+ }
167
+
168
+ $w configure -menu $w.menu
169
+
170
+ bind Menu <<MenuSelect>> {
171
+ global $menustatus
172
+ if {[catch {%W entrycget active -label} label]} {
173
+ set label " "
174
+ }
175
+ set menustatus $label
176
+ update idletasks
177
+ }
janus/lib/tk8.6/demos/msgbox.tcl ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # msgbox.tcl --
2
+ #
3
+ # This demonstration script creates message boxes of various type
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .msgbox
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Message Box Demonstration"
15
+ wm iconname $w "messagebox"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 4i -justify left -text "Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box."
19
+ pack $w.msg -side top
20
+
21
+ pack [addSeeDismiss $w.buttons $w {} {
22
+ ttk::button $w.buttons.vars -text "Message Box" -command "showMessageBox $w"
23
+ }] -side bottom -fill x
24
+ #pack $w.buttons.dismiss $w.buttons.code $w.buttons.vars -side left -expand 1
25
+
26
+ frame $w.left
27
+ frame $w.right
28
+ pack $w.left $w.right -side left -expand yes -fill y -pady .5c -padx .5c
29
+
30
+ label $w.left.label -text "Icon"
31
+ frame $w.left.sep -relief ridge -bd 1 -height 2
32
+ pack $w.left.label -side top
33
+ pack $w.left.sep -side top -fill x -expand no
34
+
35
+ set msgboxIcon info
36
+ foreach i {error info question warning} {
37
+ radiobutton $w.left.b$i -text $i -variable msgboxIcon \
38
+ -relief flat -value $i -width 16 -anchor w
39
+ pack $w.left.b$i -side top -pady 2 -anchor w -fill x
40
+ }
41
+
42
+ label $w.right.label -text "Type"
43
+ frame $w.right.sep -relief ridge -bd 1 -height 2
44
+ pack $w.right.label -side top
45
+ pack $w.right.sep -side top -fill x -expand no
46
+
47
+ set msgboxType ok
48
+ foreach t {abortretryignore ok okcancel retrycancel yesno yesnocancel} {
49
+ radiobutton $w.right.$t -text $t -variable msgboxType \
50
+ -relief flat -value $t -width 16 -anchor w
51
+ pack $w.right.$t -side top -pady 2 -anchor w -fill x
52
+ }
53
+
54
+ proc showMessageBox {w} {
55
+ global msgboxIcon msgboxType
56
+ set button [tk_messageBox -icon $msgboxIcon -type $msgboxType \
57
+ -title Message -parent $w\
58
+ -message "This is a \"$msgboxType\" type messagebox with the \"$msgboxIcon\" icon"]
59
+
60
+ tk_messageBox -icon info -message "You have selected \"$button\"" -type ok\
61
+ -parent $w
62
+ }
janus/lib/tk8.6/demos/nl.msg ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ::msgcat::mcset nl "Widget Demonstration" "Demonstratie van widgets"
2
+ ::msgcat::mcset nl "tkWidgetDemo" "tkWidgetDemo"
3
+ ::msgcat::mcset nl "&File" "&Bestand"
4
+ ::msgcat::mcset nl "About..." "Info..."
5
+ ::msgcat::mcset nl "&About..." "&Info..."
6
+ ::msgcat::mcset nl "<F1>" "<F1>"
7
+ ::msgcat::mcset nl "&Quit" "&Einde"
8
+ ::msgcat::mcset nl "Meta+Q" "Meta+E" ;# Displayed hotkey
9
+ ::msgcat::mcset nl "Meta-q" "Meta-e" ;# Actual binding sequence
10
+ ::msgcat::mcset nl "Ctrl+Q" "Ctrl+E" ;# Displayed hotkey
11
+ ::msgcat::mcset nl "Control-q" "Control-e" ;# Actual binding sequence
12
+ ::msgcat::mcset nl "Dismiss" "Sluiten"
13
+ ::msgcat::mcset nl "See Variables" "Bekijk Variabelen"
14
+ ::msgcat::mcset nl "Variable Values" "Waarden Variabelen"
15
+ ::msgcat::mcset nl "OK" "OK"
16
+ ::msgcat::mcset nl "Run the \"%s\" sample program" "Start voorbeeld \"%s\""
17
+ ::msgcat::mcset nl "Print Code" "Code Afdrukken"
18
+ ::msgcat::mcset nl "Demo code: %s" "Code van Demo %s"
19
+ ::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie"
20
+ ::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets"
21
+ ::msgcat::mcset nl "Copyright © %s"
22
+
23
+ ::msgcat::mcset nl "Tk Widget Demonstrations" "Demonstratie van Tk widgets"
24
+ ::msgcat::mcset nl "This application provides a front end for several short scripts" \
25
+ "Dit programma is een schil rond enkele korte scripts waarmee"
26
+ ::msgcat::mcset nl "that demonstrate what you can do with Tk widgets. Each of the" \
27
+ "gedemonstreerd wordt wat je kunt doen met Tk widgets. Elk van de"
28
+ ::msgcat::mcset nl "numbered lines below describes a demonstration; you can click on" \
29
+ "genummerde regels hieronder omschrijft een demonstratie; je kunt de"
30
+ ::msgcat::mcset nl "it to invoke the demonstration. Once the demonstration window" \
31
+ "demonstratie starten door op de regel te klikken."
32
+ ::msgcat::mcset nl "appears, you can click the" \
33
+ "Zodra het nieuwe venster verschijnt, kun je op de knop"
34
+ ::msgcat::mcset nl "See Code" "Bekijk Code" ;# This is also button text!
35
+ ::msgcat::mcset nl "button to see the Tcl/Tk code that created the demonstration. If" \
36
+ "drukken om de achterliggende Tcl/Tk code te zien. Als je dat wilt,"
37
+ ::msgcat::mcset nl "you wish, you can edit the code and click the" \
38
+ "kun je de code wijzigen en op de knop"
39
+ ::msgcat::mcset nl "Rerun Demo" "Herstart Demo" ;# This is also button text!
40
+ ::msgcat::mcset nl "button in the code window to reinvoke the demonstration with the" \
41
+ "drukken in het codevenster om de demonstratie uit te voeren met de"
42
+ ::msgcat::mcset nl "modified code." \
43
+ "nieuwe code."
44
+
45
+ ::msgcat::mcset nl "Labels, buttons, checkbuttons, and radiobuttons" \
46
+ "Labels, knoppen, vinkjes/aankruishokjes en radioknoppen"
47
+
48
+ ::msgcat::mcset nl "Labels (text and bitmaps)" "Labels (tekst en plaatjes)"
49
+ ::msgcat::mcset nl "Labels and UNICODE text" "Labels en tekst in UNICODE"
50
+ ::msgcat::mcset nl "Buttons" "Buttons (drukknoppen)"
51
+ ::msgcat::mcset nl "Check-buttons (select any of a group)" \
52
+ "Check-buttons (een of meer uit een groep)"
53
+ ::msgcat::mcset nl "Radio-buttons (select one of a group)" \
54
+ "Radio-buttons (een van een groep)"
55
+ ::msgcat::mcset nl "A 15-puzzle game made out of buttons" \
56
+ "Een schuifpuzzel van buttons"
57
+ ::msgcat::mcset nl "Iconic buttons that use bitmaps" \
58
+ "Buttons met pictogrammen"
59
+ ::msgcat::mcset nl "Two labels displaying images" \
60
+ "Twee labels met plaatjes in plaats van tekst"
61
+ ::msgcat::mcset nl "A simple user interface for viewing images" \
62
+ "Een eenvoudige user-interface voor het bekijken van plaatjes"
63
+ ::msgcat::mcset nl "Labelled frames" \
64
+ "Kaders met bijschrift"
65
+
66
+ ::msgcat::mcset nl "Listboxes" "Keuzelijsten"
67
+ ::msgcat::mcset nl "The 50 states" "De 50 staten van de VS"
68
+ ::msgcat::mcset nl "Colors: change the color scheme for the application" \
69
+ "Kleuren: verander het kleurenschema voor het programma"
70
+ ::msgcat::mcset nl "A collection of famous and infamous sayings" \
71
+ "Beroemde en beruchte citaten en gezegden"
72
+
73
+ ::msgcat::mcset nl "Entries and Spin-boxes" "Invulvelden en Spinboxen"
74
+ ::msgcat::mcset nl "Entries without scrollbars" "Invulvelden zonder schuifbalk"
75
+ ::msgcat::mcset nl "Entries with scrollbars" "Invulvelden met schuifbalk"
76
+ ::msgcat::mcset nl "Validated entries and password fields" \
77
+ "Invulvelden met controle of wachtwoorden"
78
+ ::msgcat::mcset nl "Spin-boxes" "Spinboxen"
79
+ ::msgcat::mcset nl "Simple Rolodex-like form" "Simpel kaartsysteem"
80
+
81
+ ::msgcat::mcset nl "Text" "Tekst"
82
+ ::msgcat::mcset nl "Basic editable text" "Voorbeeld met te wijzigen tekst"
83
+ ::msgcat::mcset nl "Text display styles" "Tekst met verschillende stijlen"
84
+ ::msgcat::mcset nl "Hypertext (tag bindings)" \
85
+ "Hypertext (verwijzingen via \"tags\")"
86
+ ::msgcat::mcset nl "A text widget with embedded windows" \
87
+ "Tekstwidget met windows erin"
88
+ ::msgcat::mcset nl "A search tool built with a text widget" \
89
+ "Zoeken in tekst met behulp van een tekstwidget"
90
+
91
+ ::msgcat::mcset nl "Canvases" "Canvaswidgets"
92
+ ::msgcat::mcset nl "The canvas item types" "Objecten in een canvas"
93
+ ::msgcat::mcset nl "A simple 2-D plot" "Eenvoudige 2D-grafiek"
94
+ ::msgcat::mcset nl "Text items in canvases" "Tekstobjecten in een canvas"
95
+ ::msgcat::mcset nl "An editor for arrowheads on canvas lines" \
96
+ "Editor voor de vorm van de pijl (begin/eind van een lijn)"
97
+ ::msgcat::mcset nl "A ruler with adjustable tab stops" \
98
+ "Een meetlat met aanpasbare ruiters"
99
+ ::msgcat::mcset nl "A building floor plan" "Plattegrond van een gebouw"
100
+ ::msgcat::mcset nl "A simple scrollable canvas" "Een schuifbaar canvas"
101
+
102
+ ::msgcat::mcset nl "Scales" "Schaalverdelingen"
103
+ ::msgcat::mcset nl "Horizontal scale" "Horizontale schaal"
104
+ ::msgcat::mcset nl "Vertical scale" "Verticale schaal"
105
+
106
+ ::msgcat::mcset nl "Paned Windows" "Vensters opgedeeld in stukken"
107
+ ::msgcat::mcset nl "Horizontal paned window" "Horizontaal gedeeld venster"
108
+ ::msgcat::mcset nl "Vertical paned window" "Verticaal gedeeld venster"
109
+
110
+ ::msgcat::mcset nl "Menus" "Menu's"
111
+ ::msgcat::mcset nl "Menus and cascades (sub-menus)" \
112
+ "Menu's en cascades (submenu's)"
113
+ ::msgcat::mcset nl "Menu-buttons" "Menu-buttons"
114
+
115
+ ::msgcat::mcset nl "Common Dialogs" "Veel voorkomende dialoogvensters"
116
+ ::msgcat::mcset nl "Message boxes" "Mededeling (message box)"
117
+ ::msgcat::mcset nl "File selection dialog" "Selectie van bestanden"
118
+ ::msgcat::mcset nl "Color picker" "Kleurenpalet"
119
+
120
+ ::msgcat::mcset nl "Miscellaneous" "Diversen"
121
+ ::msgcat::mcset nl "The built-in bitmaps" "Ingebouwde plaatjes"
122
+ ::msgcat::mcset nl "A dialog box with a local grab" \
123
+ "Een dialoogvenster met een locale \"grab\""
124
+ ::msgcat::mcset nl "A dialog box with a global grab" \
125
+ "Een dialoogvenster met een globale \"grab\""
janus/lib/tk8.6/demos/paned1.tcl ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # paned1.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # a paned window that separates two windows horizontally.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .paned1
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Horizontal Paned Window Demonstration"
16
+ wm iconname $w "paned1"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)"
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ panedwindow $w.pane
27
+ pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m
28
+
29
+ label $w.pane.left -text "This is the\nleft side" -fg black -bg yellow
30
+ label $w.pane.right -text "This is the\nright side" -fg black -bg cyan
31
+
32
+ $w.pane add $w.pane.left $w.pane.right
janus/lib/tk8.6/demos/paned2.tcl ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # paned2.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # a paned window that separates two windows vertically.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .paned2
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Vertical Paned Window Demonstration"
16
+ wm iconname $w "paned2"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)"
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ # Create the pane itself
27
+ panedwindow $w.pane -orient vertical
28
+ pack $w.pane -side top -expand yes -fill both -pady 2 -padx 2m
29
+
30
+ # The top window is a listbox with scrollbar
31
+ set paneList {
32
+ {List of Tk Widgets}
33
+ button
34
+ canvas
35
+ checkbutton
36
+ entry
37
+ frame
38
+ label
39
+ labelframe
40
+ listbox
41
+ menu
42
+ menubutton
43
+ message
44
+ panedwindow
45
+ radiobutton
46
+ scale
47
+ scrollbar
48
+ spinbox
49
+ text
50
+ toplevel
51
+ }
52
+ set f [frame $w.pane.top]
53
+ listbox $f.list -listvariable paneList -yscrollcommand "$f.scr set"
54
+ # Invert the first item to highlight it
55
+ $f.list itemconfigure 0 \
56
+ -background [$f.list cget -fg] -foreground [$f.list cget -bg]
57
+ ttk::scrollbar $f.scr -orient vertical -command "$f.list yview"
58
+ pack $f.scr -side right -fill y
59
+ pack $f.list -fill both -expand 1
60
+
61
+ # The bottom window is a text widget with scrollbar
62
+ set f [frame $w.pane.bottom]
63
+ text $f.text -xscrollcommand "$f.xscr set" -yscrollcommand "$f.yscr set" \
64
+ -width 30 -height 8 -wrap none
65
+ ttk::scrollbar $f.xscr -orient horizontal -command "$f.text xview"
66
+ ttk::scrollbar $f.yscr -orient vertical -command "$f.text yview"
67
+ grid $f.text $f.yscr -sticky nsew
68
+ grid $f.xscr -sticky nsew
69
+ grid columnconfigure $f 0 -weight 1
70
+ grid rowconfigure $f 0 -weight 1
71
+ $f.text insert 1.0 "This is just a normal text widget"
72
+
73
+ # Now add our contents to the paned window
74
+ $w.pane add $w.pane.top $w.pane.bottom
janus/lib/tk8.6/demos/pendulum.tcl ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # pendulum.tcl --
2
+ #
3
+ # This demonstration illustrates how Tcl/Tk can be used to construct
4
+ # simulations of physical systems.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .pendulum
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Pendulum Animation Demonstration"
16
+ wm iconname $w "pendulum"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows how Tcl/Tk can be used to carry out animations that are linked to simulations of physical systems. In the left canvas is a graphical representation of the physical system itself, a simple pendulum, and in the right canvas is a graph of the phase space of the system, which is a plot of the angle (relative to the vertical) against the angular velocity. The pendulum bob may be repositioned by clicking and dragging anywhere on the left canvas."
20
+ pack $w.msg
21
+
22
+ ## See Code / Dismiss buttons
23
+ set btns [addSeeDismiss $w.buttons $w]
24
+ pack $btns -side bottom -fill x
25
+
26
+ # Create some structural widgets
27
+ pack [panedwindow $w.p] -fill both -expand 1
28
+ $w.p add [labelframe $w.p.l1 -text "Pendulum Simulation"]
29
+ $w.p add [labelframe $w.p.l2 -text "Phase Space"]
30
+
31
+ # Create the canvas containing the graphical representation of the
32
+ # simulated system.
33
+ canvas $w.c -width 320 -height 200 -background white -bd 2 -relief sunken
34
+ $w.c create text 5 5 -anchor nw -text "Click to Adjust Bob Start Position"
35
+ # Coordinates of these items don't matter; they will be set properly below
36
+ $w.c create line 0 25 320 25 -tags plate -fill grey50 -width 2
37
+ $w.c create oval 155 20 165 30 -tags pivot -fill grey50 -outline {}
38
+ $w.c create line 1 1 1 1 -tags rod -fill black -width 3
39
+ $w.c create oval 1 1 2 2 -tags bob -fill yellow -outline black
40
+ pack $w.c -in $w.p.l1 -fill both -expand true
41
+
42
+ # Create the canvas containing the phase space graph; this consists of
43
+ # a line that gets gradually paler as it ages, which is an extremely
44
+ # effective visual trick.
45
+ canvas $w.k -width 320 -height 200 -background white -bd 2 -relief sunken
46
+ $w.k create line 160 200 160 0 -fill grey75 -arrow last -tags y_axis
47
+ $w.k create line 0 100 320 100 -fill grey75 -arrow last -tags x_axis
48
+ for {set i 90} {$i>=0} {incr i -10} {
49
+ # Coordinates of these items don't matter; they will be set properly below
50
+ $w.k create line 0 0 1 1 -smooth true -tags graph$i -fill grey$i
51
+ }
52
+
53
+ $w.k create text 0 0 -anchor ne -text "\u03b8" -tags label_theta
54
+ $w.k create text 0 0 -anchor ne -text "\u03b4\u03b8" -tags label_dtheta
55
+ pack $w.k -in $w.p.l2 -fill both -expand true
56
+
57
+ # Initialize some variables
58
+ set points {}
59
+ set Theta 45.0
60
+ set dTheta 0.0
61
+ set pi 3.1415926535897933
62
+ set length 150
63
+ set home 160
64
+
65
+ # This procedure makes the pendulum appear at the correct place on the
66
+ # canvas. If the additional arguments "at $x $y" are passed (the 'at'
67
+ # is really just syntactic sugar) instead of computing the position of
68
+ # the pendulum from the length of the pendulum rod and its angle, the
69
+ # length and angle are computed in reverse from the given location
70
+ # (which is taken to be the centre of the pendulum bob.)
71
+ proc showPendulum {canvas {at {}} {x {}} {y {}}} {
72
+ global Theta dTheta pi length home
73
+ if {$at eq "at" && ($x!=$home || $y!=25)} {
74
+ set dTheta 0.0
75
+ set x2 [expr {$x - $home}]
76
+ set y2 [expr {$y - 25}]
77
+ set length [expr {hypot($x2, $y2)}]
78
+ set Theta [expr {atan2($x2, $y2) * 180/$pi}]
79
+ } else {
80
+ set angle [expr {$Theta * $pi/180}]
81
+ set x [expr {$home + $length*sin($angle)}]
82
+ set y [expr {25 + $length*cos($angle)}]
83
+ }
84
+ $canvas coords rod $home 25 $x $y
85
+ $canvas coords bob [expr {$x - 15}] [expr {$y - 15}] \
86
+ [expr {$x + 15}] [expr {$y + 15}]
87
+ }
88
+ showPendulum $w.c
89
+
90
+ # Update the phase-space graph according to the current angle and the
91
+ # rate at which the angle is changing (the first derivative with
92
+ # respect to time.)
93
+ proc showPhase {canvas} {
94
+ global Theta dTheta points psw psh
95
+ lappend points [expr {$Theta + $psw}] [expr {-20*$dTheta + $psh}]
96
+ if {[llength $points] > 100} {
97
+ set points [lrange $points end-99 end]
98
+ }
99
+ for {set i 0} {$i<100} {incr i 10} {
100
+ set list [lrange $points end-[expr {$i-1}] end-[expr {$i-12}]]
101
+ if {[llength $list] >= 4} {
102
+ $canvas coords graph$i $list
103
+ }
104
+ }
105
+ }
106
+
107
+ # Set up some bindings on the canvases. Note that when the user
108
+ # clicks we stop the animation until they release the mouse
109
+ # button. Also note that both canvases are sensitive to <Configure>
110
+ # events, which allows them to find out when they have been resized by
111
+ # the user.
112
+ bind $w.c <Destroy> {
113
+ after cancel $animationCallbacks(pendulum)
114
+ unset animationCallbacks(pendulum)
115
+ }
116
+ bind $w.c <Button-1> {
117
+ after cancel $animationCallbacks(pendulum)
118
+ showPendulum %W at %x %y
119
+ }
120
+ bind $w.c <B1-Motion> {
121
+ showPendulum %W at %x %y
122
+ }
123
+ bind $w.c <ButtonRelease-1> {
124
+ showPendulum %W at %x %y
125
+ set animationCallbacks(pendulum) [after 15 repeat [winfo toplevel %W]]
126
+ }
127
+ bind $w.c <Configure> {
128
+ %W coords plate 0 25 %w 25
129
+ set home [expr {%w/2}]
130
+ %W coords pivot [expr {$home - 5}] 20 [expr {$home + 5}] 30
131
+ }
132
+ bind $w.k <Configure> {
133
+ set psh [expr {%h/2}]
134
+ set psw [expr {%w/2}]
135
+ %W coords x_axis 2 $psh [expr {%w - 2}] $psh
136
+ %W coords y_axis $psw [expr {%h - 2}] $psw 2
137
+ %W coords label_dtheta [expr {$psw - 4}] 6
138
+ %W coords label_theta [expr {%w - 6}] [expr {$psh + 4}]
139
+ }
140
+
141
+ # This procedure is the "business" part of the simulation that does
142
+ # simple numerical integration of the formula for a simple rotational
143
+ # pendulum.
144
+ proc recomputeAngle {} {
145
+ global Theta dTheta pi length
146
+ set scaling [expr {3000.0/$length/$length}]
147
+
148
+ # To estimate the integration accurately, we really need to
149
+ # compute the end-point of our time-step. But to do *that*, we
150
+ # need to estimate the integration accurately! So we try this
151
+ # technique, which is inaccurate, but better than doing it in a
152
+ # single step. What we really want is bound up in the
153
+ # differential equation:
154
+ # .. - sin theta
155
+ # theta + theta = -----------
156
+ # length
157
+ # But my math skills are not good enough to solve this!
158
+
159
+ # first estimate
160
+ set firstDDTheta [expr {-sin($Theta * $pi/180)*$scaling}]
161
+ set midDTheta [expr {$dTheta + $firstDDTheta}]
162
+ set midTheta [expr {$Theta + ($dTheta + $midDTheta)/2}]
163
+ # second estimate
164
+ set midDDTheta [expr {-sin($midTheta * $pi/180)*$scaling}]
165
+ set midDTheta [expr {$dTheta + ($firstDDTheta + $midDDTheta)/2}]
166
+ set midTheta [expr {$Theta + ($dTheta + $midDTheta)/2}]
167
+ # Now we do a double-estimate approach for getting the final value
168
+ # first estimate
169
+ set midDDTheta [expr {-sin($midTheta * $pi/180)*$scaling}]
170
+ set lastDTheta [expr {$midDTheta + $midDDTheta}]
171
+ set lastTheta [expr {$midTheta + ($midDTheta + $lastDTheta)/2}]
172
+ # second estimate
173
+ set lastDDTheta [expr {-sin($lastTheta * $pi/180)*$scaling}]
174
+ set lastDTheta [expr {$midDTheta + ($midDDTheta + $lastDDTheta)/2}]
175
+ set lastTheta [expr {$midTheta + ($midDTheta + $lastDTheta)/2}]
176
+ # Now put the values back in our globals
177
+ set dTheta $lastDTheta
178
+ set Theta $lastTheta
179
+ }
180
+
181
+ # This method ties together the simulation engine and the graphical
182
+ # display code that visualizes it.
183
+ proc repeat w {
184
+ global animationCallbacks
185
+
186
+ # Simulate
187
+ recomputeAngle
188
+
189
+ # Update the display
190
+ showPendulum $w.c
191
+ showPhase $w.k
192
+
193
+ # Reschedule ourselves
194
+ set animationCallbacks(pendulum) [after 15 [list repeat $w]]
195
+ }
196
+ # Start the simulation after a short pause
197
+ set animationCallbacks(pendulum) [after 500 [list repeat $w]]
janus/lib/tk8.6/demos/plot.tcl ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # plot.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget showing a 2-D
4
+ # plot with data points that can be dragged with the mouse.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .plot
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Plot Demonstration"
16
+ wm iconname $w "Plot"
17
+ positionWindow $w
18
+ set c $w.c
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."
21
+ pack $w.msg -side top
22
+
23
+ ## See Code / Dismiss buttons
24
+ set btns [addSeeDismiss $w.buttons $w]
25
+ pack $btns -side bottom -fill x
26
+
27
+ canvas $c -relief raised -width 450 -height 300
28
+ pack $w.c -side top -fill x
29
+
30
+ set plotFont {Helvetica 18}
31
+
32
+ $c create line 100 250 400 250 -width 2
33
+ $c create line 100 250 100 50 -width 2
34
+ $c create text 225 20 -text "A Simple Plot" -font $plotFont -fill brown
35
+
36
+ for {set i 0} {$i <= 10} {incr i} {
37
+ set x [expr {100 + ($i*30)}]
38
+ $c create line $x 250 $x 245 -width 2
39
+ $c create text $x 254 -text [expr {10*$i}] -anchor n -font $plotFont
40
+ }
41
+ for {set i 0} {$i <= 5} {incr i} {
42
+ set y [expr {250 - ($i*40)}]
43
+ $c create line 100 $y 105 $y -width 2
44
+ $c create text 96 $y -text [expr {$i*50}].0 -anchor e -font $plotFont
45
+ }
46
+
47
+ foreach point {
48
+ {12 56} {20 94} {33 98} {32 120} {61 180} {75 160} {98 223}
49
+ } {
50
+ set x [expr {100 + (3*[lindex $point 0])}]
51
+ set y [expr {250 - (4*[lindex $point 1])/5}]
52
+ set item [$c create oval [expr {$x-6}] [expr {$y-6}] \
53
+ [expr {$x+6}] [expr {$y+6}] -width 1 -outline black \
54
+ -fill SkyBlue2]
55
+ $c addtag point withtag $item
56
+ }
57
+
58
+ $c bind point <Enter> "$c itemconfig current -fill red"
59
+ $c bind point <Leave> "$c itemconfig current -fill SkyBlue2"
60
+ $c bind point <Button-1> "plotDown $c %x %y"
61
+ $c bind point <ButtonRelease-1> "$c dtag selected"
62
+ bind $c <B1-Motion> "plotMove $c %x %y"
63
+
64
+ set plot(lastX) 0
65
+ set plot(lastY) 0
66
+
67
+ # plotDown --
68
+ # This procedure is invoked when the mouse is pressed over one of the
69
+ # data points. It sets up state to allow the point to be dragged.
70
+ #
71
+ # Arguments:
72
+ # w - The canvas window.
73
+ # x, y - The coordinates of the mouse press.
74
+
75
+ proc plotDown {w x y} {
76
+ global plot
77
+ $w dtag selected
78
+ $w addtag selected withtag current
79
+ $w raise current
80
+ set plot(lastX) $x
81
+ set plot(lastY) $y
82
+ }
83
+
84
+ # plotMove --
85
+ # This procedure is invoked during mouse motion events. It drags the
86
+ # current item.
87
+ #
88
+ # Arguments:
89
+ # w - The canvas window.
90
+ # x, y - The coordinates of the mouse.
91
+
92
+ proc plotMove {w x y} {
93
+ global plot
94
+ $w move selected [expr {$x-$plot(lastX)}] [expr {$y-$plot(lastY)}]
95
+ set plot(lastX) $x
96
+ set plot(lastY) $y
97
+ }
janus/lib/tk8.6/demos/puzzle.tcl ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # puzzle.tcl --
2
+ #
3
+ # This demonstration script creates a 15-puzzle game using a collection
4
+ # of buttons.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # puzzleSwitch --
13
+ # This procedure is invoked when the user clicks on a particular button;
14
+ # if the button is next to the empty space, it moves the button into the
15
+ # empty space.
16
+
17
+ proc puzzleSwitch {w num} {
18
+ global xpos ypos
19
+ if {(($ypos($num) >= ($ypos(space) - .01))
20
+ && ($ypos($num) <= ($ypos(space) + .01))
21
+ && ($xpos($num) >= ($xpos(space) - .26))
22
+ && ($xpos($num) <= ($xpos(space) + .26)))
23
+ || (($xpos($num) >= ($xpos(space) - .01))
24
+ && ($xpos($num) <= ($xpos(space) + .01))
25
+ && ($ypos($num) >= ($ypos(space) - .26))
26
+ && ($ypos($num) <= ($ypos(space) + .26)))} {
27
+ set tmp $xpos(space)
28
+ set xpos(space) $xpos($num)
29
+ set xpos($num) $tmp
30
+ set tmp $ypos(space)
31
+ set ypos(space) $ypos($num)
32
+ set ypos($num) $tmp
33
+ place $w.frame.$num -relx $xpos($num) -rely $ypos($num)
34
+ }
35
+ }
36
+
37
+ set w .puzzle
38
+ catch {destroy $w}
39
+ toplevel $w
40
+ wm title $w "15-Puzzle Demonstration"
41
+ wm iconname $w "15-Puzzle"
42
+ positionWindow $w
43
+
44
+ label $w.msg -font $font -wraplength 4i -justify left -text "A 15-puzzle appears below as a collection of buttons. Click on any of the pieces next to the space, and that piece will slide over the space. Continue this until the pieces are arranged in numerical order from upper-left to lower-right."
45
+ pack $w.msg -side top
46
+
47
+ ## See Code / Dismiss buttons
48
+ set btns [addSeeDismiss $w.buttons $w]
49
+ pack $btns -side bottom -fill x
50
+
51
+ # Special trick: select a darker color for the space by creating a
52
+ # scrollbar widget and using its trough color.
53
+
54
+ scrollbar $w.s
55
+
56
+ # The button metrics are a bit bigger in Aqua, and since we are
57
+ # using place which doesn't autosize, then we need to have a
58
+ # slightly larger frame here...
59
+
60
+ if {[tk windowingsystem] eq "aqua"} {
61
+ set frameSize 168
62
+ } else {
63
+ set frameSize 120
64
+ }
65
+
66
+ frame $w.frame -width $frameSize -height $frameSize -borderwidth 2\
67
+ -relief sunken -bg [$w.s cget -troughcolor]
68
+ pack $w.frame -side top -pady 1c -padx 1c
69
+ destroy $w.s
70
+
71
+ set order {3 1 6 2 5 7 15 13 4 11 8 9 14 10 12}
72
+ for {set i 0} {$i < 15} {set i [expr {$i+1}]} {
73
+ set num [lindex $order $i]
74
+ set xpos($num) [expr {($i%4)*.25}]
75
+ set ypos($num) [expr {($i/4)*.25}]
76
+ button $w.frame.$num -relief raised -text $num -bd 0 -highlightthickness 0 \
77
+ -command "puzzleSwitch $w $num"
78
+ place $w.frame.$num -relx $xpos($num) -rely $ypos($num) \
79
+ -relwidth .25 -relheight .25
80
+ }
81
+ set xpos(space) .75
82
+ set ypos(space) .75
janus/lib/tk8.6/demos/radio.tcl ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # radio.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several radiobutton widgets.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .radio
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Radiobutton Demonstration"
16
+ wm iconname $w "radio"
17
+ positionWindow $w
18
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. When the 'Tristate' button is pressed, the radio buttons will display the tri-state mode. Selecting any radio button will return the buttons to their respective on/off state. Click the \"See Variables\" button to see the current values of the variables."
19
+ grid $w.msg -row 0 -column 0 -columnspan 3 -sticky nsew
20
+
21
+ ## See Code / Dismiss buttons
22
+ set btns [addSeeDismiss $w.buttons $w [list size color align]]
23
+ grid $btns -row 3 -column 0 -columnspan 3 -sticky ew
24
+
25
+ labelframe $w.left -pady 2 -text "Point Size" -padx 2
26
+ labelframe $w.mid -pady 2 -text "Color" -padx 2
27
+ labelframe $w.right -pady 2 -text "Alignment" -padx 2
28
+ button $w.tristate -text Tristate -command "set size multi; set color multi" \
29
+ -pady 2 -padx 2
30
+ if {[tk windowingsystem] eq "aqua"} {
31
+ $w.tristate configure -padx 10
32
+ }
33
+ grid $w.left -column 0 -row 1 -pady .5c -padx .5c -rowspan 2
34
+ grid $w.mid -column 1 -row 1 -pady .5c -padx .5c -rowspan 2
35
+ grid $w.right -column 2 -row 1 -pady .5c -padx .5c
36
+ grid $w.tristate -column 2 -row 2 -pady .5c -padx .5c
37
+
38
+ foreach i {10 12 14 18 24} {
39
+ radiobutton $w.left.b$i -text "Point Size $i" -variable size \
40
+ -relief flat -value $i -tristatevalue "multi"
41
+ pack $w.left.b$i -side top -pady 2 -anchor w -fill x
42
+ }
43
+
44
+ foreach c {Red Green Blue Yellow Orange Purple} {
45
+ set lower [string tolower $c]
46
+ radiobutton $w.mid.$lower -text $c -variable color \
47
+ -relief flat -value $lower -anchor w \
48
+ -command "$w.mid configure -fg \$color" \
49
+ -tristatevalue "multi"
50
+ pack $w.mid.$lower -side top -pady 2 -fill x
51
+ }
52
+
53
+
54
+ label $w.right.l -text "Label" -bitmap questhead -compound left
55
+ $w.right.l configure -width [winfo reqwidth $w.right.l] -compound top
56
+ $w.right.l configure -height [winfo reqheight $w.right.l]
57
+ foreach a {Top Left Right Bottom} {
58
+ set lower [string tolower $a]
59
+ radiobutton $w.right.$lower -text $a -variable align \
60
+ -relief flat -value $lower -indicatoron 0 -width 7 \
61
+ -command "$w.right.l configure -compound \$align"
62
+ }
63
+
64
+ grid x $w.right.top
65
+ grid $w.right.left $w.right.l $w.right.right
66
+ grid x $w.right.bottom
janus/lib/tk8.6/demos/rmt ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # rmt --
6
+ # This script implements a simple remote-control mechanism for
7
+ # Tk applications. It allows you to select an application and
8
+ # then type commands to that application.
9
+
10
+ package require Tk
11
+
12
+ wm title . "Tk Remote Controller"
13
+ wm iconname . "Tk Remote"
14
+ wm minsize . 1 1
15
+
16
+ # The global variable below keeps track of the remote application
17
+ # that we're sending to. If it's an empty string then we execute
18
+ # the commands locally.
19
+
20
+ set app "local"
21
+
22
+ # The global variable below keeps track of whether we're in the
23
+ # middle of executing a command entered via the text.
24
+
25
+ set executing 0
26
+
27
+ # The global variable below keeps track of the last command executed,
28
+ # so it can be re-executed in response to !! commands.
29
+
30
+ set lastCommand ""
31
+
32
+ # Create menu bar. Arrange to recreate all the information in the
33
+ # applications sub-menu whenever it is cascaded to.
34
+
35
+ . configure -menu [menu .menu]
36
+ menu .menu.file
37
+ menu .menu.file.apps -postcommand fillAppsMenu
38
+ .menu add cascade -label "File" -underline 0 -menu .menu.file
39
+ .menu.file add cascade -label "Select Application" -underline 0 \
40
+ -menu .menu.file.apps
41
+ .menu.file add command -label "Quit" -command "destroy ." -underline 0
42
+
43
+ # Create text window and scrollbar.
44
+
45
+ text .t -yscrollcommand ".s set" -setgrid true
46
+ scrollbar .s -command ".t yview"
47
+ grid .t .s -sticky nsew
48
+ grid rowconfigure . 0 -weight 1
49
+ grid columnconfigure . 0 -weight 1
50
+
51
+ # Create a binding to forward commands to the target application,
52
+ # plus modify many of the built-in bindings so that only information
53
+ # in the current command can be deleted (can still set the cursor
54
+ # earlier in the text and select and insert; just can't delete).
55
+
56
+ bindtags .t {.t Text . all}
57
+ bind .t <Return> {
58
+ .t mark set insert {end - 1c}
59
+ .t insert insert \n
60
+ invoke
61
+ break
62
+ }
63
+ bind .t <Delete> {
64
+ catch {.t tag remove sel sel.first promptEnd}
65
+ if {[.t tag nextrange sel 1.0 end] eq ""} {
66
+ if {[.t compare insert < promptEnd]} {
67
+ break
68
+ }
69
+ }
70
+ }
71
+ bind .t <BackSpace> {
72
+ catch {.t tag remove sel sel.first promptEnd}
73
+ if {[.t tag nextrange sel 1.0 end] eq ""} {
74
+ if {[.t compare insert <= promptEnd]} {
75
+ break
76
+ }
77
+ }
78
+ }
79
+ bind .t <Control-d> {
80
+ if {[.t compare insert < promptEnd]} {
81
+ break
82
+ }
83
+ }
84
+ bind .t <Control-k> {
85
+ if {[.t compare insert < promptEnd]} {
86
+ .t mark set insert promptEnd
87
+ }
88
+ }
89
+ bind .t <Control-t> {
90
+ if {[.t compare insert < promptEnd]} {
91
+ break
92
+ }
93
+ }
94
+ bind .t <Meta-d> {
95
+ if {[.t compare insert < promptEnd]} {
96
+ break
97
+ }
98
+ }
99
+ bind .t <Meta-BackSpace> {
100
+ if {[.t compare insert <= promptEnd]} {
101
+ break
102
+ }
103
+ }
104
+ bind .t <Control-h> {
105
+ if {[.t compare insert <= promptEnd]} {
106
+ break
107
+ }
108
+ }
109
+ ### This next bit *isn't* nice - DKF ###
110
+ auto_load tk::TextInsert
111
+ proc tk::TextInsert {w s} {
112
+ if {$s eq ""} {
113
+ return
114
+ }
115
+ catch {
116
+ if {
117
+ [$w compare sel.first <= insert] && [$w compare sel.last >= insert]
118
+ } then {
119
+ $w tag remove sel sel.first promptEnd
120
+ $w delete sel.first sel.last
121
+ }
122
+ }
123
+ $w insert insert $s
124
+ $w see insert
125
+ }
126
+
127
+ .t configure -font {Courier 12}
128
+ .t tag configure bold -font {Courier 12 bold}
129
+
130
+ # The procedure below is used to print out a prompt at the
131
+ # insertion point (which should be at the beginning of a line
132
+ # right now).
133
+
134
+ proc prompt {} {
135
+ global app
136
+ .t insert insert "$app: "
137
+ .t mark set promptEnd {insert}
138
+ .t mark gravity promptEnd left
139
+ .t tag add bold {promptEnd linestart} promptEnd
140
+ }
141
+
142
+ # The procedure below executes a command (it takes everything on the
143
+ # current line after the prompt and either sends it to the remote
144
+ # application or executes it locally, depending on "app".
145
+
146
+ proc invoke {} {
147
+ global app executing lastCommand
148
+ set cmd [.t get promptEnd insert]
149
+ incr executing 1
150
+ if {[info complete $cmd]} {
151
+ if {$cmd eq "!!\n"} {
152
+ set cmd $lastCommand
153
+ } else {
154
+ set lastCommand $cmd
155
+ }
156
+ if {$app eq "local"} {
157
+ set result [catch [list uplevel #0 $cmd] msg]
158
+ } else {
159
+ set result [catch [list send $app $cmd] msg]
160
+ }
161
+ if {$result != 0} {
162
+ .t insert insert "Error: $msg\n"
163
+ } elseif {$msg ne ""} {
164
+ .t insert insert $msg\n
165
+ }
166
+ prompt
167
+ .t mark set promptEnd insert
168
+ }
169
+ incr executing -1
170
+ .t yview -pickplace insert
171
+ }
172
+
173
+ # The following procedure is invoked to change the application that
174
+ # we're talking to. It also updates the prompt for the current
175
+ # command, unless we're in the middle of executing a command from
176
+ # the text item (in which case a new prompt is about to be output
177
+ # so there's no need to change the old one).
178
+
179
+ proc newApp appName {
180
+ global app executing
181
+ set app $appName
182
+ if {!$executing} {
183
+ .t mark gravity promptEnd right
184
+ .t delete "promptEnd linestart" promptEnd
185
+ .t insert promptEnd "$appName: "
186
+ .t tag add bold "promptEnd linestart" promptEnd
187
+ .t mark gravity promptEnd left
188
+ }
189
+ return
190
+ }
191
+
192
+ # The procedure below will fill in the applications sub-menu with a list
193
+ # of all the applications that currently exist.
194
+
195
+ proc fillAppsMenu {} {
196
+ set m .menu.file.apps
197
+ catch {$m delete 0 last}
198
+ foreach i [lsort [winfo interps]] {
199
+ $m add command -label $i -command [list newApp $i]
200
+ }
201
+ $m add command -label local -command {newApp local}
202
+ }
203
+
204
+ set app [winfo name .]
205
+ prompt
206
+ focus .t
207
+
208
+ # Local Variables:
209
+ # mode: tcl
210
+ # End:
janus/lib/tk8.6/demos/rolodex ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # rolodex --
6
+ # This script was written as an entry in Tom LaStrange's rolodex
7
+ # benchmark. It creates something that has some of the look and
8
+ # feel of a rolodex program, although it's lifeless and doesn't
9
+ # actually do the rolodex application.
10
+
11
+ package require Tk
12
+
13
+ foreach i [winfo children .] {
14
+ catch {destroy $i}
15
+ }
16
+
17
+ set version 1.2
18
+
19
+ #------------------------------------------
20
+ # Phase 0: create the front end.
21
+ #------------------------------------------
22
+
23
+ frame .frame -relief flat
24
+ pack .frame -side top -fill y -anchor center
25
+
26
+ set names {{} Name: Address: {} {} {Home Phone:} {Work Phone:} Fax:}
27
+ foreach i {1 2 3 4 5 6 7} {
28
+ label .frame.label$i -text [lindex $names $i] -anchor e
29
+ entry .frame.entry$i -width 35
30
+ grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1
31
+ }
32
+
33
+ frame .buttons
34
+ pack .buttons -side bottom -pady 2 -anchor center
35
+ button .buttons.clear -text Clear
36
+ button .buttons.add -text Add
37
+ button .buttons.search -text Search
38
+ button .buttons.delete -text "Delete ..."
39
+ pack .buttons.clear .buttons.add .buttons.search .buttons.delete \
40
+ -side left -padx 2
41
+
42
+ #------------------------------------------
43
+ # Phase 1: Add menus, dialog boxes
44
+ #------------------------------------------
45
+
46
+ # DKF - note that this is an old-style menu bar; I just have not yet
47
+ # got around to converting the context help code to work with the new
48
+ # menu system and its <<MenuSelect>> virtual event.
49
+
50
+ frame .menu -relief raised -borderwidth 1
51
+ pack .menu -before .frame -side top -fill x
52
+
53
+ menubutton .menu.file -text "File" -menu .menu.file.m -underline 0
54
+ menu .menu.file.m
55
+ .menu.file.m add command -label "Load ..." -command fileAction -underline 0
56
+ .menu.file.m add command -label "Exit" -command {destroy .} -underline 0
57
+ pack .menu.file -side left
58
+
59
+ menubutton .menu.help -text "Help" -menu .menu.help.m -underline 0
60
+ menu .menu.help.m
61
+ pack .menu.help -side right
62
+
63
+ proc deleteAction {} {
64
+ if {[tk_dialog .delete {Confirm Action} {Are you sure?} {} 0 Cancel]
65
+ == 0} {
66
+ clearAction
67
+ }
68
+ }
69
+ .buttons.delete config -command deleteAction
70
+
71
+ proc fileAction {} {
72
+ tk_dialog .fileSelection {File Selection} {This is a dummy file selection dialog box, which is used because there isn't a good file selection dialog built into Tk yet.} {} 0 OK
73
+ puts stderr {dummy file name}
74
+ }
75
+
76
+ #------------------------------------------
77
+ # Phase 3: Print contents of card
78
+ #------------------------------------------
79
+
80
+ proc addAction {} {
81
+ global names
82
+ foreach i {1 2 3 4 5 6 7} {
83
+ puts stderr [format "%-12s %s" [lindex $names $i] [.frame.entry$i get]]
84
+ }
85
+ }
86
+ .buttons.add config -command addAction
87
+
88
+ #------------------------------------------
89
+ # Phase 4: Miscellaneous other actions
90
+ #------------------------------------------
91
+
92
+ proc clearAction {} {
93
+ foreach i {1 2 3 4 5 6 7} {
94
+ .frame.entry$i delete 0 end
95
+ }
96
+ }
97
+ .buttons.clear config -command clearAction
98
+
99
+ proc fillCard {} {
100
+ clearAction
101
+ .frame.entry1 insert 0 "John Ousterhout"
102
+ .frame.entry2 insert 0 "CS Division, Department of EECS"
103
+ .frame.entry3 insert 0 "University of California"
104
+ .frame.entry4 insert 0 "Berkeley, CA 94720"
105
+ .frame.entry5 insert 0 "private"
106
+ .frame.entry6 insert 0 "510-642-0865"
107
+ .frame.entry7 insert 0 "510-642-5775"
108
+ }
109
+ .buttons.search config -command "addAction; fillCard"
110
+
111
+ #----------------------------------------------------
112
+ # Phase 5: Accelerators, mnemonics, command-line info
113
+ #----------------------------------------------------
114
+
115
+ .buttons.clear config -text "Clear Ctrl+C"
116
+ bind . <Control-c> clearAction
117
+ .buttons.add config -text "Add Ctrl+A"
118
+ bind . <Control-a> addAction
119
+ .buttons.search config -text "Search Ctrl+S"
120
+ bind . <Control-s> "addAction; fillCard"
121
+ .buttons.delete config -text "Delete... Ctrl+D"
122
+ bind . <Control-d> deleteAction
123
+
124
+ .menu.file.m entryconfig 1 -accel Ctrl+F
125
+ bind . <Control-f> fileAction
126
+ .menu.file.m entryconfig 2 -accel Ctrl+Q
127
+ bind . <Control-q> {destroy .}
128
+
129
+ focus .frame.entry1
130
+
131
+ #----------------------------------------------------
132
+ # Phase 6: help
133
+ #----------------------------------------------------
134
+
135
+ proc Help {topic {x 0} {y 0}} {
136
+ global helpTopics helpCmds
137
+ if {$topic == ""} return
138
+ while {[info exists helpCmds($topic)]} {
139
+ set topic [eval $helpCmds($topic)]
140
+ }
141
+ if [info exists helpTopics($topic)] {
142
+ set msg $helpTopics($topic)
143
+ } else {
144
+ set msg "Sorry, but no help is available for this topic"
145
+ }
146
+ tk_dialog .help {Rolodex Help} "Information on $topic:\n\n$msg" \
147
+ {} 0 OK
148
+ }
149
+
150
+ proc getMenuTopic {w x y} {
151
+ return $w.[$w index @[expr {$y-[winfo rooty $w]}]]
152
+ }
153
+
154
+ event add <<Help>> <F1> <Help>
155
+ bind . <<Help>> {Help [winfo containing %X %Y] %X %Y}
156
+ bind Menu <<Help>> {Help [winfo containing %X %Y] %X %Y}
157
+
158
+ # Help text and commands follow:
159
+
160
+ set helpTopics(.menu.file) {This is the "file" menu. It can be used to invoke some overall operations on the rolodex applications, such as loading a file or exiting.}
161
+
162
+ set helpCmds(.menu.file.m) {getMenuTopic $topic $x $y}
163
+ set helpTopics(.menu.file.m.1) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file}
164
+ set helpTopics(.menu.file.m.2) {The "Exit" entry in the "File" menu causes the rolodex application to terminate}
165
+ set helpCmds(.menu.file.m.none) {set topic ".menu.file"}
166
+
167
+ set helpTopics(.frame.entry1) {In this field of the rolodex entry you should type the person's name}
168
+ set helpTopics(.frame.entry2) {In this field of the rolodex entry you should type the first line of the person's address}
169
+ set helpTopics(.frame.entry3) {In this field of the rolodex entry you should type the second line of the person's address}
170
+ set helpTopics(.frame.entry4) {In this field of the rolodex entry you should type the third line of the person's address}
171
+ set helpTopics(.frame.entry5) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized}
172
+ set helpTopics(.frame.entry6) {In this field of the rolodex entry you should type the person's work phone number}
173
+ set helpTopics(.frame.entry7) {In this field of the rolodex entry you should type the phone number for the person's FAX machine}
174
+
175
+ set helpCmds(.frame.label1) {set topic .frame.entry1}
176
+ set helpCmds(.frame.label2) {set topic .frame.entry2}
177
+ set helpCmds(.frame.label3) {set topic .frame.entry3}
178
+ set helpCmds(.frame.label4) {set topic .frame.entry4}
179
+ set helpCmds(.frame.label5) {set topic .frame.entry5}
180
+ set helpCmds(.frame.label6) {set topic .frame.entry6}
181
+ set helpCmds(.frame.label7) {set topic .frame.entry7}
182
+
183
+ set helpTopics(context) {Unfortunately, this application doesn't support context-sensitive help in the usual way, because when this demo was written Tk didn't have a grab mechanism and this is needed for context-sensitive help. Instead, you can achieve much the same effect by simply moving the mouse over the window you're curious about and pressing the Help or F1 keys. You can do this anytime.}
184
+ set helpTopics(help) {This application provides only very crude help. Besides the entries in this menu, you can get help on individual windows by moving the mouse cursor over the window and pressing the Help or F1 keys.}
185
+ set helpTopics(window) {This window is a dummy rolodex application created as part of Tom LaStrange's toolkit benchmark. It doesn't really do anything useful except to demonstrate a few features of the Tk toolkit.}
186
+ set helpTopics(keys) "The following accelerator keys are defined for this application (in addition to those already available for the entry windows):\n\nCtrl+A:\t\tAdd\nCtrl+C:\t\tClear\nCtrl+D:\t\tDelete\nCtrl+F:\t\tEnter file name\nCtrl+Q:\t\tExit application (quit)\nCtrl+S:\t\tSearch (dummy operation)"
187
+ set helpTopics(version) "This is version $version."
188
+
189
+ # Entries in "Help" menu
190
+
191
+ .menu.help.m add command -label "On Context..." -command {Help context} \
192
+ -underline 3
193
+ .menu.help.m add command -label "On Help..." -command {Help help} \
194
+ -underline 3
195
+ .menu.help.m add command -label "On Window..." -command {Help window} \
196
+ -underline 3
197
+ .menu.help.m add command -label "On Keys..." -command {Help keys} \
198
+ -underline 3
199
+ .menu.help.m add command -label "On Version..." -command {Help version} \
200
+ -underline 3
201
+
202
+ # Local Variables:
203
+ # mode: tcl
204
+ # End:
janus/lib/tk8.6/demos/ruler.tcl ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ruler.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widget that displays a ruler
4
+ # with tab stops that can be set, moved, and deleted.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ # rulerMkTab --
13
+ # This procedure creates a new triangular polygon in a canvas to
14
+ # represent a tab stop.
15
+ #
16
+ # Arguments:
17
+ # c - The canvas window.
18
+ # x, y - Coordinates at which to create the tab stop.
19
+
20
+ proc rulerMkTab {c x y} {
21
+ upvar #0 demo_rulerInfo v
22
+ set newTab [$c create polygon $x $y \
23
+ [expr {$x+$v(size)}] [expr {$y+$v(size)}] \
24
+ [expr {$x-$v(size)}] [expr {$y+$v(size)}]]
25
+ set fill [$c itemcget $newTab -outline]
26
+ $c itemconfigure $newTab -fill $fill -outline {}
27
+ set v(normalStyle) "-fill $fill"
28
+ return $newTab
29
+ }
30
+
31
+ set w .ruler
32
+ catch {destroy $w}
33
+ toplevel $w
34
+ wm title $w "Ruler Demonstration"
35
+ wm iconname $w "ruler"
36
+ positionWindow $w
37
+ set c $w.c
38
+
39
+ label $w.msg -font $font -wraplength 5i -justify left -text "This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."
40
+ pack $w.msg -side top
41
+
42
+ ## See Code / Dismiss buttons
43
+ set btns [addSeeDismiss $w.buttons $w]
44
+ pack $btns -side bottom -fill x
45
+
46
+ canvas $c -width 14.8c -height 2.5c
47
+ pack $w.c -side top -fill x
48
+
49
+ set demo_rulerInfo(grid) .25c
50
+ set demo_rulerInfo(left) [winfo fpixels $c 1c]
51
+ set demo_rulerInfo(right) [winfo fpixels $c 13c]
52
+ set demo_rulerInfo(top) [winfo fpixels $c 1c]
53
+ set demo_rulerInfo(bottom) [winfo fpixels $c 1.5c]
54
+ set demo_rulerInfo(size) [winfo fpixels $c .2c]
55
+ # Main widget program sets variable tk_demoDirectory
56
+ if {[winfo depth $c] > 1} {
57
+ set demo_rulerInfo(activeStyle) "-fill red -stipple {}"
58
+ set demo_rulerInfo(deleteStyle) [list -fill red \
59
+ -stipple @[file join $tk_demoDirectory images gray25.xbm]]
60
+ } else {
61
+ set demo_rulerInfo(activeStyle) "-fill black -stipple {}"
62
+ set demo_rulerInfo(deleteStyle) [list -fill black \
63
+ -stipple @[file join $tk_demoDirectory images gray25.xbm]]
64
+ }
65
+
66
+ $c create line 1c 0.5c 1c 1c 13c 1c 13c 0.5c -width 1
67
+ for {set i 0} {$i < 12} {incr i} {
68
+ set x [expr {$i+1}]
69
+ $c create line ${x}c 1c ${x}c 0.6c -width 1
70
+ $c create line $x.25c 1c $x.25c 0.8c -width 1
71
+ $c create line $x.5c 1c $x.5c 0.7c -width 1
72
+ $c create line $x.75c 1c $x.75c 0.8c -width 1
73
+ $c create text $x.15c .75c -text $i -anchor sw
74
+ }
75
+ $c addtag well withtag [$c create rect 13.2c 1c 13.8c 0.5c \
76
+ -fill [lindex [$c config -bg] 4]]
77
+ $c addtag well withtag [rulerMkTab $c [winfo pixels $c 13.5c] \
78
+ [winfo pixels $c .65c]]
79
+
80
+ $c bind well <Button-1> "rulerNewTab $c %x %y"
81
+ $c bind tab <Button-1> "rulerSelectTab $c %x %y"
82
+ bind $c <B1-Motion> "rulerMoveTab $c %x %y"
83
+ bind $c <ButtonRelease-1> "rulerReleaseTab $c"
84
+
85
+ # rulerNewTab --
86
+ # Does all the work of creating a tab stop, including creating the
87
+ # triangle object and adding tags to it to give it tab behavior.
88
+ #
89
+ # Arguments:
90
+ # c - The canvas window.
91
+ # x, y - The coordinates of the tab stop.
92
+
93
+ proc rulerNewTab {c x y} {
94
+ upvar #0 demo_rulerInfo v
95
+ $c addtag active withtag [rulerMkTab $c $x $y]
96
+ $c addtag tab withtag active
97
+ set v(x) $x
98
+ set v(y) $y
99
+ rulerMoveTab $c $x $y
100
+ }
101
+
102
+ # rulerSelectTab --
103
+ # This procedure is invoked when mouse button 1 is pressed over
104
+ # a tab. It remembers information about the tab so that it can
105
+ # be dragged interactively.
106
+ #
107
+ # Arguments:
108
+ # c - The canvas widget.
109
+ # x, y - The coordinates of the mouse (identifies the point by
110
+ # which the tab was picked up for dragging).
111
+
112
+ proc rulerSelectTab {c x y} {
113
+ upvar #0 demo_rulerInfo v
114
+ set v(x) [$c canvasx $x $v(grid)]
115
+ set v(y) [expr {$v(top)+2}]
116
+ $c addtag active withtag current
117
+ eval "$c itemconf active $v(activeStyle)"
118
+ $c raise active
119
+ }
120
+
121
+ # rulerMoveTab --
122
+ # This procedure is invoked during mouse motion events to drag a tab.
123
+ # It adjusts the position of the tab, and changes its appearance if
124
+ # it is about to be dragged out of the ruler.
125
+ #
126
+ # Arguments:
127
+ # c - The canvas widget.
128
+ # x, y - The coordinates of the mouse.
129
+
130
+ proc rulerMoveTab {c x y} {
131
+ upvar #0 demo_rulerInfo v
132
+ if {[$c find withtag active] == ""} {
133
+ return
134
+ }
135
+ set cx [$c canvasx $x $v(grid)]
136
+ set cy [$c canvasy $y]
137
+ if {$cx < $v(left)} {
138
+ set cx $v(left)
139
+ }
140
+ if {$cx > $v(right)} {
141
+ set cx $v(right)
142
+ }
143
+ if {($cy >= $v(top)) && ($cy <= $v(bottom))} {
144
+ set cy [expr {$v(top)+2}]
145
+ eval "$c itemconf active $v(activeStyle)"
146
+ } else {
147
+ set cy [expr {$cy-$v(size)-2}]
148
+ eval "$c itemconf active $v(deleteStyle)"
149
+ }
150
+ $c move active [expr {$cx-$v(x)}] [expr {$cy-$v(y)}]
151
+ set v(x) $cx
152
+ set v(y) $cy
153
+ }
154
+
155
+ # rulerReleaseTab --
156
+ # This procedure is invoked during button release events that end
157
+ # a tab drag operation. It deselects the tab and deletes the tab if
158
+ # it was dragged out of the ruler.
159
+ #
160
+ # Arguments:
161
+ # c - The canvas widget.
162
+ # x, y - The coordinates of the mouse.
163
+
164
+ proc rulerReleaseTab c {
165
+ upvar #0 demo_rulerInfo v
166
+ if {[$c find withtag active] == {}} {
167
+ return
168
+ }
169
+ if {$v(y) != $v(top)+2} {
170
+ $c delete active
171
+ } else {
172
+ eval "$c itemconf active $v(normalStyle)"
173
+ $c dtag active
174
+ }
175
+ }
janus/lib/tk8.6/demos/search.tcl ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # search.tcl --
2
+ #
3
+ # This demonstration script creates a collection of widgets that
4
+ # allow you to load a file into a text widget, then perform searches
5
+ # on that file.
6
+
7
+ if {![info exists widgetDemo]} {
8
+ error "This script should be run from the \"widget\" demo."
9
+ }
10
+
11
+ package require Tk
12
+
13
+ # textLoadFile --
14
+ # This procedure below loads a file into a text widget, discarding
15
+ # the previous contents of the widget. Tags for the old widget are
16
+ # not affected, however.
17
+ #
18
+ # Arguments:
19
+ # w - The window into which to load the file. Must be a
20
+ # text widget.
21
+ # file - The name of the file to load. Must be readable.
22
+
23
+ proc textLoadFile {w file} {
24
+ set f [open $file]
25
+ $w delete 1.0 end
26
+ while {![eof $f]} {
27
+ $w insert end [read $f 10000]
28
+ }
29
+ close $f
30
+ }
31
+
32
+ # textSearch --
33
+ # Search for all instances of a given string in a text widget and
34
+ # apply a given tag to each instance found.
35
+ #
36
+ # Arguments:
37
+ # w - The window in which to search. Must be a text widget.
38
+ # string - The string to search for. The search is done using
39
+ # exact matching only; no special characters.
40
+ # tag - Tag to apply to each instance of a matching string.
41
+
42
+ proc textSearch {w string tag} {
43
+ $w tag remove search 0.0 end
44
+ if {$string == ""} {
45
+ return
46
+ }
47
+ set cur 1.0
48
+ while 1 {
49
+ set cur [$w search -count length $string $cur end]
50
+ if {$cur == ""} {
51
+ break
52
+ }
53
+ $w tag add $tag $cur "$cur + $length char"
54
+ set cur [$w index "$cur + $length char"]
55
+ }
56
+ }
57
+
58
+ # textToggle --
59
+ # This procedure is invoked repeatedly to invoke two commands at
60
+ # periodic intervals. It normally reschedules itself after each
61
+ # execution but if an error occurs (e.g. because the window was
62
+ # deleted) then it doesn't reschedule itself.
63
+ #
64
+ # Arguments:
65
+ # cmd1 - Command to execute when procedure is called.
66
+ # sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
67
+ # cmd2 - Command to execute in the *next* invocation of this
68
+ # procedure.
69
+ # sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
70
+
71
+ proc textToggle {cmd1 sleep1 cmd2 sleep2} {
72
+ catch {
73
+ eval $cmd1
74
+ after $sleep1 [list textToggle $cmd2 $sleep2 $cmd1 $sleep1]
75
+ }
76
+ }
77
+
78
+ set w .search
79
+ catch {destroy $w}
80
+ toplevel $w
81
+ wm title $w "Text Demonstration - Search and Highlight"
82
+ wm iconname $w "search"
83
+ positionWindow $w
84
+
85
+ ## See Code / Dismiss buttons
86
+ set btns [addSeeDismiss $w.buttons $w]
87
+ pack $btns -side bottom -fill x
88
+
89
+ frame $w.file
90
+ label $w.file.label -text "File name:" -width 13 -anchor w
91
+ entry $w.file.entry -width 40 -textvariable fileName
92
+ button $w.file.button -text "Load File" \
93
+ -command "textLoadFile $w.text \$fileName"
94
+ pack $w.file.label $w.file.entry -side left
95
+ pack $w.file.button -side left -pady 5 -padx 10
96
+ bind $w.file.entry <Return> "
97
+ textLoadFile $w.text \$fileName
98
+ focus $w.string.entry
99
+ "
100
+ focus $w.file.entry
101
+
102
+ frame $w.string
103
+ label $w.string.label -text "Search string:" -width 13 -anchor w
104
+ entry $w.string.entry -width 40 -textvariable searchString
105
+ button $w.string.button -text "Highlight" \
106
+ -command "textSearch $w.text \$searchString search"
107
+ pack $w.string.label $w.string.entry -side left
108
+ pack $w.string.button -side left -pady 5 -padx 10
109
+ bind $w.string.entry <Return> "textSearch $w.text \$searchString search"
110
+
111
+ text $w.text -yscrollcommand "$w.scroll set" -setgrid true
112
+ ttk::scrollbar $w.scroll -command "$w.text yview"
113
+ pack $w.file $w.string -side top -fill x
114
+ pack $w.scroll -side right -fill y
115
+ pack $w.text -expand yes -fill both
116
+
117
+ # Set up display styles for text highlighting.
118
+
119
+ if {[winfo depth $w] > 1} {
120
+ textToggle "$w.text tag configure search -background \
121
+ #ce5555 -foreground white" 800 "$w.text tag configure \
122
+ search -background {} -foreground {}" 200
123
+ } else {
124
+ textToggle "$w.text tag configure search -background \
125
+ black -foreground white" 800 "$w.text tag configure \
126
+ search -background {} -foreground {}" 200
127
+ }
128
+ $w.text insert 1.0 \
129
+ {This window demonstrates how to use the tagging facilities in text
130
+ widgets to implement a searching mechanism. First, type a file name
131
+ in the top entry, then type <Return> or click on "Load File". Then
132
+ type a string in the lower entry and type <Return> or click on
133
+ "Load File". This will cause all of the instances of the string to
134
+ be tagged with the tag "search", and it will arrange for the tag's
135
+ display attributes to change to make all of the strings blink.}
136
+ $w.text mark set insert 0.0
137
+
138
+ set fileName ""
139
+ set searchString ""
janus/lib/tk8.6/demos/spin.tcl ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # spin.tcl --
2
+ #
3
+ # This demonstration script creates several spinbox widgets.
4
+
5
+ if {![info exists widgetDemo]} {
6
+ error "This script should be run from the \"widget\" demo."
7
+ }
8
+
9
+ package require Tk
10
+
11
+ set w .spin
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Spinbox Demonstration"
15
+ wm iconname $w "spin"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three different\
19
+ spin-boxes are displayed below. You can add characters by pointing,\
20
+ clicking and typing. The normal Motif editing characters are\
21
+ supported, along with many Emacs bindings. For example, Backspace\
22
+ and Control-h delete the character to the left of the insertion\
23
+ cursor and Delete and Control-d delete the chararacter to the right\
24
+ of the insertion cursor. For values that are too large to fit in the\
25
+ window all at once, you can scan through the value by dragging with\
26
+ mouse button2 pressed. Note that the first spin-box will only permit\
27
+ you to type in integers, and the third selects from a list of\
28
+ Australian cities."
29
+ pack $w.msg -side top
30
+
31
+ ## See Code / Dismiss buttons
32
+ set btns [addSeeDismiss $w.buttons $w]
33
+ pack $btns -side bottom -fill x
34
+
35
+ set australianCities {
36
+ Canberra Sydney Melbourne Perth Adelaide Brisbane
37
+ Hobart Darwin "Alice Springs"
38
+ }
39
+
40
+ spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \
41
+ -vcmd {string is integer %P}
42
+ spinbox $w.s2 -from 0 -to 3 -increment .5 -format %05.2f -width 10
43
+ spinbox $w.s3 -values $australianCities -width 10
44
+
45
+ #entry $w.e1
46
+ #entry $w.e2
47
+ #entry $w.e3
48
+ pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x
49
+
50
+ #$w.e1 insert 0 "Initial value"
51
+ #$w.e2 insert end "This entry contains a long value, much too long "
52
+ #$w.e2 insert end "to fit in the window at one time, so long in fact "
53
+ #$w.e2 insert end "that you'll have to scan or scroll to see the end."
janus/lib/tk8.6/demos/states.tcl ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # states.tcl --
2
+ #
3
+ # This demonstration script creates a listbox widget that displays
4
+ # the names of the 50 states in the United States of America.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .states
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Listbox Demonstration (50 states)"
16
+ wm iconname $w "states"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down."
20
+ pack $w.msg -side top
21
+
22
+ labelframe $w.justif -text Justification
23
+ foreach c {Left Center Right} {
24
+ set lower [string tolower $c]
25
+ radiobutton $w.justif.$lower -text $c -variable just \
26
+ -relief flat -value $lower -anchor w \
27
+ -command "$w.frame.list configure -justify \$just" \
28
+ -tristatevalue "multi"
29
+ pack $w.justif.$lower -side left -pady 2 -fill x
30
+ }
31
+ pack $w.justif
32
+
33
+ ## See Code / Dismiss buttons
34
+ set btns [addSeeDismiss $w.buttons $w]
35
+ pack $btns -side bottom -fill x
36
+
37
+ frame $w.frame -borderwidth .5c
38
+ pack $w.frame -side top -expand yes -fill y
39
+
40
+ ttk::scrollbar $w.frame.scroll -command "$w.frame.list yview"
41
+ listbox $w.frame.list -yscroll "$w.frame.scroll set" -setgrid 1 -height 12
42
+ pack $w.frame.scroll -side right -fill y
43
+ pack $w.frame.list -side left -expand 1 -fill both
44
+
45
+ $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
46
+ Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
47
+ Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
48
+ Massachusetts Michigan Minnesota Mississippi Missouri \
49
+ Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
50
+ "New York" "North Carolina" "North Dakota" \
51
+ Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
52
+ "South Carolina" "South Dakota" \
53
+ Tennessee Texas Utah Vermont Virginia Washington \
54
+ "West Virginia" Wisconsin Wyoming
janus/lib/tk8.6/demos/style.tcl ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # style.tcl --
2
+ #
3
+ # This demonstration script creates a text widget that illustrates the
4
+ # various display styles that may be set for tags.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .style
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Text Demonstration - Display Styles"
16
+ wm iconname $w "style"
17
+ positionWindow $w
18
+
19
+ ## See Code / Dismiss buttons
20
+ set btns [addSeeDismiss $w.buttons $w]
21
+ pack $btns -side bottom -fill x
22
+
23
+ # Only set the font family in one place for simplicity and consistency
24
+
25
+ set family Courier
26
+
27
+ text $w.text -yscrollcommand "$w.scroll set" -setgrid true \
28
+ -width 70 -height 32 -wrap word -font "$family 12"
29
+ ttk::scrollbar $w.scroll -command "$w.text yview"
30
+ pack $w.scroll -side right -fill y
31
+ pack $w.text -expand yes -fill both
32
+
33
+ # Set up display styles
34
+
35
+ $w.text tag configure bold -font "$family 12 bold italic"
36
+ $w.text tag configure big -font "$family 14 bold"
37
+ $w.text tag configure verybig -font "Helvetica 24 bold"
38
+ $w.text tag configure tiny -font "Times 8 bold"
39
+ if {[winfo depth $w] > 1} {
40
+ $w.text tag configure color1 -background #a0b7ce
41
+ $w.text tag configure color2 -foreground red
42
+ $w.text tag configure raised -relief raised -borderwidth 1
43
+ $w.text tag configure sunken -relief sunken -borderwidth 1
44
+ } else {
45
+ $w.text tag configure color1 -background black -foreground white
46
+ $w.text tag configure color2 -background black -foreground white
47
+ $w.text tag configure raised -background white -relief raised \
48
+ -borderwidth 1
49
+ $w.text tag configure sunken -background white -relief sunken \
50
+ -borderwidth 1
51
+ }
52
+ $w.text tag configure bgstipple -background black -borderwidth 0 \
53
+ -bgstipple gray12
54
+ $w.text tag configure fgstipple -fgstipple gray50
55
+ $w.text tag configure underline -underline on
56
+ $w.text tag configure overstrike -overstrike on
57
+ $w.text tag configure right -justify right
58
+ $w.text tag configure center -justify center
59
+ $w.text tag configure super -offset 4p -font "$family 10"
60
+ $w.text tag configure sub -offset -2p -font "$family 10"
61
+ $w.text tag configure margins -lmargin1 12m -lmargin2 6m -rmargin 10m
62
+ $w.text tag configure spacing -spacing1 10p -spacing2 2p \
63
+ -lmargin1 12m -lmargin2 6m -rmargin 10m
64
+
65
+ $w.text insert end {Text widgets like this one allow you to display information in a
66
+ variety of styles. Display styles are controlled using a mechanism
67
+ called }
68
+ $w.text insert end tags bold
69
+ $w.text insert end {. Tags are just textual names that you can apply to one
70
+ or more ranges of characters within a text widget. You can configure
71
+ tags with various display styles. If you do this, then the tagged
72
+ characters will be displayed with the styles you chose. The
73
+ available display styles are:
74
+ }
75
+ $w.text insert end "\n1. Font." big
76
+ $w.text insert end " You can choose any system font, "
77
+ $w.text insert end large verybig
78
+ $w.text insert end " or "
79
+ $w.text insert end "small" tiny ".\n"
80
+ $w.text insert end "\n2. Color." big
81
+ $w.text insert end " You can change either the "
82
+ $w.text insert end background color1
83
+ $w.text insert end " or "
84
+ $w.text insert end foreground color2
85
+ $w.text insert end "\ncolor, or "
86
+ $w.text insert end both {color1 color2}
87
+ $w.text insert end ".\n"
88
+ $w.text insert end "\n3. Stippling." big
89
+ $w.text insert end " You can cause either the "
90
+ $w.text insert end background bgstipple
91
+ $w.text insert end " or "
92
+ $w.text insert end foreground fgstipple
93
+ $w.text insert end {
94
+ information to be drawn with a stipple fill instead of a solid fill.
95
+ }
96
+ $w.text insert end "\n4. Underlining." big
97
+ $w.text insert end " You can "
98
+ $w.text insert end underline underline
99
+ $w.text insert end " ranges of text.\n"
100
+ $w.text insert end "\n5. Overstrikes." big
101
+ $w.text insert end " You can "
102
+ $w.text insert end "draw lines through" overstrike
103
+ $w.text insert end " ranges of text.\n"
104
+ $w.text insert end "\n6. 3-D effects." big
105
+ $w.text insert end { You can arrange for the background to be drawn
106
+ with a border that makes characters appear either }
107
+ $w.text insert end raised raised
108
+ $w.text insert end " or "
109
+ $w.text insert end sunken sunken
110
+ $w.text insert end ".\n"
111
+ $w.text insert end "\n7. Justification." big
112
+ $w.text insert end " You can arrange for lines to be displayed\n"
113
+ $w.text insert end "left-justified,\n"
114
+ $w.text insert end "right-justified, or\n" right
115
+ $w.text insert end "centered.\n" center
116
+ $w.text insert end "\n8. Superscripts and subscripts." big
117
+ $w.text insert end " You can control the vertical\n"
118
+ $w.text insert end "position of text to generate superscript effects like 10"
119
+ $w.text insert end "n" super
120
+ $w.text insert end " or\nsubscript effects like X"
121
+ $w.text insert end "i" sub
122
+ $w.text insert end ".\n"
123
+ $w.text insert end "\n9. Margins." big
124
+ $w.text insert end " You can control the amount of extra space left"
125
+ $w.text insert end " on\neach side of the text:\n"
126
+ $w.text insert end "This paragraph is an example of the use of " margins
127
+ $w.text insert end "margins. It consists of a single line of text " margins
128
+ $w.text insert end "that wraps around on the screen. There are two " margins
129
+ $w.text insert end "separate left margin values, one for the first " margins
130
+ $w.text insert end "display line associated with the text line, " margins
131
+ $w.text insert end "and one for the subsequent display lines, which " margins
132
+ $w.text insert end "occur because of wrapping. There is also a " margins
133
+ $w.text insert end "separate specification for the right margin, " margins
134
+ $w.text insert end "which is used to choose wrap points for lines.\n" margins
135
+ $w.text insert end "\n10. Spacing." big
136
+ $w.text insert end " You can control the spacing of lines with three\n"
137
+ $w.text insert end "separate parameters. \"Spacing1\" tells how much "
138
+ $w.text insert end "extra space to leave\nabove a line, \"spacing3\" "
139
+ $w.text insert end "tells how much space to leave below a line,\nand "
140
+ $w.text insert end "if a text line wraps, \"spacing2\" tells how much "
141
+ $w.text insert end "space to leave\nbetween the display lines that "
142
+ $w.text insert end "make up the text line.\n"
143
+ $w.text insert end "These indented paragraphs illustrate how spacing " spacing
144
+ $w.text insert end "can be used. Each paragraph is actually a " spacing
145
+ $w.text insert end "single line in the text widget, which is " spacing
146
+ $w.text insert end "word-wrapped by the widget.\n" spacing
147
+ $w.text insert end "Spacing1 is set to 10 points for this text, " spacing
148
+ $w.text insert end "which results in relatively large gaps between " spacing
149
+ $w.text insert end "the paragraphs. Spacing2 is set to 2 points, " spacing
150
+ $w.text insert end "which results in just a bit of extra space " spacing
151
+ $w.text insert end "within a pararaph. Spacing3 isn't used " spacing
152
+ $w.text insert end "in this example.\n" spacing
153
+ $w.text insert end "To see where the space is, select ranges of " spacing
154
+ $w.text insert end "text within these paragraphs. The selection " spacing
155
+ $w.text insert end "highlight will cover the extra space." spacing
janus/lib/tk8.6/demos/tclIndex ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Tcl autoload index file, version 2.0
2
+ # This file is generated by the "auto_mkindex" command
3
+ # and sourced to set up indexing information for one or
4
+ # more commands. Typically each line is a command that
5
+ # sets an element in the auto_index array, where the
6
+ # element name is the name of a command and the value is
7
+ # a script that loads the command.
8
+
9
+ set auto_index(arrowSetup) [list source -encoding utf-8 [file join $dir arrow.tcl]]
10
+ set auto_index(arrowMove1) [list source -encoding utf-8 [file join $dir arrow.tcl]]
11
+ set auto_index(arrowMove2) [list source -encoding utf-8 [file join $dir arrow.tcl]]
12
+ set auto_index(arrowMove3) [list source -encoding utf-8 [file join $dir arrow.tcl]]
13
+ set auto_index(textLoadFile) [list source -encoding utf-8 [file join $dir search.tcl]]
14
+ set auto_index(textSearch) [list source -encoding utf-8 [file join $dir search.tcl]]
15
+ set auto_index(textToggle) [list source -encoding utf-8 [file join $dir search.tcl]]
16
+ set auto_index(itemEnter) [list source -encoding utf-8 [file join $dir items.tcl]]
17
+ set auto_index(itemLeave) [list source -encoding utf-8 [file join $dir items.tcl]]
18
+ set auto_index(itemMark) [list source -encoding utf-8 [file join $dir items.tcl]]
19
+ set auto_index(itemStroke) [list source -encoding utf-8 [file join $dir items.tcl]]
20
+ set auto_index(itemsUnderArea) [list source -encoding utf-8 [file join $dir items.tcl]]
21
+ set auto_index(itemStartDrag) [list source -encoding utf-8 [file join $dir items.tcl]]
22
+ set auto_index(itemDrag) [list source -encoding utf-8 [file join $dir items.tcl]]
23
+ set auto_index(butPress) [list source -encoding utf-8 [file join $dir items.tcl]]
24
+ set auto_index(loadDir) [list source -encoding utf-8 [file join $dir image2.tcl]]
25
+ set auto_index(loadImage) [list source -encoding utf-8 [file join $dir image2.tcl]]
26
+ set auto_index(rulerMkTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
27
+ set auto_index(rulerNewTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
28
+ set auto_index(rulerSelectTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
29
+ set auto_index(rulerMoveTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
30
+ set auto_index(rulerReleaseTab) [list source -encoding utf-8 [file join $dir ruler.tcl]]
31
+ set auto_index(mkTextConfig) [list source -encoding utf-8 [file join $dir ctext.tcl]]
32
+ set auto_index(textEnter) [list source -encoding utf-8 [file join $dir ctext.tcl]]
33
+ set auto_index(textInsert) [list source -encoding utf-8 [file join $dir ctext.tcl]]
34
+ set auto_index(textPaste) [list source -encoding utf-8 [file join $dir ctext.tcl]]
35
+ set auto_index(textB1Press) [list source -encoding utf-8 [file join $dir ctext.tcl]]
36
+ set auto_index(textB1Move) [list source -encoding utf-8 [file join $dir ctext.tcl]]
37
+ set auto_index(textBs) [list source -encoding utf-8 [file join $dir ctext.tcl]]
38
+ set auto_index(textDel) [list source -encoding utf-8 [file join $dir ctext.tcl]]
39
+ set auto_index(bitmapRow) [list source -encoding utf-8 [file join $dir bitmap.tcl]]
40
+ set auto_index(scrollEnter) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
41
+ set auto_index(scrollLeave) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
42
+ set auto_index(scrollButton) [list source -encoding utf-8 [file join $dir cscroll.tcl]]
43
+ set auto_index(textWindOn) [list source -encoding utf-8 [file join $dir twind.tcl]]
44
+ set auto_index(textWindOff) [list source -encoding utf-8 [file join $dir twind.tcl]]
45
+ set auto_index(textWindPlot) [list source -encoding utf-8 [file join $dir twind.tcl]]
46
+ set auto_index(embPlotDown) [list source -encoding utf-8 [file join $dir twind.tcl]]
47
+ set auto_index(embPlotMove) [list source -encoding utf-8 [file join $dir twind.tcl]]
48
+ set auto_index(textWindDel) [list source -encoding utf-8 [file join $dir twind.tcl]]
49
+ set auto_index(embDefBg) [list source -encoding utf-8 [file join $dir twind.tcl]]
50
+ set auto_index(floorDisplay) [list source -encoding utf-8 [file join $dir floor.tcl]]
51
+ set auto_index(newRoom) [list source -encoding utf-8 [file join $dir floor.tcl]]
52
+ set auto_index(roomChanged) [list source -encoding utf-8 [file join $dir floor.tcl]]
53
+ set auto_index(bg1) [list source -encoding utf-8 [file join $dir floor.tcl]]
54
+ set auto_index(bg2) [list source -encoding utf-8 [file join $dir floor.tcl]]
55
+ set auto_index(bg3) [list source -encoding utf-8 [file join $dir floor.tcl]]
56
+ set auto_index(fg1) [list source -encoding utf-8 [file join $dir floor.tcl]]
57
+ set auto_index(fg2) [list source -encoding utf-8 [file join $dir floor.tcl]]
58
+ set auto_index(fg3) [list source -encoding utf-8 [file join $dir floor.tcl]]
59
+ set auto_index(setWidth) [list source -encoding utf-8 [file join $dir hscale.tcl]]
60
+ set auto_index(plotDown) [list source -encoding utf-8 [file join $dir plot.tcl]]
61
+ set auto_index(plotMove) [list source -encoding utf-8 [file join $dir plot.tcl]]
62
+ set auto_index(puzzleSwitch) [list source -encoding utf-8 [file join $dir puzzle.tcl]]
63
+ set auto_index(setHeight) [list source -encoding utf-8 [file join $dir vscale.tcl]]
64
+ set auto_index(showMessageBox) [list source -encoding utf-8 [file join $dir msgbox.tcl]]
65
+ set auto_index(setColor) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
66
+ set auto_index(setColor_helper) [list source -encoding utf-8 [file join $dir clrpick.tcl]]
67
+ set auto_index(fileDialog) [list source -encoding utf-8 [file join $dir filebox.tcl]]
janus/lib/tk8.6/demos/tcolor ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # tcolor --
6
+ # This script implements a simple color editor, where you can
7
+ # create colors using either the RGB, HSB, or CYM color spaces
8
+ # and apply the color to existing applications.
9
+
10
+ package require Tk
11
+ wm title . "Color Editor"
12
+
13
+ # Global variables that control the program:
14
+ #
15
+ # colorSpace - Color space currently being used for
16
+ # editing. Must be "rgb", "cmy", or "hsb".
17
+ # label1, label2, label3 - Labels for the scales.
18
+ # red, green, blue - Current color intensities in decimal
19
+ # on a scale of 0-65535.
20
+ # color - A string giving the current color value
21
+ # in the proper form for x:
22
+ # #RRRRGGGGBBBB
23
+ # updating - Non-zero means that we're in the middle of
24
+ # updating the scales to load a new color,so
25
+ # information shouldn't be propagating back
26
+ # from the scales to other elements of the
27
+ # program: this would make an infinite loop.
28
+ # command - Holds the command that has been typed
29
+ # into the "Command" entry.
30
+ # autoUpdate - 1 means execute the update command
31
+ # automatically whenever the color changes.
32
+ # name - Name for new color, typed into entry.
33
+
34
+ set colorSpace hsb
35
+ set red 65535
36
+ set green 0
37
+ set blue 0
38
+ set color #ffff00000000
39
+ set updating 0
40
+ set autoUpdate 1
41
+ set name ""
42
+
43
+ # Create the menu bar at the top of the window.
44
+
45
+ . configure -menu [menu .menu]
46
+ menu .menu.file
47
+ .menu add cascade -menu .menu.file -label File -underline 0
48
+ .menu.file add radio -label "RGB color space" -variable colorSpace \
49
+ -value rgb -underline 0 -command {changeColorSpace rgb}
50
+ .menu.file add radio -label "CMY color space" -variable colorSpace \
51
+ -value cmy -underline 0 -command {changeColorSpace cmy}
52
+ .menu.file add radio -label "HSB color space" -variable colorSpace \
53
+ -value hsb -underline 0 -command {changeColorSpace hsb}
54
+ .menu.file add separator
55
+ .menu.file add radio -label "Automatic updates" -variable autoUpdate \
56
+ -value 1 -underline 0
57
+ .menu.file add radio -label "Manual updates" -variable autoUpdate \
58
+ -value 0 -underline 0
59
+ .menu.file add separator
60
+ .menu.file add command -label "Exit program" -underline 0 -command {exit}
61
+
62
+ # Create the command entry window at the bottom of the window, along
63
+ # with the update button.
64
+
65
+ labelframe .command -text "Command:" -padx {1m 0}
66
+ entry .command.e -textvariable command
67
+ button .command.update -text Update -command doUpdate
68
+ pack .command.update -side right -pady .1c -padx {.25c 0}
69
+ pack .command.e -expand yes -fill x -ipadx 0.25c
70
+
71
+
72
+ # Create the listbox that holds all of the color names in rgb.txt,
73
+ # if an rgb.txt file can be found.
74
+
75
+ grid .command -sticky nsew -row 2 -columnspan 3 -padx 1m -pady {0 1m}
76
+
77
+ grid columnconfigure . {1 2} -weight 1
78
+ grid rowconfigure . 0 -weight 1
79
+ foreach i {
80
+ /usr/local/lib/X11/rgb.txt /usr/lib/X11/rgb.txt
81
+ /X11/R5/lib/X11/rgb.txt /X11/R4/lib/rgb/rgb.txt
82
+ /usr/openwin/lib/X11/rgb.txt
83
+ } {
84
+ if {![file readable $i]} {
85
+ continue;
86
+ }
87
+ set f [open $i]
88
+ labelframe .names -text "Select:" -padx .1c -pady .1c
89
+ grid .names -row 0 -column 0 -sticky nsew -padx .15c -pady .15c -rowspan 2
90
+ grid columnconfigure . 0 -weight 1
91
+ listbox .names.lb -width 20 -height 12 -yscrollcommand ".names.s set" \
92
+ -exportselection false
93
+ bind .names.lb <Double-Button-1> {
94
+ tc_loadNamedColor [.names.lb get [.names.lb curselection]]
95
+ }
96
+ scrollbar .names.s -orient vertical -command ".names.lb yview"
97
+ pack .names.lb .names.s -side left -fill y -expand 1
98
+ while {[gets $f line] >= 0} {
99
+ if {[regexp {^\s*\d+\s+\d+\s+\d+\s+(\S+)$} $line -> col]} {
100
+ .names.lb insert end $col
101
+ }
102
+ }
103
+ close $f
104
+ break
105
+ }
106
+
107
+ # Create the three scales for editing the color, and the entry for
108
+ # typing in a color value.
109
+
110
+ frame .adjust
111
+ foreach i {1 2 3} {
112
+ label .adjust.l$i -textvariable label$i -pady 0
113
+ labelframe .adjust.$i -labelwidget .adjust.l$i -padx 1m -pady 1m
114
+ scale .scale$i -from 0 -to 1000 -length 6c -orient horizontal \
115
+ -command tc_scaleChanged
116
+ pack .scale$i -in .adjust.$i
117
+ pack .adjust.$i
118
+ }
119
+ grid .adjust -row 0 -column 1 -sticky nsew -padx .15c -pady .15c
120
+
121
+ labelframe .name -text "Name:" -padx 1m -pady 1m
122
+ entry .name.e -textvariable name -width 10
123
+ pack .name.e -side right -expand 1 -fill x
124
+ bind .name.e <Return> {tc_loadNamedColor $name}
125
+ grid .name -column 1 -row 1 -sticky nsew -padx .15c -pady .15c
126
+
127
+ # Create the color display swatch on the right side of the window.
128
+
129
+ labelframe .sample -text "Color:" -padx 1m -pady 1m
130
+ frame .sample.swatch -width 2c -height 5c -background $color
131
+ label .sample.value -textvariable color -width 13 -font {Courier 12}
132
+ pack .sample.swatch -side top -expand yes -fill both
133
+ pack .sample.value -side bottom -pady .25c
134
+ grid .sample -row 0 -column 2 -sticky nsew -padx .15c -pady .15c -rowspan 2
135
+
136
+
137
+ # The procedure below is invoked when one of the scales is adjusted.
138
+ # It propagates color information from the current scale readings
139
+ # to everywhere else that it is used.
140
+
141
+ proc tc_scaleChanged args {
142
+ global red green blue colorSpace color updating autoUpdate
143
+ if {$updating} {
144
+ return
145
+ }
146
+ switch $colorSpace {
147
+ rgb {
148
+ set red [format %.0f [expr {[.scale1 get]*65.535}]]
149
+ set green [format %.0f [expr {[.scale2 get]*65.535}]]
150
+ set blue [format %.0f [expr {[.scale3 get]*65.535}]]
151
+ }
152
+ cmy {
153
+ set red [format %.0f [expr {65535 - [.scale1 get]*65.535}]]
154
+ set green [format %.0f [expr {65535 - [.scale2 get]*65.535}]]
155
+ set blue [format %.0f [expr {65535 - [.scale3 get]*65.535}]]
156
+ }
157
+ hsb {
158
+ set list [hsbToRgb [expr {[.scale1 get]/1000.0}] \
159
+ [expr {[.scale2 get]/1000.0}] \
160
+ [expr {[.scale3 get]/1000.0}]]
161
+ set red [lindex $list 0]
162
+ set green [lindex $list 1]
163
+ set blue [lindex $list 2]
164
+ }
165
+ }
166
+ set color [format "#%04x%04x%04x" $red $green $blue]
167
+ .sample.swatch config -bg $color
168
+ if {$autoUpdate} doUpdate
169
+ update idletasks
170
+ }
171
+
172
+ # The procedure below is invoked to update the scales from the
173
+ # current red, green, and blue intensities. It's invoked after
174
+ # a change in the color space and after a named color value has
175
+ # been loaded.
176
+
177
+ proc tc_setScales {} {
178
+ global red green blue colorSpace updating
179
+ set updating 1
180
+ switch $colorSpace {
181
+ rgb {
182
+ .scale1 set [format %.0f [expr {$red/65.535}]]
183
+ .scale2 set [format %.0f [expr {$green/65.535}]]
184
+ .scale3 set [format %.0f [expr {$blue/65.535}]]
185
+ }
186
+ cmy {
187
+ .scale1 set [format %.0f [expr {(65535-$red)/65.535}]]
188
+ .scale2 set [format %.0f [expr {(65535-$green)/65.535}]]
189
+ .scale3 set [format %.0f [expr {(65535-$blue)/65.535}]]
190
+ }
191
+ hsb {
192
+ set list [rgbToHsv $red $green $blue]
193
+ .scale1 set [format %.0f [expr {[lindex $list 0] * 1000.0}]]
194
+ .scale2 set [format %.0f [expr {[lindex $list 1] * 1000.0}]]
195
+ .scale3 set [format %.0f [expr {[lindex $list 2] * 1000.0}]]
196
+ }
197
+ }
198
+ set updating 0
199
+ }
200
+
201
+ # The procedure below is invoked when a named color has been
202
+ # selected from the listbox or typed into the entry. It loads
203
+ # the color into the editor.
204
+
205
+ proc tc_loadNamedColor name {
206
+ global red green blue color autoUpdate
207
+
208
+ if {[string index $name 0] != "#"} {
209
+ set list [winfo rgb .sample.swatch $name]
210
+ set red [lindex $list 0]
211
+ set green [lindex $list 1]
212
+ set blue [lindex $list 2]
213
+ } else {
214
+ switch [string length $name] {
215
+ 4 {set format "#%1x%1x%1x"; set shift 12}
216
+ 7 {set format "#%2x%2x%2x"; set shift 8}
217
+ 10 {set format "#%3x%3x%3x"; set shift 4}
218
+ 13 {set format "#%4x%4x%4x"; set shift 0}
219
+ default {error "syntax error in color name \"$name\""}
220
+ }
221
+ if {[scan $name $format red green blue] != 3} {
222
+ error "syntax error in color name \"$name\""
223
+ }
224
+ set red [expr {$red<<$shift}]
225
+ set green [expr {$green<<$shift}]
226
+ set blue [expr {$blue<<$shift}]
227
+ }
228
+ tc_setScales
229
+ set color [format "#%04x%04x%04x" $red $green $blue]
230
+ .sample.swatch config -bg $color
231
+ if {$autoUpdate} doUpdate
232
+ }
233
+
234
+ # The procedure below is invoked when a new color space is selected.
235
+ # It changes the labels on the scales and re-loads the scales with
236
+ # the appropriate values for the current color in the new color space
237
+
238
+ proc changeColorSpace space {
239
+ global label1 label2 label3
240
+ switch $space {
241
+ rgb {
242
+ set label1 "Adjust Red:"
243
+ set label2 "Adjust Green:"
244
+ set label3 "Adjust Blue:"
245
+ tc_setScales
246
+ return
247
+ }
248
+ cmy {
249
+ set label1 "Adjust Cyan:"
250
+ set label2 "Adjust Magenta:"
251
+ set label3 "Adjust Yellow:"
252
+ tc_setScales
253
+ return
254
+ }
255
+ hsb {
256
+ set label1 "Adjust Hue:"
257
+ set label2 "Adjust Saturation:"
258
+ set label3 "Adjust Brightness:"
259
+ tc_setScales
260
+ return
261
+ }
262
+ }
263
+ }
264
+
265
+ # The procedure below converts an RGB value to HSB. It takes red, green,
266
+ # and blue components (0-65535) as arguments, and returns a list containing
267
+ # HSB components (floating-point, 0-1) as result. The code here is a copy
268
+ # of the code on page 615 of "Fundamentals of Interactive Computer Graphics"
269
+ # by Foley and Van Dam.
270
+
271
+ proc rgbToHsv {red green blue} {
272
+ if {$red > $green} {
273
+ set max [expr {double($red)}]
274
+ set min [expr {double($green)}]
275
+ } else {
276
+ set max [expr {double($green)}]
277
+ set min [expr {double($red)}]
278
+ }
279
+ if {$blue > $max} {
280
+ set max [expr {double($blue)}]
281
+ } elseif {$blue < $min} {
282
+ set min [expr {double($blue)}]
283
+ }
284
+ set range [expr {$max-$min}]
285
+ if {$max == 0} {
286
+ set sat 0
287
+ } else {
288
+ set sat [expr {($max-$min)/$max}]
289
+ }
290
+ if {$sat == 0} {
291
+ set hue 0
292
+ } else {
293
+ set rc [expr {($max - $red)/$range}]
294
+ set gc [expr {($max - $green)/$range}]
295
+ set bc [expr {($max - $blue)/$range}]
296
+ if {$red == $max} {
297
+ set hue [expr {($bc - $gc)/6.0}]
298
+ } elseif {$green == $max} {
299
+ set hue [expr {(2 + $rc - $bc)/6.0}]
300
+ } else {
301
+ set hue [expr {(4 + $gc - $rc)/6.0}]
302
+ }
303
+ if {$hue < 0.0} {
304
+ set hue [expr {$hue + 1.0}]
305
+ }
306
+ }
307
+ return [list $hue $sat [expr {$max/65535}]]
308
+ }
309
+
310
+ # The procedure below converts an HSB value to RGB. It takes hue, saturation,
311
+ # and value components (floating-point, 0-1.0) as arguments, and returns a
312
+ # list containing RGB components (integers, 0-65535) as result. The code
313
+ # here is a copy of the code on page 616 of "Fundamentals of Interactive
314
+ # Computer Graphics" by Foley and Van Dam.
315
+
316
+ proc hsbToRgb {hue sat value} {
317
+ set v [format %.0f [expr {65535.0*$value}]]
318
+ if {$sat == 0} {
319
+ return "$v $v $v"
320
+ } else {
321
+ set hue [expr {$hue*6.0}]
322
+ if {$hue >= 6.0} {
323
+ set hue 0.0
324
+ }
325
+ scan $hue. %d i
326
+ set f [expr {$hue-$i}]
327
+ set p [format %.0f [expr {65535.0*$value*(1 - $sat)}]]
328
+ set q [format %.0f [expr {65535.0*$value*(1 - ($sat*$f))}]]
329
+ set t [format %.0f [expr {65535.0*$value*(1 - ($sat*(1 - $f)))}]]
330
+ switch $i {
331
+ 0 {return "$v $t $p"}
332
+ 1 {return "$q $v $p"}
333
+ 2 {return "$p $v $t"}
334
+ 3 {return "$p $q $v"}
335
+ 4 {return "$t $p $v"}
336
+ 5 {return "$v $p $q"}
337
+ default {error "i value $i is out of range"}
338
+ }
339
+ }
340
+ }
341
+
342
+ # The procedure below is invoked when the "Update" button is pressed,
343
+ # and whenever the color changes if update mode is enabled. It
344
+ # propagates color information as determined by the command in the
345
+ # Command entry.
346
+
347
+ proc doUpdate {} {
348
+ global color command
349
+ set newCmd $command
350
+ regsub -all %% $command $color newCmd
351
+ eval $newCmd
352
+ }
353
+
354
+ changeColorSpace hsb
355
+
356
+ # Local Variables:
357
+ # mode: tcl
358
+ # End:
janus/lib/tk8.6/demos/text.tcl ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # text.tcl --
2
+ #
3
+ # This demonstration script creates a text widget that describes
4
+ # the basic editing functions.
5
+
6
+ if {![info exists widgetDemo]} {
7
+ error "This script should be run from the \"widget\" demo."
8
+ }
9
+
10
+ package require Tk
11
+
12
+ set w .text
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Text Demonstration - Basic Facilities"
16
+ wm iconname $w "text"
17
+ positionWindow $w
18
+
19
+ ## See Code / Dismiss buttons
20
+ set btns [addSeeDismiss $w.buttons $w {} \
21
+ {ttk::button $w.buttons.fontchooser -command fontchooserToggle}]
22
+ pack $btns -side bottom -fill x
23
+
24
+ text $w.text -yscrollcommand [list $w.scroll set] -setgrid 1 \
25
+ -height 30 -undo 1 -autosep 1
26
+ ttk::scrollbar $w.scroll -command [list $w.text yview]
27
+ pack $w.scroll -side right -fill y
28
+ pack $w.text -expand yes -fill both
29
+
30
+ # TIP 324 Demo: [tk fontchooser]
31
+ proc fontchooserToggle {} {
32
+ tk fontchooser [expr {[tk fontchooser configure -visible] ?
33
+ "hide" : "show"}]
34
+ }
35
+ proc fontchooserVisibility {w} {
36
+ $w configure -text [expr {[tk fontchooser configure -visible] ?
37
+ "Hide Font Dialog" : "Show Font Dialog"}]
38
+ }
39
+ proc fontchooserFocus {w} {
40
+ tk fontchooser configure -font [$w cget -font] \
41
+ -command [list fontchooserFontSel $w]
42
+ }
43
+ proc fontchooserFontSel {w font args} {
44
+ $w configure -font [font actual $font]
45
+ }
46
+ tk fontchooser configure -parent $w
47
+ bind $w.text <FocusIn> [list fontchooserFocus $w.text]
48
+ fontchooserVisibility $w.buttons.fontchooser
49
+ bind $w <<TkFontchooserVisibility>> [list \
50
+ fontchooserVisibility $w.buttons.fontchooser]
51
+ focus $w.text
52
+
53
+ $w.text insert 0.0 \
54
+ {This window is a text widget. It displays one or more lines of text
55
+ and allows you to edit the text. Here is a summary of the things you
56
+ can do to a text widget:
57
+
58
+ 1. Scrolling. Use the scrollbar to adjust the view in the text window.
59
+
60
+ 2. Scanning. Press the middle mouse button in the text window and drag up
61
+ or down. This will drag the text at high speed to allow you to scan its
62
+ contents.
63
+
64
+ 3. Insert text. Press mouse button 1 to set the insertion cursor, then
65
+ type text. What you type will be added to the widget.
66
+
67
+ 4. Select. Press mouse button 1 and drag to select a range of characters.
68
+ Once you've released the button, you can adjust the selection by pressing
69
+ button 1 with the shift key down. This will reset the end of the
70
+ selection nearest the mouse cursor and you can drag that end of the
71
+ selection by dragging the mouse before releasing the mouse button.
72
+ You can double-click to select whole words or triple-click to select
73
+ whole lines.
74
+
75
+ 5. Delete and replace. To delete text, select the characters you'd like
76
+ to delete and type Backspace or Delete. Alternatively, you can type new
77
+ text, in which case it will replace the selected text.
78
+
79
+ 6. Copy the selection. To copy the selection into this window, select
80
+ what you want to copy (either here or in another application), then
81
+ click the middle mouse button to copy the selection to the point of the
82
+ mouse cursor.
83
+
84
+ 7. Edit. Text widgets support the standard Motif editing characters
85
+ plus many Emacs editing characters. Backspace and Control-h erase the
86
+ character to the left of the insertion cursor. Delete and Control-d
87
+ erase the character to the right of the insertion cursor. Meta-backspace
88
+ deletes the word to the left of the insertion cursor, and Meta-d deletes
89
+ the word to the right of the insertion cursor. Control-k deletes from
90
+ the insertion cursor to the end of the line, or it deletes the newline
91
+ character if that is the only thing left on the line. Control-o opens
92
+ a new line by inserting a newline character to the right of the insertion
93
+ cursor. Control-t transposes the two characters on either side of the
94
+ insertion cursor. Control-z undoes the last editing action performed,
95
+ and }
96
+
97
+ switch [tk windowingsystem] {
98
+ "aqua" - "x11" {
99
+ $w.text insert end "Control-Shift-z"
100
+ }
101
+ "win32" {
102
+ $w.text insert end "Control-y"
103
+ }
104
+ }
105
+
106
+ $w.text insert end { redoes undone edits.
107
+
108
+ 7. Resize the window. This widget has been configured with the "setGrid"
109
+ option on, so that if you resize the window it will always resize to an
110
+ even number of characters high and wide. Also, if you make the window
111
+ narrow you can see that long lines automatically wrap around onto
112
+ additional lines so that all the information is always visible.}
113
+ $w.text mark set insert 0.0
janus/lib/tk8.6/demos/timer ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # timer --
6
+ # This script generates a counter with start and stop buttons.
7
+
8
+ package require Tk
9
+
10
+ label .counter -text 0.00 -relief raised -width 10 -padx 2m -pady 1m
11
+ button .start -text Start -command {
12
+ if {$stopped} {
13
+ set stopped 0
14
+ set startMoment [clock clicks -milliseconds]
15
+ tick
16
+ .stop configure -state normal
17
+ .start configure -state disabled
18
+ }
19
+ }
20
+ button .stop -text Stop -state disabled -command {
21
+ set stopped 1
22
+ .stop configure -state disabled
23
+ .start configure -state normal
24
+ }
25
+ pack .counter -side bottom -fill both
26
+ pack .start -side left -fill both -expand yes
27
+ pack .stop -side right -fill both -expand yes
28
+
29
+ set startMoment {}
30
+
31
+ set stopped 1
32
+
33
+ proc tick {} {
34
+ global startMoment stopped
35
+ if {$stopped} {return}
36
+ after 50 tick
37
+ set elapsedMS [expr {[clock clicks -milliseconds] - $startMoment}]
38
+ .counter config -text [format "%.2f" [expr {double($elapsedMS)/1000}]]
39
+ }
40
+
41
+ bind . <Control-c> {destroy .}
42
+ bind . <Control-q> {destroy .}
43
+ focus .
44
+
45
+ # Local Variables:
46
+ # mode: tcl
47
+ # End: