ZTWHHH commited on
Commit
763ce52
·
verified ·
1 Parent(s): 5a0e841

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 +1 -0
  2. janus/lib/engines-3/padlock.so +0 -0
  3. janus/lib/python3.10/lib-dynload/_decimal.cpython-310-x86_64-linux-gnu.so +3 -0
  4. janus/lib/python3.10/site-packages/numpy/lib/tests/data/py2-np0-objarr.npy +3 -0
  5. janus/lib/tcl8/8.4/platform-1.0.19.tm +450 -0
  6. janus/lib/tcl8/8.5/tcltest-2.5.7.tm +0 -0
  7. janus/lib/tcl8/8.6/tdbc/sqlite3-1.1.7.tm +723 -0
  8. janus/lib/tdbcodbc1.1.7/libtdbcodbc1.1.7.so +0 -0
  9. janus/lib/tdbcodbc1.1.7/pkgIndex.tcl +14 -0
  10. janus/lib/tk8.6/bgerror.tcl +272 -0
  11. janus/lib/tk8.6/choosedir.tcl +310 -0
  12. janus/lib/tk8.6/comdlg.tcl +322 -0
  13. janus/lib/tk8.6/demos/README +44 -0
  14. janus/lib/tk8.6/demos/anilabel.tcl +160 -0
  15. janus/lib/tk8.6/demos/button.tcl +47 -0
  16. janus/lib/tk8.6/demos/clrpick.tcl +54 -0
  17. janus/lib/tk8.6/demos/dialog1.tcl +25 -0
  18. janus/lib/tk8.6/demos/dialog2.tcl +18 -0
  19. janus/lib/tk8.6/demos/entry1.tcl +34 -0
  20. janus/lib/tk8.6/demos/entry2.tcl +46 -0
  21. janus/lib/tk8.6/demos/filebox.tcl +81 -0
  22. janus/lib/tk8.6/demos/floor.tcl +1372 -0
  23. janus/lib/tk8.6/demos/form.tcl +38 -0
  24. janus/lib/tk8.6/demos/goldberg.tcl +1834 -0
  25. janus/lib/tk8.6/demos/icon.tcl +51 -0
  26. janus/lib/tk8.6/demos/image1.tcl +35 -0
  27. janus/lib/tk8.6/demos/image2.tcl +108 -0
  28. janus/lib/tk8.6/demos/label.tcl +40 -0
  29. janus/lib/tk8.6/demos/license.terms +40 -0
  30. janus/lib/tk8.6/demos/mclist.tcl +119 -0
  31. janus/lib/tk8.6/demos/menubu.tcl +87 -0
  32. janus/lib/tk8.6/demos/sayings.tcl +44 -0
  33. janus/lib/tk8.6/demos/textpeer.tcl +62 -0
  34. janus/lib/tk8.6/demos/tree.tcl +89 -0
  35. janus/lib/tk8.6/demos/ttkpane.tcl +112 -0
  36. janus/lib/tk8.6/demos/unicodeout.tcl +145 -0
  37. janus/lib/tk8.6/demos/vscale.tcl +46 -0
  38. janus/lib/tk8.6/demos/widget +734 -0
  39. janus/lib/tk8.6/entry.tcl +699 -0
  40. janus/lib/tk8.6/fontchooser.tcl +515 -0
  41. janus/lib/tk8.6/listbox.tcl +560 -0
  42. janus/lib/tk8.6/mkpsenc.tcl +1488 -0
  43. janus/lib/tk8.6/msgbox.tcl +427 -0
  44. janus/lib/tk8.6/optMenu.tcl +43 -0
  45. janus/lib/tk8.6/palette.tcl +244 -0
  46. janus/lib/tk8.6/pkgIndex.tcl +2 -0
  47. janus/lib/tk8.6/safetk.tcl +262 -0
  48. janus/lib/tk8.6/scrlbar.tcl +456 -0
  49. janus/lib/tk8.6/tclIndex +253 -0
  50. janus/lib/tk8.6/text.tcl +1242 -0
.gitattributes CHANGED
@@ -525,3 +525,4 @@ janus/lib/python3.10/site-packages/numpy/random/bit_generator.cpython-310-x86_64
525
  janus/lib/python3.10/site-packages/numpy/random/_bounded_integers.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
 
 
525
  janus/lib/python3.10/site-packages/numpy/random/_bounded_integers.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
janus/lib/engines-3/padlock.so ADDED
Binary file (36.1 kB). View file
 
janus/lib/python3.10/lib-dynload/_decimal.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc76e957d5709b4ea4778b19d26be671770cd04d9a6ce7cf94a5b43c94285a26
3
+ size 1420752
janus/lib/python3.10/site-packages/numpy/lib/tests/data/py2-np0-objarr.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64ba08ecade24295c392ea03175626c9ce896f0e099e06d0282f60adab9546c9
3
+ size 258
janus/lib/tcl8/8.4/platform-1.0.19.tm ADDED
@@ -0,0 +1,450 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- tcl -*-
2
+ # ### ### ### ######### ######### #########
3
+ ## Overview
4
+
5
+ # Heuristics to assemble a platform identifier from publicly available
6
+ # information. The identifier describes the platform of the currently
7
+ # running tcl shell. This is a mixture of the runtime environment and
8
+ # of build-time properties of the executable itself.
9
+ #
10
+ # Examples:
11
+ # <1> A tcl shell executing on a x86_64 processor, but having a
12
+ # wordsize of 4 was compiled for the x86 environment, i.e. 32
13
+ # bit, and loaded packages have to match that, and not the
14
+ # actual cpu.
15
+ #
16
+ # <2> The hp/solaris 32/64 bit builds of the core cannot be
17
+ # distinguished by looking at tcl_platform. As packages have to
18
+ # match the 32/64 information we have to look in more places. In
19
+ # this case we inspect the executable itself (magic numbers,
20
+ # i.e. fileutil::magic::filetype).
21
+ #
22
+ # The basic information used comes out of the 'os' and 'machine'
23
+ # entries of the 'tcl_platform' array. A number of general and
24
+ # os/machine specific transformation are applied to get a canonical
25
+ # result.
26
+ #
27
+ # General
28
+ # Only the first element of 'os' is used - we don't care whether we
29
+ # are on "Windows NT" or "Windows XP" or whatever.
30
+ #
31
+ # Machine specific
32
+ # % amd64 -> x86_64
33
+ # % arm* -> arm
34
+ # % sun4* -> sparc
35
+ # % ia32* -> ix86
36
+ # % intel -> ix86
37
+ # % i*86* -> ix86
38
+ # % Power* -> powerpc
39
+ # % x86_64 + wordSize 4 => x86 code
40
+ #
41
+ # OS specific
42
+ # % AIX are always powerpc machines
43
+ # % HP-UX 9000/800 etc means parisc
44
+ # % linux has to take glibc version into account
45
+ # % sunos -> solaris, and keep version number
46
+ #
47
+ # NOTE: A platform like linux glibc 2.3, which can use glibc 2.2 stuff
48
+ # has to provide all possible allowed platform identifiers when
49
+ # searching search. Ditto a solaris 2.8 platform can use solaris 2.6
50
+ # packages. Etc. This is handled by the other procedure, see below.
51
+
52
+ # ### ### ### ######### ######### #########
53
+ ## Requirements
54
+
55
+ namespace eval ::platform {}
56
+
57
+ # ### ### ### ######### ######### #########
58
+ ## Implementation
59
+
60
+ # -- platform::generic
61
+ #
62
+ # Assembles an identifier for the generic platform. It leaves out
63
+ # details like kernel version, libc version, etc.
64
+
65
+ proc ::platform::generic {} {
66
+ global tcl_platform
67
+
68
+ set plat [string tolower [lindex $tcl_platform(os) 0]]
69
+ set cpu $tcl_platform(machine)
70
+
71
+ switch -glob -- $cpu {
72
+ sun4* {
73
+ set cpu sparc
74
+ }
75
+ intel -
76
+ ia32* -
77
+ i*86* {
78
+ set cpu ix86
79
+ }
80
+ x86_64 {
81
+ if {$tcl_platform(wordSize) == 4} {
82
+ # See Example <1> at the top of this file.
83
+ set cpu ix86
84
+ }
85
+ }
86
+ ppc -
87
+ "Power*" {
88
+ set cpu powerpc
89
+ }
90
+ "arm*" {
91
+ set cpu arm
92
+ }
93
+ ia64 {
94
+ if {$tcl_platform(wordSize) == 4} {
95
+ append cpu _32
96
+ }
97
+ }
98
+ }
99
+
100
+ switch -glob -- $plat {
101
+ windows {
102
+ if {$tcl_platform(platform) == "unix"} {
103
+ set plat cygwin
104
+ } else {
105
+ set plat win32
106
+ }
107
+ if {$cpu eq "amd64"} {
108
+ # Do not check wordSize, win32-x64 is an IL32P64 platform.
109
+ set cpu x86_64
110
+ }
111
+ }
112
+ sunos {
113
+ set plat solaris
114
+ if {[string match "ix86" $cpu]} {
115
+ if {$tcl_platform(wordSize) == 8} {
116
+ set cpu x86_64
117
+ }
118
+ } elseif {![string match "ia64*" $cpu]} {
119
+ # sparc
120
+ if {$tcl_platform(wordSize) == 8} {
121
+ append cpu 64
122
+ }
123
+ }
124
+ }
125
+ darwin {
126
+ set plat macosx
127
+ # Correctly identify the cpu when running as a 64bit
128
+ # process on a machine with a 32bit kernel
129
+ if {$cpu eq "ix86"} {
130
+ if {$tcl_platform(wordSize) == 8} {
131
+ set cpu x86_64
132
+ }
133
+ }
134
+ }
135
+ aix {
136
+ set cpu powerpc
137
+ if {$tcl_platform(wordSize) == 8} {
138
+ append cpu 64
139
+ }
140
+ }
141
+ hp-ux {
142
+ set plat hpux
143
+ if {![string match "ia64*" $cpu]} {
144
+ set cpu parisc
145
+ if {$tcl_platform(wordSize) == 8} {
146
+ append cpu 64
147
+ }
148
+ }
149
+ }
150
+ osf1 {
151
+ set plat tru64
152
+ }
153
+ default {
154
+ set plat [lindex [split $plat _-] 0]
155
+ }
156
+ }
157
+
158
+ return "${plat}-${cpu}"
159
+ }
160
+
161
+ # -- platform::identify
162
+ #
163
+ # Assembles an identifier for the exact platform, by extending the
164
+ # generic identifier. I.e. it adds in details like kernel version,
165
+ # libc version, etc., if they are relevant for the loading of
166
+ # packages on the platform.
167
+
168
+ proc ::platform::identify {} {
169
+ global tcl_platform
170
+
171
+ set id [generic]
172
+ regexp {^([^-]+)-([^-]+)$} $id -> plat cpu
173
+
174
+ switch -- $plat {
175
+ solaris {
176
+ regsub {^5} $tcl_platform(osVersion) 2 text
177
+ append plat $text
178
+ return "${plat}-${cpu}"
179
+ }
180
+ macosx {
181
+ set major [lindex [split $tcl_platform(osVersion) .] 0]
182
+ if {$major > 19} {
183
+ set minor [lindex [split $tcl_platform(osVersion) .] 1]
184
+ incr major -9
185
+ append plat $major.[expr {$minor - 1}]
186
+ } else {
187
+ incr major -4
188
+ append plat 10.$major
189
+ return "${plat}-${cpu}"
190
+ }
191
+ return "${plat}-${cpu}"
192
+ }
193
+ linux {
194
+ # Look for the libc*.so and determine its version
195
+ # (libc5/6, libc6 further glibc 2.X)
196
+
197
+ set v unknown
198
+
199
+ # Determine in which directory to look. /lib, or /lib64.
200
+ # For that we use the tcl_platform(wordSize).
201
+ #
202
+ # We could use the 'cpu' info, per the equivalence below,
203
+ # that however would be restricted to intel. And this may
204
+ # be a arm, mips, etc. system. The wordsize is more
205
+ # fundamental.
206
+ #
207
+ # ix86 <=> (wordSize == 4) <=> 32 bit ==> /lib
208
+ # x86_64 <=> (wordSize == 8) <=> 64 bit ==> /lib64
209
+ #
210
+ # Do not look into /lib64 even if present, if the cpu
211
+ # doesn't fit.
212
+
213
+ # TODO: Determine the prefixes (i386, x86_64, ...) for
214
+ # other cpus. The path after the generic one is utterly
215
+ # specific to intel right now. Ok, on Ubuntu, possibly
216
+ # other Debian systems we may apparently be able to query
217
+ # the necessary CPU code. If we can't we simply use the
218
+ # hardwired fallback.
219
+
220
+ switch -exact -- $tcl_platform(wordSize) {
221
+ 4 {
222
+ lappend bases /lib
223
+ if {[catch {
224
+ exec dpkg-architecture -qDEB_HOST_MULTIARCH
225
+ } res]} {
226
+ lappend bases /lib/i386-linux-gnu
227
+ } else {
228
+ # dpkg-arch returns the full tripled, not just cpu.
229
+ lappend bases /lib/$res
230
+ }
231
+ }
232
+ 8 {
233
+ lappend bases /lib64
234
+ if {[catch {
235
+ exec dpkg-architecture -qDEB_HOST_MULTIARCH
236
+ } res]} {
237
+ lappend bases /lib/x86_64-linux-gnu
238
+ } else {
239
+ # dpkg-arch returns the full tripled, not just cpu.
240
+ lappend bases /lib/$res
241
+ }
242
+ }
243
+ default {
244
+ return -code error "Bad wordSize $tcl_platform(wordSize), expected 4 or 8"
245
+ }
246
+ }
247
+
248
+ foreach base $bases {
249
+ if {[LibcVersion $base -> v]} break
250
+ }
251
+
252
+ append plat -$v
253
+ return "${plat}-${cpu}"
254
+ }
255
+ }
256
+
257
+ return $id
258
+ }
259
+
260
+ proc ::platform::LibcVersion {base _->_ vv} {
261
+ upvar 1 $vv v
262
+ set libclist [lsort [glob -nocomplain -directory $base libc*]]
263
+
264
+ if {![llength $libclist]} { return 0 }
265
+
266
+ set libc [lindex $libclist 0]
267
+
268
+ # Try executing the library first. This should succeed
269
+ # for a glibc library, and return the version
270
+ # information.
271
+
272
+ if {![catch {
273
+ set vdata [lindex [split [exec $libc] \n] 0]
274
+ }]} {
275
+ regexp {version ([0-9]+(\.[0-9]+)*)} $vdata -> v
276
+ foreach {major minor} [split $v .] break
277
+ set v glibc${major}.${minor}
278
+ return 1
279
+ } else {
280
+ # We had trouble executing the library. We are now
281
+ # inspecting its name to determine the version
282
+ # number. This code by Larry McVoy.
283
+
284
+ if {[regexp -- {libc-([0-9]+)\.([0-9]+)} $libc -> major minor]} {
285
+ set v glibc${major}.${minor}
286
+ return 1
287
+ }
288
+ }
289
+ return 0
290
+ }
291
+
292
+ # -- platform::patterns
293
+ #
294
+ # Given an exact platform identifier, i.e. _not_ the generic
295
+ # identifier it assembles a list of exact platform identifier
296
+ # describing platform which should be compatible with the
297
+ # input.
298
+ #
299
+ # I.e. packages for all platforms in the result list should be
300
+ # loadable on the specified platform.
301
+
302
+ # << Should we add the generic identifier to the list as well ? In
303
+ # general it is not compatible I believe. So better not. In many
304
+ # cases the exact identifier is identical to the generic one
305
+ # anyway.
306
+ # >>
307
+
308
+ proc ::platform::patterns {id} {
309
+ set res [list $id]
310
+ if {$id eq "tcl"} {return $res}
311
+
312
+ switch -glob -- $id {
313
+ solaris*-* {
314
+ if {[regexp {solaris([^-]*)-(.*)} $id -> v cpu]} {
315
+ if {$v eq ""} {return $id}
316
+ foreach {major minor} [split $v .] break
317
+ incr minor -1
318
+ for {set j $minor} {$j >= 6} {incr j -1} {
319
+ lappend res solaris${major}.${j}-${cpu}
320
+ }
321
+ }
322
+ }
323
+ linux*-* {
324
+ if {[regexp {linux-glibc([^-]*)-(.*)} $id -> v cpu]} {
325
+ foreach {major minor} [split $v .] break
326
+ incr minor -1
327
+ for {set j $minor} {$j >= 0} {incr j -1} {
328
+ lappend res linux-glibc${major}.${j}-${cpu}
329
+ }
330
+ }
331
+ }
332
+ macosx-powerpc {
333
+ lappend res macosx-universal
334
+ }
335
+ macosx-x86_64 {
336
+ lappend res macosx-i386-x86_64
337
+ }
338
+ macosx-ix86 {
339
+ lappend res macosx-universal macosx-i386-x86_64
340
+ }
341
+ macosx*-* {
342
+ # 10.5+,11.0+
343
+ if {[regexp {macosx([^-]*)-(.*)} $id -> v cpu]} {
344
+
345
+ switch -exact -- $cpu {
346
+ ix86 {
347
+ lappend alt i386-x86_64
348
+ lappend alt universal
349
+ }
350
+ x86_64 {
351
+ if {[lindex [split $::tcl_platform(osVersion) .] 0] < 19} {
352
+ set alt i386-x86_64
353
+ } else {
354
+ set alt {}
355
+ }
356
+ }
357
+ arm {
358
+ lappend alt x86_64
359
+ }
360
+ default { set alt {} }
361
+ }
362
+
363
+ if {$v ne ""} {
364
+ foreach {major minor} [split $v .] break
365
+
366
+ set res {}
367
+ if {$major eq 13} {
368
+ # Add 13.0 to 13.minor to patterns.
369
+ for {set j $minor} {$j >= 0} {incr j -1} {
370
+ lappend res macosx${major}.${j}-${cpu}
371
+ foreach a $alt {
372
+ lappend res macosx${major}.${j}-$a
373
+ }
374
+ }
375
+ set major 12
376
+ set minor 5
377
+ }
378
+ if {$major eq 12} {
379
+ # Add 12.0 to 12.minor to patterns.
380
+ for {set j $minor} {$j >= 0} {incr j -1} {
381
+ lappend res macosx${major}.${j}-${cpu}
382
+ foreach a $alt {
383
+ lappend res macosx${major}.${j}-$a
384
+ }
385
+ }
386
+ set major 11
387
+ set minor 5
388
+ }
389
+ if {$major eq 11} {
390
+ # Add 11.0 to 11.minor to patterns.
391
+ for {set j $minor} {$j >= 0} {incr j -1} {
392
+ lappend res macosx${major}.${j}-${cpu}
393
+ foreach a $alt {
394
+ lappend res macosx${major}.${j}-$a
395
+ }
396
+ }
397
+ set major 10
398
+ set minor 15
399
+ }
400
+ # Add 10.5 to 10.minor to patterns.
401
+ for {set j $minor} {$j >= 5} {incr j -1} {
402
+ if {$cpu ne "arm"} {
403
+ lappend res macosx${major}.${j}-${cpu}
404
+ }
405
+ foreach a $alt {
406
+ lappend res macosx${major}.${j}-$a
407
+ }
408
+ }
409
+
410
+ # Add unversioned patterns for 10.3/10.4 builds.
411
+ lappend res macosx-${cpu}
412
+ foreach a $alt {
413
+ lappend res macosx-$a
414
+ }
415
+ } else {
416
+ # No version, just do unversioned patterns.
417
+ foreach a $alt {
418
+ lappend res macosx-$a
419
+ }
420
+ }
421
+ } else {
422
+ # no v, no cpu ... nothing
423
+ }
424
+ }
425
+ }
426
+ lappend res tcl ; # Pure tcl packages are always compatible.
427
+ return $res
428
+ }
429
+
430
+
431
+ # ### ### ### ######### ######### #########
432
+ ## Ready
433
+
434
+ package provide platform 1.0.19
435
+
436
+ # ### ### ### ######### ######### #########
437
+ ## Demo application
438
+
439
+ if {[info exists argv0] && ($argv0 eq [info script])} {
440
+ puts ====================================
441
+ parray tcl_platform
442
+ puts ====================================
443
+ puts Generic\ identification:\ [::platform::generic]
444
+ puts Exact\ identification:\ \ \ [::platform::identify]
445
+ puts ====================================
446
+ puts Search\ patterns:
447
+ puts *\ [join [::platform::patterns [::platform::identify]] \n*\ ]
448
+ puts ====================================
449
+ exit 0
450
+ }
janus/lib/tcl8/8.5/tcltest-2.5.7.tm ADDED
The diff for this file is too large to render. See raw diff
 
janus/lib/tcl8/8.6/tdbc/sqlite3-1.1.7.tm ADDED
@@ -0,0 +1,723 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tdbcsqlite3.tcl --
2
+ #
3
+ # SQLite3 database driver for TDBC
4
+ #
5
+ # Copyright (c) 2008 by Kevin B. Kenny.
6
+ # See the file "license.terms" for information on usage and redistribution
7
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
+ #
9
+ # RCS: @(#) $Id: tdbcodbc.tcl,v 1.47 2008/02/27 02:08:27 kennykb Exp $
10
+ #
11
+ #------------------------------------------------------------------------------
12
+
13
+ package require tdbc
14
+ package require sqlite3
15
+
16
+ package provide tdbc::sqlite3 1.1.7
17
+
18
+ namespace eval tdbc::sqlite3 {
19
+ namespace export connection
20
+ }
21
+
22
+ #------------------------------------------------------------------------------
23
+ #
24
+ # tdbc::sqlite3::connection --
25
+ #
26
+ # Class representing a SQLite3 database connection
27
+ #
28
+ #------------------------------------------------------------------------------
29
+
30
+ ::oo::class create ::tdbc::sqlite3::connection {
31
+
32
+ superclass ::tdbc::connection
33
+
34
+ variable timeout
35
+ variable keepcase
36
+
37
+ # The constructor accepts a database name and opens the database.
38
+
39
+ constructor {databaseName args} {
40
+ set timeout 0
41
+ set keepcase 0
42
+ if {[llength $args] % 2 != 0} {
43
+ set cmd [lrange [info level 0] 0 end-[llength $args]]
44
+ return -code error \
45
+ -errorcode {TDBC GENERAL_ERROR HY000 SQLITE3 WRONGNUMARGS} \
46
+ "wrong # args, should be \"$cmd ?-option value?...\""
47
+ }
48
+ next
49
+ sqlite3 [namespace current]::db $databaseName
50
+ if {[llength $args] > 0} {
51
+ my configure {*}$args
52
+ }
53
+ db nullvalue \ufffd
54
+ }
55
+
56
+ # The 'statementCreate' method forwards to the constructor of the
57
+ # statement class
58
+
59
+ forward statementCreate ::tdbc::sqlite3::statement create
60
+
61
+ # The 'configure' method queries and sets options to the database
62
+
63
+ method configure args {
64
+ if {[llength $args] == 0} {
65
+
66
+ # Query all configuration options
67
+
68
+ set result {-encoding utf-8}
69
+ lappend result -isolation
70
+ if {[db onecolumn {PRAGMA read_uncommitted}]} {
71
+ lappend result readuncommitted
72
+ } else {
73
+ lappend result serializable
74
+ }
75
+ lappend result -keepcase $keepcase
76
+ lappend result -readonly 0
77
+ lappend result -timeout $timeout
78
+ return $result
79
+
80
+ } elseif {[llength $args] == 1} {
81
+
82
+ # Query a single option
83
+
84
+ set option [lindex $args 0]
85
+ if {[catch {::tcl::prefix match -message "option" {
86
+ -encoding -isolation -keepcase -readonly -timeout
87
+ } $option} opt]} {
88
+ return -code error \
89
+ -errorcode [list TDBC GENERAL_ERROR HY000 SQLITE3 \
90
+ BADOPTION $option] $opt
91
+ }
92
+ switch -exact -- $opt {
93
+ -encoding {
94
+ return utf-8
95
+ }
96
+ -isolation {
97
+ if {[db onecolumn {PRAGMA read_uncommitted}]} {
98
+ return readuncommitted
99
+ } else {
100
+ return serializable
101
+ }
102
+ }
103
+ -keepcase {
104
+ return $keepcase
105
+ }
106
+ -readonly {
107
+ return 0
108
+ }
109
+ -timeout {
110
+ return $timeout
111
+ }
112
+ }
113
+
114
+ } elseif {[llength $args] % 2 != 0} {
115
+
116
+ # Syntax error
117
+
118
+ set cmd [lrange [info level 0] 0 end-[llength $args]]
119
+ return -code error \
120
+ -errorcode [list TDBC GENERAL_ERROR HY000 \
121
+ SQLITE3 WRONGNUMARGS] \
122
+ "wrong # args, should be \" $cmd ?-option value?...\""
123
+ }
124
+
125
+ # Set one or more options
126
+
127
+ foreach {option value} $args {
128
+ if {[catch {::tcl::prefix match -message "option" {
129
+ -encoding -isolation -keepcase -readonly -timeout
130
+ } $option} opt]} {
131
+ return -code error \
132
+ -errorcode [list TDBC GENERAL_ERROR HY000 SQLITE3 \
133
+ BADOPTION $option] $opt
134
+ }
135
+
136
+ switch -exact -- $opt {
137
+ -encoding {
138
+ if {$value ne {utf-8}} {
139
+ return -code error \
140
+ -errorcode [list TDBC FEATURE_NOT_SUPPORTED 0A000 \
141
+ SQLITE3 ENCODING] \
142
+ "-encoding not supported. SQLite3 is always\
143
+ Unicode."
144
+ }
145
+ }
146
+ -isolation {
147
+ if {[catch {::tcl::prefix match -message "isolation level" {
148
+ readuncommitted readcommitted repeatableread
149
+ serializable readonly
150
+ } $value} val]} {
151
+ return -code error \
152
+ -errorcode [list TDBC GENERAL_ERROR HY000 \
153
+ SQLITE3 BADISOLATION $value] \
154
+ $val
155
+ }
156
+ switch -exact -- $val {
157
+ readuncommitted {
158
+ db eval {PRAGMA read_uncommitted = 1}
159
+ }
160
+ readcommitted -
161
+ repeatableread -
162
+ serializable -
163
+ readonly {
164
+ db eval {PRAGMA read_uncommitted = 0}
165
+ }
166
+ }
167
+ }
168
+ -keepcase {
169
+ if {![string is boolean -strict $value]} {
170
+ return -code error \
171
+ -errorcode [list TDBC DATA_EXCEPTION 22018 \
172
+ SQLITE3 $value] \
173
+ "expected boolean but got \"$value\""
174
+ }
175
+ # Normalize boolean value to 0/1
176
+ set keepcase [expr {bool($value)}]
177
+ }
178
+ -readonly {
179
+ if {$value} {
180
+ return -code error \
181
+ -errorcode [list TDBC FEATURE_NOT_SUPPORTED 0A000 \
182
+ SQLITE3 READONLY] \
183
+ "SQLite3's Tcl API does not support read-only\
184
+ access"
185
+ }
186
+ }
187
+ -timeout {
188
+ if {![string is integer -strict $value]} {
189
+ return -code error \
190
+ -errorcode [list TDBC DATA_EXCEPTION 22018 \
191
+ SQLITE3 $value] \
192
+ "expected integer but got \"$value\""
193
+ }
194
+ db timeout $value
195
+ set timeout $value
196
+ }
197
+ }
198
+ }
199
+ return
200
+ }
201
+
202
+ # The 'tables' method introspects on the tables in the database.
203
+
204
+ method tables {{pattern %}} {
205
+ set retval {}
206
+ my foreach row {
207
+ SELECT * from sqlite_master
208
+ WHERE type IN ('table', 'view')
209
+ AND name LIKE :pattern
210
+ } {
211
+ if {!$keepcase} {
212
+ dict set row name [string tolower [dict get $row name]]
213
+ }
214
+ dict set retval [dict get $row name] $row
215
+ }
216
+ return $retval
217
+ }
218
+
219
+ # The 'columns' method introspects on columns of a table.
220
+
221
+ method columns {table {pattern %}} {
222
+ regsub -all ' $table '' table
223
+ set retval {}
224
+ set pattern [string map [list \
225
+ * {[*]} \
226
+ ? {[?]} \
227
+ \[ \\\[ \
228
+ \] \\\[ \
229
+ _ ? \
230
+ % *] [string tolower $pattern]]
231
+ my foreach origrow "PRAGMA table_info('$table')" {
232
+ set row {}
233
+ dict for {key value} $origrow {
234
+ dict set row [string tolower $key] $value
235
+ }
236
+ if {!$keepcase} {
237
+ dict set row name [string tolower [dict get $row name]]
238
+ }
239
+ if {![string match $pattern \
240
+ [string tolower [dict get $row name]]]} {
241
+ continue
242
+ }
243
+ switch -regexp -matchvar info [dict get $row type] {
244
+ {^(.+)\(\s*([[:digit:]]+)\s*,\s*([[:digit:]]+)\s*\)\s*$} {
245
+ dict set row type \
246
+ [string trim [string tolower [lindex $info 1]]]
247
+ dict set row precision [lindex $info 2]
248
+ dict set row scale [lindex $info 3]
249
+ }
250
+ {^(.+)\(\s*([[:digit:]]+)\s*\)\s*$} {
251
+ dict set row type [string tolower [lindex $info 1]]
252
+ dict set row precision [lindex $info 2]
253
+ dict set row scale 0
254
+ }
255
+ default {
256
+ dict set row type [string tolower [dict get $row type]]
257
+ dict set row precision 0
258
+ dict set row scale 0
259
+ }
260
+ }
261
+ dict set row nullable [expr {![dict get $row notnull]}]
262
+ dict set retval [dict get $row name] $row
263
+ }
264
+ return $retval
265
+ }
266
+
267
+ # The 'primarykeys' method enumerates the primary keys on a table.
268
+
269
+ method primarykeys {table} {
270
+ set result {}
271
+ my foreach row "PRAGMA table_info($table)" {
272
+ if {[dict get $row pk]} {
273
+ lappend result [dict create ordinalPosition \
274
+ [expr {[dict get $row cid]+1}] \
275
+ columnName \
276
+ [dict get $row name]]
277
+ }
278
+ }
279
+ return $result
280
+ }
281
+
282
+ # The 'foreignkeys' method enumerates the foreign keys that are
283
+ # declared in a table or that refer to a given table.
284
+
285
+ method foreignkeys {args} {
286
+
287
+ variable ::tdbc::generalError
288
+
289
+ # Check arguments
290
+
291
+ set argdict {}
292
+ if {[llength $args] % 2 != 0} {
293
+ set errorcode $generalError
294
+ lappend errorcode wrongNumArgs
295
+ return -code error -errorcode $errorcode \
296
+ "wrong # args: should be [lrange [info level 0] 0 1]\
297
+ ?-option value?..."
298
+ }
299
+ foreach {key value} $args {
300
+ if {$key ni {-primary -foreign}} {
301
+ set errorcode $generalError
302
+ lappend errorcode badOption
303
+ return -code error -errorcode $errorcode \
304
+ "bad option \"$key\", must be -primary or -foreign"
305
+ }
306
+ set key [string range $key 1 end]
307
+ if {[dict exists $argdict $key]} {
308
+ set errorcode $generalError
309
+ lappend errorcode dupOption
310
+ return -code error -errorcode $errorcode \
311
+ "duplicate option \"$key\" supplied"
312
+ }
313
+ dict set argdict $key $value
314
+ }
315
+
316
+ # If we know the table with the foreign key, search just its
317
+ # foreign keys. Otherwise, iterate over all the tables in the
318
+ # database.
319
+
320
+ if {[dict exists $argdict foreign]} {
321
+ return [my ForeignKeysForTable [dict get $argdict foreign] \
322
+ $argdict]
323
+ } else {
324
+ set result {}
325
+ foreach foreignTable [dict keys [my tables]] {
326
+ lappend result {*}[my ForeignKeysForTable \
327
+ $foreignTable $argdict]
328
+ }
329
+ return $result
330
+ }
331
+
332
+ }
333
+
334
+ # The private ForeignKeysForTable method enumerates the foreign keys
335
+ # in a specific table.
336
+ #
337
+ # Parameters:
338
+ #
339
+ # foreignTable - Name of the table containing foreign keys.
340
+ # argdict - Dictionary that may or may not contain a key,
341
+ # 'primary', whose value is the name of a table that
342
+ # must hold the primary key corresponding to the foreign
343
+ # key. If the 'primary' key is absent, all tables are
344
+ # candidates.
345
+ # Results:
346
+ #
347
+ # Returns the list of foreign keys that meed the specified
348
+ # conditions, as a list of dictionaries, each containing the
349
+ # keys, foreignConstraintName, foreignTable, foreignColumn,
350
+ # primaryTable, primaryColumn, and ordinalPosition. Note that the
351
+ # foreign constraint name is constructed arbitrarily, since SQLite3
352
+ # does not report this information.
353
+
354
+ method ForeignKeysForTable {foreignTable argdict} {
355
+
356
+ set result {}
357
+ set n 0
358
+
359
+ # Go through the foreign keys in the given table, looking for
360
+ # ones that refer to the primary table (if one is given), or
361
+ # for any primary keys if none is given.
362
+ my foreach row "PRAGMA foreign_key_list($foreignTable)" {
363
+ if {(![dict exists $argdict primary])
364
+ || ([string tolower [dict get $row table]]
365
+ eq [string tolower [dict get $argdict primary]])} {
366
+
367
+ # Construct a dictionary for each key, translating
368
+ # SQLite names to TDBC ones and converting sequence
369
+ # numbers to 1-based indexing.
370
+
371
+ set rrow [dict create foreignTable $foreignTable \
372
+ foreignConstraintName \
373
+ ?$foreignTable?[dict get $row id]]
374
+ if {[dict exists $row seq]} {
375
+ dict set rrow ordinalPosition \
376
+ [expr {1 + [dict get $row seq]}]
377
+ }
378
+ foreach {to from} {
379
+ foreignColumn from
380
+ primaryTable table
381
+ primaryColumn to
382
+ deleteAction on_delete
383
+ updateAction on_update
384
+ } {
385
+ if {[dict exists $row $from]} {
386
+ dict set rrow $to [dict get $row $from]
387
+ }
388
+ }
389
+
390
+ # Add the newly-constucted dictionary to the result list
391
+
392
+ lappend result $rrow
393
+ }
394
+ }
395
+
396
+ return $result
397
+ }
398
+
399
+ # The 'preparecall' method prepares a call to a stored procedure.
400
+ # SQLite3 does not have stored procedures, since it's an in-process
401
+ # server.
402
+
403
+ method preparecall {call} {
404
+ return -code error \
405
+ -errorcode [list TDBC FEATURE_NOT_SUPPORTED 0A000 \
406
+ SQLITE3 PREPARECALL] \
407
+ {SQLite3 does not support stored procedures}
408
+ }
409
+
410
+ # The 'begintransaction' method launches a database transaction
411
+
412
+ method begintransaction {} {
413
+ db eval {BEGIN TRANSACTION}
414
+ }
415
+
416
+ # The 'commit' method commits a database transaction
417
+
418
+ method commit {} {
419
+ db eval {COMMIT}
420
+ }
421
+
422
+ # The 'rollback' method abandons a database transaction
423
+
424
+ method rollback {} {
425
+ db eval {ROLLBACK}
426
+ }
427
+
428
+ # The 'transaction' method executes a script as a single transaction.
429
+ # We override the 'transaction' method of the base class, since SQLite3
430
+ # has a faster implementation of the same thing. (The base class's generic
431
+ # method should also work.)
432
+ # (Don't overload the base class method, because 'break', 'continue'
433
+ # and 'return' in the transaction body don't work!)
434
+
435
+ #method transaction {script} {
436
+ # uplevel 1 [list {*}[namespace code db] transaction $script]
437
+ #}
438
+
439
+ method prepare {sqlCode} {
440
+ set result [next $sqlCode]
441
+ return $result
442
+ }
443
+
444
+ method getDBhandle {} {
445
+ return [namespace which db]
446
+ }
447
+ }
448
+
449
+ #------------------------------------------------------------------------------
450
+ #
451
+ # tdbc::sqlite3::statement --
452
+ #
453
+ # Class representing a statement to execute against a SQLite3 database
454
+ #
455
+ #------------------------------------------------------------------------------
456
+
457
+ ::oo::class create ::tdbc::sqlite3::statement {
458
+
459
+ superclass ::tdbc::statement
460
+
461
+ variable Params db sql
462
+
463
+ # The constructor accepts the handle to the connection and the SQL
464
+ # code for the statement to prepare. All that it does is to parse the
465
+ # statement and store it. The parse is used to support the
466
+ # 'params' and 'paramtype' methods.
467
+
468
+ constructor {connection sqlcode} {
469
+ next
470
+ set Params {}
471
+ set db [$connection getDBhandle]
472
+ set sql $sqlcode
473
+ foreach token [::tdbc::tokenize $sqlcode] {
474
+ if {[string index $token 0] in {$ : @}} {
475
+ dict set Params [string range $token 1 end] \
476
+ {type Tcl_Obj precision 0 scale 0 nullable 1 direction in}
477
+ }
478
+ }
479
+ }
480
+
481
+ # The 'resultSetCreate' method relays to the result set constructor
482
+
483
+ forward resultSetCreate ::tdbc::sqlite3::resultset create
484
+
485
+ # The 'params' method returns descriptions of the parameters accepted
486
+ # by the statement
487
+
488
+ method params {} {
489
+ return $Params
490
+ }
491
+
492
+ # The 'paramtype' method need do nothing; Sqlite3 uses manifest typing.
493
+
494
+ method paramtype args {;}
495
+
496
+ method getDBhandle {} {
497
+ return $db
498
+ }
499
+
500
+ method getSql {} {
501
+ return $sql
502
+ }
503
+
504
+ }
505
+
506
+ #-------------------------------------------------------------------------------
507
+ #
508
+ # tdbc::sqlite3::resultset --
509
+ #
510
+ # Class that represents a SQLlite result set in Tcl
511
+ #
512
+ #-------------------------------------------------------------------------------
513
+
514
+ ::oo::class create ::tdbc::sqlite3::resultset {
515
+
516
+ superclass ::tdbc::resultset
517
+
518
+ # The variables of this class all have peculiar names. The reason is
519
+ # that the RunQuery method needs to execute with an activation record
520
+ # that has no local variables whose names could conflict with names
521
+ # in the SQL query. We start the variable names with hyphens because
522
+ # they can't be bind variables.
523
+
524
+ variable -set {*}{
525
+ -columns -db -needcolumns -resultArray
526
+ -results -sql -Cursor -RowCount -END
527
+ }
528
+
529
+ constructor {statement args} {
530
+ next
531
+ set -db [$statement getDBhandle]
532
+ set -sql [$statement getSql]
533
+ set -columns {}
534
+ set -results {}
535
+ ${-db} trace [namespace code {my RecordStatement}]
536
+ if {[llength $args] == 0} {
537
+
538
+ # Variable substitutions are evaluated in caller's context
539
+
540
+ uplevel 1 [list ${-db} eval ${-sql} \
541
+ [namespace which -variable -resultArray] \
542
+ [namespace code {my RecordResult}]]
543
+
544
+ } elseif {[llength $args] == 1} {
545
+
546
+ # Variable substitutions are in the dictionary at [lindex $args 0].
547
+
548
+ set -paramDict [lindex $args 0]
549
+
550
+ # At this point, the activation record must contain no variables
551
+ # that might be bound within the query. All variables at this point
552
+ # begin with hyphens so that they are syntactically incorrect
553
+ # as bound variables in SQL.
554
+
555
+ unset args
556
+ unset statement
557
+
558
+ dict with -paramDict {
559
+ ${-db} eval ${-sql} -resultArray {
560
+ my RecordResult
561
+ }
562
+ }
563
+
564
+ } else {
565
+
566
+ ${-db} trace {}
567
+
568
+ # Too many args
569
+
570
+ return -code error \
571
+ -errorcode [list TDBC GENERAL_ERROR HY000 \
572
+ SQLITE3 WRONGNUMARGS] \
573
+ "wrong # args: should be\
574
+ [lrange [info level 0] 0 1] statement ?dictionary?"
575
+
576
+ }
577
+ ${-db} trace {}
578
+ set -Cursor 0
579
+ if {${-Cursor} < [llength ${-results}]
580
+ && [lindex ${-results} ${-Cursor}] eq {statement}} {
581
+ incr -Cursor 2
582
+ }
583
+ if {${-Cursor} < [llength ${-results}]
584
+ && [lindex ${-results} ${-Cursor}] eq {columns}} {
585
+ incr -Cursor
586
+ set -columns [lindex ${-results} ${-Cursor}]
587
+ incr -Cursor
588
+ }
589
+ set -RowCount [${-db} changes]
590
+ }
591
+
592
+ # Record the start of a SQL statement
593
+
594
+ method RecordStatement {stmt} {
595
+ set -needcolumns 1
596
+ lappend -results statement {}
597
+ }
598
+
599
+ # Record one row of results from a query by appending it as a dictionary
600
+ # to the 'results' list. As a side effect, set 'columns' to a list
601
+ # comprising the names of the columns of the result.
602
+
603
+ method RecordResult {} {
604
+ set columns ${-resultArray(*)}
605
+ if {[info exists -needcolumns]} {
606
+ lappend -results columns $columns
607
+ unset -needcolumns
608
+ }
609
+ set dict {}
610
+ foreach key $columns {
611
+ if {[set -resultArray($key)] ne "\ufffd"} {
612
+ dict set dict $key [set -resultArray($key)]
613
+ }
614
+ }
615
+ lappend -results row $dict
616
+ }
617
+
618
+ # Advance to the next result set
619
+
620
+ method nextresults {} {
621
+ set have 0
622
+ while {${-Cursor} < [llength ${-results}]} {
623
+ if {[lindex ${-results} ${-Cursor}] eq {statement}} {
624
+ set have 1
625
+ incr -Cursor 2
626
+ break
627
+ }
628
+ incr -Cursor 2
629
+ }
630
+ if {!$have} {
631
+ set -END {}
632
+ }
633
+ if {${-Cursor} >= [llength ${-results}]} {
634
+ set -columns {}
635
+ } elseif {[lindex ${-results} ${-Cursor}] eq {columns}} {
636
+ incr -Cursor
637
+ set -columns [lindex ${-results} ${-Cursor}]
638
+ incr -Cursor
639
+ } else {
640
+ set -columns {}
641
+ }
642
+ return $have
643
+ }
644
+
645
+ method getDBhandle {} {
646
+ return ${-db}
647
+ }
648
+
649
+ # Return a list of the columns
650
+
651
+ method columns {} {
652
+ if {[info exists -END]} {
653
+ return -code error \
654
+ -errorcode {TDBC GENERAL_ERROR HY010 SQLITE3 FUNCTIONSEQ} \
655
+ "Function sequence error: result set is exhausted."
656
+ }
657
+ return ${-columns}
658
+ }
659
+
660
+ # Return the next row of the result set as a list
661
+
662
+ method nextlist var {
663
+
664
+ upvar 1 $var row
665
+
666
+ if {[info exists -END]} {
667
+ return -code error \
668
+ -errorcode {TDBC GENERAL_ERROR HY010 SQLITE3 FUNCTIONSEQ} \
669
+ "Function sequence error: result set is exhausted."
670
+ }
671
+ if {${-Cursor} >= [llength ${-results}]
672
+ || [lindex ${-results} ${-Cursor}] ne {row}} {
673
+ return 0
674
+ } else {
675
+ set row {}
676
+ incr -Cursor
677
+ set d [lindex ${-results} ${-Cursor}]
678
+ incr -Cursor
679
+ foreach key ${-columns} {
680
+ if {[dict exists $d $key]} {
681
+ lappend row [dict get $d $key]
682
+ } else {
683
+ lappend row {}
684
+ }
685
+ }
686
+ }
687
+ return 1
688
+ }
689
+
690
+ # Return the next row of the result set as a dict
691
+
692
+ method nextdict var {
693
+
694
+ upvar 1 $var row
695
+
696
+ if {[info exists -END]} {
697
+ return -code error \
698
+ -errorcode {TDBC GENERAL_ERROR HY010 SQLITE3 FUNCTIONSEQ} \
699
+ "Function sequence error: result set is exhausted."
700
+ }
701
+ if {${-Cursor} >= [llength ${-results}]
702
+ || [lindex ${-results} ${-Cursor}] ne {row}} {
703
+ return 0
704
+ } else {
705
+ incr -Cursor
706
+ set row [lindex ${-results} ${-Cursor}]
707
+ incr -Cursor
708
+ }
709
+ return 1
710
+ }
711
+
712
+ # Return the number of rows affected by a statement
713
+
714
+ method rowcount {} {
715
+ if {[info exists -END]} {
716
+ return -code error \
717
+ -errorcode {TDBC GENERAL_ERROR HY010 SQLITE3 FUNCTIONSEQ} \
718
+ "Function sequence error: result set is exhausted."
719
+ }
720
+ return ${-RowCount}
721
+ }
722
+
723
+ }
janus/lib/tdbcodbc1.1.7/libtdbcodbc1.1.7.so ADDED
Binary file (66 kB). View file
 
janus/lib/tdbcodbc1.1.7/pkgIndex.tcl ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Index file to load the TDBC ODBC package.
2
+
3
+ if {![package vsatisfies [package provide Tcl] 8.6-]} {
4
+ return
5
+ }
6
+ if {[package vsatisfies [package provide Tcl] 9.0-]} {
7
+ package ifneeded tdbc::odbc 1.1.7 \
8
+ "[list source [file join $dir tdbcodbc.tcl]]\;\
9
+ [list load [file join $dir libtcl9tdbcodbc1.1.7.so] [string totitle tdbcodbc]]"
10
+ } else {
11
+ package ifneeded tdbc::odbc 1.1.7 \
12
+ "[list source [file join $dir tdbcodbc.tcl]]\;\
13
+ [list load [file join $dir libtdbcodbc1.1.7.so] [string totitle tdbcodbc]]"
14
+ }
janus/lib/tk8.6/bgerror.tcl ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # bgerror.tcl --
2
+ #
3
+ # Implementation of the bgerror procedure. It posts a dialog box with
4
+ # the error message and gives the user a chance to see a more detailed
5
+ # stack trace, and possible do something more interesting with that
6
+ # trace (like save it to a log). This is adapted from work done by
7
+ # Donal K. Fellows.
8
+ #
9
+ # Copyright (c) 1998-2000 by Ajuba Solutions.
10
+ # Copyright (c) 2007 by ActiveState Software Inc.
11
+ # Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
12
+ # Copyright (c) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
13
+
14
+ namespace eval ::tk::dialog::error {
15
+ namespace import -force ::tk::msgcat::*
16
+ namespace export bgerror
17
+ option add *ErrorDialog.function.text [mc "Save To Log"] \
18
+ widgetDefault
19
+ option add *ErrorDialog.function.command [namespace code SaveToLog]
20
+ option add *ErrorDialog*Label.font TkCaptionFont widgetDefault
21
+ if {[tk windowingsystem] eq "aqua"} {
22
+ option add *ErrorDialog*background systemAlertBackgroundActive \
23
+ widgetDefault
24
+ option add *ErrorDialog*info.text.background \
25
+ systemTextBackgroundColor widgetDefault
26
+ option add *ErrorDialog*Button.highlightBackground \
27
+ systemAlertBackgroundActive widgetDefault
28
+ }
29
+ }
30
+
31
+ proc ::tk::dialog::error::Return {which code} {
32
+ variable button
33
+
34
+ .bgerrorDialog.$which state {active selected focus}
35
+ update idletasks
36
+ after 100
37
+ set button $code
38
+ }
39
+
40
+ proc ::tk::dialog::error::Details {} {
41
+ set w .bgerrorDialog
42
+ set caption [option get $w.function text {}]
43
+ set command [option get $w.function command {}]
44
+ if {($caption eq "") || ($command eq "")} {
45
+ grid forget $w.function
46
+ }
47
+ lappend command [$w.top.info.text get 1.0 end-1c]
48
+ $w.function configure -text $caption -command $command
49
+ grid $w.top.info - -sticky nsew -padx 3m -pady 3m
50
+ }
51
+
52
+ proc ::tk::dialog::error::SaveToLog {text} {
53
+ if {$::tcl_platform(platform) eq "windows"} {
54
+ set allFiles *.*
55
+ } else {
56
+ set allFiles *
57
+ }
58
+ set types [list \
59
+ [list [mc "Log Files"] .log] \
60
+ [list [mc "Text Files"] .txt] \
61
+ [list [mc "All Files"] $allFiles] \
62
+ ]
63
+ set filename [tk_getSaveFile -title [mc "Select Log File"] \
64
+ -filetypes $types -defaultextension .log -parent .bgerrorDialog]
65
+ if {$filename ne {}} {
66
+ set f [open $filename w]
67
+ puts -nonewline $f $text
68
+ close $f
69
+ }
70
+ return
71
+ }
72
+
73
+ proc ::tk::dialog::error::Destroy {w} {
74
+ if {$w eq ".bgerrorDialog"} {
75
+ variable button
76
+ set button -1
77
+ }
78
+ }
79
+
80
+ proc ::tk::dialog::error::DeleteByProtocol {} {
81
+ variable button
82
+ set button 1
83
+ }
84
+
85
+ proc ::tk::dialog::error::ReturnInDetails w {
86
+ bind $w <Return> {}; # Remove this binding
87
+ $w invoke
88
+ return -code break
89
+ }
90
+
91
+ # ::tk::dialog::error::bgerror --
92
+ #
93
+ # This is the default version of bgerror.
94
+ # It tries to execute tkerror, if that fails it posts a dialog box
95
+ # containing the error message and gives the user a chance to ask
96
+ # to see a stack trace.
97
+ #
98
+ # Arguments:
99
+ # err - The error message.
100
+ #
101
+ proc ::tk::dialog::error::bgerror {err {flag 1}} {
102
+ global errorInfo
103
+ variable button
104
+
105
+ set info $errorInfo
106
+
107
+ set ret [catch {::tkerror $err} msg];
108
+ if {$ret != 1} {return -code $ret $msg}
109
+
110
+ # The application's tkerror either failed or was not found
111
+ # so we use the default dialog. But on Aqua we cannot display
112
+ # the dialog if the background error occurs in an idle task
113
+ # being processed inside of [NSView drawRect]. In that case
114
+ # we post the dialog as an after task instead.
115
+ set windowingsystem [tk windowingsystem]
116
+ if {$windowingsystem eq "aqua"} {
117
+ if $flag {
118
+ set errorInfo $info
119
+ after 500 [list bgerror "$err" 0]
120
+ return
121
+ }
122
+ }
123
+
124
+ set ok [mc OK]
125
+ # Truncate the message if it is too wide (>maxLine characters) or
126
+ # too tall (>4 lines). Truncation occurs at the first point at
127
+ # which one of those conditions is met.
128
+ set displayedErr ""
129
+ set lines 0
130
+ set maxLine 45
131
+ foreach line [split $err \n] {
132
+ if {[string length $line] > $maxLine} {
133
+ append displayedErr "[string range $line 0 $maxLine-3]..."
134
+ break
135
+ }
136
+ if {$lines > 4} {
137
+ append displayedErr "..."
138
+ break
139
+ } else {
140
+ append displayedErr "${line}\n"
141
+ }
142
+ incr lines
143
+ }
144
+
145
+ set title [mc "Application Error"]
146
+ set text [mc "Error: %1\$s" $displayedErr]
147
+ set buttons [list ok $ok dismiss [mc "Skip Messages"] \
148
+ function [mc "Details >>"]]
149
+
150
+ # 1. Create the top-level window and divide it into top
151
+ # and bottom parts.
152
+
153
+ set dlg .bgerrorDialog
154
+ set bg [ttk::style lookup . -background]
155
+ destroy $dlg
156
+ toplevel $dlg -class ErrorDialog -background $bg
157
+ wm withdraw $dlg
158
+ wm title $dlg $title
159
+ wm iconname $dlg ErrorDialog
160
+ wm protocol $dlg WM_DELETE_WINDOW [namespace code DeleteByProtocol]
161
+
162
+ if {$windowingsystem eq "aqua"} {
163
+ ::tk::unsupported::MacWindowStyle style $dlg moveableAlert {}
164
+ } elseif {$windowingsystem eq "x11"} {
165
+ wm attributes $dlg -type dialog
166
+ }
167
+
168
+ ttk::frame $dlg.bot
169
+ ttk::frame $dlg.top
170
+ pack $dlg.bot -side bottom -fill both
171
+ pack $dlg.top -side top -fill both -expand 1
172
+
173
+ set W [ttk::frame $dlg.top.info]
174
+ text $W.text -setgrid true -height 10 -wrap char \
175
+ -yscrollcommand [list $W.scroll set]
176
+ if {$windowingsystem ne "aqua"} {
177
+ $W.text configure -width 40
178
+ }
179
+
180
+ ttk::scrollbar $W.scroll -command [list $W.text yview]
181
+ pack $W.scroll -side right -fill y
182
+ pack $W.text -side left -expand yes -fill both
183
+ $W.text insert 0.0 "$err\n$info"
184
+ $W.text mark set insert 0.0
185
+ bind $W.text <Button-1> {focus %W}
186
+ $W.text configure -state disabled
187
+
188
+ # 2. Fill the top part with bitmap and message
189
+
190
+ # Max-width of message is the width of the screen...
191
+ set wrapwidth [winfo screenwidth $dlg]
192
+ # ...minus the width of the icon, padding and a fudge factor for
193
+ # the window manager decorations and aesthetics.
194
+ set wrapwidth [expr {$wrapwidth-60-[winfo pixels $dlg 9m]}]
195
+ ttk::label $dlg.msg -justify left -text $text -wraplength $wrapwidth
196
+ ttk::label $dlg.bitmap -image ::tk::icons::error
197
+
198
+ grid $dlg.bitmap $dlg.msg -in $dlg.top -row 0 -padx 3m -pady 3m
199
+ grid configure $dlg.bitmap -sticky ne
200
+ grid configure $dlg.msg -sticky nsw -padx {0 3m}
201
+ grid rowconfigure $dlg.top 1 -weight 1
202
+ grid columnconfigure $dlg.top 1 -weight 1
203
+
204
+ # 3. Create a row of buttons at the bottom of the dialog.
205
+
206
+ set i 0
207
+ foreach {name caption} $buttons {
208
+ ttk::button $dlg.$name -text $caption -default normal \
209
+ -command [namespace code [list set button $i]]
210
+ grid $dlg.$name -in $dlg.bot -column $i -row 0 -sticky ew -padx 10
211
+ grid columnconfigure $dlg.bot $i -weight 1
212
+ # We boost the size of some Mac buttons for l&f
213
+ if {$windowingsystem eq "aqua"} {
214
+ if {($name eq "ok") || ($name eq "dismiss")} {
215
+ grid columnconfigure $dlg.bot $i -minsize 90
216
+ }
217
+ grid configure $dlg.$name -pady 7
218
+ }
219
+ incr i
220
+ }
221
+ # The "OK" button is the default for this dialog.
222
+ $dlg.ok configure -default active
223
+
224
+ bind $dlg <Return> [namespace code {Return ok 0}]
225
+ bind $dlg <Escape> [namespace code {Return dismiss 1}]
226
+ bind $dlg <Destroy> [namespace code {Destroy %W}]
227
+ bind $dlg.function <Return> [namespace code {ReturnInDetails %W}]
228
+ $dlg.function configure -command [namespace code Details]
229
+
230
+ # 6. Withdraw the window, then update all the geometry information
231
+ # so we know how big it wants to be, then center the window in the
232
+ # display (Motif style) and de-iconify it.
233
+
234
+ ::tk::PlaceWindow $dlg
235
+
236
+ # 7. Set a grab and claim the focus too.
237
+
238
+ ::tk::SetFocusGrab $dlg $dlg.ok
239
+
240
+ # 8. Ensure that we are topmost.
241
+
242
+ raise $dlg
243
+ if {[tk windowingsystem] eq "win32"} {
244
+ # Place it topmost if we aren't at the top of the stacking
245
+ # order to ensure that it's seen
246
+ if {[lindex [wm stackorder .] end] ne "$dlg"} {
247
+ wm attributes $dlg -topmost 1
248
+ }
249
+ }
250
+
251
+ # 9. Wait for the user to respond, then restore the focus and
252
+ # return the index of the selected button. Restore the focus
253
+ # before deleting the window, since otherwise the window manager
254
+ # may take the focus away so we can't redirect it. Finally,
255
+ # restore any grab that was in effect.
256
+
257
+ vwait [namespace which -variable button]
258
+ set copy $button; # Save a copy...
259
+
260
+ ::tk::RestoreFocusGrab $dlg $dlg.ok destroy
261
+
262
+ if {$copy == 1} {
263
+ return -code break
264
+ }
265
+ }
266
+
267
+ namespace eval :: {
268
+ # Fool the indexer
269
+ proc bgerror err {}
270
+ rename bgerror {}
271
+ namespace import ::tk::dialog::error::bgerror
272
+ }
janus/lib/tk8.6/choosedir.tcl ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # choosedir.tcl --
2
+ #
3
+ # Choose directory dialog implementation for Unix/Mac.
4
+ #
5
+ # Copyright (c) 1998-2000 by Scriptics Corporation.
6
+ # All rights reserved.
7
+
8
+ # Make sure the tk::dialog namespace, in which all dialogs should live, exists
9
+ namespace eval ::tk::dialog {}
10
+ namespace eval ::tk::dialog::file {}
11
+
12
+ # Make the chooseDir namespace inside the dialog namespace
13
+ namespace eval ::tk::dialog::file::chooseDir {
14
+ namespace import -force ::tk::msgcat::*
15
+ }
16
+
17
+ # ::tk::dialog::file::chooseDir:: --
18
+ #
19
+ # Implements the TK directory selection dialog.
20
+ #
21
+ # Arguments:
22
+ # args Options parsed by the procedure.
23
+ #
24
+ proc ::tk::dialog::file::chooseDir:: {args} {
25
+ variable ::tk::Priv
26
+ set dataName __tk_choosedir
27
+ upvar ::tk::dialog::file::$dataName data
28
+ Config $dataName $args
29
+
30
+ if {$data(-parent) eq "."} {
31
+ set w .$dataName
32
+ } else {
33
+ set w $data(-parent).$dataName
34
+ }
35
+
36
+ # (re)create the dialog box if necessary
37
+ #
38
+ if {![winfo exists $w]} {
39
+ ::tk::dialog::file::Create $w TkChooseDir
40
+ } elseif {[winfo class $w] ne "TkChooseDir"} {
41
+ destroy $w
42
+ ::tk::dialog::file::Create $w TkChooseDir
43
+ } else {
44
+ set data(dirMenuBtn) $w.contents.f1.menu
45
+ set data(dirMenu) $w.contents.f1.menu.menu
46
+ set data(upBtn) $w.contents.f1.up
47
+ set data(icons) $w.contents.icons
48
+ set data(ent) $w.contents.f2.ent
49
+ set data(okBtn) $w.contents.f2.ok
50
+ set data(cancelBtn) $w.contents.f2.cancel
51
+ set data(hiddenBtn) $w.contents.f2.hidden
52
+ }
53
+ if {$::tk::dialog::file::showHiddenBtn} {
54
+ $data(hiddenBtn) configure -state normal
55
+ grid $data(hiddenBtn)
56
+ } else {
57
+ $data(hiddenBtn) configure -state disabled
58
+ grid remove $data(hiddenBtn)
59
+ }
60
+
61
+ # When using -mustexist, manage the OK button state for validity
62
+ $data(okBtn) configure -state normal
63
+ if {$data(-mustexist)} {
64
+ $data(ent) configure -validate key \
65
+ -validatecommand [list ::tk::dialog::file::chooseDir::IsOK? $w %P]
66
+ } else {
67
+ $data(ent) configure -validate none
68
+ }
69
+
70
+ # Dialog boxes should be transient with respect to their parent,
71
+ # so that they will always stay on top of their parent window. However,
72
+ # some window managers will create the window as withdrawn if the parent
73
+ # window is withdrawn or iconified. Combined with the grab we put on the
74
+ # window, this can hang the entire application. Therefore we only make
75
+ # the dialog transient if the parent is viewable.
76
+
77
+ if {[winfo viewable [winfo toplevel $data(-parent)]] } {
78
+ wm transient $w $data(-parent)
79
+ }
80
+
81
+ trace add variable data(selectPath) write \
82
+ [list ::tk::dialog::file::SetPath $w]
83
+ $data(dirMenuBtn) configure \
84
+ -textvariable ::tk::dialog::file::${dataName}(selectPath)
85
+
86
+ set data(filter) "*"
87
+ set data(previousEntryText) ""
88
+ ::tk::dialog::file::UpdateWhenIdle $w
89
+
90
+ # Withdraw the window, then update all the geometry information
91
+ # so we know how big it wants to be, then center the window in the
92
+ # display (Motif style) and de-iconify it.
93
+
94
+ ::tk::PlaceWindow $w widget $data(-parent)
95
+ wm title $w $data(-title)
96
+
97
+ # Set a grab and claim the focus too.
98
+
99
+ ::tk::SetFocusGrab $w $data(ent)
100
+ $data(ent) delete 0 end
101
+ $data(ent) insert 0 $data(selectPath)
102
+ $data(ent) selection range 0 end
103
+ $data(ent) icursor end
104
+
105
+ # Wait for the user to respond, then restore the focus and
106
+ # return the index of the selected button. Restore the focus
107
+ # before deleting the window, since otherwise the window manager
108
+ # may take the focus away so we can't redirect it. Finally,
109
+ # restore any grab that was in effect.
110
+
111
+ vwait ::tk::Priv(selectFilePath)
112
+
113
+ ::tk::RestoreFocusGrab $w $data(ent) withdraw
114
+
115
+ # Cleanup traces on selectPath variable
116
+ #
117
+
118
+ foreach trace [trace info variable data(selectPath)] {
119
+ trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1]
120
+ }
121
+ if {[winfo exists $data(dirMenuBtn)]} {
122
+ $data(dirMenuBtn) configure -textvariable {}
123
+ }
124
+
125
+ # Return value to user
126
+ #
127
+
128
+ return $Priv(selectFilePath)
129
+ }
130
+
131
+ # ::tk::dialog::file::chooseDir::Config --
132
+ #
133
+ # Configures the Tk choosedir dialog according to the argument list
134
+ #
135
+ proc ::tk::dialog::file::chooseDir::Config {dataName argList} {
136
+ upvar ::tk::dialog::file::$dataName data
137
+
138
+ # 0: Delete all variable that were set on data(selectPath) the
139
+ # last time the file dialog is used. The traces may cause troubles
140
+ # if the dialog is now used with a different -parent option.
141
+ #
142
+ foreach trace [trace info variable data(selectPath)] {
143
+ trace remove variable data(selectPath) [lindex $trace 0] [lindex $trace 1]
144
+ }
145
+
146
+ # 1: the configuration specs
147
+ #
148
+ set specs {
149
+ {-mustexist "" "" 0}
150
+ {-initialdir "" "" ""}
151
+ {-parent "" "" "."}
152
+ {-title "" "" ""}
153
+ }
154
+
155
+ # 2: default values depending on the type of the dialog
156
+ #
157
+ if {![info exists data(selectPath)]} {
158
+ # first time the dialog has been popped up
159
+ set data(selectPath) [pwd]
160
+ }
161
+
162
+ # 3: parse the arguments
163
+ #
164
+ tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList
165
+
166
+ if {$data(-title) eq ""} {
167
+ set data(-title) "[mc "Choose Directory"]"
168
+ }
169
+
170
+ # Stub out the -multiple value for the dialog; it doesn't make sense for
171
+ # choose directory dialogs, but we have to have something there because we
172
+ # share so much code with the file dialogs.
173
+ set data(-multiple) 0
174
+
175
+ # 4: set the default directory and selection according to the -initial
176
+ # settings
177
+ #
178
+ if {$data(-initialdir) ne ""} {
179
+ # Ensure that initialdir is an absolute path name.
180
+ if {[file isdirectory $data(-initialdir)]} {
181
+ set old [pwd]
182
+ cd $data(-initialdir)
183
+ set data(selectPath) [pwd]
184
+ cd $old
185
+ } else {
186
+ set data(selectPath) [pwd]
187
+ }
188
+ }
189
+
190
+ if {![winfo exists $data(-parent)]} {
191
+ return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
192
+ "bad window path name \"$data(-parent)\""
193
+ }
194
+ }
195
+
196
+ # Gets called when user presses Return in the "Selection" entry or presses OK.
197
+ #
198
+ proc ::tk::dialog::file::chooseDir::OkCmd {w} {
199
+ upvar ::tk::dialog::file::[winfo name $w] data
200
+
201
+ # This is the brains behind selecting non-existant directories. Here's
202
+ # the flowchart:
203
+ # 1. If the icon list has a selection, join it with the current dir,
204
+ # and return that value.
205
+ # 1a. If the icon list does not have a selection ...
206
+ # 2. If the entry is empty, do nothing.
207
+ # 3. If the entry contains an invalid directory, then...
208
+ # 3a. If the value is the same as last time through here, end dialog.
209
+ # 3b. If the value is different than last time, save it and return.
210
+ # 4. If entry contains a valid directory, then...
211
+ # 4a. If the value is the same as the current directory, end dialog.
212
+ # 4b. If the value is different from the current directory, change to
213
+ # that directory.
214
+
215
+ set selection [$data(icons) selection get]
216
+ if {[llength $selection] != 0} {
217
+ set iconText [$data(icons) get [lindex $selection 0]]
218
+ set iconText [file join $data(selectPath) $iconText]
219
+ Done $w $iconText
220
+ } else {
221
+ set text [$data(ent) get]
222
+ if {$text eq ""} {
223
+ return
224
+ }
225
+ set text [file join {*}[file split [string trim $text]]]
226
+ if {![file exists $text] || ![file isdirectory $text]} {
227
+ # Entry contains an invalid directory. If it's the same as the
228
+ # last time they came through here, reset the saved value and end
229
+ # the dialog. Otherwise, save the value (so we can do this test
230
+ # next time).
231
+ if {$text eq $data(previousEntryText)} {
232
+ set data(previousEntryText) ""
233
+ Done $w $text
234
+ } else {
235
+ set data(previousEntryText) $text
236
+ }
237
+ } else {
238
+ # Entry contains a valid directory. If it is the same as the
239
+ # current directory, end the dialog. Otherwise, change to that
240
+ # directory.
241
+ if {$text eq $data(selectPath)} {
242
+ Done $w $text
243
+ } else {
244
+ set data(selectPath) $text
245
+ }
246
+ }
247
+ }
248
+ return
249
+ }
250
+
251
+ # Change state of OK button to match -mustexist correctness of entry
252
+ #
253
+ proc ::tk::dialog::file::chooseDir::IsOK? {w text} {
254
+ upvar ::tk::dialog::file::[winfo name $w] data
255
+
256
+ set ok [file isdirectory $text]
257
+ $data(okBtn) configure -state [expr {$ok ? "normal" : "disabled"}]
258
+
259
+ # always return 1
260
+ return 1
261
+ }
262
+
263
+ proc ::tk::dialog::file::chooseDir::DblClick {w} {
264
+ upvar ::tk::dialog::file::[winfo name $w] data
265
+ set selection [$data(icons) selection get]
266
+ if {[llength $selection] != 0} {
267
+ set filenameFragment [$data(icons) get [lindex $selection 0]]
268
+ set file $data(selectPath)
269
+ if {[file isdirectory $file]} {
270
+ ::tk::dialog::file::ListInvoke $w [list $filenameFragment]
271
+ return
272
+ }
273
+ }
274
+ }
275
+
276
+ # Gets called when user browses the IconList widget (dragging mouse, arrow
277
+ # keys, etc)
278
+ #
279
+ proc ::tk::dialog::file::chooseDir::ListBrowse {w text} {
280
+ upvar ::tk::dialog::file::[winfo name $w] data
281
+
282
+ if {$text eq ""} {
283
+ return
284
+ }
285
+
286
+ set file [::tk::dialog::file::JoinFile $data(selectPath) $text]
287
+ $data(ent) delete 0 end
288
+ $data(ent) insert 0 $file
289
+ }
290
+
291
+ # ::tk::dialog::file::chooseDir::Done --
292
+ #
293
+ # Gets called when user has input a valid filename. Pops up a
294
+ # dialog box to confirm selection when necessary. Sets the
295
+ # Priv(selectFilePath) variable, which will break the "vwait"
296
+ # loop in tk_chooseDirectory and return the selected filename to the
297
+ # script that calls tk_getOpenFile or tk_getSaveFile
298
+ #
299
+ proc ::tk::dialog::file::chooseDir::Done {w {selectFilePath ""}} {
300
+ upvar ::tk::dialog::file::[winfo name $w] data
301
+ variable ::tk::Priv
302
+
303
+ if {$selectFilePath eq ""} {
304
+ set selectFilePath $data(selectPath)
305
+ }
306
+ if {$data(-mustexist) && ![file isdirectory $selectFilePath]} {
307
+ return
308
+ }
309
+ set Priv(selectFilePath) $selectFilePath
310
+ }
janus/lib/tk8.6/comdlg.tcl ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # comdlg.tcl --
2
+ #
3
+ # Some functions needed for the common dialog boxes. Probably need to go
4
+ # in a different file.
5
+ #
6
+ # Copyright (c) 1996 Sun Microsystems, Inc.
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+ #
11
+
12
+ # tclParseConfigSpec --
13
+ #
14
+ # Parses a list of "-option value" pairs. If all options and
15
+ # values are legal, the values are stored in
16
+ # $data($option). Otherwise an error message is returned. When
17
+ # an error happens, the data() array may have been partially
18
+ # modified, but all the modified members of the data(0 array are
19
+ # guaranteed to have valid values. This is different than
20
+ # Tk_ConfigureWidget() which does not modify the value of a
21
+ # widget record if any error occurs.
22
+ #
23
+ # Arguments:
24
+ #
25
+ # w = widget record to modify. Must be the pathname of a widget.
26
+ #
27
+ # specs = {
28
+ # {-commandlineswitch resourceName ResourceClass defaultValue verifier}
29
+ # {....}
30
+ # }
31
+ #
32
+ # flags = a list of flags. Currently supported flags are:
33
+ # DONTSETDEFAULTS = skip default values setting
34
+ #
35
+ # argList = The list of "-option value" pairs.
36
+ #
37
+ proc tclParseConfigSpec {w specs flags argList} {
38
+ upvar #0 $w data
39
+
40
+ # 1: Put the specs in associative arrays for faster access
41
+ #
42
+ foreach spec $specs {
43
+ if {[llength $spec] < 4} {
44
+ return -code error -errorcode {TK VALUE CONFIG_SPEC} \
45
+ "\"spec\" should contain 5 or 4 elements"
46
+ }
47
+ set cmdsw [lindex $spec 0]
48
+ set cmd($cmdsw) ""
49
+ set rname($cmdsw) [lindex $spec 1]
50
+ set rclass($cmdsw) [lindex $spec 2]
51
+ set def($cmdsw) [lindex $spec 3]
52
+ set verproc($cmdsw) [lindex $spec 4]
53
+ }
54
+
55
+ if {[llength $argList] & 1} {
56
+ set cmdsw [lindex $argList end]
57
+ if {![info exists cmd($cmdsw)]} {
58
+ return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \
59
+ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]"
60
+ }
61
+ return -code error -errorcode {TK VALUE_MISSING} \
62
+ "value for \"$cmdsw\" missing"
63
+ }
64
+
65
+ # 2: set the default values
66
+ #
67
+ if {"DONTSETDEFAULTS" ni $flags} {
68
+ foreach cmdsw [array names cmd] {
69
+ set data($cmdsw) $def($cmdsw)
70
+ }
71
+ }
72
+
73
+ # 3: parse the argument list
74
+ #
75
+ foreach {cmdsw value} $argList {
76
+ if {![info exists cmd($cmdsw)]} {
77
+ return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \
78
+ "bad option \"$cmdsw\": must be [tclListValidFlags cmd]"
79
+ }
80
+ set data($cmdsw) $value
81
+ }
82
+
83
+ # Done!
84
+ }
85
+
86
+ proc tclListValidFlags {v} {
87
+ upvar $v cmd
88
+
89
+ set len [llength [array names cmd]]
90
+ set i 1
91
+ set separator ""
92
+ set errormsg ""
93
+ foreach cmdsw [lsort [array names cmd]] {
94
+ append errormsg "$separator$cmdsw"
95
+ incr i
96
+ if {$i == $len} {
97
+ set separator ", or "
98
+ } else {
99
+ set separator ", "
100
+ }
101
+ }
102
+ return $errormsg
103
+ }
104
+
105
+ #----------------------------------------------------------------------
106
+ #
107
+ # Focus Group
108
+ #
109
+ # Focus groups are used to handle the user's focusing actions inside a
110
+ # toplevel.
111
+ #
112
+ # One example of using focus groups is: when the user focuses on an
113
+ # entry, the text in the entry is highlighted and the cursor is put to
114
+ # the end of the text. When the user changes focus to another widget,
115
+ # the text in the previously focused entry is validated.
116
+ #
117
+ #----------------------------------------------------------------------
118
+
119
+
120
+ # ::tk::FocusGroup_Create --
121
+ #
122
+ # Create a focus group. All the widgets in a focus group must be
123
+ # within the same focus toplevel. Each toplevel can have only
124
+ # one focus group, which is identified by the name of the
125
+ # toplevel widget.
126
+ #
127
+ proc ::tk::FocusGroup_Create {t} {
128
+ variable ::tk::Priv
129
+ if {[winfo toplevel $t] ne $t} {
130
+ return -code error -errorcode [list TK LOOKUP TOPLEVEL $t] \
131
+ "$t is not a toplevel window"
132
+ }
133
+ if {![info exists Priv(fg,$t)]} {
134
+ set Priv(fg,$t) 1
135
+ set Priv(focus,$t) ""
136
+ bind $t <FocusIn> [list tk::FocusGroup_In $t %W %d]
137
+ bind $t <FocusOut> [list tk::FocusGroup_Out $t %W %d]
138
+ bind $t <Destroy> [list tk::FocusGroup_Destroy $t %W]
139
+ }
140
+ }
141
+
142
+ # ::tk::FocusGroup_BindIn --
143
+ #
144
+ # Add a widget into the "FocusIn" list of the focus group. The $cmd will be
145
+ # called when the widget is focused on by the user.
146
+ #
147
+ proc ::tk::FocusGroup_BindIn {t w cmd} {
148
+ variable FocusIn
149
+ variable ::tk::Priv
150
+ if {![info exists Priv(fg,$t)]} {
151
+ return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \
152
+ "focus group \"$t\" doesn't exist"
153
+ }
154
+ set FocusIn($t,$w) $cmd
155
+ }
156
+
157
+
158
+ # ::tk::FocusGroup_BindOut --
159
+ #
160
+ # Add a widget into the "FocusOut" list of the focus group. The
161
+ # $cmd will be called when the widget loses the focus (User
162
+ # types Tab or click on another widget).
163
+ #
164
+ proc ::tk::FocusGroup_BindOut {t w cmd} {
165
+ variable FocusOut
166
+ variable ::tk::Priv
167
+ if {![info exists Priv(fg,$t)]} {
168
+ return -code error -errorcode [list TK LOOKUP FOCUS_GROUP $t] \
169
+ "focus group \"$t\" doesn't exist"
170
+ }
171
+ set FocusOut($t,$w) $cmd
172
+ }
173
+
174
+ # ::tk::FocusGroup_Destroy --
175
+ #
176
+ # Cleans up when members of the focus group is deleted, or when the
177
+ # toplevel itself gets deleted.
178
+ #
179
+ proc ::tk::FocusGroup_Destroy {t w} {
180
+ variable FocusIn
181
+ variable FocusOut
182
+ variable ::tk::Priv
183
+
184
+ if {$t eq $w} {
185
+ unset Priv(fg,$t)
186
+ unset Priv(focus,$t)
187
+
188
+ foreach name [array names FocusIn $t,*] {
189
+ unset FocusIn($name)
190
+ }
191
+ foreach name [array names FocusOut $t,*] {
192
+ unset FocusOut($name)
193
+ }
194
+ } else {
195
+ if {[info exists Priv(focus,$t)] && ($Priv(focus,$t) eq $w)} {
196
+ set Priv(focus,$t) ""
197
+ }
198
+ unset -nocomplain FocusIn($t,$w) FocusOut($t,$w)
199
+ }
200
+ }
201
+
202
+ # ::tk::FocusGroup_In --
203
+ #
204
+ # Handles the <FocusIn> event. Calls the FocusIn command for the newly
205
+ # focused widget in the focus group.
206
+ #
207
+ proc ::tk::FocusGroup_In {t w detail} {
208
+ variable FocusIn
209
+ variable ::tk::Priv
210
+
211
+ if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} {
212
+ # This is caused by mouse moving out&in of the window *or*
213
+ # ordinary keypresses some window managers (ie: CDE [Bug: 2960]).
214
+ return
215
+ }
216
+ if {![info exists FocusIn($t,$w)]} {
217
+ set FocusIn($t,$w) ""
218
+ return
219
+ }
220
+ if {![info exists Priv(focus,$t)]} {
221
+ return
222
+ }
223
+ if {$Priv(focus,$t) eq $w} {
224
+ # This is already in focus
225
+ #
226
+ return
227
+ } else {
228
+ set Priv(focus,$t) $w
229
+ eval $FocusIn($t,$w)
230
+ }
231
+ }
232
+
233
+ # ::tk::FocusGroup_Out --
234
+ #
235
+ # Handles the <FocusOut> event. Checks if this is really a lose
236
+ # focus event, not one generated by the mouse moving out of the
237
+ # toplevel window. Calls the FocusOut command for the widget
238
+ # who loses its focus.
239
+ #
240
+ proc ::tk::FocusGroup_Out {t w detail} {
241
+ variable FocusOut
242
+ variable ::tk::Priv
243
+
244
+ if {$detail ne "NotifyNonlinear" && $detail ne "NotifyNonlinearVirtual"} {
245
+ # This is caused by mouse moving out of the window
246
+ return
247
+ }
248
+ if {![info exists Priv(focus,$t)]} {
249
+ return
250
+ }
251
+ if {![info exists FocusOut($t,$w)]} {
252
+ return
253
+ } else {
254
+ eval $FocusOut($t,$w)
255
+ set Priv(focus,$t) ""
256
+ }
257
+ }
258
+
259
+ # ::tk::FDGetFileTypes --
260
+ #
261
+ # Process the string given by the -filetypes option of the file
262
+ # dialogs. Similar to the C function TkGetFileFilters() on the Mac
263
+ # and Windows platform.
264
+ #
265
+ proc ::tk::FDGetFileTypes {string} {
266
+ foreach t $string {
267
+ if {[llength $t] < 2 || [llength $t] > 3} {
268
+ return -code error -errorcode {TK VALUE FILE_TYPE} \
269
+ "bad file type \"$t\", should be \"typeName {extension ?extensions ...?} ?{macType ?macTypes ...?}?\""
270
+ }
271
+ lappend fileTypes([lindex $t 0]) {*}[lindex $t 1]
272
+ }
273
+
274
+ set types {}
275
+ foreach t $string {
276
+ set label [lindex $t 0]
277
+ set exts {}
278
+
279
+ if {[info exists hasDoneType($label)]} {
280
+ continue
281
+ }
282
+
283
+ # Validate each macType. This is to agree with the
284
+ # behaviour of TkGetFileFilters(). This list may be
285
+ # empty.
286
+ foreach macType [lindex $t 2] {
287
+ if {[string length $macType] != 4} {
288
+ return -code error -errorcode {TK VALUE MAC_TYPE} \
289
+ "bad Macintosh file type \"$macType\""
290
+ }
291
+ }
292
+
293
+ set name "$label \("
294
+ set sep ""
295
+ set doAppend 1
296
+ foreach ext $fileTypes($label) {
297
+ if {$ext eq ""} {
298
+ continue
299
+ }
300
+ regsub {^[.]} $ext "*." ext
301
+ if {![info exists hasGotExt($label,$ext)]} {
302
+ if {$doAppend} {
303
+ if {[string length $sep] && [string length $name]>40} {
304
+ set doAppend 0
305
+ append name $sep...
306
+ } else {
307
+ append name $sep$ext
308
+ }
309
+ }
310
+ lappend exts $ext
311
+ set hasGotExt($label,$ext) 1
312
+ }
313
+ set sep ","
314
+ }
315
+ append name "\)"
316
+ lappend types [list $name $exts]
317
+
318
+ set hasDoneType($label) 1
319
+ }
320
+
321
+ return $types
322
+ }
janus/lib/tk8.6/demos/README ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This directory contains a collection of programs to demonstrate
2
+ the features of the Tk toolkit. The programs are all scripts for
3
+ "wish", a windowing shell. If wish has been installed on your path
4
+ then you can invoke any of the programs in this directory just
5
+ by typing its file name to your command shell under Unix. Otherwise
6
+ invoke wish with the file as its first argument, e.g., "wish hello".
7
+ The rest of this file contains a brief description of each program.
8
+ Files with names ending in ".tcl" are procedure packages used by one
9
+ or more of the demo programs; they can't be used as programs by
10
+ themselves so they aren't described below.
11
+
12
+ hello - Creates a single button; if you click on it, a message
13
+ is typed and the application terminates.
14
+
15
+ widget - Contains a collection of demonstrations of the widgets
16
+ currently available in the Tk library. Most of the .tcl
17
+ files are scripts for individual demos available through
18
+ the "widget" program.
19
+
20
+ ixset - A simple Tk-based wrapper for the "xset" program, which
21
+ allows you to interactively query and set various X options
22
+ such as mouse acceleration and bell volume. Thanks to
23
+ Pierre David for contributing this example.
24
+
25
+ rolodex - A mock-up of a simple rolodex application. It has much of
26
+ the user interface for such an application but no back-end
27
+ database. This program was written in response to Tom
28
+ LaStrange's toolkit benchmark challenge.
29
+
30
+ tcolor - A color editor. Allows you to edit colors in several
31
+ different ways, and will also perform automatic updates
32
+ using "send".
33
+
34
+ rmt - Allows you to "hook-up" remotely to any Tk application
35
+ on the display. Select an application with the menu,
36
+ then just type commands: they'll go to that application.
37
+
38
+ timer - Displays a seconds timer with start and stop buttons.
39
+ Control-c and control-q cause it to exit.
40
+
41
+ browse - A simple directory browser. Invoke it with and argument
42
+ giving the name of the directory you'd like to browse.
43
+ Double-click on files or subdirectories to browse them.
44
+ Control-c and control-q cause the program to exit.
janus/lib/tk8.6/demos/anilabel.tcl ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # anilabel.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several animated label 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 .anilabel
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Animated Label Demonstration"
16
+ wm iconname $w "anilabel"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "Four animated labels are displayed below; each of the labels on the left is animated by making the text message inside it appear to scroll, and the label on the right is animated by animating the image that it displays."
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
+ # Ensure that this this is an array
27
+ array set animationCallbacks {}
28
+
29
+ ## This callback is the core of how to do animation in Tcl/Tk; all
30
+ ## animations work in basically the same way, with a procedure that
31
+ ## uses the [after] command to reschedule itself at some point in the
32
+ ## future. Of course, the details of how to update the state will vary
33
+ ## according to what is being animated.
34
+ proc RotateLabelText {w interval} {
35
+ global animationCallbacks
36
+
37
+ # Schedule the calling of this procedure again in the future
38
+ set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
39
+
40
+ # We do marquee-like scrolling text by chopping characters off the
41
+ # front of the text and sticking them on the end.
42
+ set text [$w cget -text]
43
+ set newText [string range $text 1 end][string index $text 0]
44
+ $w configure -text $newText
45
+ }
46
+
47
+ ## A helper procedure to start the animation happening.
48
+ proc animateLabelText {w text interval} {
49
+ global animationCallbacks
50
+
51
+ # Install the text into the widget
52
+ $w configure -text $text
53
+
54
+ # Schedule the start of the animation loop
55
+ set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
56
+
57
+ # Make sure that the animation stops and is cleaned up after itself
58
+ # when the animated label is destroyed. Note that at this point we
59
+ # cannot manipulate the widget itself, as that has already died.
60
+ bind $w <Destroy> {
61
+ after cancel $animationCallbacks(%W)
62
+ unset animationCallbacks(%W)
63
+ }
64
+ }
65
+
66
+ ## Next, a similar pair of procedures to animate a GIF loaded into a
67
+ ## photo image.
68
+ proc SelectNextImageFrame {w interval} {
69
+ global animationCallbacks
70
+ set animationCallbacks($w) \
71
+ [after $interval SelectNextImageFrame $w $interval]
72
+ set image [$w cget -image]
73
+
74
+ # The easy way to animate a GIF!
75
+ set idx -1
76
+ scan [$image cget -format] "GIF -index %d" idx
77
+ if {[catch {
78
+ # Note that we get an error if the index is out of range
79
+ $image configure -format "GIF -index [incr idx]"
80
+ }]} then {
81
+ $image configure -format "GIF -index 0"
82
+ }
83
+ }
84
+ proc animateLabelImage {w imageData interval} {
85
+ global animationCallbacks
86
+
87
+ # Create a multi-frame GIF from base-64-encoded data
88
+ set image [image create photo -format GIF -data $imageData]
89
+
90
+ # Install the image into the widget
91
+ $w configure -image $image
92
+
93
+ # Schedule the start of the animation loop
94
+ set animationCallbacks($w) \
95
+ [after $interval SelectNextImageFrame $w $interval]
96
+
97
+ # Make sure that the animation stops and is cleaned up after itself
98
+ # when the animated label is destroyed. Note that at this point we
99
+ # cannot manipulate the widget itself, as that has already died.
100
+ # Also note that this script is in double-quotes; this is always OK
101
+ # because image names are chosen automatically to be simple words.
102
+ bind $w <Destroy> "
103
+ after cancel \$animationCallbacks(%W)
104
+ unset animationCallbacks(%W)
105
+ rename $image {}
106
+ "
107
+ }
108
+
109
+ # Make some widgets to contain the animations
110
+ labelframe $w.left -text "Scrolling Texts"
111
+ labelframe $w.right -text "GIF Image"
112
+ pack $w.left $w.right -side left -padx 10 -pady 10 -expand yes
113
+
114
+ # This method of scrolling text looks far better with a fixed-width font
115
+ label $w.left.l1 -bd 4 -relief ridge -font fixedFont
116
+ label $w.left.l2 -bd 4 -relief groove -font fixedFont
117
+ label $w.left.l3 -bd 4 -relief flat -font fixedFont -width 18
118
+ pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 10 -pady 10 -anchor w
119
+ # Don't need to do very much with this label except turn off the border
120
+ label $w.right.l -bd 0
121
+ pack $w.right.l -side top -expand yes -padx 10 -pady 10
122
+
123
+ # This is a base-64-encoded animated GIF file.
124
+ set tclPoweredData {
125
+ R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM
126
+ zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm
127
+ mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt
128
+ YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP
129
+ dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM
130
+ ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC
131
+ DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0
132
+ qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6
133
+ NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT
134
+ 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk
135
+ UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY
136
+ 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC
137
+ Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4
138
+ AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn
139
+ wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo
140
+ IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY
141
+ 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a
142
+ N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2
143
+ KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA
144
+ LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK
145
+ z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA
146
+ eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+
147
+ r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc
148
+ WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF
149
+ CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A
150
+ NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR
151
+ oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j
152
+ Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7
153
+ ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw==
154
+ }
155
+
156
+ # Finally, set up the text scrolling animation
157
+ animateLabelText $w.left.l1 "* Slow Animation *" 300
158
+ animateLabelText $w.left.l2 "* Fast Animation *" 80
159
+ animateLabelText $w.left.l3 "This is a longer scrolling text in a widget that will not show the whole message at once. " 150
160
+ animateLabelImage $w.right.l $tclPoweredData 100
janus/lib/tk8.6/demos/button.tcl ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # button.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several button 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 .button
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Button Demonstration"
16
+ wm iconname $w "button"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button. You can press Tab to move among the buttons, then press Space to invoke the current button."
20
+ pack $w.msg -side top
21
+
22
+ ## See Code / Dismiss buttons
23
+ pack [addSeeDismiss $w.buttons $w] -side bottom -fill x
24
+
25
+ proc colorrefresh {w col} {
26
+ $w configure -bg $col
27
+ if {[tk windowingsystem] eq "aqua"} {
28
+ # set highlightbackground of all buttons in $w
29
+ set l [list $w]
30
+ while {[llength $l]} {
31
+ set l [concat [lassign $l b] [winfo children $b]]
32
+ if {[winfo class $b] eq "Button"} {
33
+ $b configure -highlightbackground $col
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ button $w.b1 -text "Peach Puff" -width 10 \
40
+ -command [list colorrefresh $w PeachPuff1]
41
+ button $w.b2 -text "Light Blue" -width 10 \
42
+ -command [list colorrefresh $w LightBlue1]
43
+ button $w.b3 -text "Sea Green" -width 10 \
44
+ -command [list colorrefresh $w SeaGreen2]
45
+ button $w.b4 -text "Yellow" -width 10 \
46
+ -command [list colorrefresh $w Yellow1]
47
+ pack $w.b1 $w.b2 $w.b3 $w.b4 -side top -expand yes -pady 2
janus/lib/tk8.6/demos/clrpick.tcl ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # clrpick.tcl --
2
+ #
3
+ # This demonstration script prompts the user to select a color.
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 .clrpick
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Color Selection Dialog"
15
+ wm iconname $w "colors"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 4i -justify left -text "Press the buttons below to choose the foreground and background colors for the widgets in this window."
19
+ pack $w.msg -side top
20
+
21
+ ## See Code / Dismiss buttons
22
+ set btns [addSeeDismiss $w.buttons $w]
23
+ pack $btns -side bottom -fill x
24
+
25
+ button $w.back -text "Set background color ..." \
26
+ -command \
27
+ "setColor $w $w.back background {-background -highlightbackground}"
28
+ button $w.fore -text "Set foreground color ..." \
29
+ -command \
30
+ "setColor $w $w.back foreground -foreground"
31
+
32
+ pack $w.back $w.fore -side top -anchor c -pady 2m
33
+
34
+ proc setColor {w button name options} {
35
+ grab $w
36
+ set initialColor [$button cget -$name]
37
+ set color [tk_chooseColor -title "Choose a $name color" -parent $w \
38
+ -initialcolor $initialColor]
39
+ if {[string compare $color ""]} {
40
+ setColor_helper $w $options $color
41
+ }
42
+ grab release $w
43
+ }
44
+
45
+ proc setColor_helper {w options color} {
46
+ foreach option $options {
47
+ catch {
48
+ $w config $option $color
49
+ }
50
+ }
51
+ foreach child [winfo children $w] {
52
+ setColor_helper $child $options $color
53
+ }
54
+ }
janus/lib/tk8.6/demos/dialog1.tcl ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dialog1.tcl --
2
+ #
3
+ # This demonstration script creates a dialog box with a local grab.
4
+
5
+ interp create child
6
+ load {} Tk child
7
+ child eval {
8
+ wm title . child
9
+ wm geometry . +700+30
10
+ pack [text .t -width 30 -height 10]
11
+ }
12
+
13
+ after idle {.dialog1.msg configure -wraplength 4i}
14
+ set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "child" which was created by a child interpreter.} \
15
+ info 0 OK Cancel {Show Code}]
16
+
17
+ switch $i {
18
+ 0 {puts "You pressed OK"}
19
+ 1 {puts "You pressed Cancel"}
20
+ 2 {showCode .dialog1}
21
+ }
22
+
23
+ if {[interp exists child]} {
24
+ interp delete child
25
+ }
janus/lib/tk8.6/demos/dialog2.tcl ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dialog2.tcl --
2
+ #
3
+ # This demonstration script creates a dialog box with a global grab.
4
+
5
+ after idle {
6
+ .dialog2.msg configure -wraplength 4i
7
+ }
8
+ after 100 {
9
+ grab -global .dialog2
10
+ }
11
+ set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\
12
+ warning 0 OK Cancel {Show Code}]
13
+
14
+ switch $i {
15
+ 0 {puts "You pressed OK"}
16
+ 1 {puts "You pressed Cancel"}
17
+ 2 {showCode .dialog2}
18
+ }
janus/lib/tk8.6/demos/entry1.tcl ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry1.tcl --
2
+ #
3
+ # This demonstration script creates several entry widgets without
4
+ # scrollbars.
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 .entry1
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Entry Demonstration (no scrollbars)"
16
+ wm iconname $w "entry1"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse the middle mouse button pressed."
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
+ entry $w.e1
27
+ entry $w.e2
28
+ entry $w.e3
29
+ pack $w.e1 $w.e2 $w.e3 -side top -pady 5 -padx 10 -fill x
30
+
31
+ $w.e1 insert 0 "Initial value"
32
+ $w.e2 insert end "This entry contains a long value, much too long "
33
+ $w.e2 insert end "to fit in the window at one time, so long in fact "
34
+ $w.e2 insert end "that you'll have to scan or scroll to see the end."
janus/lib/tk8.6/demos/entry2.tcl ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry2.tcl --
2
+ #
3
+ # This demonstration script is the same as the entry1.tcl script
4
+ # except that it creates scrollbars for the entries.
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 .entry2
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Entry Demonstration (with scrollbars)"
16
+ wm iconname $w "entry2"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed."
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
+ frame $w.frame -borderwidth 10
27
+ pack $w.frame -side top -fill x -expand 1
28
+
29
+ entry $w.frame.e1 -xscrollcommand "$w.frame.s1 set"
30
+ ttk::scrollbar $w.frame.s1 -orient horizontal -command \
31
+ "$w.frame.e1 xview"
32
+ frame $w.frame.spacer1 -width 20 -height 10
33
+ entry $w.frame.e2 -xscrollcommand "$w.frame.s2 set"
34
+ ttk::scrollbar $w.frame.s2 -orient horizontal -command \
35
+ "$w.frame.e2 xview"
36
+ frame $w.frame.spacer2 -width 20 -height 10
37
+ entry $w.frame.e3 -xscrollcommand "$w.frame.s3 set"
38
+ ttk::scrollbar $w.frame.s3 -orient horizontal -command \
39
+ "$w.frame.e3 xview"
40
+ pack $w.frame.e1 $w.frame.s1 $w.frame.spacer1 $w.frame.e2 $w.frame.s2 \
41
+ $w.frame.spacer2 $w.frame.e3 $w.frame.s3 -side top -fill x
42
+
43
+ $w.frame.e1 insert 0 "Initial value"
44
+ $w.frame.e2 insert end "This entry contains a long value, much too long "
45
+ $w.frame.e2 insert end "to fit in the window at one time, so long in fact "
46
+ $w.frame.e2 insert end "that you'll have to scan or scroll to see the end."
janus/lib/tk8.6/demos/filebox.tcl ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filebox.tcl --
2
+ #
3
+ # This demonstration script prompts the user to select a file.
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 .filebox
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "File Selection Dialogs"
15
+ wm iconname $w "filebox"
16
+ positionWindow $w
17
+
18
+ ttk::frame $w._bg
19
+ place $w._bg -x 0 -y 0 -relwidth 1 -relheight 1
20
+
21
+ ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog."
22
+ pack $w.msg -side top
23
+
24
+ ## See Code / Dismiss buttons
25
+ set btns [addSeeDismiss $w.buttons $w]
26
+ pack $btns -side bottom -fill x
27
+
28
+ foreach i {open save} {
29
+ set f [ttk::frame $w.$i]
30
+ ttk::label $f.lab -text "Select a file to $i: " -anchor e
31
+ ttk::entry $f.ent -width 20
32
+ ttk::button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i"
33
+ pack $f.lab -side left
34
+ pack $f.ent -side left -expand yes -fill x
35
+ pack $f.but -side left
36
+ pack $f -fill x -padx 1c -pady 3
37
+ }
38
+
39
+ if {[tk windowingsystem] eq "x11"} {
40
+ ttk::checkbutton $w.strict -text "Use Motif Style Dialog" \
41
+ -variable tk_strictMotif -onvalue 1 -offvalue 0
42
+ pack $w.strict -anchor c
43
+
44
+ # This binding ensures that we don't run the rest of the demos
45
+ # with motif style interactions
46
+ bind $w.strict <Destroy> {set tk_strictMotif 0}
47
+ }
48
+
49
+ proc fileDialog {w ent operation} {
50
+ # Type names Extension(s) Mac File Type(s)
51
+ #
52
+ #---------------------------------------------------------
53
+ set types {
54
+ {"Text files" {.txt .doc} }
55
+ {"Text files" {} TEXT}
56
+ {"Tcl Scripts" {.tcl} TEXT}
57
+ {"C Source Files" {.c .h} }
58
+ {"All Source Files" {.tcl .c .h} }
59
+ {"Image Files" {.gif} }
60
+ {"Image Files" {.jpeg .jpg} }
61
+ {"Image Files" "" {GIFF JPEG}}
62
+ {"All files" *}
63
+ }
64
+ if {$operation == "open"} {
65
+ global selected_type
66
+ if {![info exists selected_type]} {
67
+ set selected_type "Tcl Scripts"
68
+ }
69
+ set file [tk_getOpenFile -filetypes $types -parent $w \
70
+ -typevariable selected_type]
71
+ puts "You selected filetype \"$selected_type\""
72
+ } else {
73
+ set file [tk_getSaveFile -filetypes $types -parent $w \
74
+ -initialfile Untitled -defaultextension .txt]
75
+ }
76
+ if {[string compare $file ""]} {
77
+ $ent delete 0 end
78
+ $ent insert 0 $file
79
+ $ent xview end
80
+ }
81
+ }
janus/lib/tk8.6/demos/floor.tcl ADDED
@@ -0,0 +1,1372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # floor.tcl --
2
+ #
3
+ # This demonstration script creates a canvas widet that displays the
4
+ # floorplan for DEC's Western Research Laboratory.
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
+ # floorDisplay --
13
+ # Recreate the floorplan display in the canvas given by "w". The
14
+ # floor given by "active" is displayed on top with its office structure
15
+ # visible.
16
+ #
17
+ # Arguments:
18
+ # w - Name of the canvas window.
19
+ # active - Number of active floor (1, 2, or 3).
20
+
21
+ proc floorDisplay {w active} {
22
+ global floorLabels floorItems colors activeFloor
23
+
24
+ if {$activeFloor == $active} {
25
+ return
26
+ }
27
+
28
+ $w delete all
29
+ set activeFloor $active
30
+
31
+ # First go through the three floors, displaying the backgrounds for
32
+ # each floor.
33
+
34
+ bg1 $w $colors(bg1) $colors(outline1)
35
+ bg2 $w $colors(bg2) $colors(outline2)
36
+ bg3 $w $colors(bg3) $colors(outline3)
37
+
38
+ # Raise the background for the active floor so that it's on top.
39
+
40
+ $w raise floor$active
41
+
42
+ # Create a dummy item just to mark this point in the display list,
43
+ # so we can insert highlights here.
44
+
45
+ $w create rect 0 100 1 101 -fill {} -outline {} -tags marker
46
+
47
+ # Add the walls and labels for the active floor, along with
48
+ # transparent polygons that define the rooms on the floor.
49
+ # Make sure that the room polygons are on top.
50
+
51
+ catch {unset floorLabels}
52
+ catch {unset floorItems}
53
+ fg$active $w $colors(offices)
54
+ $w raise room
55
+
56
+ # Offset the floors diagonally from each other.
57
+
58
+ $w move floor1 2c 2c
59
+ $w move floor2 1c 1c
60
+
61
+ # Create items for the room entry and its label.
62
+
63
+ $w create window 600 100 -anchor w -window $w.entry
64
+ $w create text 600 100 -anchor e -text "Room: "
65
+
66
+ $w config -scrollregion [$w bbox all]
67
+ }
68
+
69
+ # newRoom --
70
+ # This procedure is invoked whenever the mouse enters a room
71
+ # in the floorplan. It changes tags so that the current room is
72
+ # highlighted.
73
+ #
74
+ # Arguments:
75
+ # w - The name of the canvas window.
76
+
77
+ proc newRoom w {
78
+ global currentRoom floorLabels
79
+
80
+ set id [$w find withtag current]
81
+ if {$id != ""} {
82
+ set currentRoom $floorLabels($id)
83
+ }
84
+ update idletasks
85
+ }
86
+
87
+ # roomChanged --
88
+ # This procedure is invoked whenever the currentRoom variable changes.
89
+ # It highlights the current room and unhighlights any previous room.
90
+ #
91
+ # Arguments:
92
+ # w - The canvas window displaying the floorplan.
93
+ # args - Not used.
94
+
95
+ proc roomChanged {w args} {
96
+ global currentRoom floorItems colors
97
+ $w delete highlight
98
+ if {[catch {set item $floorItems($currentRoom)}]} {
99
+ return
100
+ }
101
+ set new [eval \
102
+ "$w create polygon [$w coords $item] -fill $colors(active) \
103
+ -outline {} -tags highlight"]
104
+ $w raise $new marker
105
+ }
106
+
107
+ # bg1 --
108
+ # This procedure represents part of the floorplan database. When
109
+ # invoked, it instantiates the background information for the first
110
+ # floor.
111
+ #
112
+ # Arguments:
113
+ # w - The canvas window.
114
+ # fill - Fill color to use for the floor's background.
115
+ # outline - Color to use for the floor's outline.
116
+
117
+ proc bg1 {w fill outline} {
118
+ $w create polygon 347 80 349 82 351 84 353 85 363 92 375 99 386 104 \
119
+ 386 129 398 129 398 162 484 162 484 129 559 129 559 133 725 \
120
+ 133 725 129 802 129 802 389 644 389 644 391 559 391 559 327 \
121
+ 508 327 508 311 484 311 484 278 395 278 395 288 400 288 404 \
122
+ 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 \
123
+ 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 \
124
+ 342 331 347 332 351 334 354 336 357 341 359 340 360 335 363 \
125
+ 331 365 326 366 304 366 304 355 258 355 258 387 60 387 60 391 \
126
+ 0 391 0 337 3 337 3 114 8 114 8 25 30 25 30 5 93 5 98 5 104 7 \
127
+ 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 34 221 \
128
+ 22 223 17 227 13 231 8 236 4 242 2 246 0 260 0 283 1 300 5 \
129
+ 321 14 335 22 348 25 365 29 363 39 358 48 352 56 337 70 \
130
+ 344 76 347 80 \
131
+ -tags {floor1 bg} -fill $fill -outline {}
132
+ $w create line 386 129 398 129 -fill $outline -tags {floor1 bg}
133
+ $w create line 258 355 258 387 -fill $outline -tags {floor1 bg}
134
+ $w create line 60 387 60 391 -fill $outline -tags {floor1 bg}
135
+ $w create line 0 337 0 391 -fill $outline -tags {floor1 bg}
136
+ $w create line 60 391 0 391 -fill $outline -tags {floor1 bg}
137
+ $w create line 3 114 3 337 -fill $outline -tags {floor1 bg}
138
+ $w create line 258 387 60 387 -fill $outline -tags {floor1 bg}
139
+ $w create line 484 162 398 162 -fill $outline -tags {floor1 bg}
140
+ $w create line 398 162 398 129 -fill $outline -tags {floor1 bg}
141
+ $w create line 484 278 484 311 -fill $outline -tags {floor1 bg}
142
+ $w create line 484 311 508 311 -fill $outline -tags {floor1 bg}
143
+ $w create line 508 327 508 311 -fill $outline -tags {floor1 bg}
144
+ $w create line 559 327 508 327 -fill $outline -tags {floor1 bg}
145
+ $w create line 644 391 559 391 -fill $outline -tags {floor1 bg}
146
+ $w create line 644 389 644 391 -fill $outline -tags {floor1 bg}
147
+ $w create line 559 129 484 129 -fill $outline -tags {floor1 bg}
148
+ $w create line 484 162 484 129 -fill $outline -tags {floor1 bg}
149
+ $w create line 725 133 559 133 -fill $outline -tags {floor1 bg}
150
+ $w create line 559 129 559 133 -fill $outline -tags {floor1 bg}
151
+ $w create line 725 129 802 129 -fill $outline -tags {floor1 bg}
152
+ $w create line 802 389 802 129 -fill $outline -tags {floor1 bg}
153
+ $w create line 3 337 0 337 -fill $outline -tags {floor1 bg}
154
+ $w create line 559 391 559 327 -fill $outline -tags {floor1 bg}
155
+ $w create line 802 389 644 389 -fill $outline -tags {floor1 bg}
156
+ $w create line 725 133 725 129 -fill $outline -tags {floor1 bg}
157
+ $w create line 8 25 8 114 -fill $outline -tags {floor1 bg}
158
+ $w create line 8 114 3 114 -fill $outline -tags {floor1 bg}
159
+ $w create line 30 25 8 25 -fill $outline -tags {floor1 bg}
160
+ $w create line 484 278 395 278 -fill $outline -tags {floor1 bg}
161
+ $w create line 30 25 30 5 -fill $outline -tags {floor1 bg}
162
+ $w create line 93 5 30 5 -fill $outline -tags {floor1 bg}
163
+ $w create line 98 5 93 5 -fill $outline -tags {floor1 bg}
164
+ $w create line 104 7 98 5 -fill $outline -tags {floor1 bg}
165
+ $w create line 110 10 104 7 -fill $outline -tags {floor1 bg}
166
+ $w create line 116 16 110 10 -fill $outline -tags {floor1 bg}
167
+ $w create line 119 20 116 16 -fill $outline -tags {floor1 bg}
168
+ $w create line 122 28 119 20 -fill $outline -tags {floor1 bg}
169
+ $w create line 123 32 122 28 -fill $outline -tags {floor1 bg}
170
+ $w create line 123 68 123 32 -fill $outline -tags {floor1 bg}
171
+ $w create line 220 68 123 68 -fill $outline -tags {floor1 bg}
172
+ $w create line 386 129 386 104 -fill $outline -tags {floor1 bg}
173
+ $w create line 386 104 375 99 -fill $outline -tags {floor1 bg}
174
+ $w create line 375 99 363 92 -fill $outline -tags {floor1 bg}
175
+ $w create line 353 85 363 92 -fill $outline -tags {floor1 bg}
176
+ $w create line 220 68 220 34 -fill $outline -tags {floor1 bg}
177
+ $w create line 337 70 352 56 -fill $outline -tags {floor1 bg}
178
+ $w create line 352 56 358 48 -fill $outline -tags {floor1 bg}
179
+ $w create line 358 48 363 39 -fill $outline -tags {floor1 bg}
180
+ $w create line 363 39 365 29 -fill $outline -tags {floor1 bg}
181
+ $w create line 365 29 348 25 -fill $outline -tags {floor1 bg}
182
+ $w create line 348 25 335 22 -fill $outline -tags {floor1 bg}
183
+ $w create line 335 22 321 14 -fill $outline -tags {floor1 bg}
184
+ $w create line 321 14 300 5 -fill $outline -tags {floor1 bg}
185
+ $w create line 300 5 283 1 -fill $outline -tags {floor1 bg}
186
+ $w create line 283 1 260 0 -fill $outline -tags {floor1 bg}
187
+ $w create line 260 0 246 0 -fill $outline -tags {floor1 bg}
188
+ $w create line 246 0 242 2 -fill $outline -tags {floor1 bg}
189
+ $w create line 242 2 236 4 -fill $outline -tags {floor1 bg}
190
+ $w create line 236 4 231 8 -fill $outline -tags {floor1 bg}
191
+ $w create line 231 8 227 13 -fill $outline -tags {floor1 bg}
192
+ $w create line 223 17 227 13 -fill $outline -tags {floor1 bg}
193
+ $w create line 221 22 223 17 -fill $outline -tags {floor1 bg}
194
+ $w create line 220 34 221 22 -fill $outline -tags {floor1 bg}
195
+ $w create line 340 360 335 363 -fill $outline -tags {floor1 bg}
196
+ $w create line 335 363 331 365 -fill $outline -tags {floor1 bg}
197
+ $w create line 331 365 326 366 -fill $outline -tags {floor1 bg}
198
+ $w create line 326 366 304 366 -fill $outline -tags {floor1 bg}
199
+ $w create line 304 355 304 366 -fill $outline -tags {floor1 bg}
200
+ $w create line 395 288 400 288 -fill $outline -tags {floor1 bg}
201
+ $w create line 404 288 400 288 -fill $outline -tags {floor1 bg}
202
+ $w create line 409 290 404 288 -fill $outline -tags {floor1 bg}
203
+ $w create line 413 292 409 290 -fill $outline -tags {floor1 bg}
204
+ $w create line 418 297 413 292 -fill $outline -tags {floor1 bg}
205
+ $w create line 421 302 418 297 -fill $outline -tags {floor1 bg}
206
+ $w create line 422 309 421 302 -fill $outline -tags {floor1 bg}
207
+ $w create line 421 318 422 309 -fill $outline -tags {floor1 bg}
208
+ $w create line 421 318 417 325 -fill $outline -tags {floor1 bg}
209
+ $w create line 417 325 411 330 -fill $outline -tags {floor1 bg}
210
+ $w create line 411 330 405 332 -fill $outline -tags {floor1 bg}
211
+ $w create line 405 332 397 333 -fill $outline -tags {floor1 bg}
212
+ $w create line 397 333 344 333 -fill $outline -tags {floor1 bg}
213
+ $w create line 344 333 340 334 -fill $outline -tags {floor1 bg}
214
+ $w create line 340 334 336 336 -fill $outline -tags {floor1 bg}
215
+ $w create line 336 336 335 338 -fill $outline -tags {floor1 bg}
216
+ $w create line 335 338 332 342 -fill $outline -tags {floor1 bg}
217
+ $w create line 331 347 332 342 -fill $outline -tags {floor1 bg}
218
+ $w create line 332 351 331 347 -fill $outline -tags {floor1 bg}
219
+ $w create line 334 354 332 351 -fill $outline -tags {floor1 bg}
220
+ $w create line 336 357 334 354 -fill $outline -tags {floor1 bg}
221
+ $w create line 341 359 336 357 -fill $outline -tags {floor1 bg}
222
+ $w create line 341 359 340 360 -fill $outline -tags {floor1 bg}
223
+ $w create line 395 288 395 278 -fill $outline -tags {floor1 bg}
224
+ $w create line 304 355 258 355 -fill $outline -tags {floor1 bg}
225
+ $w create line 347 80 344 76 -fill $outline -tags {floor1 bg}
226
+ $w create line 344 76 337 70 -fill $outline -tags {floor1 bg}
227
+ $w create line 349 82 347 80 -fill $outline -tags {floor1 bg}
228
+ $w create line 351 84 349 82 -fill $outline -tags {floor1 bg}
229
+ $w create line 353 85 351 84 -fill $outline -tags {floor1 bg}
230
+ }
231
+
232
+ # bg2 --
233
+ # This procedure represents part of the floorplan database. When
234
+ # invoked, it instantiates the background information for the second
235
+ # floor.
236
+ #
237
+ # Arguments:
238
+ # w - The canvas window.
239
+ # fill - Fill color to use for the floor's background.
240
+ # outline - Color to use for the floor's outline.
241
+
242
+ proc bg2 {w fill outline} {
243
+ $w create polygon 559 129 484 129 484 162 398 162 398 129 315 129 \
244
+ 315 133 176 133 176 129 96 129 96 133 3 133 3 339 0 339 0 391 \
245
+ 60 391 60 387 258 387 258 329 350 329 350 311 395 311 395 280 \
246
+ 484 280 484 311 508 311 508 327 558 327 558 391 644 391 644 \
247
+ 367 802 367 802 129 725 129 725 133 559 133 559 129 \
248
+ -tags {floor2 bg} -fill $fill -outline {}
249
+ $w create line 350 311 350 329 -fill $outline -tags {floor2 bg}
250
+ $w create line 398 129 398 162 -fill $outline -tags {floor2 bg}
251
+ $w create line 802 367 802 129 -fill $outline -tags {floor2 bg}
252
+ $w create line 802 129 725 129 -fill $outline -tags {floor2 bg}
253
+ $w create line 725 133 725 129 -fill $outline -tags {floor2 bg}
254
+ $w create line 559 129 559 133 -fill $outline -tags {floor2 bg}
255
+ $w create line 559 133 725 133 -fill $outline -tags {floor2 bg}
256
+ $w create line 484 162 484 129 -fill $outline -tags {floor2 bg}
257
+ $w create line 559 129 484 129 -fill $outline -tags {floor2 bg}
258
+ $w create line 802 367 644 367 -fill $outline -tags {floor2 bg}
259
+ $w create line 644 367 644 391 -fill $outline -tags {floor2 bg}
260
+ $w create line 644 391 558 391 -fill $outline -tags {floor2 bg}
261
+ $w create line 558 327 558 391 -fill $outline -tags {floor2 bg}
262
+ $w create line 558 327 508 327 -fill $outline -tags {floor2 bg}
263
+ $w create line 508 327 508 311 -fill $outline -tags {floor2 bg}
264
+ $w create line 484 311 508 311 -fill $outline -tags {floor2 bg}
265
+ $w create line 484 280 484 311 -fill $outline -tags {floor2 bg}
266
+ $w create line 398 162 484 162 -fill $outline -tags {floor2 bg}
267
+ $w create line 484 280 395 280 -fill $outline -tags {floor2 bg}
268
+ $w create line 395 280 395 311 -fill $outline -tags {floor2 bg}
269
+ $w create line 258 387 60 387 -fill $outline -tags {floor2 bg}
270
+ $w create line 3 133 3 339 -fill $outline -tags {floor2 bg}
271
+ $w create line 3 339 0 339 -fill $outline -tags {floor2 bg}
272
+ $w create line 60 391 0 391 -fill $outline -tags {floor2 bg}
273
+ $w create line 0 339 0 391 -fill $outline -tags {floor2 bg}
274
+ $w create line 60 387 60 391 -fill $outline -tags {floor2 bg}
275
+ $w create line 258 329 258 387 -fill $outline -tags {floor2 bg}
276
+ $w create line 350 329 258 329 -fill $outline -tags {floor2 bg}
277
+ $w create line 395 311 350 311 -fill $outline -tags {floor2 bg}
278
+ $w create line 398 129 315 129 -fill $outline -tags {floor2 bg}
279
+ $w create line 176 133 315 133 -fill $outline -tags {floor2 bg}
280
+ $w create line 176 129 96 129 -fill $outline -tags {floor2 bg}
281
+ $w create line 3 133 96 133 -fill $outline -tags {floor2 bg}
282
+ $w create line 315 133 315 129 -fill $outline -tags {floor2 bg}
283
+ $w create line 176 133 176 129 -fill $outline -tags {floor2 bg}
284
+ $w create line 96 133 96 129 -fill $outline -tags {floor2 bg}
285
+ }
286
+
287
+ # bg3 --
288
+ # This procedure represents part of the floorplan database. When
289
+ # invoked, it instantiates the background information for the third
290
+ # floor.
291
+ #
292
+ # Arguments:
293
+ # w - The canvas window.
294
+ # fill - Fill color to use for the floor's background.
295
+ # outline - Color to use for the floor's outline.
296
+
297
+ proc bg3 {w fill outline} {
298
+ $w create polygon 159 300 107 300 107 248 159 248 159 129 96 129 96 \
299
+ 133 21 133 21 331 0 331 0 391 60 391 60 370 159 370 159 300 \
300
+ -tags {floor3 bg} -fill $fill -outline {}
301
+ $w create polygon 258 370 258 329 350 329 350 311 399 311 399 129 \
302
+ 315 129 315 133 176 133 176 129 159 129 159 370 258 370 \
303
+ -tags {floor3 bg} -fill $fill -outline {}
304
+ $w create line 96 133 96 129 -fill $outline -tags {floor3 bg}
305
+ $w create line 176 129 96 129 -fill $outline -tags {floor3 bg}
306
+ $w create line 176 129 176 133 -fill $outline -tags {floor3 bg}
307
+ $w create line 315 133 176 133 -fill $outline -tags {floor3 bg}
308
+ $w create line 315 133 315 129 -fill $outline -tags {floor3 bg}
309
+ $w create line 399 129 315 129 -fill $outline -tags {floor3 bg}
310
+ $w create line 399 311 399 129 -fill $outline -tags {floor3 bg}
311
+ $w create line 399 311 350 311 -fill $outline -tags {floor3 bg}
312
+ $w create line 350 329 350 311 -fill $outline -tags {floor3 bg}
313
+ $w create line 350 329 258 329 -fill $outline -tags {floor3 bg}
314
+ $w create line 258 370 258 329 -fill $outline -tags {floor3 bg}
315
+ $w create line 60 370 258 370 -fill $outline -tags {floor3 bg}
316
+ $w create line 60 370 60 391 -fill $outline -tags {floor3 bg}
317
+ $w create line 60 391 0 391 -fill $outline -tags {floor3 bg}
318
+ $w create line 0 391 0 331 -fill $outline -tags {floor3 bg}
319
+ $w create line 21 331 0 331 -fill $outline -tags {floor3 bg}
320
+ $w create line 21 331 21 133 -fill $outline -tags {floor3 bg}
321
+ $w create line 96 133 21 133 -fill $outline -tags {floor3 bg}
322
+ $w create line 107 300 159 300 159 248 107 248 107 300 \
323
+ -fill $outline -tags {floor3 bg}
324
+ }
325
+
326
+ # fg1 --
327
+ # This procedure represents part of the floorplan database. When
328
+ # invoked, it instantiates the foreground information for the first
329
+ # floor (office outlines and numbers).
330
+ #
331
+ # Arguments:
332
+ # w - The canvas window.
333
+ # color - Color to use for drawing foreground information.
334
+
335
+ proc fg1 {w color} {
336
+ global floorLabels floorItems
337
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor1 room}]
338
+ set floorLabels($i) 101
339
+ set {floorItems(101)} $i
340
+ $w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label}
341
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor1 room}]
342
+ set floorLabels($i) {Pub Lift1}
343
+ set {floorItems(Pub Lift1)} $i
344
+ $w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label}
345
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor1 room}]
346
+ set floorLabels($i) {Priv Lift1}
347
+ set {floorItems(Priv Lift1)} $i
348
+ $w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label}
349
+ set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -outline {} -tags {floor1 room}]
350
+ set floorLabels($i) 110
351
+ set {floorItems(110)} $i
352
+ $w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label}
353
+ set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -outline {} -tags {floor1 room}]
354
+ set floorLabels($i) 109
355
+ set {floorItems(109)} $i
356
+ $w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label}
357
+ set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -outline {} -tags {floor1 room}]
358
+ set floorLabels($i) 111
359
+ set {floorItems(111)} $i
360
+ $w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label}
361
+ set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -outline {} -tags {floor1 room}]
362
+ set floorLabels($i) 117B
363
+ set {floorItems(117B)} $i
364
+ $w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label}
365
+ set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -outline {} -tags {floor1 room}]
366
+ set floorLabels($i) 112
367
+ set {floorItems(112)} $i
368
+ $w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label}
369
+ set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -outline {} -tags {floor1 room}]
370
+ set floorLabels($i) 113
371
+ set {floorItems(113)} $i
372
+ $w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label}
373
+ set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -outline {} -tags {floor1 room}]
374
+ set floorLabels($i) 117A
375
+ set {floorItems(117A)} $i
376
+ $w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label}
377
+ set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -outline {} -tags {floor1 room}]
378
+ set floorLabels($i) 117
379
+ set {floorItems(117)} $i
380
+ $w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label}
381
+ set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -outline {} -tags {floor1 room}]
382
+ set floorLabels($i) 114
383
+ set {floorItems(114)} $i
384
+ $w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label}
385
+ set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -outline {} -tags {floor1 room}]
386
+ set floorLabels($i) 115
387
+ set {floorItems(115)} $i
388
+ $w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label}
389
+ set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -outline {} -tags {floor1 room}]
390
+ set floorLabels($i) 116
391
+ set {floorItems(116)} $i
392
+ $w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label}
393
+ set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -outline {} -tags {floor1 room}]
394
+ set floorLabels($i) 118
395
+ set {floorItems(118)} $i
396
+ $w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label}
397
+ set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -outline {} -tags {floor1 room}]
398
+ set floorLabels($i) 120
399
+ set {floorItems(120)} $i
400
+ $w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label}
401
+ set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -outline {} -tags {floor1 room}]
402
+ set floorLabels($i) 122
403
+ set {floorItems(122)} $i
404
+ $w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label}
405
+ set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -outline {} -tags {floor1 room}]
406
+ set floorLabels($i) 121
407
+ set {floorItems(121)} $i
408
+ $w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label}
409
+ set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -outline {} -tags {floor1 room}]
410
+ set floorLabels($i) 106A
411
+ set {floorItems(106A)} $i
412
+ $w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label}
413
+ set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -outline {} -tags {floor1 room}]
414
+ set floorLabels($i) 105
415
+ set {floorItems(105)} $i
416
+ $w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label}
417
+ set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -outline {} -tags {floor1 room}]
418
+ set floorLabels($i) 106B
419
+ set {floorItems(106B)} $i
420
+ $w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label}
421
+ set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -outline {} -tags {floor1 room}]
422
+ set floorLabels($i) 104
423
+ set {floorItems(104)} $i
424
+ $w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label}
425
+ set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -outline {} -tags {floor1 room}]
426
+ set floorLabels($i) 108
427
+ set {floorItems(108)} $i
428
+ $w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label}
429
+ set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -outline {} -tags {floor1 room}]
430
+ set floorLabels($i) 107
431
+ set {floorItems(107)} $i
432
+ $w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label}
433
+ set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -outline {} -tags {floor1 room}]
434
+ set floorLabels($i) Smoking
435
+ set {floorItems(Smoking)} $i
436
+ $w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label}
437
+ set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -outline {} -tags {floor1 room}]
438
+ set floorLabels($i) 123
439
+ set {floorItems(123)} $i
440
+ $w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label}
441
+ set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -outline {} -tags {floor1 room}]
442
+ set floorLabels($i) 103
443
+ set {floorItems(103)} $i
444
+ $w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label}
445
+ set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -outline {} -tags {floor1 room}]
446
+ set floorLabels($i) 124
447
+ set {floorItems(124)} $i
448
+ $w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label}
449
+ set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -outline {} -tags {floor1 room}]
450
+ set floorLabels($i) 125
451
+ set {floorItems(125)} $i
452
+ $w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label}
453
+ set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -outline {} -tags {floor1 room}]
454
+ set floorLabels($i) 126
455
+ set {floorItems(126)} $i
456
+ $w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label}
457
+ set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -outline {} -tags {floor1 room}]
458
+ set floorLabels($i) 127
459
+ set {floorItems(127)} $i
460
+ $w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label}
461
+ set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -outline {} -tags {floor1 room}]
462
+ set floorLabels($i) MShower
463
+ set {floorItems(MShower)} $i
464
+ $w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label}
465
+ set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -outline {} -tags {floor1 room}]
466
+ set floorLabels($i) Closet
467
+ set {floorItems(Closet)} $i
468
+ $w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label}
469
+ set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -outline {} -tags {floor1 room}]
470
+ set floorLabels($i) WShower
471
+ set {floorItems(WShower)} $i
472
+ $w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label}
473
+ set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -outline {} -tags {floor1 room}]
474
+ set floorLabels($i) 130
475
+ set {floorItems(130)} $i
476
+ $w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label}
477
+ set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -outline {} -tags {floor1 room}]
478
+ set floorLabels($i) 102
479
+ set {floorItems(102)} $i
480
+ $w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label}
481
+ set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -outline {} -tags {floor1 room}]
482
+ set floorLabels($i) 128
483
+ set {floorItems(128)} $i
484
+ $w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label}
485
+ set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -outline {} -tags {floor1 room}]
486
+ set floorLabels($i) 129
487
+ set {floorItems(129)} $i
488
+ $w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label}
489
+ set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -outline {} -tags {floor1 room}]
490
+ set floorLabels($i) 133
491
+ set {floorItems(133)} $i
492
+ $w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label}
493
+ set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -outline {} -tags {floor1 room}]
494
+ set floorLabels($i) 132
495
+ set {floorItems(132)} $i
496
+ $w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label}
497
+ set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -outline {} -tags {floor1 room}]
498
+ set floorLabels($i) 134
499
+ set {floorItems(134)} $i
500
+ $w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label}
501
+ set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -outline {} -tags {floor1 room}]
502
+ set floorLabels($i) 135
503
+ set {floorItems(135)} $i
504
+ $w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label}
505
+ set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -outline {} -tags {floor1 room}]
506
+ set floorLabels($i) {Ramona Stair}
507
+ set {floorItems(Ramona Stair)} $i
508
+ $w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label}
509
+ set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -outline {} -tags {floor1 room}]
510
+ set floorLabels($i) {University Stair}
511
+ set {floorItems(University Stair)} $i
512
+ $w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label}
513
+ set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -outline {} -tags {floor1 room}]
514
+ set floorLabels($i) {Plaza Stair}
515
+ set {floorItems(Plaza Stair)} $i
516
+ $w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label}
517
+ set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -outline {} -tags {floor1 room}]
518
+ set floorLabels($i) {Plaza Deck}
519
+ set {floorItems(Plaza Deck)} $i
520
+ $w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label}
521
+ set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -outline {} -tags {floor1 room}]
522
+ set floorLabels($i) 106
523
+ set {floorItems(106)} $i
524
+ $w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label}
525
+ set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -outline {} -tags {floor1 room}]
526
+ set floorLabels($i) 119
527
+ set {floorItems(119)} $i
528
+ $w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label}
529
+ $w create line 155 191 155 189 -fill $color -tags {floor1 wall}
530
+ $w create line 155 177 155 169 -fill $color -tags {floor1 wall}
531
+ $w create line 96 129 96 169 -fill $color -tags {floor1 wall}
532
+ $w create line 78 169 176 169 -fill $color -tags {floor1 wall}
533
+ $w create line 176 247 176 129 -fill $color -tags {floor1 wall}
534
+ $w create line 340 206 307 206 -fill $color -tags {floor1 wall}
535
+ $w create line 340 187 340 170 -fill $color -tags {floor1 wall}
536
+ $w create line 340 210 340 201 -fill $color -tags {floor1 wall}
537
+ $w create line 340 247 340 224 -fill $color -tags {floor1 wall}
538
+ $w create line 340 241 307 241 -fill $color -tags {floor1 wall}
539
+ $w create line 376 246 376 170 -fill $color -tags {floor1 wall}
540
+ $w create line 307 247 307 170 -fill $color -tags {floor1 wall}
541
+ $w create line 376 170 307 170 -fill $color -tags {floor1 wall}
542
+ $w create line 315 129 315 170 -fill $color -tags {floor1 wall}
543
+ $w create line 147 129 176 129 -fill $color -tags {floor1 wall}
544
+ $w create line 202 133 176 133 -fill $color -tags {floor1 wall}
545
+ $w create line 398 129 315 129 -fill $color -tags {floor1 wall}
546
+ $w create line 258 352 258 387 -fill $color -tags {floor1 wall}
547
+ $w create line 60 387 60 391 -fill $color -tags {floor1 wall}
548
+ $w create line 0 337 0 391 -fill $color -tags {floor1 wall}
549
+ $w create line 60 391 0 391 -fill $color -tags {floor1 wall}
550
+ $w create line 3 114 3 337 -fill $color -tags {floor1 wall}
551
+ $w create line 258 387 60 387 -fill $color -tags {floor1 wall}
552
+ $w create line 52 237 52 273 -fill $color -tags {floor1 wall}
553
+ $w create line 52 189 52 225 -fill $color -tags {floor1 wall}
554
+ $w create line 52 140 52 177 -fill $color -tags {floor1 wall}
555
+ $w create line 395 306 395 311 -fill $color -tags {floor1 wall}
556
+ $w create line 531 254 398 254 -fill $color -tags {floor1 wall}
557
+ $w create line 475 178 475 238 -fill $color -tags {floor1 wall}
558
+ $w create line 502 162 398 162 -fill $color -tags {floor1 wall}
559
+ $w create line 398 129 398 188 -fill $color -tags {floor1 wall}
560
+ $w create line 383 188 376 188 -fill $color -tags {floor1 wall}
561
+ $w create line 408 188 408 194 -fill $color -tags {floor1 wall}
562
+ $w create line 398 227 398 254 -fill $color -tags {floor1 wall}
563
+ $w create line 408 227 398 227 -fill $color -tags {floor1 wall}
564
+ $w create line 408 222 408 227 -fill $color -tags {floor1 wall}
565
+ $w create line 408 206 408 210 -fill $color -tags {floor1 wall}
566
+ $w create line 408 208 475 208 -fill $color -tags {floor1 wall}
567
+ $w create line 484 278 484 311 -fill $color -tags {floor1 wall}
568
+ $w create line 484 311 508 311 -fill $color -tags {floor1 wall}
569
+ $w create line 508 327 508 311 -fill $color -tags {floor1 wall}
570
+ $w create line 559 327 508 327 -fill $color -tags {floor1 wall}
571
+ $w create line 644 391 559 391 -fill $color -tags {floor1 wall}
572
+ $w create line 644 389 644 391 -fill $color -tags {floor1 wall}
573
+ $w create line 514 205 475 205 -fill $color -tags {floor1 wall}
574
+ $w create line 496 189 496 187 -fill $color -tags {floor1 wall}
575
+ $w create line 559 129 484 129 -fill $color -tags {floor1 wall}
576
+ $w create line 484 162 484 129 -fill $color -tags {floor1 wall}
577
+ $w create line 725 133 559 133 -fill $color -tags {floor1 wall}
578
+ $w create line 559 129 559 133 -fill $color -tags {floor1 wall}
579
+ $w create line 725 149 725 167 -fill $color -tags {floor1 wall}
580
+ $w create line 725 129 802 129 -fill $color -tags {floor1 wall}
581
+ $w create line 802 389 802 129 -fill $color -tags {floor1 wall}
582
+ $w create line 739 167 802 167 -fill $color -tags {floor1 wall}
583
+ $w create line 396 188 408 188 -fill $color -tags {floor1 wall}
584
+ $w create line 0 337 9 337 -fill $color -tags {floor1 wall}
585
+ $w create line 58 337 21 337 -fill $color -tags {floor1 wall}
586
+ $w create line 43 391 43 337 -fill $color -tags {floor1 wall}
587
+ $w create line 105 337 75 337 -fill $color -tags {floor1 wall}
588
+ $w create line 91 387 91 337 -fill $color -tags {floor1 wall}
589
+ $w create line 154 337 117 337 -fill $color -tags {floor1 wall}
590
+ $w create line 139 387 139 337 -fill $color -tags {floor1 wall}
591
+ $w create line 227 337 166 337 -fill $color -tags {floor1 wall}
592
+ $w create line 258 337 251 337 -fill $color -tags {floor1 wall}
593
+ $w create line 258 328 302 328 -fill $color -tags {floor1 wall}
594
+ $w create line 302 355 302 311 -fill $color -tags {floor1 wall}
595
+ $w create line 395 311 302 311 -fill $color -tags {floor1 wall}
596
+ $w create line 484 278 395 278 -fill $color -tags {floor1 wall}
597
+ $w create line 395 294 395 278 -fill $color -tags {floor1 wall}
598
+ $w create line 473 278 473 275 -fill $color -tags {floor1 wall}
599
+ $w create line 473 256 473 254 -fill $color -tags {floor1 wall}
600
+ $w create line 533 257 531 254 -fill $color -tags {floor1 wall}
601
+ $w create line 553 276 551 274 -fill $color -tags {floor1 wall}
602
+ $w create line 698 276 553 276 -fill $color -tags {floor1 wall}
603
+ $w create line 559 391 559 327 -fill $color -tags {floor1 wall}
604
+ $w create line 802 389 644 389 -fill $color -tags {floor1 wall}
605
+ $w create line 741 314 741 389 -fill $color -tags {floor1 wall}
606
+ $w create line 698 280 698 167 -fill $color -tags {floor1 wall}
607
+ $w create line 707 280 698 280 -fill $color -tags {floor1 wall}
608
+ $w create line 802 280 731 280 -fill $color -tags {floor1 wall}
609
+ $w create line 741 280 741 302 -fill $color -tags {floor1 wall}
610
+ $w create line 698 167 727 167 -fill $color -tags {floor1 wall}
611
+ $w create line 725 137 725 129 -fill $color -tags {floor1 wall}
612
+ $w create line 514 254 514 175 -fill $color -tags {floor1 wall}
613
+ $w create line 496 175 514 175 -fill $color -tags {floor1 wall}
614
+ $w create line 502 175 502 162 -fill $color -tags {floor1 wall}
615
+ $w create line 475 166 475 162 -fill $color -tags {floor1 wall}
616
+ $w create line 496 176 496 175 -fill $color -tags {floor1 wall}
617
+ $w create line 491 189 496 189 -fill $color -tags {floor1 wall}
618
+ $w create line 491 205 491 189 -fill $color -tags {floor1 wall}
619
+ $w create line 487 238 475 238 -fill $color -tags {floor1 wall}
620
+ $w create line 487 240 487 238 -fill $color -tags {floor1 wall}
621
+ $w create line 487 252 487 254 -fill $color -tags {floor1 wall}
622
+ $w create line 315 133 304 133 -fill $color -tags {floor1 wall}
623
+ $w create line 256 133 280 133 -fill $color -tags {floor1 wall}
624
+ $w create line 78 247 270 247 -fill $color -tags {floor1 wall}
625
+ $w create line 307 247 294 247 -fill $color -tags {floor1 wall}
626
+ $w create line 214 133 232 133 -fill $color -tags {floor1 wall}
627
+ $w create line 217 247 217 266 -fill $color -tags {floor1 wall}
628
+ $w create line 217 309 217 291 -fill $color -tags {floor1 wall}
629
+ $w create line 217 309 172 309 -fill $color -tags {floor1 wall}
630
+ $w create line 154 309 148 309 -fill $color -tags {floor1 wall}
631
+ $w create line 175 300 175 309 -fill $color -tags {floor1 wall}
632
+ $w create line 151 300 175 300 -fill $color -tags {floor1 wall}
633
+ $w create line 151 247 151 309 -fill $color -tags {floor1 wall}
634
+ $w create line 78 237 78 265 -fill $color -tags {floor1 wall}
635
+ $w create line 78 286 78 309 -fill $color -tags {floor1 wall}
636
+ $w create line 106 309 78 309 -fill $color -tags {floor1 wall}
637
+ $w create line 130 309 125 309 -fill $color -tags {floor1 wall}
638
+ $w create line 99 309 99 247 -fill $color -tags {floor1 wall}
639
+ $w create line 127 299 99 299 -fill $color -tags {floor1 wall}
640
+ $w create line 127 309 127 299 -fill $color -tags {floor1 wall}
641
+ $w create line 155 191 137 191 -fill $color -tags {floor1 wall}
642
+ $w create line 137 169 137 191 -fill $color -tags {floor1 wall}
643
+ $w create line 78 171 78 169 -fill $color -tags {floor1 wall}
644
+ $w create line 78 190 78 218 -fill $color -tags {floor1 wall}
645
+ $w create line 86 192 86 169 -fill $color -tags {floor1 wall}
646
+ $w create line 86 192 78 192 -fill $color -tags {floor1 wall}
647
+ $w create line 52 301 3 301 -fill $color -tags {floor1 wall}
648
+ $w create line 52 286 52 301 -fill $color -tags {floor1 wall}
649
+ $w create line 52 252 3 252 -fill $color -tags {floor1 wall}
650
+ $w create line 52 203 3 203 -fill $color -tags {floor1 wall}
651
+ $w create line 3 156 52 156 -fill $color -tags {floor1 wall}
652
+ $w create line 8 25 8 114 -fill $color -tags {floor1 wall}
653
+ $w create line 63 114 3 114 -fill $color -tags {floor1 wall}
654
+ $w create line 75 114 97 114 -fill $color -tags {floor1 wall}
655
+ $w create line 108 114 129 114 -fill $color -tags {floor1 wall}
656
+ $w create line 129 114 129 89 -fill $color -tags {floor1 wall}
657
+ $w create line 52 114 52 128 -fill $color -tags {floor1 wall}
658
+ $w create line 132 89 88 89 -fill $color -tags {floor1 wall}
659
+ $w create line 88 25 88 89 -fill $color -tags {floor1 wall}
660
+ $w create line 88 114 88 89 -fill $color -tags {floor1 wall}
661
+ $w create line 218 89 144 89 -fill $color -tags {floor1 wall}
662
+ $w create line 147 111 147 129 -fill $color -tags {floor1 wall}
663
+ $w create line 162 111 147 111 -fill $color -tags {floor1 wall}
664
+ $w create line 162 109 162 111 -fill $color -tags {floor1 wall}
665
+ $w create line 162 96 162 89 -fill $color -tags {floor1 wall}
666
+ $w create line 218 89 218 94 -fill $color -tags {floor1 wall}
667
+ $w create line 218 89 218 119 -fill $color -tags {floor1 wall}
668
+ $w create line 8 25 88 25 -fill $color -tags {floor1 wall}
669
+ $w create line 258 337 258 328 -fill $color -tags {floor1 wall}
670
+ $w create line 113 129 96 129 -fill $color -tags {floor1 wall}
671
+ $w create line 302 355 258 355 -fill $color -tags {floor1 wall}
672
+ $w create line 386 104 386 129 -fill $color -tags {floor1 wall}
673
+ $w create line 377 100 386 104 -fill $color -tags {floor1 wall}
674
+ $w create line 365 94 377 100 -fill $color -tags {floor1 wall}
675
+ $w create line 350 83 365 94 -fill $color -tags {floor1 wall}
676
+ $w create line 337 70 350 83 -fill $color -tags {floor1 wall}
677
+ $w create line 337 70 323 56 -fill $color -tags {floor1 wall}
678
+ $w create line 312 49 323 56 -fill $color -tags {floor1 wall}
679
+ $w create line 295 40 312 49 -fill $color -tags {floor1 wall}
680
+ $w create line 282 37 295 40 -fill $color -tags {floor1 wall}
681
+ $w create line 260 34 282 37 -fill $color -tags {floor1 wall}
682
+ $w create line 253 34 260 34 -fill $color -tags {floor1 wall}
683
+ $w create line 386 128 386 104 -fill $color -tags {floor1 wall}
684
+ $w create line 113 152 156 152 -fill $color -tags {floor1 wall}
685
+ $w create line 113 152 156 152 -fill $color -tags {floor1 wall}
686
+ $w create line 113 152 113 129 -fill $color -tags {floor1 wall}
687
+ }
688
+
689
+ # fg2 --
690
+ # This procedure represents part of the floorplan database. When
691
+ # invoked, it instantiates the foreground information for the second
692
+ # floor (office outlines and numbers).
693
+ #
694
+ # Arguments:
695
+ # w - The canvas window.
696
+ # color - Color to use for drawing foreground information.
697
+
698
+ proc fg2 {w color} {
699
+ global floorLabels floorItems
700
+ set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -outline {} -tags {floor2 room}]
701
+ set floorLabels($i) 238
702
+ set {floorItems(238)} $i
703
+ $w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label}
704
+ set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -outline {} -tags {floor2 room}]
705
+ set floorLabels($i) 237
706
+ set {floorItems(237)} $i
707
+ $w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label}
708
+ set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -outline {} -tags {floor2 room}]
709
+ set floorLabels($i) 246
710
+ set {floorItems(246)} $i
711
+ $w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label}
712
+ set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -outline {} -tags {floor2 room}]
713
+ set floorLabels($i) 247
714
+ set {floorItems(247)} $i
715
+ $w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label}
716
+ set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -outline {} -tags {floor2 room}]
717
+ set floorLabels($i) 202
718
+ set {floorItems(202)} $i
719
+ $w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label}
720
+ set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -outline {} -tags {floor2 room}]
721
+ set floorLabels($i) 206
722
+ set {floorItems(206)} $i
723
+ $w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label}
724
+ set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -outline {} -tags {floor2 room}]
725
+ set floorLabels($i) 212
726
+ set {floorItems(212)} $i
727
+ $w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label}
728
+ set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -outline {} -tags {floor2 room}]
729
+ set floorLabels($i) 245
730
+ set {floorItems(245)} $i
731
+ $w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label}
732
+ set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -outline {} -tags {floor2 room}]
733
+ set floorLabels($i) 244
734
+ set {floorItems(244)} $i
735
+ $w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label}
736
+ set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -outline {} -tags {floor2 room}]
737
+ set floorLabels($i) 243
738
+ set {floorItems(243)} $i
739
+ $w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label}
740
+ set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -outline {} -tags {floor2 room}]
741
+ set floorLabels($i) 242
742
+ set {floorItems(242)} $i
743
+ $w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label}
744
+ set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -outline {} -tags {floor2 room}]
745
+ set floorLabels($i) {Barbecue Deck}
746
+ set {floorItems(Barbecue Deck)} $i
747
+ $w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label}
748
+ set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -outline {} -tags {floor2 room}]
749
+ set floorLabels($i) 240
750
+ set {floorItems(240)} $i
751
+ $w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label}
752
+ set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -outline {} -tags {floor2 room}]
753
+ set floorLabels($i) 241
754
+ set {floorItems(241)} $i
755
+ $w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label}
756
+ set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -outline {} -tags {floor2 room}]
757
+ set floorLabels($i) 239
758
+ set {floorItems(239)} $i
759
+ $w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label}
760
+ set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -outline {} -tags {floor2 room}]
761
+ set floorLabels($i) 248
762
+ set {floorItems(248)} $i
763
+ $w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label}
764
+ set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -outline {} -tags {floor2 room}]
765
+ set floorLabels($i) 236
766
+ set {floorItems(236)} $i
767
+ $w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label}
768
+ set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -outline {} -tags {floor2 room}]
769
+ set floorLabels($i) 235
770
+ set {floorItems(235)} $i
771
+ $w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label}
772
+ set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -outline {} -tags {floor2 room}]
773
+ set floorLabels($i) 234
774
+ set {floorItems(234)} $i
775
+ $w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label}
776
+ set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -outline {} -tags {floor2 room}]
777
+ set floorLabels($i) 233
778
+ set {floorItems(233)} $i
779
+ $w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label}
780
+ set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -outline {} -tags {floor2 room}]
781
+ set floorLabels($i) 230
782
+ set {floorItems(230)} $i
783
+ $w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label}
784
+ set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -outline {} -tags {floor2 room}]
785
+ set floorLabels($i) 232
786
+ set {floorItems(232)} $i
787
+ $w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label}
788
+ set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -outline {} -tags {floor2 room}]
789
+ set floorLabels($i) 229
790
+ set {floorItems(229)} $i
791
+ $w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label}
792
+ set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -outline {} -tags {floor2 room}]
793
+ set floorLabels($i) 227
794
+ set {floorItems(227)} $i
795
+ $w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label}
796
+ set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -outline {} -tags {floor2 room}]
797
+ set floorLabels($i) 228
798
+ set {floorItems(228)} $i
799
+ $w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label}
800
+ set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -outline {} -tags {floor2 room}]
801
+ set floorLabels($i) 226
802
+ set {floorItems(226)} $i
803
+ $w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label}
804
+ set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -outline {} -tags {floor2 room}]
805
+ set floorLabels($i) 225
806
+ set {floorItems(225)} $i
807
+ $w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label}
808
+ set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -outline {} -tags {floor2 room}]
809
+ set floorLabels($i) 224
810
+ set {floorItems(224)} $i
811
+ $w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label}
812
+ set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -outline {} -tags {floor2 room}]
813
+ set floorLabels($i) 223
814
+ set {floorItems(223)} $i
815
+ $w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label}
816
+ set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -outline {} -tags {floor2 room}]
817
+ set floorLabels($i) 222
818
+ set {floorItems(222)} $i
819
+ $w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label}
820
+ set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -outline {} -tags {floor2 room}]
821
+ set floorLabels($i) 221
822
+ set {floorItems(221)} $i
823
+ $w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label}
824
+ set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -outline {} -tags {floor2 room}]
825
+ set floorLabels($i) 204
826
+ set {floorItems(204)} $i
827
+ $w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label}
828
+ set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -outline {} -tags {floor2 room}]
829
+ set floorLabels($i) 205
830
+ set {floorItems(205)} $i
831
+ $w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label}
832
+ set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -outline {} -tags {floor2 room}]
833
+ set floorLabels($i) 207
834
+ set {floorItems(207)} $i
835
+ $w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label}
836
+ set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -outline {} -tags {floor2 room}]
837
+ set floorLabels($i) 208
838
+ set {floorItems(208)} $i
839
+ $w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label}
840
+ set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -outline {} -tags {floor2 room}]
841
+ set floorLabels($i) 209
842
+ set {floorItems(209)} $i
843
+ $w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label}
844
+ set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -outline {} -tags {floor2 room}]
845
+ set floorLabels($i) 217
846
+ set {floorItems(217)} $i
847
+ $w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label}
848
+ set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -outline {} -tags {floor2 room}]
849
+ set floorLabels($i) 217A
850
+ set {floorItems(217A)} $i
851
+ $w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label}
852
+ set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -outline {} -tags {floor2 room}]
853
+ set floorLabels($i) 216
854
+ set {floorItems(216)} $i
855
+ $w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label}
856
+ set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -outline {} -tags {floor2 room}]
857
+ set floorLabels($i) 215
858
+ set {floorItems(215)} $i
859
+ $w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label}
860
+ set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -outline {} -tags {floor2 room}]
861
+ set floorLabels($i) 214
862
+ set {floorItems(214)} $i
863
+ $w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label}
864
+ set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -outline {} -tags {floor2 room}]
865
+ set floorLabels($i) 213
866
+ set {floorItems(213)} $i
867
+ $w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label}
868
+ set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -outline {} -tags {floor2 room}]
869
+ set floorLabels($i) 210
870
+ set {floorItems(210)} $i
871
+ $w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label}
872
+ set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -outline {} -tags {floor2 room}]
873
+ set floorLabels($i) 211
874
+ set {floorItems(211)} $i
875
+ $w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label}
876
+ set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -outline {} -tags {floor2 room}]
877
+ set floorLabels($i) 203
878
+ set {floorItems(203)} $i
879
+ $w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label}
880
+ set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -outline {} -tags {floor2 room}]
881
+ set floorLabels($i) 220
882
+ set {floorItems(220)} $i
883
+ $w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label}
884
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor2 room}]
885
+ set floorLabels($i) {Priv Lift2}
886
+ set {floorItems(Priv Lift2)} $i
887
+ $w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label}
888
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor2 room}]
889
+ set floorLabels($i) {Pub Lift 2}
890
+ set {floorItems(Pub Lift 2)} $i
891
+ $w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label}
892
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor2 room}]
893
+ set floorLabels($i) 218
894
+ set {floorItems(218)} $i
895
+ $w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label}
896
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor2 room}]
897
+ set floorLabels($i) 219
898
+ set {floorItems(219)} $i
899
+ $w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label}
900
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor2 room}]
901
+ set floorLabels($i) 201
902
+ set {floorItems(201)} $i
903
+ $w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label}
904
+ $w create line 641 186 678 186 -fill $color -tags {floor2 wall}
905
+ $w create line 757 350 757 367 -fill $color -tags {floor2 wall}
906
+ $w create line 634 133 634 144 -fill $color -tags {floor2 wall}
907
+ $w create line 634 144 627 144 -fill $color -tags {floor2 wall}
908
+ $w create line 572 133 572 144 -fill $color -tags {floor2 wall}
909
+ $w create line 572 144 579 144 -fill $color -tags {floor2 wall}
910
+ $w create line 398 129 398 162 -fill $color -tags {floor2 wall}
911
+ $w create line 174 197 175 197 -fill $color -tags {floor2 wall}
912
+ $w create line 175 197 175 227 -fill $color -tags {floor2 wall}
913
+ $w create line 757 206 757 221 -fill $color -tags {floor2 wall}
914
+ $w create line 396 188 408 188 -fill $color -tags {floor2 wall}
915
+ $w create line 727 189 725 189 -fill $color -tags {floor2 wall}
916
+ $w create line 747 167 802 167 -fill $color -tags {floor2 wall}
917
+ $w create line 747 167 747 189 -fill $color -tags {floor2 wall}
918
+ $w create line 755 189 739 189 -fill $color -tags {floor2 wall}
919
+ $w create line 769 224 757 224 -fill $color -tags {floor2 wall}
920
+ $w create line 802 224 802 129 -fill $color -tags {floor2 wall}
921
+ $w create line 802 129 725 129 -fill $color -tags {floor2 wall}
922
+ $w create line 725 189 725 129 -fill $color -tags {floor2 wall}
923
+ $w create line 725 186 690 186 -fill $color -tags {floor2 wall}
924
+ $w create line 676 133 676 186 -fill $color -tags {floor2 wall}
925
+ $w create line 627 144 627 186 -fill $color -tags {floor2 wall}
926
+ $w create line 629 186 593 186 -fill $color -tags {floor2 wall}
927
+ $w create line 579 144 579 186 -fill $color -tags {floor2 wall}
928
+ $w create line 559 129 559 133 -fill $color -tags {floor2 wall}
929
+ $w create line 725 133 559 133 -fill $color -tags {floor2 wall}
930
+ $w create line 484 162 484 129 -fill $color -tags {floor2 wall}
931
+ $w create line 559 129 484 129 -fill $color -tags {floor2 wall}
932
+ $w create line 526 129 526 186 -fill $color -tags {floor2 wall}
933
+ $w create line 540 186 581 186 -fill $color -tags {floor2 wall}
934
+ $w create line 528 186 523 186 -fill $color -tags {floor2 wall}
935
+ $w create line 511 186 475 186 -fill $color -tags {floor2 wall}
936
+ $w create line 496 190 496 186 -fill $color -tags {floor2 wall}
937
+ $w create line 496 205 496 202 -fill $color -tags {floor2 wall}
938
+ $w create line 475 205 527 205 -fill $color -tags {floor2 wall}
939
+ $w create line 558 205 539 205 -fill $color -tags {floor2 wall}
940
+ $w create line 558 205 558 249 -fill $color -tags {floor2 wall}
941
+ $w create line 558 249 475 249 -fill $color -tags {floor2 wall}
942
+ $w create line 662 206 642 206 -fill $color -tags {floor2 wall}
943
+ $w create line 695 206 675 206 -fill $color -tags {floor2 wall}
944
+ $w create line 695 278 642 278 -fill $color -tags {floor2 wall}
945
+ $w create line 642 291 642 206 -fill $color -tags {floor2 wall}
946
+ $w create line 695 291 695 206 -fill $color -tags {floor2 wall}
947
+ $w create line 716 208 716 206 -fill $color -tags {floor2 wall}
948
+ $w create line 757 206 716 206 -fill $color -tags {floor2 wall}
949
+ $w create line 757 221 757 224 -fill $color -tags {floor2 wall}
950
+ $w create line 793 224 802 224 -fill $color -tags {floor2 wall}
951
+ $w create line 757 262 716 262 -fill $color -tags {floor2 wall}
952
+ $w create line 716 220 716 264 -fill $color -tags {floor2 wall}
953
+ $w create line 716 315 716 276 -fill $color -tags {floor2 wall}
954
+ $w create line 757 315 703 315 -fill $color -tags {floor2 wall}
955
+ $w create line 757 325 757 224 -fill $color -tags {floor2 wall}
956
+ $w create line 757 367 644 367 -fill $color -tags {floor2 wall}
957
+ $w create line 689 367 689 315 -fill $color -tags {floor2 wall}
958
+ $w create line 647 315 644 315 -fill $color -tags {floor2 wall}
959
+ $w create line 659 315 691 315 -fill $color -tags {floor2 wall}
960
+ $w create line 600 325 600 391 -fill $color -tags {floor2 wall}
961
+ $w create line 627 325 644 325 -fill $color -tags {floor2 wall}
962
+ $w create line 644 391 644 315 -fill $color -tags {floor2 wall}
963
+ $w create line 615 325 575 325 -fill $color -tags {floor2 wall}
964
+ $w create line 644 391 558 391 -fill $color -tags {floor2 wall}
965
+ $w create line 563 325 558 325 -fill $color -tags {floor2 wall}
966
+ $w create line 558 391 558 314 -fill $color -tags {floor2 wall}
967
+ $w create line 558 327 508 327 -fill $color -tags {floor2 wall}
968
+ $w create line 558 275 484 275 -fill $color -tags {floor2 wall}
969
+ $w create line 558 302 558 275 -fill $color -tags {floor2 wall}
970
+ $w create line 508 327 508 311 -fill $color -tags {floor2 wall}
971
+ $w create line 484 311 508 311 -fill $color -tags {floor2 wall}
972
+ $w create line 484 275 484 311 -fill $color -tags {floor2 wall}
973
+ $w create line 475 208 408 208 -fill $color -tags {floor2 wall}
974
+ $w create line 408 206 408 210 -fill $color -tags {floor2 wall}
975
+ $w create line 408 222 408 227 -fill $color -tags {floor2 wall}
976
+ $w create line 408 227 398 227 -fill $color -tags {floor2 wall}
977
+ $w create line 398 227 398 254 -fill $color -tags {floor2 wall}
978
+ $w create line 408 188 408 194 -fill $color -tags {floor2 wall}
979
+ $w create line 383 188 376 188 -fill $color -tags {floor2 wall}
980
+ $w create line 398 188 398 162 -fill $color -tags {floor2 wall}
981
+ $w create line 398 162 484 162 -fill $color -tags {floor2 wall}
982
+ $w create line 475 162 475 254 -fill $color -tags {floor2 wall}
983
+ $w create line 398 254 475 254 -fill $color -tags {floor2 wall}
984
+ $w create line 484 280 395 280 -fill $color -tags {floor2 wall}
985
+ $w create line 395 311 395 275 -fill $color -tags {floor2 wall}
986
+ $w create line 307 197 293 197 -fill $color -tags {floor2 wall}
987
+ $w create line 278 197 233 197 -fill $color -tags {floor2 wall}
988
+ $w create line 233 197 233 249 -fill $color -tags {floor2 wall}
989
+ $w create line 307 179 284 179 -fill $color -tags {floor2 wall}
990
+ $w create line 233 249 278 249 -fill $color -tags {floor2 wall}
991
+ $w create line 269 179 269 133 -fill $color -tags {floor2 wall}
992
+ $w create line 220 179 220 133 -fill $color -tags {floor2 wall}
993
+ $w create line 155 191 110 191 -fill $color -tags {floor2 wall}
994
+ $w create line 90 190 98 190 -fill $color -tags {floor2 wall}
995
+ $w create line 98 169 98 190 -fill $color -tags {floor2 wall}
996
+ $w create line 52 133 52 165 -fill $color -tags {floor2 wall}
997
+ $w create line 52 214 52 177 -fill $color -tags {floor2 wall}
998
+ $w create line 52 226 52 262 -fill $color -tags {floor2 wall}
999
+ $w create line 52 274 52 276 -fill $color -tags {floor2 wall}
1000
+ $w create line 234 275 234 339 -fill $color -tags {floor2 wall}
1001
+ $w create line 226 339 258 339 -fill $color -tags {floor2 wall}
1002
+ $w create line 211 387 211 339 -fill $color -tags {floor2 wall}
1003
+ $w create line 214 339 177 339 -fill $color -tags {floor2 wall}
1004
+ $w create line 258 387 60 387 -fill $color -tags {floor2 wall}
1005
+ $w create line 3 133 3 339 -fill $color -tags {floor2 wall}
1006
+ $w create line 165 339 129 339 -fill $color -tags {floor2 wall}
1007
+ $w create line 117 339 80 339 -fill $color -tags {floor2 wall}
1008
+ $w create line 68 339 59 339 -fill $color -tags {floor2 wall}
1009
+ $w create line 0 339 46 339 -fill $color -tags {floor2 wall}
1010
+ $w create line 60 391 0 391 -fill $color -tags {floor2 wall}
1011
+ $w create line 0 339 0 391 -fill $color -tags {floor2 wall}
1012
+ $w create line 60 387 60 391 -fill $color -tags {floor2 wall}
1013
+ $w create line 258 329 258 387 -fill $color -tags {floor2 wall}
1014
+ $w create line 350 329 258 329 -fill $color -tags {floor2 wall}
1015
+ $w create line 395 311 350 311 -fill $color -tags {floor2 wall}
1016
+ $w create line 398 129 315 129 -fill $color -tags {floor2 wall}
1017
+ $w create line 176 133 315 133 -fill $color -tags {floor2 wall}
1018
+ $w create line 176 129 96 129 -fill $color -tags {floor2 wall}
1019
+ $w create line 3 133 96 133 -fill $color -tags {floor2 wall}
1020
+ $w create line 66 387 66 339 -fill $color -tags {floor2 wall}
1021
+ $w create line 115 387 115 339 -fill $color -tags {floor2 wall}
1022
+ $w create line 163 387 163 339 -fill $color -tags {floor2 wall}
1023
+ $w create line 234 275 276 275 -fill $color -tags {floor2 wall}
1024
+ $w create line 288 275 309 275 -fill $color -tags {floor2 wall}
1025
+ $w create line 298 275 298 329 -fill $color -tags {floor2 wall}
1026
+ $w create line 341 283 350 283 -fill $color -tags {floor2 wall}
1027
+ $w create line 321 275 341 275 -fill $color -tags {floor2 wall}
1028
+ $w create line 375 275 395 275 -fill $color -tags {floor2 wall}
1029
+ $w create line 315 129 315 170 -fill $color -tags {floor2 wall}
1030
+ $w create line 376 170 307 170 -fill $color -tags {floor2 wall}
1031
+ $w create line 307 250 307 170 -fill $color -tags {floor2 wall}
1032
+ $w create line 376 245 376 170 -fill $color -tags {floor2 wall}
1033
+ $w create line 340 241 307 241 -fill $color -tags {floor2 wall}
1034
+ $w create line 340 245 340 224 -fill $color -tags {floor2 wall}
1035
+ $w create line 340 210 340 201 -fill $color -tags {floor2 wall}
1036
+ $w create line 340 187 340 170 -fill $color -tags {floor2 wall}
1037
+ $w create line 340 206 307 206 -fill $color -tags {floor2 wall}
1038
+ $w create line 293 250 307 250 -fill $color -tags {floor2 wall}
1039
+ $w create line 271 179 238 179 -fill $color -tags {floor2 wall}
1040
+ $w create line 226 179 195 179 -fill $color -tags {floor2 wall}
1041
+ $w create line 176 129 176 179 -fill $color -tags {floor2 wall}
1042
+ $w create line 182 179 176 179 -fill $color -tags {floor2 wall}
1043
+ $w create line 174 169 176 169 -fill $color -tags {floor2 wall}
1044
+ $w create line 162 169 90 169 -fill $color -tags {floor2 wall}
1045
+ $w create line 96 169 96 129 -fill $color -tags {floor2 wall}
1046
+ $w create line 175 227 90 227 -fill $color -tags {floor2 wall}
1047
+ $w create line 90 190 90 227 -fill $color -tags {floor2 wall}
1048
+ $w create line 52 179 3 179 -fill $color -tags {floor2 wall}
1049
+ $w create line 52 228 3 228 -fill $color -tags {floor2 wall}
1050
+ $w create line 52 276 3 276 -fill $color -tags {floor2 wall}
1051
+ $w create line 155 177 155 169 -fill $color -tags {floor2 wall}
1052
+ $w create line 110 191 110 169 -fill $color -tags {floor2 wall}
1053
+ $w create line 155 189 155 197 -fill $color -tags {floor2 wall}
1054
+ $w create line 350 283 350 329 -fill $color -tags {floor2 wall}
1055
+ $w create line 162 197 155 197 -fill $color -tags {floor2 wall}
1056
+ $w create line 341 275 341 283 -fill $color -tags {floor2 wall}
1057
+ }
1058
+
1059
+ # fg3 --
1060
+ # This procedure represents part of the floorplan database. When
1061
+ # invoked, it instantiates the foreground information for the third
1062
+ # floor (office outlines and numbers).
1063
+ #
1064
+ # Arguments:
1065
+ # w - The canvas window.
1066
+ # color - Color to use for drawing foreground information.
1067
+
1068
+ proc fg3 {w color} {
1069
+ global floorLabels floorItems
1070
+ set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -outline {} -tags {floor3 room}]
1071
+ set floorLabels($i) 316
1072
+ set {floorItems(316)} $i
1073
+ $w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label}
1074
+ set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -outline {} -tags {floor3 room}]
1075
+ set floorLabels($i) 309
1076
+ set {floorItems(309)} $i
1077
+ $w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label}
1078
+ set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -outline {} -tags {floor3 room}]
1079
+ set floorLabels($i) 308
1080
+ set {floorItems(308)} $i
1081
+ $w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label}
1082
+ set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -outline {} -tags {floor3 room}]
1083
+ set floorLabels($i) 307
1084
+ set {floorItems(307)} $i
1085
+ $w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label}
1086
+ set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -outline {} -tags {floor3 room}]
1087
+ set floorLabels($i) 305
1088
+ set {floorItems(305)} $i
1089
+ $w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label}
1090
+ set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -outline {} -tags {floor3 room}]
1091
+ set floorLabels($i) 324B
1092
+ set {floorItems(324B)} $i
1093
+ $w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label}
1094
+ set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -outline {} -tags {floor3 room}]
1095
+ set floorLabels($i) 324A
1096
+ set {floorItems(324A)} $i
1097
+ $w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label}
1098
+ set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -outline {} -tags {floor3 room}]
1099
+ set floorLabels($i) 320
1100
+ set {floorItems(320)} $i
1101
+ $w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label}
1102
+ set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -outline {} -tags {floor3 room}]
1103
+ set floorLabels($i) 310
1104
+ set {floorItems(310)} $i
1105
+ $w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label}
1106
+ set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -outline {} -tags {floor3 room}]
1107
+ set floorLabels($i) 312
1108
+ set {floorItems(312)} $i
1109
+ $w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label}
1110
+ set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -outline {} -tags {floor3 room}]
1111
+ set floorLabels($i) 313
1112
+ set {floorItems(313)} $i
1113
+ $w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label}
1114
+ set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -outline {} -tags {floor3 room}]
1115
+ set floorLabels($i) 314
1116
+ set {floorItems(314)} $i
1117
+ $w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label}
1118
+ set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -outline {} -tags {floor3 room}]
1119
+ set floorLabels($i) 315
1120
+ set {floorItems(315)} $i
1121
+ $w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label}
1122
+ set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -outline {} -tags {floor3 room}]
1123
+ set floorLabels($i) 316B
1124
+ set {floorItems(316B)} $i
1125
+ $w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label}
1126
+ set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -outline {} -tags {floor3 room}]
1127
+ set floorLabels($i) 316A
1128
+ set {floorItems(316A)} $i
1129
+ $w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label}
1130
+ set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -outline {} -tags {floor3 room}]
1131
+ set floorLabels($i) 319
1132
+ set {floorItems(319)} $i
1133
+ $w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label}
1134
+ set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -outline {} -tags {floor3 room}]
1135
+ set floorLabels($i) 311
1136
+ set {floorItems(311)} $i
1137
+ $w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label}
1138
+ set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor3 room}]
1139
+ set floorLabels($i) 318
1140
+ set {floorItems(318)} $i
1141
+ $w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label}
1142
+ set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor3 room}]
1143
+ set floorLabels($i) 317
1144
+ set {floorItems(317)} $i
1145
+ $w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label}
1146
+ set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -outline {} -tags {floor3 room}]
1147
+ set floorLabels($i) 323
1148
+ set {floorItems(323)} $i
1149
+ $w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label}
1150
+ set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -outline {} -tags {floor3 room}]
1151
+ set floorLabels($i) 325
1152
+ set {floorItems(325)} $i
1153
+ $w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label}
1154
+ set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -outline {} -tags {floor3 room}]
1155
+ set floorLabels($i) 321
1156
+ set {floorItems(321)} $i
1157
+ $w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label}
1158
+ set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -outline {} -tags {floor3 room}]
1159
+ set floorLabels($i) 322
1160
+ set {floorItems(322)} $i
1161
+ $w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label}
1162
+ set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor3 room}]
1163
+ set floorLabels($i) {Pub Lift3}
1164
+ set {floorItems(Pub Lift3)} $i
1165
+ $w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label}
1166
+ set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor3 room}]
1167
+ set floorLabels($i) {Priv Lift3}
1168
+ set {floorItems(Priv Lift3)} $i
1169
+ $w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label}
1170
+ set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -outline {} -tags {floor3 room}]
1171
+ set floorLabels($i) 303
1172
+ set {floorItems(303)} $i
1173
+ $w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label}
1174
+ set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -outline {} -tags {floor3 room}]
1175
+ set floorLabels($i) 324
1176
+ set {floorItems(324)} $i
1177
+ $w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label}
1178
+ set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -outline {} -tags {floor3 room}]
1179
+ set floorLabels($i) 304
1180
+ set {floorItems(304)} $i
1181
+ $w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label}
1182
+ set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor3 room}]
1183
+ set floorLabels($i) 301
1184
+ set {floorItems(301)} $i
1185
+ $w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label}
1186
+ set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -outline {} -tags {floor3 room}]
1187
+ set floorLabels($i) 327
1188
+ set {floorItems(327)} $i
1189
+ $w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label}
1190
+ set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -outline {} -tags {floor3 room}]
1191
+ set floorLabels($i) 326
1192
+ set {floorItems(326)} $i
1193
+ $w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label}
1194
+ set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -outline {} -tags {floor3 room}]
1195
+ set floorLabels($i) 302
1196
+ set {floorItems(302)} $i
1197
+ $w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label}
1198
+ set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -outline {} -tags {floor3 room}]
1199
+ set floorLabels($i) 306
1200
+ set {floorItems(306)} $i
1201
+ $w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label}
1202
+ $w create line 341 275 341 283 -fill $color -tags {floor3 wall}
1203
+ $w create line 162 197 155 197 -fill $color -tags {floor3 wall}
1204
+ $w create line 396 247 399 247 -fill $color -tags {floor3 wall}
1205
+ $w create line 399 129 399 311 -fill $color -tags {floor3 wall}
1206
+ $w create line 258 202 243 202 -fill $color -tags {floor3 wall}
1207
+ $w create line 350 283 350 329 -fill $color -tags {floor3 wall}
1208
+ $w create line 251 231 243 231 -fill $color -tags {floor3 wall}
1209
+ $w create line 243 220 251 220 -fill $color -tags {floor3 wall}
1210
+ $w create line 243 250 243 202 -fill $color -tags {floor3 wall}
1211
+ $w create line 155 197 155 190 -fill $color -tags {floor3 wall}
1212
+ $w create line 110 192 110 169 -fill $color -tags {floor3 wall}
1213
+ $w create line 155 192 110 192 -fill $color -tags {floor3 wall}
1214
+ $w create line 155 177 155 169 -fill $color -tags {floor3 wall}
1215
+ $w create line 176 197 176 227 -fill $color -tags {floor3 wall}
1216
+ $w create line 69 280 69 274 -fill $color -tags {floor3 wall}
1217
+ $w create line 21 276 69 276 -fill $color -tags {floor3 wall}
1218
+ $w create line 69 262 69 226 -fill $color -tags {floor3 wall}
1219
+ $w create line 21 228 69 228 -fill $color -tags {floor3 wall}
1220
+ $w create line 21 179 75 179 -fill $color -tags {floor3 wall}
1221
+ $w create line 69 179 69 214 -fill $color -tags {floor3 wall}
1222
+ $w create line 90 220 90 227 -fill $color -tags {floor3 wall}
1223
+ $w create line 90 204 90 202 -fill $color -tags {floor3 wall}
1224
+ $w create line 90 203 100 203 -fill $color -tags {floor3 wall}
1225
+ $w create line 90 187 90 179 -fill $color -tags {floor3 wall}
1226
+ $w create line 90 227 176 227 -fill $color -tags {floor3 wall}
1227
+ $w create line 100 179 100 227 -fill $color -tags {floor3 wall}
1228
+ $w create line 100 179 87 179 -fill $color -tags {floor3 wall}
1229
+ $w create line 96 179 96 129 -fill $color -tags {floor3 wall}
1230
+ $w create line 162 169 96 169 -fill $color -tags {floor3 wall}
1231
+ $w create line 173 169 176 169 -fill $color -tags {floor3 wall}
1232
+ $w create line 182 179 176 179 -fill $color -tags {floor3 wall}
1233
+ $w create line 176 129 176 179 -fill $color -tags {floor3 wall}
1234
+ $w create line 195 179 226 179 -fill $color -tags {floor3 wall}
1235
+ $w create line 224 133 224 179 -fill $color -tags {floor3 wall}
1236
+ $w create line 264 179 264 133 -fill $color -tags {floor3 wall}
1237
+ $w create line 238 179 264 179 -fill $color -tags {floor3 wall}
1238
+ $w create line 273 207 273 193 -fill $color -tags {floor3 wall}
1239
+ $w create line 273 235 273 250 -fill $color -tags {floor3 wall}
1240
+ $w create line 273 224 273 219 -fill $color -tags {floor3 wall}
1241
+ $w create line 273 193 307 193 -fill $color -tags {floor3 wall}
1242
+ $w create line 273 222 307 222 -fill $color -tags {floor3 wall}
1243
+ $w create line 273 250 307 250 -fill $color -tags {floor3 wall}
1244
+ $w create line 384 247 376 247 -fill $color -tags {floor3 wall}
1245
+ $w create line 340 206 307 206 -fill $color -tags {floor3 wall}
1246
+ $w create line 340 187 340 170 -fill $color -tags {floor3 wall}
1247
+ $w create line 340 210 340 201 -fill $color -tags {floor3 wall}
1248
+ $w create line 340 247 340 224 -fill $color -tags {floor3 wall}
1249
+ $w create line 340 241 307 241 -fill $color -tags {floor3 wall}
1250
+ $w create line 376 247 376 170 -fill $color -tags {floor3 wall}
1251
+ $w create line 307 250 307 170 -fill $color -tags {floor3 wall}
1252
+ $w create line 376 170 307 170 -fill $color -tags {floor3 wall}
1253
+ $w create line 315 129 315 170 -fill $color -tags {floor3 wall}
1254
+ $w create line 376 283 366 283 -fill $color -tags {floor3 wall}
1255
+ $w create line 376 283 376 275 -fill $color -tags {floor3 wall}
1256
+ $w create line 399 275 376 275 -fill $color -tags {floor3 wall}
1257
+ $w create line 341 275 320 275 -fill $color -tags {floor3 wall}
1258
+ $w create line 341 283 350 283 -fill $color -tags {floor3 wall}
1259
+ $w create line 298 275 298 329 -fill $color -tags {floor3 wall}
1260
+ $w create line 308 275 298 275 -fill $color -tags {floor3 wall}
1261
+ $w create line 243 322 243 275 -fill $color -tags {floor3 wall}
1262
+ $w create line 243 275 284 275 -fill $color -tags {floor3 wall}
1263
+ $w create line 258 322 226 322 -fill $color -tags {floor3 wall}
1264
+ $w create line 212 370 212 322 -fill $color -tags {floor3 wall}
1265
+ $w create line 214 322 177 322 -fill $color -tags {floor3 wall}
1266
+ $w create line 163 370 163 322 -fill $color -tags {floor3 wall}
1267
+ $w create line 165 322 129 322 -fill $color -tags {floor3 wall}
1268
+ $w create line 84 322 117 322 -fill $color -tags {floor3 wall}
1269
+ $w create line 71 322 64 322 -fill $color -tags {floor3 wall}
1270
+ $w create line 115 322 115 370 -fill $color -tags {floor3 wall}
1271
+ $w create line 66 322 66 370 -fill $color -tags {floor3 wall}
1272
+ $w create line 52 322 21 322 -fill $color -tags {floor3 wall}
1273
+ $w create line 21 331 0 331 -fill $color -tags {floor3 wall}
1274
+ $w create line 21 331 21 133 -fill $color -tags {floor3 wall}
1275
+ $w create line 96 133 21 133 -fill $color -tags {floor3 wall}
1276
+ $w create line 176 129 96 129 -fill $color -tags {floor3 wall}
1277
+ $w create line 315 133 176 133 -fill $color -tags {floor3 wall}
1278
+ $w create line 315 129 399 129 -fill $color -tags {floor3 wall}
1279
+ $w create line 399 311 350 311 -fill $color -tags {floor3 wall}
1280
+ $w create line 350 329 258 329 -fill $color -tags {floor3 wall}
1281
+ $w create line 258 322 258 370 -fill $color -tags {floor3 wall}
1282
+ $w create line 60 370 258 370 -fill $color -tags {floor3 wall}
1283
+ $w create line 60 370 60 391 -fill $color -tags {floor3 wall}
1284
+ $w create line 0 391 0 331 -fill $color -tags {floor3 wall}
1285
+ $w create line 60 391 0 391 -fill $color -tags {floor3 wall}
1286
+ $w create line 307 250 307 242 -fill $color -tags {floor3 wall}
1287
+ $w create line 273 250 307 250 -fill $color -tags {floor3 wall}
1288
+ $w create line 258 250 243 250 -fill $color -tags {floor3 wall}
1289
+ }
1290
+
1291
+ # Below is the "main program" that creates the floorplan demonstration.
1292
+
1293
+ set w .floor
1294
+ global c currentRoom colors activeFloor
1295
+ catch {destroy $w}
1296
+ toplevel $w
1297
+ wm title $w "Floorplan Canvas Demonstration"
1298
+ wm iconname $w "Floorplan"
1299
+ wm geometry $w +20+20
1300
+ wm minsize $w 100 100
1301
+
1302
+ label $w.msg -font $font -wraplength 8i -justify left -text "This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."
1303
+ pack $w.msg -side top
1304
+
1305
+ ## See Code / Dismiss buttons
1306
+ set btns [addSeeDismiss $w.buttons $w]
1307
+ pack $btns -side bottom -fill x
1308
+
1309
+ set f [frame $w.frame]
1310
+ pack $f -side top -fill both -expand yes
1311
+ set h [ttk::scrollbar $f.hscroll -orient horizontal]
1312
+ set v [ttk::scrollbar $f.vscroll -orient vertical]
1313
+ set f1 [frame $f.f1 -borderwidth 2 -relief sunken]
1314
+ set c [canvas $f1.c -width 900 -height 500 -highlightthickness 0 \
1315
+ -xscrollcommand [list $h set] \
1316
+ -yscrollcommand [list $v set]]
1317
+ pack $c -expand yes -fill both
1318
+ grid $f1 -padx 1 -pady 1 -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
1319
+ grid $v -padx 1 -pady 1 -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
1320
+ grid $h -padx 1 -pady 1 -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
1321
+ grid rowconfig $f 0 -weight 1 -minsize 0
1322
+ grid columnconfig $f 0 -weight 1 -minsize 0
1323
+ pack $f -expand yes -fill both -padx 1 -pady 1
1324
+
1325
+ $v configure -command [list $c yview]
1326
+ $h configure -command [list $c xview]
1327
+
1328
+ # Create an entry for displaying and typing in current room.
1329
+
1330
+ entry $c.entry -width 10 -textvariable currentRoom
1331
+
1332
+ # Choose colors, then fill in the floorplan.
1333
+
1334
+ if {[winfo depth $c] > 1} {
1335
+ set colors(bg1) #a9c1da
1336
+ set colors(outline1) #77889a
1337
+ set colors(bg2) #9ab0c6
1338
+ set colors(outline2) #687786
1339
+ set colors(bg3) #8ba0b3
1340
+ set colors(outline3) #596673
1341
+ set colors(offices) Black
1342
+ set colors(active) #c4d1df
1343
+ } else {
1344
+ set colors(bg1) white
1345
+ set colors(outline1) black
1346
+ set colors(bg2) white
1347
+ set colors(outline2) black
1348
+ set colors(bg3) white
1349
+ set colors(outline3) black
1350
+ set colors(offices) Black
1351
+ set colors(active) black
1352
+ }
1353
+ set activeFloor ""
1354
+ floorDisplay $c 3
1355
+
1356
+ # Set up event bindings for canvas:
1357
+
1358
+ $c bind floor1 <Button-1> "floorDisplay $c 1"
1359
+ $c bind floor2 <Button-1> "floorDisplay $c 2"
1360
+ $c bind floor3 <Button-1> "floorDisplay $c 3"
1361
+ $c bind room <Enter> "newRoom $c"
1362
+ $c bind room <Leave> {set currentRoom ""}
1363
+ if {[tk windowingsystem] eq "aqua" && ![package vsatisfies [package provide Tk] 8.7-]} {
1364
+ bind $c <Button-3> "$c scan mark %x %y"
1365
+ bind $c <B3-Motion> "$c scan dragto %x %y"
1366
+ } else {
1367
+ bind $c <Button-2> "$c scan mark %x %y"
1368
+ bind $c <B2-Motion> "$c scan dragto %x %y"
1369
+ }
1370
+ bind $c <Destroy> "unset currentRoom"
1371
+ set currentRoom ""
1372
+ trace add variable currentRoom write "roomChanged $c"
janus/lib/tk8.6/demos/form.tcl ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # form.tcl --
2
+ #
3
+ # This demonstration script creates a simple form with a bunch
4
+ # of entry 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 .form
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Form Demonstration"
16
+ wm iconname $w "form"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries."
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
+ foreach i {f1 f2 f3 f4 f5} {
27
+ frame $w.$i -bd 2
28
+ entry $w.$i.entry -relief sunken -width 40
29
+ label $w.$i.label
30
+ pack $w.$i.entry -side right
31
+ pack $w.$i.label -side left
32
+ }
33
+ $w.f1.label config -text Name:
34
+ $w.f2.label config -text Address:
35
+ $w.f5.label config -text Phone:
36
+ pack $w.msg $w.f1 $w.f2 $w.f3 $w.f4 $w.f5 -side top -fill x
37
+ bind $w <Return> "destroy $w"
38
+ focus $w.f1.entry
janus/lib/tk8.6/demos/goldberg.tcl ADDED
@@ -0,0 +1,1834 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##+#################################################################
2
+ #
3
+ # TkGoldberg.tcl
4
+ # by Keith Vetter, March 13, 2003
5
+ #
6
+ # "Man will always find a difficult means to perform a simple task"
7
+ # Rube Goldberg
8
+ #
9
+ # Reproduced here with permission.
10
+ #
11
+ ##+#################################################################
12
+ #
13
+ # Keith Vetter 2003-03-21: this started out as a simple little program
14
+ # but was so much fun that it grew and grew. So I apologize about the
15
+ # size but I just couldn't resist sharing it.
16
+ #
17
+ # This is a whizzlet that does a Rube Goldberg type animation, the
18
+ # design of which comes from an New Years e-card from IncrediMail.
19
+ # That version had nice sound effects which I eschewed. On the other
20
+ # hand, that version was in black and white (actually dark blue and
21
+ # light blue) and this one is fully colorized.
22
+ #
23
+ # One thing I learned from this project is that drawing filled complex
24
+ # objects on a canvas is really hard. More often than not I had to
25
+ # draw each item twice--once with the desired fill color but no
26
+ # outline, and once with no fill but with the outline. Another trick
27
+ # is erasing by drawing with the background color. Having a flood fill
28
+ # command would have been extremely helpful.
29
+ #
30
+ # Two wiki pages were extremely helpful: Drawing rounded rectangles
31
+ # which I generalized into Drawing rounded polygons, and regular
32
+ # polygons which allowed me to convert ovals and arcs into polygons
33
+ # which could then be rotated (see Canvas Rotation). I also wrote
34
+ # Named Colors to aid in the color selection.
35
+ #
36
+ # I could comment on the code, but it's just 26 state machines with
37
+ # lots of canvas create and move calls.
38
+
39
+ if {![info exists widgetDemo]} {
40
+ error "This script should be run from the \"widget\" demo."
41
+ }
42
+
43
+ package require Tk
44
+
45
+ set w .goldberg
46
+ catch {destroy $w}
47
+ toplevel $w
48
+ wm title $w "Tk Goldberg (demonstration)"
49
+ wm iconname $w "goldberg"
50
+ wm resizable $w 0 0
51
+ #positionWindow $w
52
+
53
+ label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\
54
+ demonstration of just how complex you can make your animations\
55
+ become. Click the ball to start things moving!\n\n\"Man will always\
56
+ find a difficult means to perform a simple task\"\n - Rube Goldberg"
57
+ pack $w.msg -side top
58
+
59
+ ###--- End of Boilerplate ---###
60
+
61
+ # Ensure that this this is an array
62
+ array set animationCallbacks {}
63
+ bind $w <Destroy> {
64
+ if {"%W" eq [winfo toplevel %W]} {
65
+ unset S C speed
66
+ }
67
+ }
68
+
69
+ set S(title) "Tk Goldberg"
70
+ set S(speed) 5
71
+ set S(cnt) 0
72
+ set S(message) "\\nWelcome\\nto\\nTcl/Tk"
73
+ array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500}
74
+
75
+ set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5
76
+ set S(mode) $::MSTART
77
+
78
+ # Colors for everything
79
+ set C(fg) black
80
+ set C(bg) cornflowerblue
81
+
82
+ set C(0) white; set C(1a) darkgreen; set C(1b) yellow
83
+ set C(2) red; set C(3a) green; set C(3b) darkblue
84
+ set C(4) $C(fg); set C(5a) brown; set C(5b) white
85
+ set C(6) magenta; set C(7) green; set C(8) $C(fg)
86
+ set C(9) blue4; set C(10a) white; set C(10b) cyan
87
+ set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2
88
+ set C(13a) yellow; set C(13b) red; set C(14) white
89
+ set C(15a) green; set C(15b) yellow; set C(16) gray65
90
+ set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50
91
+ set C(20) cyan; set C(21) gray65; set C(22) $C(20)
92
+ set C(23a) blue; set C(23b) red; set C(23c) yellow
93
+ set C(24a) red; set C(24b) white;
94
+ set C(24c) black; set C(26) $C(0);
95
+
96
+ proc DoDisplay {w} {
97
+ global S C
98
+
99
+ ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5
100
+ pack [frame $w.screen -bd 2 -relief raised] \
101
+ -side left -fill both -expand 1
102
+
103
+ canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0
104
+ $w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up
105
+ $w.c yview moveto .05
106
+ pack $w.c -in $w.screen -side top -fill both -expand 1
107
+
108
+ bind $w.c <Button-3> [list $w.pause invoke]
109
+ bind $w.c <Destroy> {
110
+ after cancel $animationCallbacks(goldberg)
111
+ unset animationCallbacks(goldberg)
112
+ }
113
+ DoCtrlFrame $w
114
+ DoDetailFrame $w
115
+ if {[tk windowingsystem] ne "aqua"} {
116
+ ttk::button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2
117
+ } else {
118
+ button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg)
119
+ }
120
+ place $w.show -in $w.c -relx 1 -rely 0 -anchor ne
121
+ update
122
+ }
123
+
124
+ proc DoCtrlFrame {w} {
125
+ global S
126
+ ttk::button $w.start -text "Start" -command [list DoButton $w 0]
127
+ ttk::checkbutton $w.pause -text "Pause" -command [list DoButton $w 1] \
128
+ -variable S(pause)
129
+ ttk::button $w.step -text "Single Step" -command [list DoButton $w 2]
130
+ ttk::button $w.bstep -text "Big Step" -command [list DoButton $w 4]
131
+ ttk::button $w.reset -text "Reset" -command [list DoButton $w 3]
132
+ ttk::labelframe $w.details
133
+ raise $w.details
134
+ set S(details) 0
135
+ ttk::checkbutton $w.details.cb -text "Details" -variable S(details)
136
+ ttk::labelframe $w.message -text "Message"
137
+ ttk::entry $w.message.e -textvariable S(message) -justify center
138
+ ttk::labelframe $w.speed -text "Speed: 0"
139
+ ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 -variable S(speed)
140
+ ttk::button $w.about -text About -command [list About $w]
141
+
142
+ grid $w.start -in $w.ctrl -row 0 -sticky ew
143
+ grid rowconfigure $w.ctrl 1 -minsize 10
144
+ grid $w.pause -in $w.ctrl -row 2 -sticky ew
145
+ grid $w.step -in $w.ctrl -sticky ew -pady 2
146
+ grid $w.bstep -in $w.ctrl -sticky ew
147
+ grid $w.reset -in $w.ctrl -sticky ew -pady 2
148
+ grid rowconfigure $w.ctrl 10 -minsize 18
149
+ grid $w.details -in $w.ctrl -row 11 -sticky ew
150
+ grid rowconfigure $w.ctrl 11 -minsize 20
151
+ $w.details configure -labelwidget $w.details.cb
152
+ grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug
153
+ raise $w.details
154
+ raise $w.details.cb
155
+ grid rowconfigure $w.ctrl 50 -weight 1
156
+ trace add variable ::S(mode) write [list ActiveGUI $w]
157
+ trace add variable ::S(details) write [list ActiveGUI $w]
158
+ trace add variable ::S(speed) write [list ActiveGUI $w]
159
+
160
+ grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5
161
+ grid $w.message.e -sticky nsew
162
+ grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5}
163
+ pack $w.speed.scale -fill both -expand 1
164
+ grid $w.about -in $w.ctrl -row 100 -sticky ew
165
+ bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging
166
+
167
+ ## See Code / Dismiss buttons hack!
168
+ set btns [addSeeDismiss $w.ctrl.buttons $w]
169
+ grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4
170
+ set i 0
171
+ foreach b [winfo children $btns] {
172
+ if {[winfo class $b] eq "TButton"} {
173
+ grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew
174
+ foreach b3 [$b configure] {
175
+ set b3 [lindex $b3 0]
176
+ # Some options are read-only; ignore those errors
177
+ catch {$b2 configure $b3 [$b cget $b3]}
178
+ }
179
+ }
180
+ }
181
+ destroy $btns
182
+ }
183
+
184
+ proc DoDetailFrame {w} {
185
+ set w2 $w.details.f
186
+ ttk::frame $w2
187
+
188
+ ttk::label $w2.l -textvariable S(cnt) -background white
189
+ grid $w2.l - - - -sticky ew -row 0
190
+ for {set i 1} {1} {incr i} {
191
+ if {[info procs "Move$i"] eq ""} break
192
+ ttk::label $w2.l$i -text $i -anchor e -width 2 -background white
193
+ ttk::label $w2.ll$i -textvariable STEP($i) -width 5 -background white
194
+ set row [expr {($i + 1) / 2}]
195
+ set col [expr {(($i + 1) & 1) * 2}]
196
+ grid $w2.l$i -sticky ew -row $row -column $col
197
+ grid $w2.ll$i -sticky ew -row $row -column [incr col]
198
+ }
199
+ grid columnconfigure $w2 1 -weight 1
200
+ }
201
+
202
+ # Map or unmap the ctrl window
203
+ proc ShowCtrl {w} {
204
+ if {[winfo ismapped $w.ctrl]} {
205
+ pack forget $w.ctrl
206
+ $w.show config -text "\xbb"
207
+ } else {
208
+ pack $w.ctrl -side right -fill both -ipady 5
209
+ $w.show config -text "\xab"
210
+ }
211
+ }
212
+
213
+ proc DrawAll {w} {
214
+ ResetStep
215
+ $w.c delete all
216
+ for {set i 0} {1} {incr i} {
217
+ set p "Draw$i"
218
+ if {[info procs $p] eq ""} break
219
+ $p $w
220
+ }
221
+ }
222
+
223
+ proc ActiveGUI {w var1 var2 op} {
224
+ global S MGO MSTART MDONE
225
+ array set z {0 disabled 1 normal}
226
+
227
+ set m $S(mode)
228
+ set S(pause) [expr {$m == 2}]
229
+ $w.start config -state $z([expr {$m != $MGO}])
230
+ $w.pause config -state $z([expr {$m != $MSTART && $m != $MDONE}])
231
+ $w.step config -state $z([expr {$m != $MGO && $m != $MDONE}])
232
+ $w.bstep config -state $z([expr {$m != $MGO && $m != $MDONE}])
233
+ $w.reset config -state $z([expr {$m != $MSTART}])
234
+
235
+ if {$S(details)} {
236
+ grid $w.details.f -sticky ew
237
+ } else {
238
+ grid forget $w.details.f
239
+ }
240
+ set S(speed) [expr {round($S(speed))}]
241
+ $w.speed config -text "Speed: $S(speed)"
242
+ }
243
+
244
+ proc Start {} {
245
+ global S MGO
246
+ set S(mode) $MGO
247
+ }
248
+
249
+ proc DoButton {w what} {
250
+ global S MDONE MGO MSSTEP MBSTEP MPAUSE
251
+
252
+ if {$what == 0} { ;# Start
253
+ if {$S(mode) == $MDONE} {
254
+ Reset $w
255
+ }
256
+ set S(mode) $MGO
257
+ } elseif {$what == 1} { ;# Pause
258
+ set S(mode) [expr {$S(pause) ? $MPAUSE : $MGO}]
259
+ } elseif {$what == 2} { ;# Step
260
+ set S(mode) $MSSTEP
261
+ } elseif {$what == 3} { ;# Reset
262
+ Reset $w
263
+ } elseif {$what == 4} { ;# Big step
264
+ set S(mode) $MBSTEP
265
+ }
266
+ }
267
+
268
+ proc Go {w {who {}}} {
269
+ global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP
270
+
271
+ set now [clock clicks -milliseconds]
272
+ catch {after cancel $animationCallbacks(goldberg)}
273
+ if {$who ne ""} { ;# Start here for debugging
274
+ set S(active) $who
275
+ set S(mode) $MGO
276
+ }
277
+ if {$S(mode) == -1} return ;# Debugging
278
+ set n 0
279
+ if {$S(mode) != $MPAUSE} { ;# Not paused
280
+ set n [NextStep $w] ;# Do the next move
281
+ }
282
+ if {$S(mode) == $MSSTEP} { ;# Single step
283
+ set S(mode) $MPAUSE
284
+ }
285
+ if {$S(mode) == $MBSTEP && $n} { ;# Big step
286
+ set S(mode) $MSSTEP
287
+ }
288
+
289
+ set elapsed [expr {[clock click -milliseconds] - $now}]
290
+ set delay [expr {$speed($S(speed)) - $elapsed}]
291
+ if {$delay <= 0} {
292
+ set delay 1
293
+ }
294
+ set animationCallbacks(goldberg) [after $delay [list Go $w]]
295
+ }
296
+
297
+ # NextStep: drives the next step of the animation
298
+ proc NextStep {w} {
299
+ global S MSTART MDONE
300
+ set rval 0 ;# Return value
301
+
302
+ if {$S(mode) != $MSTART && $S(mode) != $MDONE} {
303
+ incr S(cnt)
304
+ }
305
+ set alive {}
306
+ foreach {who} $S(active) {
307
+ set n ["Move$who" $w]
308
+ if {$n & 1} { ;# This guy still alive
309
+ lappend alive $who
310
+ }
311
+ if {$n & 2} { ;# Next guy is active
312
+ lappend alive [expr {$who + 1}]
313
+ set rval 1
314
+ }
315
+ if {$n & 4} { ;# End of puzzle flag
316
+ set S(mode) $MDONE ;# Done mode
317
+ set S(active) {} ;# No more animation
318
+ return 1
319
+ }
320
+ }
321
+ set S(active) $alive
322
+ return $rval
323
+ }
324
+ proc About {w} {
325
+ set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\
326
+ permission of the author)\n\n\"Man will always find a difficult\
327
+ means to perform a simple task.\"\nRube Goldberg"
328
+ tk_messageBox -parent $w -message $msg -title About
329
+ }
330
+ ################################################################
331
+ #
332
+ # All the drawing and moving routines
333
+ #
334
+
335
+ # START HERE! banner
336
+ proc Draw0 {w} {
337
+ set color $::C(0)
338
+ set xy {579 119}
339
+ $w.c create text $xy -text "START HERE!" -fill $color -anchor w \
340
+ -tag I0 -font {{Times Roman} 12 italic bold}
341
+ set xy {719 119 763 119}
342
+ $w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \
343
+ -arrowshape {18 18 5}
344
+ $w.c bind I0 <Button-1> Start
345
+ }
346
+ proc Move0 {w {step {}}} {
347
+ set step [GetStep 0 $step]
348
+
349
+ if {$::S(mode) > $::MSTART} { ;# Start the ball rolling
350
+ MoveAbs $w I0 {-100 -100} ;# Hide the banner
351
+ return 2
352
+ }
353
+
354
+ set pos {
355
+ {673 119} {678 119} {683 119} {688 119}
356
+ {693 119} {688 119} {683 119} {678 119}
357
+ }
358
+ set step [expr {$step % [llength $pos]}]
359
+ MoveAbs $w I0 [lindex $pos $step]
360
+ return 1
361
+ }
362
+
363
+ # Dropping ball
364
+ proc Draw1 {w} {
365
+ set color $::C(1a)
366
+ set color2 $::C(1b)
367
+ set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133}
368
+ $w.c create poly $xy -width 3 -fill $color -outline {}
369
+ set xy {771 133 685 133 685 168 751 168 751 346 771 346 771 133}
370
+ $w.c create poly $xy -width 3 -fill $color -outline {}
371
+
372
+ set xy [box 812 122 9]
373
+ $w.c create oval $xy -tag I1 -fill $color2 -outline {}
374
+ $w.c bind I1 <Button-1> Start
375
+ }
376
+ proc Move1 {w {step {}}} {
377
+ set step [GetStep 1 $step]
378
+ set pos {
379
+ {807 122} {802 122} {797 123} {793 124} {789 129} {785 153}
380
+ {785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503}
381
+ {824 585 y} {838 587} {848 593} {857 601} {-100 -100}
382
+ }
383
+ if {$step >= [llength $pos]} {
384
+ return 0
385
+ }
386
+ set where [lindex $pos $step]
387
+ MoveAbs $w I1 $where
388
+
389
+ if {[lindex $where 2] eq "y"} {
390
+ Move15a $w
391
+ }
392
+ if {[lindex $where 2] eq "x"} {
393
+ return 3
394
+ }
395
+ return 1
396
+ }
397
+
398
+ # Lighting the match
399
+ proc Draw2 {w} {
400
+ set color red
401
+ set color $::C(2)
402
+ set xy {750 369 740 392 760 392} ;# Fulcrum
403
+ $w.c create poly $xy -fill $::C(fg) -outline $::C(fg)
404
+ set xy {628 335 660 383} ;# Strike box
405
+ $w.c create rect $xy -fill {} -outline $::C(fg)
406
+ for {set y 0} {$y < 3} {incr y} {
407
+ set yy [expr {335+$y*16}]
408
+ $w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \
409
+ -foreground $::C(fg)
410
+ $w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \
411
+ -foreground $::C(fg)
412
+ }
413
+
414
+ set xy {702 366 798 366} ;# Lever
415
+ $w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0
416
+ set xy {712 363 712 355} ;# R strap
417
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1
418
+ set xy {705 363 705 355} ;# L strap
419
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2
420
+ set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick
421
+ $w.c create line $xy -fill $::C(fg) -tag I2_3
422
+
423
+ #set xy {662 352 680 365} ;# Match head
424
+ set xy {
425
+ 671 352 677.4 353.9 680 358.5 677.4 363.1 671 365 664.6 363.1
426
+ 662 358.5 664.6 353.9
427
+ }
428
+ $w.c create poly $xy -fill $color -outline $color -tag I2_4
429
+ }
430
+ proc Move2 {w {step {}}} {
431
+ set step [GetStep 2 $step]
432
+
433
+ set stages {0 0 1 2 0 2 1 0 1 2 0 2 1}
434
+ set xy(0) {
435
+ 686 333 692 323 682 316 674 309 671 295 668 307 662 318 662 328
436
+ 671 336
437
+ }
438
+ set xy(1) {687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335}
439
+ set xy(2) {
440
+ 686 331 704 322 688 300 678 283 678 283 674 298 666 309 660 324
441
+ 672 336
442
+ }
443
+
444
+ if {$step >= [llength $stages]} {
445
+ $w.c delete I2
446
+ return 0
447
+ }
448
+
449
+ if {$step == 0} { ;# Rotate the match
450
+ set beta 20
451
+ lassign [Anchor $w I2_0 s] Ox Oy ;# Where to pivot
452
+ for {set i 0} {[$w.c find withtag I2_$i] ne ""} {incr i} {
453
+ RotateItem $w I2_$i $Ox $Oy $beta
454
+ }
455
+ $w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame
456
+ return 1
457
+ }
458
+ $w.c coords I2 $xy([lindex $stages $step])
459
+ return [expr {$step == 7 ? 3 : 1}]
460
+ }
461
+
462
+ # Weight and pulleys
463
+ proc Draw3 {w} {
464
+ set color $::C(3a)
465
+ set color2 $::C(3b)
466
+
467
+ set xy {602 296 577 174 518 174}
468
+ foreach {x y} $xy { ;# 3 Pulleys
469
+ $w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \
470
+ -width 3
471
+ $w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg)
472
+ }
473
+
474
+ set xy {750 309 670 309} ;# Wall to flame
475
+ $w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1
476
+ set xy {670 309 650 309} ;# Flame to pulley 1
477
+ $w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg)
478
+ set xy {650 309 600 309} ;# Flame to pulley 1
479
+ $w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg)
480
+ set xy {589 296 589 235} ;# Pulley 1 half way to 2
481
+ $w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg)
482
+ set xy {589 235 589 174} ;# Pulley 1 other half to 2
483
+ $w.c create line $xy -width 3 -fill $::C(fg)
484
+ set xy {577 161 518 161} ;# Across the top
485
+ $w.c create line $xy -width 3 -fill $::C(fg)
486
+ set xy {505 174 505 205} ;# Down to weight
487
+ $w.c create line $xy -tag I3_w -width 3 -fill $::C(fg)
488
+
489
+ # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle
490
+ set xy {515 207 495 207}
491
+ foreach {x1 y1 x2 y2} $xy {
492
+ $w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 \
493
+ -outline $color2
494
+ $w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 \
495
+ -outline $color2
496
+ incr y1 -6; incr y2 6
497
+ $w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 \
498
+ -outline $color2
499
+ }
500
+ set xy {492 220 518 263}
501
+ set xy [RoundRect $w $xy 15]
502
+ $w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2
503
+ set xy {500 217 511 217}
504
+ $w.c create line $xy -tag I3_ -fill $color2 -width 10
505
+
506
+ set xy {502 393 522 393 522 465} ;# Bottom weight target
507
+ $w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10
508
+ }
509
+ proc Move3 {w {step {}}} {
510
+ set step [GetStep 3 $step]
511
+
512
+ set pos {{505 247} {505 297} {505 386.5} {505 386.5}}
513
+ set rope(0) {750 309 729 301 711 324 690 300}
514
+ set rope(1) {750 309 737 292 736 335 717 315 712 320}
515
+ set rope(2) {750 309 737 309 740 343 736 351 725 340}
516
+ set rope(3) {750 309 738 321 746 345 742 356}
517
+
518
+ if {$step >= [llength $pos]} {
519
+ return 0
520
+ }
521
+
522
+ $w.c delete "I3_$step" ;# Delete part of the rope
523
+ MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down
524
+ $w.c coords I3_s $rope($step) ;# Flapping rope end
525
+ $w.c coords I3_w [concat 505 174 [lindex $pos $step]]
526
+ if {$step == 2} {
527
+ $w.c move I3__ 0 30
528
+ return 2
529
+ }
530
+ return 1
531
+ }
532
+
533
+ # Cage and door
534
+ proc Draw4 {w} {
535
+ set color $::C(4)
536
+ lassign {527 356 611 464} x0 y0 x1 y1
537
+
538
+ for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars
539
+ $w.c create line $x0 $y $x1 $y -fill $color -width 1
540
+ }
541
+ for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars
542
+ $w.c create line $x $y0 $x $y1 -fill $color -width 1
543
+ }
544
+
545
+ set xy {518 464 518 428} ;# Swing gate
546
+ $w.c create line $xy -tag I4 -fill $color -width 3
547
+ }
548
+ proc Move4 {w {step {}}} {
549
+ set step [GetStep 4 $step]
550
+
551
+ set angles {-10 -20 -30 -30}
552
+ if {$step >= [llength $angles]} {
553
+ return 0
554
+ }
555
+ RotateItem $w I4 518 464 [lindex $angles $step]
556
+ $w.c raise I4
557
+ return [expr {$step == 3 ? 3 : 1}]
558
+ }
559
+
560
+ # Mouse
561
+ proc Draw5 {w} {
562
+ set color $::C(5a)
563
+ set color2 $::C(5b)
564
+ set xy {377 248 410 248 410 465 518 465} ;# Mouse course
565
+ lappend xy 518 428 451 428 451 212 377 212
566
+ $w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3
567
+
568
+ set xy {
569
+ 534.5 445.5 541 440 552 436 560 436 569 440 574 446 575 452 574 454
570
+ 566 456 554 456 545 456 537 454 530 452
571
+ }
572
+ $w.c create poly $xy -tag {I5 I5_0} -fill $color
573
+ set xy {573 452 592 458 601 460 613 456} ;# Tail
574
+ $w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3
575
+ set xy [box 540 446 2] ;# Eye
576
+ set xy {540 444 541 445 541 447 540 448 538 447 538 445}
577
+ #.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {}
578
+ $w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1
579
+ set xy {538 454 535 461} ;# Front leg
580
+ $w.c create line $xy -tag {I5 I5_3} -fill $color -width 2
581
+ set xy {566 455 569 462} ;# Back leg
582
+ $w.c create line $xy -tag {I5 I5_4} -fill $color -width 2
583
+ set xy {544 455 545 460} ;# 2nd front leg
584
+ $w.c create line $xy -tag {I5 I5_5} -fill $color -width 2
585
+ set xy {560 455 558 460} ;# 2nd back leg
586
+ $w.c create line $xy -tag {I5 I5_6} -fill $color -width 2
587
+ }
588
+ proc Move5 {w {step {}}} {
589
+ set step [GetStep 5 $step]
590
+
591
+ set pos {
592
+ {553 452} {533 452} {513 452} {493 452} {473 452}
593
+ {463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394}
594
+ {422 374} {422 354} {422 334} {422 314} {422 294}
595
+ {422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237}
596
+ }
597
+ if {$step >= [llength $pos]} {
598
+ return 0
599
+ }
600
+
601
+ lassign [lindex $pos $step] x y beta next
602
+ MoveAbs $w I5 [list $x $y]
603
+ if {$beta ne ""} {
604
+ lassign [Centroid $w I5_0] Ox Oy
605
+ foreach id {0 1 2 3 4 5 6} {
606
+ RotateItem $w I5_$id $Ox $Oy $beta
607
+ }
608
+ }
609
+ if {$next eq "x"} {
610
+ return 3
611
+ }
612
+ return 1
613
+ }
614
+
615
+ # Dropping gumballs
616
+ array set XY6 {
617
+ -1 {366 207} -2 {349 204} -3 {359 193} -4 {375 192} -5 {340 190}
618
+ -6 {349 177} -7 {366 177} -8 {380 176} -9 {332 172} -10 {342 161}
619
+ -11 {357 164} -12 {372 163} -13 {381 149} -14 {364 151} -15 {349 146}
620
+ -16 {333 148} 0 {357 219}
621
+ 1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334}
622
+ 7 {367 340} 8 {366 346} 9 {364 350} 10 {361 355} 11 {359 370} 12 {359 391}
623
+ 13,0 {360 456} 13,1 {376 456} 13,2 {346 456} 13,3 {330 456}
624
+ 13,4 {353 444} 13,5 {368 443} 13,6 {339 442} 13,7 {359 431}
625
+ 13,8 {380 437} 13,9 {345 428} 13,10 {328 434} 13,11 {373 424}
626
+ 13,12 {331 420} 13,13 {360 417} 13,14 {345 412} 13,15 {376 410}
627
+ 13,16 {360 403}
628
+ }
629
+ proc Draw6 {w} {
630
+ set color $::C(6)
631
+ set xy {324 130 391 204} ;# Ball holder
632
+ set xy [RoundRect $w $xy 10]
633
+ $w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color
634
+ set xy {339 204 376 253} ;# Below the ball holder
635
+ $w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \
636
+ -tag I6c
637
+ set xy [box 346 339 28]
638
+ $w.c create oval $xy -fill $color -outline {} ;# Rotor
639
+ $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
640
+ -start 80 -extent 205
641
+ $w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
642
+ -start -41 -extent 85
643
+
644
+ set xy [box 346 339 15] ;# Center of rotor
645
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m
646
+ set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor
647
+ $w.c create poly $xy -fill $color -outline {}
648
+ $w.c create line $xy -fill $::C(fg) -width 2
649
+
650
+ set xy {353 240 367 300} ;# Poke bottom hole
651
+ $w.c create rect $xy -fill $color -outline {}
652
+ set xy {341 190 375 210} ;# Poke another hole
653
+ $w.c create rect $xy -fill $color -outline {}
654
+
655
+ set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366}
656
+ $w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor
657
+ $w.c create line $xy -fill $::C(fg) -width 2
658
+ set xy [box 275 342 7] ;# On/off rotor
659
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(fg)
660
+ set xy {276 334 342 325} ;# Fan belt top
661
+ $w.c create line $xy -fill $::C(fg) -width 3
662
+ set xy {276 349 342 353} ;# Fan belt bottom
663
+ $w.c create line $xy -fill $::C(fg) -width 3
664
+
665
+ set xy {337 212 337 247} ;# What the mouse pushes
666
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
667
+ set xy {392 212 392 247}
668
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
669
+ set xy {337 230 392 230}
670
+ $w.c create line $xy -fill $::C(fg) -width 7 -tag I6_
671
+
672
+ set who -1 ;# All the balls
673
+ set colors {red cyan orange green blue darkblue}
674
+ lappend colors {*}$colors {*}$colors
675
+
676
+ for {set i 0} {$i < 17} {incr i} {
677
+ set loc [expr {-1 * $i}]
678
+ set color [lindex $colors $i]
679
+ $w.c create oval [box {*}$::XY6($loc) 5] -fill $color \
680
+ -outline $color -tag I6_b$i
681
+ }
682
+ Draw6a $w 12 ;# The wheel
683
+ }
684
+ proc Draw6a {w beta} {
685
+ $w.c delete I6_0
686
+ lassign {346 339} Ox Oy
687
+ for {set i 0} {$i < 4} {incr i} {
688
+ set b [expr {$beta + $i * 45}]
689
+ lassign [RotateC 28 0 0 0 $b] x y
690
+ set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \
691
+ [expr {$Ox-$x}] [expr {$Oy-$y}]]
692
+ $w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2
693
+ }
694
+ }
695
+ proc Move6 {w {step {}}} {
696
+ set step [GetStep 6 $step]
697
+ if {$step > 62} {
698
+ return 0
699
+ }
700
+
701
+ if {$step < 2} { ;# Open gate for balls to drop
702
+ $w.c move I6_ -7 0
703
+ if {$step == 1} { ;# Poke a hole
704
+ set xy {348 226 365 240}
705
+ $w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {}
706
+ }
707
+ return 1
708
+ }
709
+
710
+ set s [expr {$step - 1}] ;# Do the gumball drop dance
711
+ for {set i 0} {$i <= int(($s-1) / 3)} {incr i} {
712
+ set tag "I6_b$i"
713
+ if {[$w.c find withtag $tag] eq ""} break
714
+ set loc [expr {$s - 3 * $i}]
715
+
716
+ if {[info exists ::XY6($loc,$i)]} {
717
+ MoveAbs $w $tag $::XY6($loc,$i)
718
+ } elseif {[info exists ::XY6($loc)]} {
719
+ MoveAbs $w $tag $::XY6($loc)
720
+ }
721
+ }
722
+ if {($s % 3) == 1} {
723
+ set first [expr {($s + 2) / 3}]
724
+ for {set i $first} {1} {incr i} {
725
+ set tag "I6_b$i"
726
+ if {[$w.c find withtag $tag] eq ""} break
727
+ set loc [expr {$first - $i}]
728
+ MoveAbs $w $tag $::XY6($loc)
729
+ }
730
+ }
731
+ if {$s >= 3} { ;# Rotate the motor
732
+ set idx [expr {$s % 3}]
733
+ #Draw6a $w [lindex {12 35 64} $idx]
734
+ Draw6a $w [expr {12 + $s * 15}]
735
+ }
736
+ return [expr {$s == 3 ? 3 : 1}]
737
+ }
738
+
739
+ # On/off switch
740
+ proc Draw7 {w} {
741
+ set color $::C(7)
742
+ set xy {198 306 277 374} ;# Box
743
+ $w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z
744
+ $w.c lower I7z
745
+ set xy {275 343 230 349}
746
+ $w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \
747
+ -arrowshape {23 23 8} -width 6
748
+ set xy {225 324} ;# On button
749
+ $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
750
+ set xy {218 323} ;# On text
751
+ set font {{Times Roman} 8}
752
+ $w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font
753
+ set xy {225 350} ;# Off button
754
+ $w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
755
+ set xy {218 349} ;# Off button
756
+ $w.c create text $xy -text "off" -anchor e -fill $::C(fg) -font $font
757
+ }
758
+ proc Move7 {w {step {}}} {
759
+ set step [GetStep 7 $step]
760
+ set numsteps 30
761
+ if {$step > $numsteps} {
762
+ return 0
763
+ }
764
+ set beta [expr {30.0 / $numsteps}]
765
+ RotateItem $w I7 275 343 $beta
766
+
767
+ return [expr {$step == $numsteps ? 3 : 1}]
768
+ }
769
+
770
+ # Electricity to the fan
771
+ proc Draw8 {w} {
772
+ Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3
773
+ }
774
+ proc Move8 {w {step {}}} {
775
+ set step [GetStep 8 $step]
776
+
777
+ if {$step > 3} {
778
+ return 0
779
+ }
780
+ if {$step == 0} {
781
+ Sparkle $w [Anchor $w I8_s s] I8
782
+ return 1
783
+
784
+ } elseif {$step == 1} {
785
+ MoveAbs $w I8 [Anchor $w I8_s c]
786
+ } elseif {$step == 2} {
787
+ MoveAbs $w I8 [Anchor $w I8_s n]
788
+ } else {
789
+ $w.c delete I8
790
+ }
791
+ return [expr {$step == 2 ? 3 : 1}]
792
+ }
793
+
794
+ # Fan
795
+ proc Draw9 {w} {
796
+ set color $::C(9)
797
+ set xy {266 194 310 220}
798
+ $w.c create oval $xy -outline $color -fill $color
799
+ set xy {280 209 296 248}
800
+ $w.c create oval $xy -outline $color -fill $color
801
+ set xy {288 249 252 249 260 240 280 234 296 234 316 240 324 249 288 249}
802
+ $w.c create poly $xy -fill $color -smooth 1
803
+
804
+ set xy {248 205 265 214 264 205 265 196} ;# Spinner
805
+ $w.c create poly $xy -fill $color
806
+
807
+ set xy {255 206 265 234} ;# Fan blades
808
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
809
+ set xy {255 176 265 204}
810
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
811
+ set xy {255 206 265 220}
812
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
813
+ set xy {255 190 265 204}
814
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
815
+ }
816
+ proc Move9 {w {step {}}} {
817
+ set step [GetStep 9 $step]
818
+
819
+ if {$step & 1} {
820
+ $w.c itemconfig I9_0 -width 4
821
+ $w.c itemconfig I9_1 -width 1
822
+ $w.c lower I9_1 I9_0
823
+ } else {
824
+ $w.c itemconfig I9_0 -width 1
825
+ $w.c itemconfig I9_1 -width 4
826
+ $w.c lower I9_0 I9_1
827
+ }
828
+ if {$step == 0} {
829
+ return 3
830
+ }
831
+ return 1
832
+ }
833
+
834
+ # Boat
835
+ proc Draw10 {w} {
836
+ set color $::C(10a)
837
+ set color2 $::C(10b)
838
+ set xy {191 230 233 230 233 178 191 178} ;# Sail
839
+ $w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10
840
+ set xy [box 209 204 31] ;# Front
841
+ $w.c create arc $xy -outline {} -fill $color -style pie \
842
+ -start 120 -extent 120 -tag I10
843
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
844
+ -start 120 -extent 120 -tag I10
845
+ set xy [box 249 204 31] ;# Back
846
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \
847
+ -start 120 -extent 120 -tag I10
848
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
849
+ -start 120 -extent 120 -tag I10
850
+
851
+ set xy {200 171 200 249} ;# Mast
852
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I10
853
+ set xy {159 234 182 234} ;# Bow sprit
854
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I10
855
+ set xy {180 234 180 251 220 251} ;# Hull
856
+ $w.c create line $xy -fill $::C(fg) -width 6 -tag I10
857
+
858
+ set xy {92 255 221 255} ;# Waves
859
+ Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w
860
+
861
+ set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water
862
+ set xy [concat $xy 222 266 222 277 99 277]
863
+ $w.c create poly $xy -fill $color2 -outline $color2
864
+ set xy {222 266 222 277 97 277 97 266} ;# Water bottom
865
+ $w.c create line $xy -fill $::C(fg) -width 3
866
+
867
+ set xy [box 239 262 17]
868
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
869
+ -start 95 -extent 103
870
+ set xy [box 76 266 21]
871
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190
872
+ }
873
+ proc Move10 {w {step {}}} {
874
+ set step [GetStep 10 $step]
875
+ set pos {
876
+ {195 212} {193 212} {190 212} {186 212} {181 212} {176 212}
877
+ {171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212}
878
+ {137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212}
879
+ }
880
+
881
+ if {$step >= [llength $pos]} {
882
+ return 0
883
+ }
884
+ set where [lindex $pos $step]
885
+ MoveAbs $w I10 $where
886
+
887
+ if {[lindex $where 2] eq "x"} {
888
+ return 3
889
+ }
890
+ return 1
891
+ }
892
+
893
+ # 2nd ball drop
894
+ proc Draw11 {w} {
895
+ set color $::C(11a)
896
+ set color2 $::C(11b)
897
+ set xy {23 264 55 591} ;# Color the down tube
898
+ $w.c create rect $xy -fill $color -outline {}
899
+ set xy [box 71 460 48] ;# Color the outer loop
900
+ $w.c create oval $xy -fill $color -outline {}
901
+
902
+ set xy {55 264 55 458} ;# Top right side
903
+ $w.c create line $xy -fill $::C(fg) -width 3
904
+ set xy {55 504 55 591} ;# Bottom right side
905
+ $w.c create line $xy -fill $::C(fg) -width 3
906
+ set xy [box 71 460 48] ;# Outer loop
907
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
908
+ -start 110 -extent -290 -tag I11i
909
+ set xy [box 71 460 16] ;# Inner loop
910
+ $w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i
911
+ $w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3
912
+
913
+ set xy {23 264 23 591} ;# Left side
914
+ $w.c create line $xy -fill $::C(fg) -width 3
915
+ set xy [box 1 266 23] ;# Top left curve
916
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90
917
+
918
+ set xy [box 75 235 9] ;# The ball
919
+ $w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11
920
+ }
921
+ proc Move11 {w {step {}}} {
922
+ set step [GetStep 11 $step]
923
+ set pos {
924
+ {75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296}
925
+ {38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423}
926
+ {-100 -100} {38 505} {38 527 x} {38 591}
927
+ }
928
+
929
+ if {$step >= [llength $pos]} {
930
+ return 0
931
+ }
932
+ set where [lindex $pos $step]
933
+ MoveAbs $w I11 $where
934
+ if {[lindex $where 2] eq "x"} {
935
+ return 3
936
+ }
937
+ return 1
938
+ }
939
+
940
+ # Hand
941
+ proc Draw12 {w} {
942
+ set xy {20 637 20 617 20 610 20 590 40 590 40 590 60 590 60 610 60 610}
943
+ lappend xy 60 610 65 620 60 631 ;# Thumb
944
+ lappend xy 60 631 60 637 60 662 60 669 52 669 56 669 50 669 50 662 50 637
945
+
946
+ set y0 637 ;# Bumps for fingers
947
+ set y1 645
948
+ for {set x 50} {$x > 20} {incr x -10} {
949
+ set x1 [expr {$x - 5}]
950
+ set x2 [expr {$x - 10}]
951
+ lappend xy $x $y0 $x1 $y1 $x2 $y0
952
+ }
953
+ $w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \
954
+ -width 3
955
+ }
956
+ proc Move12 {w {step {}}} {
957
+ set step [GetStep 12 $step]
958
+ set pos {{42.5 641 x}}
959
+ if {$step >= [llength $pos]} {
960
+ return 0
961
+ }
962
+
963
+ set where [lindex $pos $step]
964
+ MoveAbs $w I12 $where
965
+ if {[lindex $where 2] eq "x"} {
966
+ return 3
967
+ }
968
+ return 1
969
+ }
970
+
971
+ # Fax
972
+ proc Draw13 {w} {
973
+ set color $::C(13a)
974
+ set xy {86 663 149 663 149 704 50 704 50 681 64 681 86 671}
975
+ set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671}
976
+ set radii {2 9 9 8 5 5 2}
977
+
978
+ RoundPoly $w.c $xy $radii -width 3 -outline $::C(fg) -fill $color
979
+ RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color
980
+
981
+ set xy {56 677}
982
+ $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
983
+ -tag I13
984
+ set xy {809 677}
985
+ $w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
986
+ -tag I13R
987
+
988
+ set xy {112 687} ;# Label
989
+ $w.c create text $xy -text "FAX" -fill $::C(fg) \
990
+ -font {{Times Roman} 12 bold}
991
+ set xy {762 687}
992
+ $w.c create text $xy -text "FAX" -fill $::C(fg) \
993
+ -font {{Times Roman} 12 bold}
994
+
995
+ set xy {138 663 148 636 178 636} ;# Paper guide
996
+ $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
997
+ set xy {732 663 722 636 692 636}
998
+ $w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
999
+
1000
+ Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3
1001
+ }
1002
+ proc Move13 {w {step {}}} {
1003
+ set step [GetStep 13 $step]
1004
+ set numsteps 7
1005
+
1006
+ if {$step == $numsteps+2} {
1007
+ MoveAbs $w I13_star {-100 -100}
1008
+ $w.c itemconfig I13R -fill $::C(13b) -width 2
1009
+ return 2
1010
+ }
1011
+ if {$step == 0} { ;# Button down
1012
+ $w.c delete I13
1013
+ Sparkle $w {-100 -100} I13_star ;# Create off screen
1014
+ return 1
1015
+ }
1016
+ lassign [Anchor $w I13_s w] x0 y0
1017
+ lassign [Anchor $w I13_s e] x1 y1
1018
+ set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
1019
+ MoveAbs $w I13_star [list $x $y0]
1020
+ return 1
1021
+ }
1022
+
1023
+ # Paper in fax
1024
+ proc Draw14 {w} {
1025
+ set color $::C(14)
1026
+ set xy {102 661 113 632 130 618} ;# Left paper edge
1027
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0
1028
+ set xy {148 629 125 640 124 662} ;# Right paper edge
1029
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1
1030
+ Draw14a $w L
1031
+
1032
+ set xy {
1033
+ 768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171
1034
+ }
1035
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_0
1036
+ $w.c lower I14R_0
1037
+ # NB. these numbers are VERY sensitive, you must start with final size
1038
+ # and shrink down to get the values
1039
+ set xy {
1040
+ 745.947897349 662.428358855 745.997829056 662.452239237 746.0 662.5
1041
+ }
1042
+ $w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1
1043
+ $w.c lower I14R_1
1044
+ }
1045
+ proc Draw14a {w side} {
1046
+ set color $::C(14)
1047
+ set xy [$w.c coords I14${side}_0]
1048
+ set xy2 [$w.c coords I14${side}_1]
1049
+ lassign $xy x0 y0 x1 y1 x2 y2
1050
+ lassign $xy2 x3 y3 x4 y4 x5 y5
1051
+ set zz [concat \
1052
+ $x0 $y0 $x0 $y0 $xy $x2 $y2 $x2 $y2 \
1053
+ $x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5]
1054
+ $w.c delete I14$side
1055
+ $w.c create poly $zz -tag I14$side -smooth 1 -fill $color -outline $color \
1056
+ -width 3
1057
+ $w.c lower I14$side
1058
+ }
1059
+ proc Move14 {w {step {}}} {
1060
+ set step [GetStep 14 $step]
1061
+
1062
+ # Paper going down
1063
+ set sc [expr {.9 - .05*$step}]
1064
+ if {$sc < .3} {
1065
+ $w.c delete I14L
1066
+ return 0
1067
+ }
1068
+
1069
+ lassign [$w.c coords I14L_0] Ox Oy
1070
+ $w.c scale I14L_0 $Ox $Oy $sc $sc
1071
+ lassign [lrange [$w.c coords I14L_1] end-1 end] Ox Oy
1072
+ $w.c scale I14L_1 $Ox $Oy $sc $sc
1073
+ Draw14a $w L
1074
+
1075
+ # Paper going up
1076
+ set sc [expr {.35 + .05*$step}]
1077
+ set sc [expr {1 / $sc}]
1078
+
1079
+ lassign [$w.c coords I14R_0] Ox Oy
1080
+ $w.c scale I14R_0 $Ox $Oy $sc $sc
1081
+ lassign [lrange [$w.c coords I14R_1] end-1 end] Ox Oy
1082
+ $w.c scale I14R_1 $Ox $Oy $sc $sc
1083
+ Draw14a $w R
1084
+
1085
+ return [expr {$step == 10 ? 3 : 1}]
1086
+ }
1087
+
1088
+ # Light beam
1089
+ proc Draw15 {w} {
1090
+ set color $::C(15a)
1091
+ set xy {824 599 824 585 820 585 829 585}
1092
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I15a
1093
+ set xy {789 599 836 643}
1094
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1095
+ set xy {778 610 788 632}
1096
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1097
+ set xy {766 617 776 625}
1098
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1099
+
1100
+ set xy {633 600 681 640}
1101
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 3
1102
+ set xy {635 567 657 599}
1103
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 2
1104
+ set xy {765 557 784 583}
1105
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 2
1106
+
1107
+ Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3
1108
+ }
1109
+ proc Move15a {w} {
1110
+ set color $::C(15b)
1111
+ $w.c scale I15a 824 599 1 .3 ;# Button down
1112
+ set xy {765 621 681 621}
1113
+ $w.c create line $xy -dash "-" -width 3 -fill $color -tag I15
1114
+ }
1115
+ proc Move15 {w {step {}}} {
1116
+ set step [GetStep 15 $step]
1117
+ set numsteps 6
1118
+
1119
+ if {$step == $numsteps+2} {
1120
+ MoveAbs $w I15_star {-100 -100}
1121
+ return 2
1122
+ }
1123
+ if {$step == 0} { ;# Break the light beam
1124
+ Sparkle $w {-100 -100} I15_star
1125
+ set xy {765 621 745 621}
1126
+ $w.c coords I15 $xy
1127
+ return 1
1128
+ }
1129
+ lassign [Anchor $w I15_s w] x0 y0
1130
+ lassign [Anchor $w I15_s e] x1 y1
1131
+ set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
1132
+ MoveAbs $w I15_star [list $x $y0]
1133
+ return 1
1134
+ }
1135
+
1136
+ # Bell
1137
+ proc Draw16 {w} {
1138
+ set color $::C(16)
1139
+ set xy {722 485 791 556}
1140
+ $w.c create rect $xy -fill {} -outline $::C(fg) -width 3
1141
+ set xy [box 752 515 25] ;# Bell
1142
+ $w.c create oval $xy -fill $color -outline black -tag I16b -width 2
1143
+ set xy [box 752 515 5] ;# Bell button
1144
+ $w.c create oval $xy -fill black -outline black -tag I16b
1145
+
1146
+ set xy {784 523 764 549} ;# Clapper
1147
+ $w.c create line $xy -width 3 -tag I16c -fill $::C(fg)
1148
+ set xy [box 784 523 4]
1149
+ $w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d
1150
+ }
1151
+ proc Move16 {w {step {}}} {
1152
+ set step [GetStep 16 $step]
1153
+
1154
+ # Note: we never stop
1155
+ lassign {760 553} Ox Oy
1156
+ if {$step & 1} {
1157
+ set beta 12
1158
+ $w.c move I16b 3 0
1159
+ } else {
1160
+ set beta -12
1161
+ $w.c move I16b -3 0
1162
+ }
1163
+ RotateItem $w I16c $Ox $Oy $beta
1164
+ RotateItem $w I16d $Ox $Oy $beta
1165
+
1166
+ return [expr {$step == 1 ? 3 : 1}]
1167
+ }
1168
+
1169
+ # Cat
1170
+ proc Draw17 {w} {
1171
+ set color $::C(17)
1172
+
1173
+ set xy {584 556 722 556}
1174
+ $w.c create line $xy -fill $::C(fg) -width 3
1175
+ set xy {584 485 722 485}
1176
+ $w.c create line $xy -fill $::C(fg) -width 3
1177
+
1178
+ set xy {664 523 717 549} ;# Body
1179
+ $w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \
1180
+ -style chord -start 128 -extent -260 -tag I17
1181
+
1182
+ set xy {709 554 690 543} ;# Paw
1183
+ $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
1184
+ set xy {657 544 676 555}
1185
+ $w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
1186
+
1187
+ set xy [box 660 535 15] ;# Lower face
1188
+ $w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
1189
+ -start 150 -extent 240 -tag I17_
1190
+ $w.c create arc $xy -outline {} -fill $color -width 1 -style chord \
1191
+ -start 150 -extent 240 -tag I17_
1192
+ set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears
1193
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1194
+ $w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c}
1195
+ set xy {652 542 628 539} ;# Whiskers
1196
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1197
+ set xy {652 543 632 545}
1198
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1199
+ set xy {652 546 632 552}
1200
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1201
+
1202
+ set xy {668 543 687 538}
1203
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1204
+ set xy {668 544 688 546}
1205
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1206
+ set xy {668 547 688 553}
1207
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
1208
+
1209
+ set xy {649 530 654 538 659 530} ;# Left eye
1210
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1211
+ set xy {671 530 666 538 661 530} ;# Right eye
1212
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1213
+ set xy {655 543 660 551 665 543} ;# Mouth
1214
+ $w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
1215
+ }
1216
+ proc Move17 {w {step {}}} {
1217
+ set step [GetStep 17 $step]
1218
+
1219
+ if {$step == 0} {
1220
+ $w.c delete I17 ;# Delete most of the cat
1221
+ set xy {655 543 660 535 665 543} ;# Mouth
1222
+ $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
1223
+ set xy [box 654 530 4] ;# Left eye
1224
+ $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
1225
+ set xy [box 666 530 4] ;# Right eye
1226
+ $w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
1227
+
1228
+ $w.c move I17_ 0 -20 ;# Move face up
1229
+ set xy {652 528 652 554} ;# Front leg
1230
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1231
+ set xy {670 528 670 554} ;# 2nd front leg
1232
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1233
+
1234
+ set xy {
1235
+ 675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525
1236
+ 706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517
1237
+ 677 512
1238
+ } ;# Body
1239
+ $w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \
1240
+ -outline $::C(fg) -width 3 -smooth 1 -tag I17_
1241
+ set xy {716 514 716 554} ;# Back leg
1242
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1243
+ set xy {694 532 694 554} ;# 2nd back leg
1244
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
1245
+ set xy {715 514 718 506 719 495 716 488};# Tail
1246
+ $w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
1247
+
1248
+ $w.c raise I17w ;# Make whiskers visible
1249
+ $w.c move I17_ -5 0 ;# Move away from wall a bit
1250
+ return 2
1251
+ }
1252
+ return 0
1253
+ }
1254
+
1255
+ # Sling shot
1256
+ proc Draw18 {w} {
1257
+ set color $::C(18)
1258
+ set xy {721 506 627 506} ;# Sling hold
1259
+ $w.c create line $xy -width 4 -fill $::C(fg) -tag I18
1260
+
1261
+ set xy {607 500 628 513} ;# Sling rock
1262
+ $w.c create oval $xy -fill $color -outline {} -tag I18a
1263
+
1264
+ set xy {526 513 606 507 494 502} ;# Sling band
1265
+ $w.c create line $xy -fill $::C(fg) -width 4 -tag I18b
1266
+ set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling
1267
+ $w.c create line $xy -fill $::C(fg) -width 6
1268
+ }
1269
+ proc Move18 {w {step {}}} {
1270
+ set step [GetStep 18 $step]
1271
+
1272
+ set pos {
1273
+ {587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506}
1274
+ {16 506} {-100 -100}
1275
+ }
1276
+
1277
+ set b(0) {490 502 719 507 524 512} ;# Band collapsing
1278
+ set b(1) {
1279
+ 491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534
1280
+ 532 519 529 499
1281
+ }
1282
+ set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500}
1283
+ set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501}
1284
+
1285
+ if {$step >= [llength $pos]} {
1286
+ return 0
1287
+ }
1288
+
1289
+ if {$step == 0} {
1290
+ $w.c delete I18
1291
+ $w.c itemconfig I18b -smooth 1
1292
+ }
1293
+ if {[info exists b($step)]} {
1294
+ $w.c coords I18b $b($step)
1295
+ }
1296
+
1297
+ set where [lindex $pos $step]
1298
+ MoveAbs $w I18a $where
1299
+ if {[lindex $where 2] eq "x"} {
1300
+ return 3
1301
+ }
1302
+ return 1
1303
+ }
1304
+
1305
+ # Water pipe
1306
+ proc Draw19 {w} {
1307
+ set color $::C(19)
1308
+ set xx {249 181 155 118 86 55 22 0}
1309
+ foreach {x1 x2} $xx {
1310
+ $w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19
1311
+ $w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top
1312
+ $w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom
1313
+ }
1314
+ $w.c raise I11i
1315
+
1316
+ set xy [box 168 460 16] ;# Bulge by the joint
1317
+ $w.c create oval $xy -fill $color -outline {}
1318
+ $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
1319
+ -start 21 -extent 136
1320
+ $w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
1321
+ -start -21 -extent -130
1322
+
1323
+ set xy {249 447 255 473} ;# First joint 26x6
1324
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1325
+
1326
+ set xy [box 257 433 34] ;# Bend up
1327
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1328
+ -style pie -start 0 -extent -91
1329
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1330
+ -style arc -start 0 -extent -90
1331
+ set xy [box 257 433 20]
1332
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1333
+ -style pie -start 0 -extent -92
1334
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1335
+ -style arc -start 0 -extent -90
1336
+ set xy [box 257 421 34] ;# Bend left
1337
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1338
+ -style pie -start 1 -extent 91
1339
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1340
+ -style arc -start 0 -extent 90
1341
+ set xy [box 257 421 20]
1342
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1343
+ -style pie -start 0 -extent 90
1344
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1345
+ -style arc -start 0 -extent 90
1346
+ set xy [box 243 421 34] ;# Bend down
1347
+ $w.c create arc $xy -outline {} -fill $color -width 1 \
1348
+ -style pie -start 90 -extent 90
1349
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1350
+ -style arc -start 90 -extent 90
1351
+ set xy [box 243 421 20]
1352
+ $w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
1353
+ -style pie -start 90 -extent 90
1354
+ $w.c create arc $xy -outline $::C(fg) -width 1 \
1355
+ -style arc -start 90 -extent 90
1356
+
1357
+ set xy {270 427 296 433} ;# 2nd joint bottom
1358
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1359
+ set xy {270 421 296 427} ;# 2nd joint top
1360
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1361
+ set xy {249 382 255 408} ;# Third joint right
1362
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1363
+ set xy {243 382 249 408} ;# Third joint left
1364
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1365
+ set xy {203 420 229 426} ;# Last joint
1366
+ $w.c create rect $xy -fill $color -outline $::C(fg) -width 1
1367
+
1368
+ set xy [box 168 460 6] ;# Handle joint
1369
+ $w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a
1370
+ set xy {168 460 168 512} ;# Handle bar
1371
+ $w.c create line $xy -fill $::C(fg) -width 5 -tag I19b
1372
+ }
1373
+ proc Move19 {w {step {}}} {
1374
+ set step [GetStep 19 $step]
1375
+
1376
+ set angles {30 30 30}
1377
+ if {$step == [llength $angles]} {
1378
+ return 2
1379
+ }
1380
+
1381
+ RotateItem $w I19b {*}[Centroid $w I19a] [lindex $angles $step]
1382
+ return 1
1383
+ }
1384
+
1385
+ # Water pouring
1386
+ proc Draw20 {w} {
1387
+ }
1388
+ proc Move20 {w {step {}}} {
1389
+ set step [GetStep 20 $step]
1390
+
1391
+ set pos {451 462 473 484 496 504 513 523 532}
1392
+ set freq {20 40 40 40 40 40 40 40 40}
1393
+ set pos {
1394
+ {451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40}
1395
+ {523 40} {532 40 x}
1396
+ }
1397
+ if {$step >= [llength $pos]} {
1398
+ return 0
1399
+ }
1400
+
1401
+ $w.c delete I20
1402
+ set where [lindex $pos $step]
1403
+ lassign $where y f
1404
+ H2O $w $y $f
1405
+ if {[lindex $where 2] eq "x"} {
1406
+ return 3
1407
+ }
1408
+ return 1
1409
+ }
1410
+ proc H2O {w y f} {
1411
+ set color $::C(20)
1412
+ $w.c delete I20
1413
+
1414
+ Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \
1415
+ -smooth 1
1416
+ $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
1417
+ -tag {I20 I20a}
1418
+ $w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
1419
+ -tag {I20 I20b}
1420
+ $w.c move I20a 8 0
1421
+ $w.c move I20b 16 0
1422
+ }
1423
+
1424
+ # Bucket
1425
+ proc Draw21 {w} {
1426
+ set color $::C(21)
1427
+ set xy {217 451 244 490} ;# Right handle
1428
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
1429
+ set xy {201 467 182 490} ;# Left handle
1430
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
1431
+
1432
+ set xy {245 490 237 535} ;# Right side
1433
+ set xy2 {189 535 181 490} ;# Left side
1434
+ $w.c create poly [concat $xy $xy2] -fill $color -outline {} \
1435
+ -tag {I21 I21f}
1436
+ $w.c create line $xy -fill $::C(fg) -width 2 -tag I21
1437
+ $w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21
1438
+
1439
+ set xy {182 486 244 498} ;# Top
1440
+ $w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f}
1441
+ $w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t}
1442
+ set xy {189 532 237 540} ;# Bottom
1443
+ $w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \
1444
+ -tag {I21 I21b}
1445
+ }
1446
+ proc Move21 {w {step {}}} {
1447
+ set step [GetStep 21 $step]
1448
+
1449
+ set numsteps 30
1450
+ if {$step >= $numsteps} {
1451
+ return 0
1452
+ }
1453
+
1454
+ lassign [$w.c coords I21b] x1 y1 x2 y2
1455
+ #lassign [$w.c coords I21t] X1 Y1 X2 Y2
1456
+ lassign {183 492 243 504} X1 Y1 X2 Y2
1457
+
1458
+ set f [expr {$step / double($numsteps)}]
1459
+ set y2 [expr {$y2 - 3}]
1460
+ set xx1 [expr {$x1 + ($X1 - $x1) * $f}]
1461
+ set yy1 [expr {$y1 + ($Y1 - $y1) * $f}]
1462
+ set xx2 [expr {$x2 + ($X2 - $x2) * $f}]
1463
+ set yy2 [expr {$y2 + ($Y2 - $y2) * $f}]
1464
+ #H2O $w $yy1 40
1465
+
1466
+ $w.c itemconfig I21b -fill $::C(20)
1467
+ $w.c delete I21w
1468
+ $w.c create poly $x2 $y2 $x1 $y1 $xx1 $yy1 $xx2 $yy1 -tag {I21 I21w} \
1469
+ -outline {} -fill $::C(20)
1470
+ $w.c lower I21w I21
1471
+ $w.c raise I21b
1472
+ $w.c lower I21f
1473
+
1474
+ return [expr {$step == $numsteps-1 ? 3 : 1}]
1475
+ }
1476
+
1477
+ # Bucket drop
1478
+ proc Draw22 {w} {
1479
+ }
1480
+ proc Move22 {w {step {}}} {
1481
+ set step [GetStep 22 $step]
1482
+ set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}}
1483
+
1484
+ if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)}
1485
+ if {$step >= [llength $pos]} {
1486
+ return 0
1487
+ }
1488
+ set where [lindex $pos $step]
1489
+ MoveAbs $w I21 $where
1490
+ H2O $w [lindex $where 1] 40
1491
+ $w.c delete I21_a ;# Delete handles
1492
+
1493
+ if {[lindex $where 2] eq "x"} {
1494
+ return 3
1495
+ }
1496
+ return 1
1497
+ }
1498
+
1499
+ # Blow dart
1500
+ proc Draw23 {w} {
1501
+ set color $::C(23a)
1502
+ set color2 $::C(23b)
1503
+ set color3 $::C(23c)
1504
+
1505
+ set xy {185 623 253 650} ;# Block
1506
+ $w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a
1507
+ set xy {187 592 241 623} ;# Balloon
1508
+ $w.c create oval $xy -outline {} -fill $color -tag I23b
1509
+ $w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \
1510
+ -style arc -start 12 -extent 336
1511
+ set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle
1512
+ $w.c create poly $xy -outline {} -fill $color -tag I23b
1513
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23b
1514
+
1515
+ set xy {285 611 250 603} ;# Dart body
1516
+ $w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d
1517
+ set xy {249 596 249 618 264 607 249 596} ;# Dart tail
1518
+ $w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d
1519
+ set xy {249 607 268 607} ;# Dart detail
1520
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
1521
+ set xy {285 607 305 607} ;# Dart needle
1522
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
1523
+ }
1524
+ proc Move23 {w {step {}}} {
1525
+ set step [GetStep 23 $step]
1526
+
1527
+ set pos {
1528
+ {277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607}
1529
+ {587 607} {687 607} {787 607} {-100 -100}
1530
+ }
1531
+
1532
+ if {$step >= [llength $pos]} {
1533
+ return 0
1534
+ }
1535
+ if {$step <= 1} {
1536
+ $w.c scale I23b {*}[Anchor $w I23a n] .9 .5
1537
+ }
1538
+ set where [lindex $pos $step]
1539
+ MoveAbs $w I23d $where
1540
+
1541
+ if {[lindex $where 2] eq "x"} {
1542
+ return 3
1543
+ }
1544
+ return 1
1545
+ }
1546
+
1547
+ # Balloon
1548
+ proc Draw24 {w} {
1549
+ set color $::C(24a)
1550
+ set xy {366 518 462 665} ;# Balloon
1551
+ $w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24
1552
+ set xy {414 666 414 729} ;# String
1553
+ $w.c create line $xy -fill $::C(fg) -width 3 -tag I24
1554
+ set xy {410 666 404 673 422 673 418 666} ;# Nozzle
1555
+ $w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24
1556
+
1557
+ set xy {387 567 390 549 404 542} ;# Reflections
1558
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1559
+ set xy {395 568 399 554 413 547}
1560
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1561
+ set xy {403 570 396 555 381 553}
1562
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1563
+ set xy {408 564 402 547 386 545}
1564
+ $w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
1565
+ }
1566
+ proc Move24 {w {step {}}} {
1567
+ global S
1568
+ set step [GetStep 24 $step]
1569
+
1570
+ if {$step > 4} {
1571
+ return 0
1572
+ } elseif {$step == 4} {
1573
+ return 2
1574
+ }
1575
+
1576
+ if {$step == 0} {
1577
+ $w.c delete I24 ;# Exploding balloon
1578
+ set xy {
1579
+ 347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626
1580
+ 320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702
1581
+ 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508
1582
+ 431 441 431 440 400 502 347 465 347 465
1583
+ }
1584
+ $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \
1585
+ -width 10 -smooth 1
1586
+ set msg [subst $S(message)]
1587
+ $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \
1588
+ -fill $::C(24c) \
1589
+ -justify center -font {{Times Roman} 18 bold}
1590
+ return 1
1591
+ }
1592
+
1593
+ $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold]
1594
+ $w.c move I24 0 -60
1595
+ $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25
1596
+ return 1
1597
+ }
1598
+
1599
+ # Displaying the message
1600
+ proc Move25 {w {step {}}} {
1601
+ global S
1602
+ set step [GetStep 25 $step]
1603
+ if {$step == 0} {
1604
+ set ::XY(25) [clock clicks -milliseconds]
1605
+ return 1
1606
+ }
1607
+ set elapsed [expr {[clock clicks -milliseconds] - $::XY(25)}]
1608
+ if {$elapsed < 5000} {
1609
+ return 1
1610
+ }
1611
+ return 2
1612
+ }
1613
+
1614
+ # Collapsing balloon
1615
+ proc Move26 {w {step {}}} {
1616
+ global S
1617
+ set step [GetStep 26 $step]
1618
+
1619
+ if {$step >= 3} {
1620
+ $w.c delete I24 I26
1621
+ $w.c create text 430 755 -anchor s -tag I26 \
1622
+ -fill $::C(26) \
1623
+ -text "click to continue" -font {{Times Roman} 24 bold}
1624
+ bind $w.c <Button-1> [list Reset $w]
1625
+ return 4
1626
+ }
1627
+
1628
+ $w.c scale I24 {*}[Centroid $w I24] .8 .8
1629
+ $w.c move I24 0 60
1630
+ $w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold]
1631
+ return 1
1632
+ }
1633
+
1634
+ ################################################################
1635
+ #
1636
+ # Helper functions
1637
+ #
1638
+
1639
+ proc box {x y r} {
1640
+ return [list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]]
1641
+ }
1642
+
1643
+ proc MoveAbs {w item xy} {
1644
+ lassign $xy x y
1645
+ lassign [Centroid $w $item] Ox Oy
1646
+ set dx [expr {$x - $Ox}]
1647
+ set dy [expr {$y - $Oy}]
1648
+ $w.c move $item $dx $dy
1649
+ }
1650
+
1651
+ proc RotateItem {w item Ox Oy beta} {
1652
+ set xy [$w.c coords $item]
1653
+ set xy2 {}
1654
+ foreach {x y} $xy {
1655
+ lappend xy2 {*}[RotateC $x $y $Ox $Oy $beta]
1656
+ }
1657
+ $w.c coords $item $xy2
1658
+ }
1659
+
1660
+ proc RotateC {x y Ox Oy beta} {
1661
+ # rotates vector (Ox,Oy)->(x,y) by beta degrees clockwise
1662
+
1663
+ set x [expr {$x - $Ox}] ;# Shift to origin
1664
+ set y [expr {$y - $Oy}]
1665
+
1666
+ set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians
1667
+ set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate
1668
+ set yy [expr {$x * sin($beta) + $y * cos($beta)}]
1669
+
1670
+ set xx [expr {$xx + $Ox}] ;# Shift back
1671
+ set yy [expr {$yy + $Oy}]
1672
+
1673
+ return [list $xx $yy]
1674
+ }
1675
+
1676
+ proc Reset {w} {
1677
+ global S
1678
+ DrawAll $w
1679
+ bind $w.c <Button-1> {}
1680
+ set S(mode) $::MSTART
1681
+ set S(active) 0
1682
+ }
1683
+
1684
+ # Each Move## keeps its state info in STEP, this retrieves and increments it
1685
+ proc GetStep {who step} {
1686
+ global STEP
1687
+ if {$step ne ""} {
1688
+ set STEP($who) $step
1689
+ } elseif {![info exists STEP($who)] || $STEP($who) eq ""} {
1690
+ set STEP($who) 0
1691
+ } else {
1692
+ incr STEP($who)
1693
+ }
1694
+ return $STEP($who)
1695
+ }
1696
+
1697
+ proc ResetStep {} {
1698
+ global STEP
1699
+ set ::S(cnt) 0
1700
+ foreach a [array names STEP] {
1701
+ set STEP($a) ""
1702
+ }
1703
+ }
1704
+
1705
+ proc Sine {w x0 y0 x1 y1 amp freq args} {
1706
+ set PI [expr {4 * atan(1)}]
1707
+ set step 2
1708
+ set xy {}
1709
+ if {$y0 == $y1} { ;# Horizontal
1710
+ for {set x $x0} {$x <= $x1} {incr x $step} {
1711
+ set beta [expr {($x - $x0) * 2 * $PI / $freq}]
1712
+ set y [expr {$y0 + $amp * sin($beta)}]
1713
+ lappend xy $x $y
1714
+ }
1715
+ } else {
1716
+ for {set y $y0} {$y <= $y1} {incr y $step} {
1717
+ set beta [expr {($y - $y0) * 2 * $PI / $freq}]
1718
+ set x [expr {$x0 + $amp * sin($beta)}]
1719
+ lappend xy $x $y
1720
+ }
1721
+ }
1722
+ return [$w.c create line $xy {*}$args]
1723
+ }
1724
+
1725
+ proc RoundRect {w xy radius args} {
1726
+ lassign $xy x0 y0 x3 y3
1727
+ set r [winfo pixels $w.c $radius]
1728
+ set d [expr {2 * $r}]
1729
+
1730
+ # Make sure that the radius of the curve is less than 3/8 size of the box!
1731
+ set maxr 0.75
1732
+ if {$d > $maxr * ($x3 - $x0)} {
1733
+ set d [expr {$maxr * ($x3 - $x0)}]
1734
+ }
1735
+ if {$d > $maxr * ($y3 - $y0)} {
1736
+ set d [expr {$maxr * ($y3 - $y0)}]
1737
+ }
1738
+
1739
+ set x1 [expr { $x0 + $d }]
1740
+ set x2 [expr { $x3 - $d }]
1741
+ set y1 [expr { $y0 + $d }]
1742
+ set y2 [expr { $y3 - $d }]
1743
+
1744
+ set xy [list $x0 $y0 $x1 $y0 $x2 $y0 $x3 $y0 $x3 $y1 $x3 $y2]
1745
+ lappend xy $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1
1746
+ return $xy
1747
+ }
1748
+
1749
+ proc RoundPoly {canv xy radii args} {
1750
+ set lenXY [llength $xy]
1751
+ set lenR [llength $radii]
1752
+ if {$lenXY != 2*$lenR} {
1753
+ error "wrong number of vertices and radii"
1754
+ }
1755
+
1756
+ set knots {}
1757
+ lassign [lrange $xy end-1 end] x0 y0
1758
+ lassign $xy x1 y1
1759
+ lappend xy {*}[lrange $xy 0 1]
1760
+
1761
+ for {set i 0} {$i < $lenXY} {incr i 2} {
1762
+ set radius [lindex $radii [expr {$i/2}]]
1763
+ set r [winfo pixels $canv $radius]
1764
+
1765
+ lassign [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] x2 y2
1766
+ set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r]
1767
+ lappend knots {*}$z
1768
+
1769
+ lassign [list $x1 $y1] x0 y0
1770
+ lassign [list $x2 $y2] x1 y1
1771
+ }
1772
+ set n [$canv create polygon $knots -smooth 1 {*}$args]
1773
+ return $n
1774
+ }
1775
+
1776
+ proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} {
1777
+ set d [expr {2 * $radius}]
1778
+ set maxr 0.75
1779
+
1780
+ set v1x [expr {$x0 - $x1}]
1781
+ set v1y [expr {$y0 - $y1}]
1782
+ set v2x [expr {$x2 - $x1}]
1783
+ set v2y [expr {$y2 - $y1}]
1784
+
1785
+ set vlen1 [expr {sqrt($v1x*$v1x + $v1y*$v1y)}]
1786
+ set vlen2 [expr {sqrt($v2x*$v2x + $v2y*$v2y)}]
1787
+ if {$d > $maxr * $vlen1} {
1788
+ set d [expr {$maxr * $vlen1}]
1789
+ }
1790
+ if {$d > $maxr * $vlen2} {
1791
+ set d [expr {$maxr * $vlen2}]
1792
+ }
1793
+
1794
+ lappend xy [expr {$x1 + $d * $v1x/$vlen1}] [expr {$y1 + $d * $v1y/$vlen1}]
1795
+ lappend xy $x1 $y1
1796
+ lappend xy [expr {$x1 + $d * $v2x/$vlen2}] [expr {$y1 + $d * $v2y/$vlen2}]
1797
+
1798
+ return $xy
1799
+ }
1800
+
1801
+ proc Sparkle {w Oxy tag} {
1802
+ set xy {299 283 298 302 295 314 271 331 239 310 242 292 256 274 281 273}
1803
+ foreach {x y} $xy {
1804
+ $w.c create line 271 304 $x $y -fill white -width 3 -tag $tag
1805
+ }
1806
+ MoveAbs $w $tag $Oxy
1807
+ }
1808
+
1809
+ proc Centroid {w item} {
1810
+ return [Anchor $w $item c]
1811
+ }
1812
+
1813
+ proc Anchor {w item where} {
1814
+ lassign [$w.c bbox $item] x1 y1 x2 y2
1815
+ if {[string match *n* $where]} {
1816
+ set y $y1
1817
+ } elseif {[string match *s* $where]} {
1818
+ set y $y2
1819
+ } else {
1820
+ set y [expr {($y1 + $y2) / 2.0}]
1821
+ }
1822
+ if {[string match *w* $where]} {
1823
+ set x $x1
1824
+ } elseif {[string match *e* $where]} {
1825
+ set x $x2
1826
+ } else {
1827
+ set x [expr {($x1 + $x2) / 2.0}]
1828
+ }
1829
+ return [list $x $y]
1830
+ }
1831
+
1832
+ DoDisplay $w
1833
+ Reset $w
1834
+ Go $w ;# Start everything going
janus/lib/tk8.6/demos/icon.tcl ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # icon.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # buttons that display bitmaps instead of text.
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 .icon
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Iconic Button Demonstration"
16
+ wm iconname $w "icon"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 5i -justify left -text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected."
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
+ # Main widget program sets variable tk_demoDirectory
27
+ image create bitmap flagup \
28
+ -file [file join $tk_demoDirectory images flagup.xbm] \
29
+ -maskfile [file join $tk_demoDirectory images flagup.xbm]
30
+ image create bitmap flagdown \
31
+ -file [file join $tk_demoDirectory images flagdown.xbm] \
32
+ -maskfile [file join $tk_demoDirectory images flagdown.xbm]
33
+ frame $w.frame -borderwidth 10
34
+ pack $w.frame -side top
35
+
36
+ checkbutton $w.frame.b1 -image flagdown -selectimage flagup \
37
+ -indicatoron 0
38
+ $w.frame.b1 configure -selectcolor [$w.frame.b1 cget -background]
39
+ checkbutton $w.frame.b2 \
40
+ -bitmap @[file join $tk_demoDirectory images letters.xbm] \
41
+ -indicatoron 0 -selectcolor SeaGreen1
42
+ frame $w.frame.left
43
+ pack $w.frame.left $w.frame.b1 $w.frame.b2 -side left -expand yes -padx 5m
44
+
45
+ radiobutton $w.frame.left.b3 \
46
+ -bitmap @[file join $tk_demoDirectory images letters.xbm] \
47
+ -variable letters -value full
48
+ radiobutton $w.frame.left.b4 \
49
+ -bitmap @[file join $tk_demoDirectory images noletter.xbm] \
50
+ -variable letters -value empty
51
+ pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes
janus/lib/tk8.6/demos/image1.tcl ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # image1.tcl --
2
+ #
3
+ # This demonstration script displays two image 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 .image1
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Image Demonstration #1"
15
+ wm iconname $w "Image1"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration displays two images, each in a separate label widget."
19
+ pack $w.msg -side top
20
+
21
+ ## See Code / Dismiss buttons
22
+ set btns [addSeeDismiss $w.buttons $w]
23
+ pack $btns -side bottom -fill x
24
+
25
+ # Main widget program sets variable tk_demoDirectory
26
+ catch {image delete image1a}
27
+ image create photo image1a -file [file join $tk_demoDirectory images earth.gif]
28
+ label $w.l1 -image image1a -bd 1 -relief sunken
29
+
30
+ catch {image delete image1b}
31
+ image create photo image1b \
32
+ -file [file join $tk_demoDirectory images earthris.gif]
33
+ label $w.l2 -image image1b -bd 1 -relief sunken
34
+
35
+ pack $w.l1 $w.l2 -side top -padx .5m -pady .5m
janus/lib/tk8.6/demos/image2.tcl ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # image2.tcl --
2
+ #
3
+ # This demonstration script creates a simple collection of widgets
4
+ # that allow you to select and view images in a Tk label.
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
+ # loadDir --
13
+ # This procedure reloads the directory listbox from the directory
14
+ # named in the demo's entry.
15
+ #
16
+ # Arguments:
17
+ # w - Name of the toplevel window of the demo.
18
+
19
+ proc loadDir w {
20
+ global dirName
21
+
22
+ $w.f.list delete 0 end
23
+ foreach i [lsort [glob -type f -directory $dirName *]] {
24
+ $w.f.list insert end [file tail $i]
25
+ }
26
+ }
27
+
28
+ # selectAndLoadDir --
29
+ # This procedure pops up a dialog to ask for a directory to load into
30
+ # the listobx and (if the user presses OK) reloads the directory
31
+ # listbox from the directory named in the demo's entry.
32
+ #
33
+ # Arguments:
34
+ # w - Name of the toplevel window of the demo.
35
+
36
+ proc selectAndLoadDir w {
37
+ global dirName
38
+ set dir [tk_chooseDirectory -initialdir $dirName -parent $w -mustexist 1]
39
+ if {$dir ne ""} {
40
+ set dirName $dir
41
+ loadDir $w
42
+ }
43
+ }
44
+
45
+ # loadImage --
46
+ # Given the name of the toplevel window of the demo and the mouse
47
+ # position, extracts the directory entry under the mouse and loads
48
+ # that file into a photo image for display.
49
+ #
50
+ # Arguments:
51
+ # w - Name of the toplevel window of the demo.
52
+ # x, y- Mouse position within the listbox.
53
+
54
+ proc loadImage {w x y} {
55
+ global dirName
56
+
57
+ set file [file join $dirName [$w.f.list get @$x,$y]]
58
+ if {[catch {
59
+ image2a configure -file $file
60
+ }]} then {
61
+ # Mark the file as not loadable
62
+ $w.f.list itemconfigure @$x,$y -bg \#c00000 -selectbackground \#ff0000
63
+ }
64
+ }
65
+
66
+ set w .image2
67
+ catch {destroy $w}
68
+ toplevel $w
69
+ wm title $w "Image Demonstration #2"
70
+ wm iconname $w "Image2"
71
+ positionWindow $w
72
+
73
+ label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then type Return to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
74
+ pack $w.msg -side top
75
+
76
+ ## See Code / Dismiss buttons
77
+ set btns [addSeeDismiss $w.buttons $w]
78
+ pack $btns -side bottom -fill x
79
+
80
+ frame $w.mid
81
+ pack $w.mid -fill both -expand 1
82
+
83
+ labelframe $w.dir -text "Directory:"
84
+ # Main widget program sets variable tk_demoDirectory
85
+ set dirName [file join $tk_demoDirectory images]
86
+ entry $w.dir.e -width 30 -textvariable dirName
87
+ button $w.dir.b -pady 0 -padx 2m -text "Select Dir." \
88
+ -command "selectAndLoadDir $w"
89
+ bind $w.dir.e <Return> "loadDir $w"
90
+ pack $w.dir.e -side left -fill both -padx 2m -pady 2m -expand true
91
+ pack $w.dir.b -side left -fill y -padx {0 2m} -pady 2m
92
+ labelframe $w.f -text "File:" -padx 2m -pady 2m
93
+
94
+ listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set"
95
+ ttk::scrollbar $w.f.scroll -command "$w.f.list yview"
96
+ pack $w.f.list $w.f.scroll -side left -fill y -expand 1
97
+ $w.f.list insert 0 earth.gif earthris.gif teapot.ppm
98
+ bind $w.f.list <Double-Button-1> "loadImage $w %x %y"
99
+
100
+ catch {image delete image2a}
101
+ image create photo image2a
102
+ labelframe $w.image -text "Image:"
103
+ label $w.image.image -image image2a
104
+ pack $w.image.image -padx 2m -pady 2m
105
+
106
+ grid $w.dir - -sticky ew -padx 1m -pady 1m -in $w.mid
107
+ grid $w.f $w.image -sticky nw -padx 1m -pady 1m -in $w.mid
108
+ grid columnconfigure $w.mid 1 -weight 1
janus/lib/tk8.6/demos/label.tcl ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # label.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing
4
+ # several label 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 .label
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Label Demonstration"
16
+ wm iconname $w "label"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -justify left -text "Five labels are displayed below: three textual ones on the left, and an image label and a text label on the right. Labels are pretty boring because you can't do anything with them."
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
+ frame $w.left
27
+ frame $w.right
28
+ pack $w.left $w.right -side left -expand yes -padx 10 -pady 10 -fill both
29
+
30
+ label $w.left.l1 -text "First label"
31
+ label $w.left.l2 -text "Second label, raised" -relief raised
32
+ label $w.left.l3 -text "Third label, sunken" -relief sunken
33
+ pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -pady 2 -anchor w
34
+
35
+ # Main widget program sets variable tk_demoDirectory
36
+ image create photo label.ousterhout \
37
+ -file [file join $tk_demoDirectory images ouster.png]
38
+ label $w.right.picture -borderwidth 2 -relief sunken -image label.ousterhout
39
+ label $w.right.caption -text "Tcl/Tk Creator"
40
+ pack $w.right.picture $w.right.caption -side top
janus/lib/tk8.6/demos/license.terms ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This software is copyrighted by the Regents of the University of
2
+ California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
3
+ Corporation, Apple Inc. and other parties. The following terms apply to
4
+ all files associated with the software unless explicitly disclaimed in
5
+ individual files.
6
+
7
+ The authors hereby grant permission to use, copy, modify, distribute,
8
+ and license this software and its documentation for any purpose, provided
9
+ that existing copyright notices are retained in all copies and that this
10
+ notice is included verbatim in any distributions. No written agreement,
11
+ license, or royalty fee is required for any of the authorized uses.
12
+ Modifications to this software may be copyrighted by their authors
13
+ and need not follow the licensing terms described here, provided that
14
+ the new terms are clearly indicated on the first page of each file where
15
+ they apply.
16
+
17
+ IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
18
+ FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
19
+ ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
20
+ DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
21
+ POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
24
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
26
+ IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
27
+ NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
28
+ MODIFICATIONS.
29
+
30
+ GOVERNMENT USE: If you are acquiring this software on behalf of the
31
+ U.S. government, the Government shall have only "Restricted Rights"
32
+ in the software and related documentation as defined in the Federal
33
+ Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
34
+ are acquiring the software on behalf of the Department of Defense, the
35
+ software shall be classified as "Commercial Computer Software" and the
36
+ Government shall have only "Restricted Rights" as defined in Clause
37
+ 252.227-7013 (b) (3) of DFARs. Notwithstanding the foregoing, the
38
+ authors grant the U.S. Government and others acting in its behalf
39
+ permission to use and distribute the software in accordance with the
40
+ terms specified in this license.
janus/lib/tk8.6/demos/mclist.tcl ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mclist.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing a Ttk
4
+ # tree widget configured as a multi-column listbox.
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 .mclist
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Multi-Column List"
16
+ wm iconname $w "mclist"
17
+ positionWindow $w
18
+
19
+ ## Explanatory text
20
+ ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them."
21
+ pack $w.msg -fill x
22
+
23
+ ## See Code / Dismiss
24
+ pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
25
+
26
+ ttk::frame $w.container
27
+ ttk::treeview $w.tree -columns {country capital currency} -show headings \
28
+ -yscroll "$w.vsb set" -xscroll "$w.hsb set"
29
+ ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview"
30
+ ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview"
31
+ pack $w.container -fill both -expand 1
32
+ grid $w.tree $w.vsb -in $w.container -sticky nsew
33
+ grid $w.hsb -in $w.container -sticky nsew
34
+ grid column $w.container 0 -weight 1
35
+ grid row $w.container 0 -weight 1
36
+
37
+ image create photo upArrow -data {
38
+ R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAImhI+
39
+ py+1LIsJHiBAh+BgmiEAJQITgW6DgUQIAECH4JN8IPqYuNxUAOw==}
40
+ image create photo downArrow -data {
41
+ R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAInhI+
42
+ py+1I4ocQ/IgDEYIPgYJICUCE4F+YIBolEoKPEJKZmVJK6ZACADs=}
43
+ image create photo noArrow -height 14 -width 14
44
+
45
+ ## The data we're going to insert
46
+ set data {
47
+ Argentina {Buenos Aires} ARS
48
+ Australia Canberra AUD
49
+ Brazil Brazilia BRL
50
+ Canada Ottawa CAD
51
+ China Beijing CNY
52
+ France Paris EUR
53
+ Germany Berlin EUR
54
+ India {New Delhi} INR
55
+ Italy Rome EUR
56
+ Japan Tokyo JPY
57
+ Mexico {Mexico City} MXN
58
+ Russia Moscow RUB
59
+ {South Africa} Pretoria ZAR
60
+ {United Kingdom} London GBP
61
+ {United States} {Washington, D.C.} USD
62
+ }
63
+
64
+ ## Code to insert the data nicely
65
+ set font [ttk::style lookup Heading -font]
66
+ foreach col {country capital currency} name {Country Capital Currency} {
67
+ $w.tree heading $col -text $name -image noArrow -anchor w \
68
+ -command [list SortBy $w.tree $col 0]
69
+ $w.tree column $col -width [expr {
70
+ [font measure $font $name] + [image width noArrow] + 5
71
+ }]
72
+ }
73
+ set font [ttk::style lookup Treeview -font]
74
+ foreach {country capital currency} $data {
75
+ $w.tree insert {} end -values [list $country $capital $currency]
76
+ foreach col {country capital currency} {
77
+ set len [font measure $font "[set $col] "]
78
+ if {[$w.tree column $col -width] < $len} {
79
+ $w.tree column $col -width $len
80
+ }
81
+ }
82
+ }
83
+
84
+ ## Code to do the sorting of the tree contents when clicked on
85
+ proc SortBy {tree col direction} {
86
+ # Determine currently sorted column and its sort direction
87
+ foreach c {country capital currency} {
88
+ set s [$tree heading $c state]
89
+ if {("selected" in $s || "alternate" in $s) && $col ne $c} {
90
+ # Sorted column has changed
91
+ $tree heading $c -image noArrow state {!selected !alternate !user1}
92
+ set direction [expr {"alternate" in $s}]
93
+ }
94
+ }
95
+
96
+ # Build something we can sort
97
+ set data {}
98
+ foreach row [$tree children {}] {
99
+ lappend data [list [$tree set $row $col] $row]
100
+ }
101
+
102
+ set dir [expr {$direction ? "-decreasing" : "-increasing"}]
103
+ set r -1
104
+
105
+ # Now reshuffle the rows into the sorted order
106
+ foreach info [lsort -dictionary -index 0 $dir $data] {
107
+ $tree move [lindex $info 1] {} [incr r]
108
+ }
109
+
110
+ # Switch the heading so that it will sort in the opposite direction
111
+ $tree heading $col -command [list SortBy $tree $col [expr {!$direction}]] \
112
+ state [expr {$direction?"!selected alternate":"selected !alternate"}]
113
+ if {[ttk::style theme use] eq "aqua"} {
114
+ # Aqua theme displays native sort arrows when user1 state is set
115
+ $tree heading $col state "user1"
116
+ } else {
117
+ $tree heading $col -image [expr {$direction?"upArrow":"downArrow"}]
118
+ }
119
+ }
janus/lib/tk8.6/demos/menubu.tcl ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # menubu.tcl --
2
+ #
3
+ # This demonstration script creates a window with a bunch of menus
4
+ # and cascaded menus using menubuttons.
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 .menubu
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Menu Button Demonstration"
16
+ wm iconname $w "menubutton"
17
+ positionWindow $w
18
+
19
+ frame $w.body
20
+ pack $w.body -expand 1 -fill both
21
+
22
+ menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised
23
+ menu $w.body.below.m -tearoff 0
24
+ $w.body.below.m add command -label "Below menu: first item" -command "puts \"You have selected the first item from the Below menu.\""
25
+ $w.body.below.m add command -label "Below menu: second item" -command "puts \"You have selected the second item from the Below menu.\""
26
+ grid $w.body.below -row 0 -column 1 -sticky n
27
+ menubutton $w.body.right -text "Right" -underline 0 -direction right -menu $w.body.right.m -relief raised
28
+ menu $w.body.right.m -tearoff 0
29
+ $w.body.right.m add command -label "Right menu: first item" -command "puts \"You have selected the first item from the Right menu.\""
30
+ $w.body.right.m add command -label "Right menu: second item" -command "puts \"You have selected the second item from the Right menu.\""
31
+ frame $w.body.center
32
+ menubutton $w.body.left -text "Left" -underline 0 -direction left -menu $w.body.left.m -relief raised
33
+ menu $w.body.left.m -tearoff 0
34
+ $w.body.left.m add command -label "Left menu: first item" -command "puts \"You have selected the first item from the Left menu.\""
35
+ $w.body.left.m add command -label "Left menu: second item" -command "puts \"You have selected the second item from the Left menu.\""
36
+ grid $w.body.right -row 1 -column 0 -sticky w
37
+ grid $w.body.center -row 1 -column 1 -sticky news
38
+ grid $w.body.left -row 1 -column 2 -sticky e
39
+ menubutton $w.body.above -text "Above" -underline 0 -direction above -menu $w.body.above.m -relief raised
40
+ menu $w.body.above.m -tearoff 0
41
+ $w.body.above.m add command -label "Above menu: first item" -command "puts \"You have selected the first item from the Above menu.\""
42
+ $w.body.above.m add command -label "Above menu: second item" -command "puts \"You have selected the second item from the Above menu.\""
43
+ grid $w.body.above -row 2 -column 1 -sticky s
44
+
45
+ ## See Code / Dismiss buttons
46
+ set btns [addSeeDismiss $w.buttons $w]
47
+ pack $btns -side bottom -fill x
48
+
49
+ set body $w.body.center
50
+ label $body.label -wraplength 300 -font "Helvetica 14" -justify left -text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette."
51
+ pack $body.label -side top -padx 25 -pady 25
52
+ frame $body.buttons
53
+ pack $body.buttons -padx 25 -pady 25
54
+ tk_optionMenu $body.buttons.options menubuttonoptions one two three
55
+ pack $body.buttons.options -side left -padx 25 -pady 25
56
+ set m [tk_optionMenu $body.buttons.colors paletteColor Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet]
57
+ if {[tk windowingsystem] eq "aqua"} {
58
+ set topBorderColor Black
59
+ set bottomBorderColor Black
60
+ } else {
61
+ set topBorderColor gray50
62
+ set bottomBorderColor gray75
63
+ }
64
+ for {set i 0} {$i <= [$m index last]} {incr i} {
65
+ set name [$m entrycget $i -label]
66
+ image create photo image_$name -height 16 -width 16
67
+ image_$name put $topBorderColor -to 0 0 16 1
68
+ image_$name put $topBorderColor -to 0 1 1 16
69
+ image_$name put $bottomBorderColor -to 0 15 16 16
70
+ image_$name put $bottomBorderColor -to 15 1 16 16
71
+ image_$name put $name -to 1 1 15 15
72
+
73
+ image create photo image_${name}_s -height 16 -width 16
74
+ image_${name}_s put Black -to 0 0 16 2
75
+ image_${name}_s put Black -to 0 2 2 16
76
+ image_${name}_s put Black -to 2 14 16 16
77
+ image_${name}_s put Black -to 14 2 16 14
78
+ image_${name}_s put $name -to 2 2 14 14
79
+
80
+ $m entryconfigure $i -image image_$name -selectimage image_${name}_s -hidemargin 1
81
+ }
82
+ $m configure -tearoff 1
83
+ foreach i {Black gray75 gray50 White} {
84
+ $m entryconfigure $i -columnbreak 1
85
+ }
86
+
87
+ pack $body.buttons.colors -side left -padx 25 -pady 25
janus/lib/tk8.6/demos/sayings.tcl ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # sayings.tcl --
2
+ #
3
+ # This demonstration script creates a listbox that can be scrolled
4
+ # both horizontally and vertically. It displays a collection of
5
+ # well-known sayings.
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 .sayings
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Listbox Demonstration (well-known sayings)"
17
+ wm iconname $w "sayings"
18
+ positionWindow $w
19
+
20
+ label $w.msg -font $font -wraplength 4i -justify left -text "The listbox below contains a collection of well-known sayings. You can scan the list using either of the scrollbars or by dragging in the listbox window with button 2 pressed."
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 both -padx 1c
29
+
30
+
31
+ ttk::scrollbar $w.frame.yscroll -command "$w.frame.list yview"
32
+ ttk::scrollbar $w.frame.xscroll -orient horizontal \
33
+ -command "$w.frame.list xview"
34
+ listbox $w.frame.list -width 20 -height 10 -setgrid 1 \
35
+ -yscroll "$w.frame.yscroll set" -xscroll "$w.frame.xscroll set"
36
+
37
+ grid $w.frame.list -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
38
+ grid $w.frame.yscroll -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
39
+ grid $w.frame.xscroll -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
40
+ grid rowconfig $w.frame 0 -weight 1 -minsize 0
41
+ grid columnconfig $w.frame 0 -weight 1 -minsize 0
42
+
43
+
44
+ $w.frame.list insert 0 "Don't speculate, measure" "Waste not, want not" "Early to bed and early to rise makes a man healthy, wealthy, and wise" "Ask not what your country can do for you, ask what you can do for your country" "I shall return" "NOT" "A picture is worth a thousand words" "User interfaces are hard to build" "Thou shalt not steal" "A penny for your thoughts" "Fool me once, shame on you; fool me twice, shame on me" "Every cloud has a silver lining" "Where there's smoke there's fire" "It takes one to know one" "Curiosity killed the cat" "Take this job and shove it" "Up a creek without a paddle" "I'm mad as hell and I'm not going to take it any more" "An apple a day keeps the doctor away" "Don't look a gift horse in the mouth" "Measure twice, cut once"
janus/lib/tk8.6/demos/textpeer.tcl ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # textpeer.tcl --
2
+ #
3
+ # This demonstration script creates a pair of text widgets that can edit a
4
+ # single logical buffer. This is particularly useful when editing related text
5
+ # in two (or more) parts of the same 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
+ set w .textpeer
14
+ catch {destroy $w}
15
+ toplevel $w
16
+ wm title $w "Text Widget Peering Demonstration"
17
+ wm iconname $w "textpeer"
18
+ positionWindow $w
19
+
20
+ set count 0
21
+
22
+ ## Define a widget that we peer from; it won't ever actually be shown though
23
+ set first [text $w.text[incr count]]
24
+ $first insert end "This is a coupled pair of text widgets; they are peers to "
25
+ $first insert end "each other. They have the same underlying data model, but "
26
+ $first insert end "can show different locations, have different current edit "
27
+ $first insert end "locations, and have different selections. You can also "
28
+ $first insert end "create additional peers of any of these text widgets using "
29
+ $first insert end "the Make Peer button beside the text widget to clone, and "
30
+ $first insert end "delete a particular peer widget using the Delete Peer "
31
+ $first insert end "button."
32
+
33
+ ## Procedures to make and kill clones; most of this is just so that the demo
34
+ ## looks nice...
35
+ proc makeClone {w parent} {
36
+ global count
37
+ set t [$parent peer create $w.text[incr count] -yscroll "$w.sb$count set"\
38
+ -height 10 -wrap word]
39
+ set sb [ttk::scrollbar $w.sb$count -command "$t yview" -orient vertical]
40
+ set b1 [button $w.clone$count -command "makeClone $w $t" \
41
+ -text "Make Peer"]
42
+ set b2 [button $w.kill$count -command "killClone $w $count" \
43
+ -text "Delete Peer"]
44
+ set row [expr {$count * 2}]
45
+ grid $t $sb $b1 -sticky nsew -row $row
46
+ grid ^ ^ $b2 -row [incr row]
47
+ grid configure $b1 $b2 -sticky new
48
+ grid rowconfigure $w $b2 -weight 1
49
+ }
50
+ proc killClone {w count} {
51
+ destroy $w.text$count $w.sb$count
52
+ destroy $w.clone$count $w.kill$count
53
+ }
54
+
55
+ ## Now set up the GUI
56
+ makeClone $w $first
57
+ makeClone $w $first
58
+ destroy $first
59
+
60
+ ## See Code / Dismiss buttons
61
+ grid [addSeeDismiss $w.buttons $w] - - -sticky ew -row 5000
62
+ grid columnconfigure $w 0 -weight 1
janus/lib/tk8.6/demos/tree.tcl ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # tree.tcl --
2
+ #
3
+ # This demonstration script creates a toplevel window containing a Ttk
4
+ # tree widget.
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 .tree
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Directory Browser"
16
+ wm iconname $w "tree"
17
+ positionWindow $w
18
+
19
+ ## Explanatory text
20
+ ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which allows the user to browse a hierarchical data-set such as a filesystem. The tree widget not only allows for the tree part itself, but it also supports an arbitrary number of additional columns which can show additional data (in this case, the size of the files found in your filesystem). You can also change the width of the columns by dragging the boundary between them."
21
+ pack $w.msg -fill x
22
+
23
+ ## See Code / Dismiss
24
+ pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
25
+
26
+ ## Code to populate the roots of the tree (can be more than one on Windows)
27
+ proc populateRoots {tree} {
28
+ foreach dir [lsort -dictionary [file volumes]] {
29
+ populateTree $tree [$tree insert {} end -text $dir \
30
+ -values [list $dir directory]]
31
+ }
32
+ }
33
+
34
+ ## Code to populate a node of the tree
35
+ proc populateTree {tree node} {
36
+ if {[$tree set $node type] ne "directory"} {
37
+ return
38
+ }
39
+ set path [$tree set $node fullpath]
40
+ $tree delete [$tree children $node]
41
+ foreach f [lsort -dictionary [glob -nocomplain -dir $path *]] {
42
+ set f [file normalize $f]
43
+ set type [file type $f]
44
+ set id [$tree insert $node end -text [file tail $f] \
45
+ -values [list $f $type]]
46
+
47
+ if {$type eq "directory"} {
48
+ ## Make it so that this node is openable
49
+ $tree insert $id 0 -text dummy ;# a dummy
50
+ $tree item $id -text [file tail $f]/
51
+
52
+ } elseif {$type eq "file"} {
53
+ set size [file size $f]
54
+ ## Format the file size nicely
55
+ if {$size >= 1024*1024*1024} {
56
+ set size [format %.1f\ GB [expr {$size/1024/1024/1024.}]]
57
+ } elseif {$size >= 1024*1024} {
58
+ set size [format %.1f\ MB [expr {$size/1024/1024.}]]
59
+ } elseif {$size >= 1024} {
60
+ set size [format %.1f\ kB [expr {$size/1024.}]]
61
+ } else {
62
+ append size " bytes"
63
+ }
64
+ $tree set $id size $size
65
+ }
66
+ }
67
+
68
+ # Stop this code from rerunning on the current node
69
+ $tree set $node type processedDirectory
70
+ }
71
+
72
+ ## Create the tree and set it up
73
+ ttk::treeview $w.tree -columns {fullpath type size} -displaycolumns {size} \
74
+ -yscroll "$w.vsb set" -xscroll "$w.hsb set"
75
+ ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview"
76
+ ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview"
77
+ $w.tree heading \#0 -text "Directory Structure"
78
+ $w.tree heading size -text "File Size"
79
+ $w.tree column size -width 70
80
+ populateRoots $w.tree
81
+ bind $w.tree <<TreeviewOpen>> {populateTree %W [%W focus]}
82
+
83
+ ## Arrange the tree and its scrollbars in the toplevel
84
+ lower [ttk::frame $w.dummy]
85
+ pack $w.dummy -fill both -expand 1
86
+ grid $w.tree $w.vsb -sticky nsew -in $w.dummy
87
+ grid $w.hsb -sticky nsew -in $w.dummy
88
+ grid columnconfigure $w.dummy 0 -weight 1
89
+ grid rowconfigure $w.dummy 0 -weight 1
janus/lib/tk8.6/demos/ttkpane.tcl ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ttkpane.tcl --
2
+ #
3
+ # This demonstration script creates a Ttk pane with some content.
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 .ttkpane
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Themed Nested Panes"
15
+ wm iconname $w "ttkpane"
16
+ positionWindow $w
17
+
18
+ ttk::label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows off a nested set of themed paned windows. Their sizes can be changed by grabbing the area between each contained pane and dragging the divider."
19
+ pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
20
+
21
+ ## See Code / Dismiss
22
+ pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
23
+
24
+ ttk::frame $w.f
25
+ pack $w.f -fill both -expand 1
26
+ set w $w.f
27
+ ttk::panedwindow $w.outer -orient horizontal
28
+ $w.outer add [ttk::panedwindow $w.outer.inLeft -orient vertical]
29
+ $w.outer add [ttk::panedwindow $w.outer.inRight -orient vertical]
30
+ $w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.top -text Button]
31
+ $w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.bot -text Clocks]
32
+ $w.outer.inRight add [ttk::labelframe $w.outer.inRight.top -text Progress]
33
+ $w.outer.inRight add [ttk::labelframe $w.outer.inRight.bot -text Text]
34
+ if {[tk windowingsystem] eq "aqua"} {
35
+ foreach i [list inLeft.top inLeft.bot inRight.top inRight.bot] {
36
+ $w.outer.$i configure -padding 3
37
+ }
38
+ }
39
+
40
+ # Fill the button pane
41
+ ttk::button $w.outer.inLeft.top.b -text "Press Me" -command {
42
+ tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \
43
+ -parent .ttkpane -title "Button Pressed"
44
+ }
45
+ pack $w.outer.inLeft.top.b -padx 2 -pady 5
46
+
47
+ # Fill the clocks pane
48
+ set i 0
49
+ proc every {delay script} {
50
+ uplevel #0 $script
51
+ after $delay [list every $delay $script]
52
+ }
53
+ set testzones {
54
+ :Europe/Berlin
55
+ :America/Argentina/Buenos_Aires
56
+ :Africa/Johannesburg
57
+ :Europe/London
58
+ :America/Los_Angeles
59
+ :Europe/Moscow
60
+ :America/New_York
61
+ :Asia/Singapore
62
+ :Australia/Sydney
63
+ :Asia/Tokyo
64
+ }
65
+ # Force a pre-load of all the timezones needed; otherwise can end up
66
+ # poor-looking synch problems!
67
+ set zones {}
68
+ foreach zone $testzones {
69
+ if {![catch {clock format 0 -timezone $zone}]} {
70
+ lappend zones $zone
71
+ }
72
+ }
73
+ if {[llength $zones] < 2} { lappend zones -0200 :GMT :UTC +0200 }
74
+ foreach zone $zones {
75
+ set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]]
76
+ if {$i} {
77
+ pack [ttk::separator $w.outer.inLeft.bot.s$i] -fill x
78
+ }
79
+ ttk::label $w.outer.inLeft.bot.l$i -text $city -anchor w
80
+ ttk::label $w.outer.inLeft.bot.t$i -textvariable time($zone) -anchor w
81
+ pack $w.outer.inLeft.bot.l$i $w.outer.inLeft.bot.t$i -fill x
82
+ every 1000 "set time($zone) \[clock format \[clock seconds\] -timezone $zone -format %T\]"
83
+ incr i
84
+ }
85
+
86
+ # Fill the progress pane
87
+ ttk::progressbar $w.outer.inRight.top.progress -mode indeterminate
88
+ pack $w.outer.inRight.top.progress -fill both -expand 1
89
+ $w.outer.inRight.top.progress start
90
+
91
+ # Fill the text pane
92
+ if {[tk windowingsystem] ne "aqua"} {
93
+ # The trick with the ttk::frame makes the text widget look like it fits with
94
+ # the current Ttk theme despite not being a themed widget itself. It is done
95
+ # by styling the frame like an entry, turning off the border in the text
96
+ # widget, and putting the text widget in the frame with enough space to allow
97
+ # the surrounding border to show through (2 pixels seems to be enough).
98
+ ttk::frame $w.outer.inRight.bot.f -style TEntry
99
+ text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
100
+ pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 2 -padx 2
101
+ ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
102
+ pack $w.sb -side right -fill y -in $w.outer.inRight.bot
103
+ pack $w.outer.inRight.bot.f -fill both -expand 1
104
+ pack $w.outer -fill both -expand 1
105
+ } else {
106
+ text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
107
+ ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
108
+ pack $w.sb -side right -fill y -in $w.outer.inRight.bot
109
+ pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot
110
+ pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10}
111
+ }
112
+
janus/lib/tk8.6/demos/unicodeout.tcl ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # unicodeout.tcl --
2
+ #
3
+ # This demonstration script shows how you can produce output (in label
4
+ # widgets) using many different alphabets.
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 .unicodeout
13
+ catch {destroy $w}
14
+ toplevel $w
15
+ wm title $w "Unicode Label Demonstration"
16
+ wm iconname $w "unicodeout"
17
+ positionWindow $w
18
+
19
+ label $w.msg -font $font -wraplength 4i -anchor w -justify left \
20
+ -text "This is a sample of Tk's support for languages that use\
21
+ non-Western character sets. However, what you will actually see\
22
+ below depends largely on what character sets you have installed,\
23
+ and what you see for characters that are not present varies greatly\
24
+ between platforms as well. The strings are written in Tcl using\
25
+ UNICODE characters using the \\uXXXX escape so as to do so in a\
26
+ portable fashion."
27
+ pack $w.msg -side top
28
+
29
+ ## See Code / Dismiss buttons
30
+ set btns [addSeeDismiss $w.buttons $w]
31
+ pack $btns -side bottom -fill x
32
+
33
+ ## The frame that will contain the sample texts.
34
+ pack [frame $w.f] -side bottom -expand 1 -fill both -padx 2m -pady 1m
35
+ grid columnconfigure $w.f 1 -weight 1
36
+ set i 0
37
+ proc addSample {w language args} {
38
+ global font i
39
+ set sample [join $args ""]
40
+ set j [incr i]
41
+ label $w.f.l$j -font $font -text "${language}:" -anchor nw -pady 0
42
+ label $w.f.s$j -font $font -text $sample -anchor nw -width 30 -pady 0
43
+ grid $w.f.l$j $w.f.s$j -sticky ew -pady 0
44
+ grid configure $w.f.l$j -padx 1m
45
+ }
46
+
47
+ ## A helper procedure that determines what form to use to express languages
48
+ ## that have complex rendering rules...
49
+ proc usePresentationFormsFor {language} {
50
+ switch [tk windowingsystem] {
51
+ aqua {
52
+ # OSX wants natural character order; the renderer knows how to
53
+ # compose things for display for all languages.
54
+ return false
55
+ }
56
+ x11 {
57
+ # The X11 font renderers that Tk supports all know nothing about
58
+ # composing characters, so we need to use presentation forms.
59
+ return true
60
+ }
61
+ win32 {
62
+ # On Windows, we need to determine whether the font system will
63
+ # render right-to-left text. This varies by language!
64
+ try {
65
+ package require registry
66
+ set rkey [join {
67
+ HKEY_LOCAL_MACHINE
68
+ SOFTWARE
69
+ Microsoft
70
+ {Windows NT}
71
+ CurrentVersion
72
+ LanguagePack
73
+ } \\]
74
+ return [expr {
75
+ [string toupper $language] ni [registry values $rkey]
76
+ }]
77
+ } trap error {} {
78
+ # Cannot work it out, so use presentation forms.
79
+ return true
80
+ }
81
+ }
82
+ default {
83
+ # Default to using presentation forms.
84
+ return true
85
+ }
86
+ }
87
+ }
88
+
89
+ ## Processing when some characters are not currently cached by the display
90
+ ## engine might take a while, so make sure we're displaying something in the
91
+ ## meantime...
92
+ pack [label $w.wait -text "Please wait while loading fonts..." \
93
+ -font {Helvetica 12 italic}]
94
+ set oldCursor [$w cget -cursor]
95
+ $w conf -cursor watch
96
+ update
97
+
98
+ ## Add the samples...
99
+ if {[usePresentationFormsFor Arabic]} {
100
+ # Using presentation forms (pre-layouted)
101
+ addSample $w Arabic \
102
+ "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \
103
+ "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D"
104
+ } else {
105
+ # Using standard text characters
106
+ addSample $w Arabic \
107
+ "\u0627\u0644\u0643\u0644\u0645\u0629 " \
108
+ "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
109
+ }
110
+ addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57"
111
+ addSample $w "Simpl. Chinese" "\u6C49\u8BED"
112
+ addSample $w French "Langue fran\xE7aise"
113
+ addSample $w Greek \
114
+ "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
115
+ "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
116
+ if {[usePresentationFormsFor Hebrew]} {
117
+ # Visual order (pre-layouted)
118
+ addSample $w Hebrew \
119
+ "\u05EA\u05D9\u05E8\u05D1\u05E2 \u05D1\u05EA\u05DB"
120
+ } else {
121
+ # Standard logical order
122
+ addSample $w Hebrew \
123
+ "\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA"
124
+ }
125
+ addSample $w Hindi \
126
+ "\u0939\u093F\u0928\u094D\u0926\u0940 \u092D\u093E\u0937\u093E"
127
+ addSample $w Icelandic "\xCDslenska"
128
+ addSample $w Japanese \
129
+ "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
130
+ "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
131
+ addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00"
132
+ addSample $w Russian \
133
+ "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A"
134
+ if {([tk windowingsystem] ne "x11") || (![catch {tk::pkgconfig get fontsystem} fs] && ($fs eq "xft"))} {
135
+ if {[package vsatisfies [package provide Tcl] 8.7-]} {
136
+ addSample $w Emoji "😀💩👍🇳🇱"
137
+ } else {
138
+ addSample $w Emoji \
139
+ "\uD83D\uDE00\uD83D\uDCA9\uD83D\uDC4D\uD83C\uDDF3\uD83C\uDDF1"
140
+ }
141
+ }
142
+
143
+ ## We're done processing, so change things back to normal running...
144
+ destroy $w.wait
145
+ $w conf -cursor $oldCursor
janus/lib/tk8.6/demos/vscale.tcl ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # vscale.tcl --
2
+ #
3
+ # This demonstration script shows an example with a vertical 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 .vscale
12
+ catch {destroy $w}
13
+ toplevel $w
14
+ wm title $w "Vertical Scale Demonstration"
15
+ wm iconname $w "vscale"
16
+ positionWindow $w
17
+
18
+ label $w.msg -font $font -wraplength 3.5i -justify left -text "An arrow and a vertical scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the size 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
27
+
28
+ scale $w.frame.scale -orient vertical -length 284 -from 0 -to 250 \
29
+ -command "setHeight $w.frame.canvas" -tickinterval 50
30
+ canvas $w.frame.canvas -width 50 -height 50 -bd 0 -highlightthickness 0
31
+ $w.frame.canvas create polygon 0 0 1 1 2 2 -fill SeaGreen3 -tags poly
32
+ $w.frame.canvas create line 0 0 1 1 2 2 0 0 -fill black -tags line
33
+ frame $w.frame.right -borderwidth 15
34
+ pack $w.frame.scale -side left -anchor ne
35
+ pack $w.frame.canvas -side left -anchor nw -fill y
36
+ $w.frame.scale set 75
37
+
38
+ proc setHeight {w height} {
39
+ incr height 21
40
+ set y2 [expr {$height - 30}]
41
+ if {$y2 < 21} {
42
+ set y2 21
43
+ }
44
+ $w coords poly 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
45
+ $w coords line 15 20 35 20 35 $y2 45 $y2 25 $height 5 $y2 15 $y2 15 20
46
+ }
janus/lib/tk8.6/demos/widget ADDED
@@ -0,0 +1,734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # the next line restarts using wish \
3
+ exec wish8.6 "$0" ${1+"$@"}
4
+
5
+ # widget --
6
+ # This script demonstrates the various widgets provided by Tk, along with many
7
+ # of the features of the Tk toolkit. This file only contains code to generate
8
+ # the main window for the application, which invokes individual
9
+ # demonstrations. The code for the actual demonstrations is contained in
10
+ # separate ".tcl" files is this directory, which are sourced by this script as
11
+ # needed.
12
+
13
+ package require Tk 8.5
14
+ package require msgcat
15
+
16
+ destroy {*}[winfo children .]
17
+ set tk_demoDirectory [file join [pwd] [file dirname [info script]]]
18
+ ::msgcat::mcload $tk_demoDirectory
19
+ namespace import ::msgcat::mc
20
+ wm title . [mc "Widget Demonstration"]
21
+ if {[tk windowingsystem] eq "x11"} {
22
+ # This won't work everywhere, but there's no other way in core Tk at the
23
+ # moment to display a coloured icon.
24
+ image create photo TclPowered \
25
+ -file [file join $tk_library images logo64.gif]
26
+ wm iconwindow . [toplevel ._iconWindow]
27
+ pack [label ._iconWindow.i -image TclPowered]
28
+ wm iconname . [mc "tkWidgetDemo"]
29
+ }
30
+
31
+ if {"defaultFont" ni [font names]} {
32
+ # TIP #145 defines some standard named fonts
33
+ if {"TkDefaultFont" in [font names] && "TkFixedFont" in [font names]} {
34
+ # FIX ME: the following technique of cloning the font to copy it works
35
+ # fine but means that if the system font is changed by Tk
36
+ # cannot update the copied font. font alias might be useful
37
+ # here -- or fix the app to use TkDefaultFont etc.
38
+ font create mainFont {*}[font configure TkDefaultFont]
39
+ font create fixedFont {*}[font configure TkFixedFont]
40
+ font create boldFont {*}[font configure TkDefaultFont] -weight bold
41
+ font create titleFont {*}[font configure TkDefaultFont] -weight bold
42
+ font create statusFont {*}[font configure TkDefaultFont]
43
+ font create varsFont {*}[font configure TkDefaultFont]
44
+ if {[tk windowingsystem] eq "aqua"} {
45
+ font configure titleFont -size 17
46
+ }
47
+ } else {
48
+ font create mainFont -family Helvetica -size 12
49
+ font create fixedFont -family Courier -size 10
50
+ font create boldFont -family Helvetica -size 12 -weight bold
51
+ font create titleFont -family Helvetica -size 18 -weight bold
52
+ font create statusFont -family Helvetica -size 10
53
+ font create varsFont -family Helvetica -size 14
54
+ }
55
+ }
56
+
57
+ set widgetDemo 1
58
+ set font mainFont
59
+
60
+ image create photo ::img::refresh -format GIF -data {
61
+ R0lGODlhEAAQAJEDAP///wAAACpnKv///yH5BAEAAAMALAAAAAAQABAAAAI63IKp
62
+ xgcPH2ouwgBCw1HIxHCQ4F3hSJKmwZXqWrmWxj7lKJ2dndcon9EBUq+gz3brVXAR
63
+ 2tICU0gXBQA7
64
+ }
65
+
66
+ image create photo ::img::view -format GIF -data {
67
+ R0lGODlhEAAQAKIHAP///wwMDAAAAMDAwNnZ2SYmJmZmZv///yH5BAEAAAcALAAA
68
+ AAAQABAAAANMKLos90+ASamDRxJCgw9YVnlDOXiQBgRDBRgHKE6sW8QR3doPKK27
69
+ yg33q/GIOhdg6OsEJzeZykiBSUcs06e56Xx6np8ScIkFGuhQAgA7
70
+ }
71
+
72
+ image create photo ::img::delete -format GIF -data {
73
+ R0lGODlhEAAQAIABAIQAAP///yH5BAEAAAEALAAAAAAQABAAAAIjjI+pmwAc3HGy
74
+ PUSvqYpuvWQg40FfSVacBa5nN6JYDI3mzRQAOw==
75
+ }
76
+
77
+ image create photo ::img::print -format GIF -data {
78
+ R0lGODlhEAAQALMKAAAAAP///52VunNkl8C82Yl+qldBgq+pyrOzs1fYAP///wAA
79
+ AAAAAAAAAAAAAAAAACH5BAEAAAoALAAAAAAQABAAAARGUMlJKwU4AztB+ODGeUiJ
80
+ fGLlgeEYmGWQXmx7aXgmAUTv/74N4EAsGhOJg1DAbDqbwoJ0Sp0KB9isNis0eL/g
81
+ ryhH5pgnEQA7
82
+ }
83
+
84
+ # Note that this is run through the message catalog! This is because this is
85
+ # actually an image of a word.
86
+ image create photo ::img::new -format PNG -data [mc {
87
+ iVBORw0KGgoAAAANSUhEUgAAAB4AAAAOCAYAAAA45qw5AAACMElEQVR4AeVTAwxd
88
+ QRCc2tZHGtQ2w9q2bdsOa9u2bUW1bdt2Z372JZe6DapJLqtb3h7+T8yKi5j4CsYD
89
+ EUQXxETclT7kWOlH2VV+tFkdQHPSwksSISF+BauCqL0qgOcMWgGfgEkaMsHxqUBk
90
+ 3plE/sOnh/qDPAPJH/CKFBivGHWzFwBRnHhlqbu1Mh6CoFNnC/JshQ9p4YC2lrKt
91
+ DCAV+THiVejyhMjAbrNSrroiEfKR9g7ZfCgOog8QfnUQV62wAk68ndQ9ZbyoWO1H
92
+ Y6eDY1LCQL6a9ApOp9Hi1T0+gQq2JKMlky/oTKQliKWxEZvyG575kpW4pl1aZnQK
93
+ CLOVt45Lkp8uXp2SL8KO6uitNTZLdpK6s+I/eZbhpmsmWeOGOVQNKYLITzpKPAO3
94
+ tY7LSNZ7ccSLxX9y3uuOxRkg3dKESMoCHvL+GRVCutXsB3guLgDCeXOv4iWWkvwG
95
+ BaS+PmlpK6SI9ApI2oC2UtrwZQEkhkH+NtolVlQXJl1I+QltuU3XEc721bIRFpa8
96
+ IA5iqTo6vNNWmkNBLQbPeXwF2g17Q94nTQAfY3YzeY+WSu8MDzQ2kpELUhSGJUHE
97
+ 0zeR3rY1L+Xl5G/re+jbiK6KhThwwInsts1fbMUUcpZszKeVtggZEiGdZDe5AtHh
98
+ 7vL4CGiRvvKPS8FAvq9Nr4ZkFadR2y6kggu1z4vlyIbBp6BugQ8JLEg4bTkD9eMZ
99
+ QZ8hpJ3VvTtuvbWrY/ElvP/9R+Aj3603+iE3fkEAAAAASUVORK5CYII=
100
+ }]
101
+
102
+ #----------------------------------------------------------------
103
+ # The code below creates the main window, consisting of a menu bar and a text
104
+ # widget that explains how to use the program, plus lists all of the demos as
105
+ # hypertext items.
106
+ #----------------------------------------------------------------
107
+
108
+ menu .menuBar -tearoff 0
109
+
110
+ # On Aqua, just use the default menu.
111
+ if {[tk windowingsystem] ne "aqua"} {
112
+ # This is a tk-internal procedure to make i18n easier
113
+ ::tk::AmpMenuArgs .menuBar add cascade -label [mc "&File"] \
114
+ -menu .menuBar.file
115
+ menu .menuBar.file -tearoff 0
116
+ ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&About..."] \
117
+ -command {tkAboutDialog} -accelerator [mc "<F1>"]
118
+ bind . <F1> {tkAboutDialog}
119
+ .menuBar.file add sep
120
+ if {[string match win* [tk windowingsystem]]} {
121
+ # Windows doesn't usually have a Meta key
122
+ ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&Quit"] \
123
+ -command {exit} -accelerator [mc "Ctrl+Q"]
124
+ bind . <[mc "Control-q"]> {exit}
125
+ } else {
126
+ ::tk::AmpMenuArgs .menuBar.file add command -label [mc "&Quit"] \
127
+ -command {exit} -accelerator [mc "Meta-Q"]
128
+ bind . <[mc "Meta-q"]> {exit}
129
+ }
130
+ . configure -menu .menuBar
131
+ }
132
+
133
+ ttk::frame .statusBar
134
+ ttk::label .statusBar.lab -text " " -anchor w
135
+ if {[tk windowingsystem] eq "aqua"} {
136
+ ttk::separator .statusBar.sep
137
+ pack .statusBar.sep -side top -expand yes -fill x -pady 0
138
+ }
139
+ pack .statusBar.lab -side left -padx 2 -expand yes -fill both
140
+ if {[tk windowingsystem] ne "aqua"} {
141
+ ttk::sizegrip .statusBar.foo
142
+ pack .statusBar.foo -side left -padx 2
143
+ }
144
+ pack .statusBar -side bottom -fill x -pady 2
145
+
146
+ set textheight 30
147
+ catch {
148
+ set textheight [expr {
149
+ ([winfo screenheight .] * 0.7) /
150
+ [font metrics mainFont -displayof . -linespace]
151
+ }]
152
+ }
153
+
154
+ ttk::frame .textFrame
155
+ ttk::scrollbar .s -orient vertical -command {.t yview} -takefocus 1
156
+ pack .s -in .textFrame -side right -fill y
157
+ text .t -yscrollcommand {.s set} -wrap word -width 70 -height $textheight \
158
+ -font mainFont -setgrid 1 -highlightthickness 0 \
159
+ -padx 4 -pady 2 -takefocus 0
160
+ pack .t -in .textFrame -expand y -fill both -padx 1
161
+ pack .textFrame -expand yes -fill both
162
+ if {[tk windowingsystem] eq "aqua"} {
163
+ pack configure .statusBar.lab -padx {10 18} -pady {4 6}
164
+ pack configure .statusBar -pady 0
165
+ .t configure -padx 10 -pady 0
166
+ }
167
+
168
+ # Create a bunch of tags to use in the text widget, such as those for section
169
+ # titles and demo descriptions. Also define the bindings for tags.
170
+
171
+ .t tag configure title -font titleFont
172
+ .t tag configure subtitle -font titleFont
173
+ .t tag configure bold -font boldFont
174
+ if {[tk windowingsystem] eq "aqua"} {
175
+ .t tag configure title -spacing1 8
176
+ .t tag configure subtitle -spacing3 3
177
+ }
178
+
179
+ # We put some "space" characters to the left and right of each demo
180
+ # description so that the descriptions are highlighted only when the mouse
181
+ # cursor is right over them (but not when the cursor is to their left or
182
+ # right).
183
+ #
184
+ .t tag configure demospace -lmargin1 1c -lmargin2 1c
185
+
186
+ if {[winfo depth .] == 1} {
187
+ .t tag configure demo -lmargin1 1c -lmargin2 1c \
188
+ -underline 1
189
+ .t tag configure visited -lmargin1 1c -lmargin2 1c \
190
+ -underline 1
191
+ .t tag configure hot -background black -foreground white
192
+ } else {
193
+ .t tag configure demo -lmargin1 1c -lmargin2 1c \
194
+ -foreground blue -underline 1
195
+ .t tag configure visited -lmargin1 1c -lmargin2 1c \
196
+ -foreground #303080 -underline 1
197
+ if {[tk windowingsystem] eq "aqua"} {
198
+ .t tag configure demo -foreground systemLinkColor
199
+ .t tag configure visited -foreground purple
200
+ }
201
+ .t tag configure hot -foreground red -underline 1
202
+ }
203
+ .t tag bind demo <ButtonRelease-1> {
204
+ invoke [.t index {@%x,%y}]
205
+ }
206
+ set lastLine ""
207
+ .t tag bind demo <Enter> {
208
+ set lastLine [.t index {@%x,%y linestart}]
209
+ .t tag add hot "$lastLine +1 chars" "$lastLine lineend -1 chars"
210
+ .t config -cursor [::ttk::cursor link]
211
+ showStatus [.t index {@%x,%y}]
212
+ }
213
+ .t tag bind demo <Leave> {
214
+ .t tag remove hot 1.0 end
215
+ .t config -cursor [::ttk::cursor text]
216
+ .statusBar.lab config -text ""
217
+ }
218
+ .t tag bind demo <Motion> {
219
+ set newLine [.t index {@%x,%y linestart}]
220
+ if {$newLine ne $lastLine} {
221
+ .t tag remove hot 1.0 end
222
+ set lastLine $newLine
223
+
224
+ set tags [.t tag names {@%x,%y}]
225
+ set i [lsearch -glob $tags demo-*]
226
+ if {$i >= 0} {
227
+ .t tag add hot "$lastLine +1 chars" "$lastLine lineend -1 chars"
228
+ }
229
+ }
230
+ showStatus [.t index {@%x,%y}]
231
+ }
232
+
233
+ ##############################################################################
234
+ # Create the text for the text widget.
235
+
236
+ # addFormattedText --
237
+ #
238
+ # Add formatted text (but not hypertext) to the text widget after first
239
+ # passing it through the message catalog to allow for localization.
240
+ # Lines starting with @@ are formatting directives (insert title, insert
241
+ # demo hyperlink, begin newline, or change style) and all other lines
242
+ # are literal strings to be inserted. Substitutions are performed,
243
+ # allowing processing pieces through the message catalog. Blank lines
244
+ # are ignored.
245
+ #
246
+ proc addFormattedText {formattedText} {
247
+ set style normal
248
+ set isNL 1
249
+ set demoCount 0
250
+ set new 0
251
+ foreach line [split $formattedText \n] {
252
+ set line [string trim $line]
253
+ if {$line eq ""} {
254
+ continue
255
+ }
256
+ if {[string match @@* $line]} {
257
+ set data [string range $line 2 end]
258
+ set key [lindex $data 0]
259
+ set values [lrange $data 1 end]
260
+ switch -exact -- $key {
261
+ title {
262
+ .t insert end [mc $values]\n title \n normal
263
+ }
264
+ newline {
265
+ .t insert end \n $style
266
+ set isNL 1
267
+ }
268
+ subtitle {
269
+ .t insert end "\n" {} [mc $values] subtitle \
270
+ " \n " demospace
271
+ set demoCount 0
272
+ }
273
+ demo {
274
+ set description [lassign $values name]
275
+ .t insert end "[incr demoCount]. [mc $description]" \
276
+ [list demo demo-$name]
277
+ if {$new} {
278
+ .t image create end -image ::img::new -padx 5
279
+ set new 0
280
+ }
281
+ .t insert end " \n " demospace
282
+ }
283
+ new {
284
+ set new 1
285
+ }
286
+ default {
287
+ set style $key
288
+ }
289
+ }
290
+ continue
291
+ }
292
+ if {!$isNL} {
293
+ .t insert end " " $style
294
+ }
295
+ set isNL 0
296
+ .t insert end [mc $line] $style
297
+ }
298
+ }
299
+
300
+ addFormattedText {
301
+ @@title Tk Widget Demonstrations
302
+
303
+ This application provides a front end for several short scripts
304
+ that demonstrate what you can do with Tk widgets. Each of the
305
+ numbered lines below describes a demonstration; you can click on
306
+ it to invoke the demonstration. Once the demonstration window
307
+ appears, you can click the
308
+ @@bold
309
+ See Code
310
+ @@normal
311
+ button to see the Tcl/Tk code that created the demonstration. If
312
+ you wish, you can edit the code and click the
313
+ @@bold
314
+ Rerun Demo
315
+ @@normal
316
+ button in the code window to reinvoke the demonstration with the
317
+ modified code.
318
+ @@newline
319
+
320
+ @@subtitle Labels, buttons, checkbuttons, and radiobuttons
321
+ @@demo label Labels (text and bitmaps)
322
+ @@demo unicodeout Labels and UNICODE text
323
+ @@demo button Buttons
324
+ @@demo check Check-buttons (select any of a group)
325
+ @@demo radio Radio-buttons (select one of a group)
326
+ @@demo puzzle A 15-puzzle game made out of buttons
327
+ @@demo icon Iconic buttons that use bitmaps
328
+ @@demo image1 Two labels displaying images
329
+ @@demo image2 A simple user interface for viewing images
330
+ @@demo labelframe Labelled frames
331
+ @@demo ttkbut The simple Themed Tk widgets
332
+
333
+ @@subtitle Listboxes and Trees
334
+ @@demo states The 50 states
335
+ @@demo colors Colors: change the color scheme for the application
336
+ @@demo sayings A collection of famous and infamous sayings
337
+ @@demo mclist A multi-column list of countries
338
+ @@demo tree A directory browser tree
339
+
340
+ @@subtitle Entries, Spin-boxes and Combo-boxes
341
+ @@demo entry1 Entries without scrollbars
342
+ @@demo entry2 Entries with scrollbars
343
+ @@demo entry3 Validated entries and password fields
344
+ @@demo spin Spin-boxes
345
+ @@demo combo Combo-boxes
346
+ @@demo form Simple Rolodex-like form
347
+
348
+ @@subtitle Text
349
+ @@demo text Basic editable text
350
+ @@demo style Text display styles
351
+ @@demo bind Hypertext (tag bindings)
352
+ @@demo twind A text widget with embedded windows and other features
353
+ @@demo search A search tool built with a text widget
354
+ @@demo textpeer Peering text widgets
355
+
356
+ @@subtitle Canvases
357
+ @@demo items The canvas item types
358
+ @@demo plot A simple 2-D plot
359
+ @@demo ctext Text items in canvases
360
+ @@demo arrow An editor for arrowheads on canvas lines
361
+ @@demo ruler A ruler with adjustable tab stops
362
+ @@demo floor A building floor plan
363
+ @@demo cscroll A simple scrollable canvas
364
+ @@demo knightstour A Knight's tour of the chess board
365
+
366
+ @@subtitle Scales and Progress Bars
367
+ @@demo hscale Horizontal scale
368
+ @@demo vscale Vertical scale
369
+ @@new
370
+ @@demo ttkscale Themed scale linked to a label with traces
371
+ @@demo ttkprogress Progress bar
372
+
373
+ @@subtitle Paned Windows and Notebooks
374
+ @@demo paned1 Horizontal paned window
375
+ @@demo paned2 Vertical paned window
376
+ @@demo ttkpane Themed nested panes
377
+ @@demo ttknote Notebook widget
378
+
379
+ @@subtitle Menus and Toolbars
380
+ @@demo menu Menus and cascades (sub-menus)
381
+ @@demo menubu Menu-buttons
382
+ @@demo ttkmenu Themed menu buttons
383
+ @@demo toolbar Themed toolbar
384
+
385
+ @@subtitle Common Dialogs
386
+ @@demo msgbox Message boxes
387
+ @@demo filebox File selection dialog
388
+ @@demo clrpick Color picker
389
+ @@demo fontchoose Font selection dialog
390
+
391
+ @@subtitle Animation
392
+ @@demo anilabel Animated labels
393
+ @@demo aniwave Animated wave
394
+ @@demo pendulum Pendulum simulation
395
+ @@demo goldberg A celebration of Rube Goldberg
396
+
397
+ @@subtitle Miscellaneous
398
+ @@demo bitmap The built-in bitmaps
399
+ @@demo dialog1 A dialog box with a local grab
400
+ @@demo dialog2 A dialog box with a global grab
401
+ }
402
+
403
+ ##############################################################################
404
+
405
+ .t configure -state disabled
406
+ focus .s
407
+
408
+ # addSeeDismiss --
409
+ # Add "See Code" and "Dismiss" button frame, with optional "See Vars"
410
+ #
411
+ # Arguments:
412
+ # w - The name of the frame to use.
413
+
414
+ proc addSeeDismiss {w show {vars {}} {extra {}}} {
415
+ ## See Code / Dismiss buttons
416
+ ttk::frame $w
417
+ ttk::separator $w.sep
418
+ #ttk::frame $w.sep -height 2 -relief sunken
419
+ grid $w.sep -columnspan 4 -row 0 -sticky ew -pady 2
420
+ ttk::button $w.dismiss -text [mc "Dismiss"] \
421
+ -image ::img::delete -compound left \
422
+ -command [list destroy [winfo toplevel $w]]
423
+ ttk::button $w.code -text [mc "See Code"] \
424
+ -image ::img::view -compound left \
425
+ -command [list showCode $show]
426
+ set buttons [list x $w.code $w.dismiss]
427
+ if {[llength $vars]} {
428
+ ttk::button $w.vars -text [mc "See Variables"] \
429
+ -image ::img::view -compound left \
430
+ -command [concat [list showVars $w.dialog] $vars]
431
+ set buttons [linsert $buttons 1 $w.vars]
432
+ }
433
+ if {$extra ne ""} {
434
+ set buttons [linsert $buttons 1 [uplevel 1 $extra]]
435
+ }
436
+ grid {*}$buttons -padx 4 -pady 4
437
+ grid columnconfigure $w 0 -weight 1
438
+ if {[tk windowingsystem] eq "aqua"} {
439
+ foreach b [lrange $buttons 1 end] {$b configure -takefocus 0}
440
+ grid configure $w.sep -pady 0
441
+ grid configure {*}$buttons -pady {10 12}
442
+ grid configure [lindex $buttons 1] -padx {16 4}
443
+ grid configure [lindex $buttons end] -padx {4 18}
444
+ }
445
+ return $w
446
+ }
447
+
448
+ # positionWindow --
449
+ # This procedure is invoked by most of the demos to position a new demo
450
+ # window.
451
+ #
452
+ # Arguments:
453
+ # w - The name of the window to position.
454
+
455
+ proc positionWindow w {
456
+ wm geometry $w +300+300
457
+ }
458
+
459
+ # showVars --
460
+ # Displays the values of one or more variables in a window, and updates the
461
+ # display whenever any of the variables changes.
462
+ #
463
+ # Arguments:
464
+ # w - Name of new window to create for display.
465
+ # args - Any number of names of variables.
466
+
467
+ proc showVars {w args} {
468
+ catch {destroy $w}
469
+ toplevel $w
470
+ if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}
471
+ wm title $w [mc "Variable values"]
472
+
473
+ set b [ttk::frame $w.frame]
474
+ grid $b -sticky news
475
+ set f [ttk::labelframe $b.title -text [mc "Variable values:"]]
476
+ foreach var $args {
477
+ ttk::label $f.n$var -text "$var:" -anchor w
478
+ ttk::label $f.v$var -textvariable $var -anchor w
479
+ grid $f.n$var $f.v$var -padx 2 -pady 2 -sticky w
480
+ }
481
+ ttk::button $b.ok -text [mc "OK"] \
482
+ -command [list destroy $w] -default active
483
+ bind $w <Return> [list $b.ok invoke]
484
+ bind $w <Escape> [list $b.ok invoke]
485
+
486
+ grid $f -sticky news -padx 4
487
+ grid $b.ok -sticky e -padx 4 -pady {6 4}
488
+ if {[tk windowingsystem] eq "aqua"} {
489
+ $b.ok configure -takefocus 0
490
+ grid configure $b.ok -pady {10 12} -padx {16 18}
491
+ grid configure $f -padx 10 -pady {10 0}
492
+ }
493
+ grid columnconfig $f 1 -weight 1
494
+ grid rowconfigure $f 100 -weight 1
495
+ grid columnconfig $b 0 -weight 1
496
+ grid rowconfigure $b 0 -weight 1
497
+ grid columnconfig $w 0 -weight 1
498
+ grid rowconfigure $w 0 -weight 1
499
+ }
500
+
501
+ # invoke --
502
+ # This procedure is called when the user clicks on a demo description. It is
503
+ # responsible for invoking the demonstration.
504
+ #
505
+ # Arguments:
506
+ # index - The index of the character that the user clicked on.
507
+
508
+ proc invoke index {
509
+ global tk_demoDirectory
510
+ set tags [.t tag names $index]
511
+ set i [lsearch -glob $tags demo-*]
512
+ if {$i < 0} {
513
+ return
514
+ }
515
+ set cursor [.t cget -cursor]
516
+ .t configure -cursor [::ttk::cursor busy]
517
+ update
518
+ set demo [string range [lindex $tags $i] 5 end]
519
+ uplevel 1 [list source -encoding utf-8 [file join $tk_demoDirectory $demo.tcl]]
520
+ update
521
+ .t configure -cursor $cursor
522
+
523
+ .t tag add visited "$index linestart +1 chars" "$index lineend -1 chars"
524
+ }
525
+
526
+ # showStatus --
527
+ #
528
+ # Show the name of the demo program in the status bar. This procedure is
529
+ # called when the user moves the cursor over a demo description.
530
+ #
531
+ proc showStatus index {
532
+ set tags [.t tag names $index]
533
+ set i [lsearch -glob $tags demo-*]
534
+ set cursor [.t cget -cursor]
535
+ if {$i < 0} {
536
+ .statusBar.lab config -text " "
537
+ set newcursor [::ttk::cursor text]
538
+ } else {
539
+ set demo [string range [lindex $tags $i] 5 end]
540
+ .statusBar.lab config -text [mc "Run the \"%s\" sample program" $demo]
541
+ set newcursor [::ttk::cursor link]
542
+ }
543
+ if {$cursor ne $newcursor} {
544
+ .t config -cursor $newcursor
545
+ }
546
+ }
547
+
548
+ # evalShowCode --
549
+ #
550
+ # Arguments:
551
+ # w - Name of text widget containing code to eval
552
+
553
+ proc evalShowCode {w} {
554
+ set code [$w get 1.0 end-1c]
555
+ uplevel #0 $code
556
+ }
557
+
558
+ # showCode --
559
+ # This procedure creates a toplevel window that displays the code for a
560
+ # demonstration and allows it to be edited and reinvoked.
561
+ #
562
+ # Arguments:
563
+ # w - The name of the demonstration's window, which can be used to
564
+ # derive the name of the file containing its code.
565
+
566
+ proc showCode w {
567
+ global tk_demoDirectory
568
+ set file [string range $w 1 end].tcl
569
+ set top .code
570
+ if {![winfo exists $top]} {
571
+ toplevel $top
572
+ if {[tk windowingsystem] eq "x11"} {wm attributes $top -type dialog}
573
+
574
+ set t [frame $top.f]
575
+ set text [text $t.text -font fixedFont -height 24 -wrap word \
576
+ -xscrollcommand [list $t.xscroll set] \
577
+ -yscrollcommand [list $t.yscroll set] \
578
+ -setgrid 1 -highlightthickness 0 -pady 2 -padx 3]
579
+ ttk::scrollbar $t.xscroll -command [list $t.text xview] \
580
+ -orient horizontal
581
+ ttk::scrollbar $t.yscroll -command [list $t.text yview] \
582
+ -orient vertical
583
+
584
+ grid $t.text $t.yscroll -sticky news
585
+ #grid $t.xscroll
586
+ grid rowconfigure $t 0 -weight 1
587
+ grid columnconfig $t 0 -weight 1
588
+
589
+ set btns [ttk::frame $top.btns]
590
+ ttk::separator $btns.sep
591
+ grid $btns.sep -columnspan 4 -row 0 -sticky ew -pady 2
592
+ ttk::button $btns.dismiss -text [mc "Dismiss"] \
593
+ -default active -command [list destroy $top] \
594
+ -image ::img::delete -compound left
595
+ ttk::button $btns.print -text [mc "Print Code"] \
596
+ -command [list printCode $text $file] \
597
+ -image ::img::print -compound left
598
+ ttk::button $btns.rerun -text [mc "Rerun Demo"] \
599
+ -command [list evalShowCode $text] \
600
+ -image ::img::refresh -compound left
601
+ set buttons [list x $btns.rerun $btns.print $btns.dismiss]
602
+ grid {*}$buttons -padx 4 -pady 4
603
+ grid columnconfigure $btns 0 -weight 1
604
+ if {[tk windowingsystem] eq "aqua"} {
605
+ foreach b [lrange $buttons 1 end] {$b configure -takefocus 0}
606
+ grid configure $btns.sep -pady 0
607
+ grid configure {*}$buttons -pady {10 12}
608
+ grid configure [lindex $buttons 1] -padx {16 4}
609
+ grid configure [lindex $buttons end] -padx {4 18}
610
+ }
611
+ grid $t -sticky news
612
+ grid $btns -sticky ew
613
+ grid rowconfigure $top 0 -weight 1
614
+ grid columnconfig $top 0 -weight 1
615
+
616
+ bind $top <Return> {
617
+ if {[winfo class %W] ne "Text"} { .code.btns.dismiss invoke }
618
+ }
619
+ bind $top <Escape> [bind $top <Return>]
620
+ } else {
621
+ wm deiconify $top
622
+ raise $top
623
+ }
624
+ wm title $top [mc "Demo code: %s" [file join $tk_demoDirectory $file]]
625
+ wm iconname $top $file
626
+ set id [open [file join $tk_demoDirectory $file]]
627
+ fconfigure $id -encoding utf-8 -eofchar "\032 {}"
628
+ $top.f.text delete 1.0 end
629
+ $top.f.text insert 1.0 [read $id]
630
+ $top.f.text mark set insert 1.0
631
+ close $id
632
+ }
633
+
634
+ # printCode --
635
+ # Prints the source code currently displayed in the See Code dialog. Much
636
+ # thanks to Arjen Markus for this.
637
+ #
638
+ # Arguments:
639
+ # w - Name of text widget containing code to print
640
+ # file - Name of the original file (implicitly for title)
641
+
642
+ proc printCode {w file} {
643
+ set code [$w get 1.0 end-1c]
644
+
645
+ set dir "."
646
+ if {[info exists ::env(HOME)]} {
647
+ set dir "$::env(HOME)"
648
+ }
649
+ if {[info exists ::env(TMP)]} {
650
+ set dir $::env(TMP)
651
+ }
652
+ if {[info exists ::env(TEMP)]} {
653
+ set dir $::env(TEMP)
654
+ }
655
+
656
+ set filename [file join $dir "tkdemo-$file"]
657
+ set outfile [open $filename "w"]
658
+ puts $outfile $code
659
+ close $outfile
660
+
661
+ switch -- $::tcl_platform(platform) {
662
+ unix {
663
+ if {[catch {exec lp -c $filename} msg]} {
664
+ tk_messageBox -title "Print spooling failure" \
665
+ -message "Print spooling probably failed: $msg"
666
+ }
667
+ }
668
+ windows {
669
+ if {[catch {PrintTextWin32 $filename} msg]} {
670
+ tk_messageBox -title "Print spooling failure" \
671
+ -message "Print spooling probably failed: $msg"
672
+ }
673
+ }
674
+ default {
675
+ tk_messageBox -title "Operation not Implemented" \
676
+ -message "Wow! Unknown platform: $::tcl_platform(platform)"
677
+ }
678
+ }
679
+
680
+ #
681
+ # Be careful to throw away the temporary file in a gentle manner ...
682
+ #
683
+ if {[file exists $filename]} {
684
+ catch {file delete $filename}
685
+ }
686
+ }
687
+
688
+ # PrintTextWin32 --
689
+ # Print a file under Windows using all the "intelligence" necessary
690
+ #
691
+ # Arguments:
692
+ # filename - Name of the file
693
+ #
694
+ # Note:
695
+ # Taken from the Wiki page by Keith Vetter, "Printing text files under
696
+ # Windows".
697
+ # Note:
698
+ # Do not execute the command in the background: that way we can dispose of the
699
+ # file smoothly.
700
+ #
701
+ proc PrintTextWin32 {filename} {
702
+ package require registry
703
+ set app [auto_execok notepad.exe]
704
+ set pcmd "$app /p %1"
705
+ catch {
706
+ set app [registry get {HKEY_CLASSES_ROOT\.txt} {}]
707
+ set pcmd [registry get \
708
+ {HKEY_CLASSES_ROOT\\$app\\shell\\print\\command} {}]
709
+ }
710
+
711
+ regsub -all {%1} $pcmd $filename pcmd
712
+ puts $pcmd
713
+
714
+ regsub -all {\\} $pcmd {\\\\} pcmd
715
+ set command "[auto_execok start] /min $pcmd"
716
+ eval exec $command
717
+ }
718
+
719
+ # tkAboutDialog --
720
+ #
721
+ # Pops up a message box with an "about" message
722
+ #
723
+ proc tkAboutDialog {} {
724
+ tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \
725
+ -message [mc "Tk widget demonstration application"] -detail \
726
+ "[mc "Copyright \xA9 %s" {1996-1997 Sun Microsystems, Inc.}]
727
+ [mc "Copyright \xA9 %s" {1997-2000 Ajuba Solutions, Inc.}]
728
+ [mc "Copyright \xA9 %s" {2001-2009 Donal K. Fellows}]
729
+ [mc "Copyright \xA9 %s" {2002-2007 Daniel A. Steffen}]"
730
+ }
731
+
732
+ # Local Variables:
733
+ # mode: tcl
734
+ # End:
janus/lib/tk8.6/entry.tcl ADDED
@@ -0,0 +1,699 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # entry.tcl --
2
+ #
3
+ # This file defines the default bindings for Tk entry widgets and provides
4
+ # procedures that help in implementing those bindings.
5
+ #
6
+ # Copyright (c) 1992-1994 The Regents of the University of California.
7
+ # Copyright (c) 1994-1997 Sun Microsystems, Inc.
8
+ #
9
+ # See the file "license.terms" for information on usage and redistribution
10
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
+ #
12
+
13
+ #-------------------------------------------------------------------------
14
+ # Elements of tk::Priv that are used in this file:
15
+ #
16
+ # afterId - If non-null, it means that auto-scanning is underway
17
+ # and it gives the "after" id for the next auto-scan
18
+ # command to be executed.
19
+ # mouseMoved - Non-zero means the mouse has moved a significant
20
+ # amount since the button went down (so, for example,
21
+ # start dragging out a selection).
22
+ # pressX - X-coordinate at which the mouse button was pressed.
23
+ # selectMode - The style of selection currently underway:
24
+ # char, word, or line.
25
+ # x, y - Last known mouse coordinates for scanning
26
+ # and auto-scanning.
27
+ # data - Used for Cut and Copy
28
+ #-------------------------------------------------------------------------
29
+
30
+ #-------------------------------------------------------------------------
31
+ # The code below creates the default class bindings for entries.
32
+ #-------------------------------------------------------------------------
33
+ bind Entry <<Cut>> {
34
+ if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} {
35
+ clipboard clear -displayof %W
36
+ clipboard append -displayof %W $tk::Priv(data)
37
+ %W delete sel.first sel.last
38
+ unset tk::Priv(data)
39
+ }
40
+ }
41
+ bind Entry <<Copy>> {
42
+ if {![catch {tk::EntryGetSelection %W} tk::Priv(data)]} {
43
+ clipboard clear -displayof %W
44
+ clipboard append -displayof %W $tk::Priv(data)
45
+ unset tk::Priv(data)
46
+ }
47
+ }
48
+ bind Entry <<Paste>> {
49
+ catch {
50
+ if {[tk windowingsystem] ne "x11"} {
51
+ catch {
52
+ %W delete sel.first sel.last
53
+ }
54
+ }
55
+ %W insert insert [::tk::GetSelection %W CLIPBOARD]
56
+ tk::EntrySeeInsert %W
57
+ }
58
+ }
59
+ bind Entry <<Clear>> {
60
+ # ignore if there is no selection
61
+ catch {%W delete sel.first sel.last}
62
+ }
63
+ bind Entry <<PasteSelection>> {
64
+ if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
65
+ || !$tk::Priv(mouseMoved)} {
66
+ tk::EntryPaste %W %x
67
+ }
68
+ }
69
+
70
+ bind Entry <<TraverseIn>> {
71
+ %W selection range 0 end
72
+ %W icursor end
73
+ }
74
+
75
+ # Standard Motif bindings:
76
+
77
+ bind Entry <Button-1> {
78
+ tk::EntryButton1 %W %x
79
+ %W selection clear
80
+ }
81
+ bind Entry <B1-Motion> {
82
+ set tk::Priv(x) %x
83
+ tk::EntryMouseSelect %W %x
84
+ }
85
+ bind Entry <Double-Button-1> {
86
+ set tk::Priv(selectMode) word
87
+ tk::EntryMouseSelect %W %x
88
+ catch {%W icursor sel.last}
89
+ }
90
+ bind Entry <Triple-Button-1> {
91
+ set tk::Priv(selectMode) line
92
+ tk::EntryMouseSelect %W %x
93
+ catch {%W icursor sel.last}
94
+ }
95
+ bind Entry <Shift-Button-1> {
96
+ set tk::Priv(selectMode) char
97
+ %W selection adjust @%x
98
+ }
99
+ bind Entry <Double-Shift-Button-1> {
100
+ set tk::Priv(selectMode) word
101
+ tk::EntryMouseSelect %W %x
102
+ }
103
+ bind Entry <Triple-Shift-Button-1> {
104
+ set tk::Priv(selectMode) line
105
+ tk::EntryMouseSelect %W %x
106
+ }
107
+ bind Entry <B1-Leave> {
108
+ set tk::Priv(x) %x
109
+ tk::EntryAutoScan %W
110
+ }
111
+ bind Entry <B1-Enter> {
112
+ tk::CancelRepeat
113
+ }
114
+ bind Entry <ButtonRelease-1> {
115
+ tk::CancelRepeat
116
+ }
117
+ bind Entry <Control-Button-1> {
118
+ %W icursor @%x
119
+ }
120
+
121
+ bind Entry <<PrevChar>> {
122
+ tk::EntrySetCursor %W [expr {[%W index insert]-1}]
123
+ }
124
+ bind Entry <<NextChar>> {
125
+ tk::EntrySetCursor %W [expr {[%W index insert]+1}]
126
+ }
127
+ bind Entry <<SelectPrevChar>> {
128
+ tk::EntryKeySelect %W [expr {[%W index insert]-1}]
129
+ tk::EntrySeeInsert %W
130
+ }
131
+ bind Entry <<SelectNextChar>> {
132
+ tk::EntryKeySelect %W [expr {[%W index insert]+1}]
133
+ tk::EntrySeeInsert %W
134
+ }
135
+ bind Entry <<PrevWord>> {
136
+ tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert]
137
+ }
138
+ bind Entry <<NextWord>> {
139
+ tk::EntrySetCursor %W [tk::EntryNextWord %W insert]
140
+ }
141
+ bind Entry <<SelectPrevWord>> {
142
+ tk::EntryKeySelect %W [tk::EntryPreviousWord %W insert]
143
+ tk::EntrySeeInsert %W
144
+ }
145
+ bind Entry <<SelectNextWord>> {
146
+ tk::EntryKeySelect %W [tk::EntryNextWord %W insert]
147
+ tk::EntrySeeInsert %W
148
+ }
149
+ bind Entry <<LineStart>> {
150
+ tk::EntrySetCursor %W 0
151
+ }
152
+ bind Entry <<SelectLineStart>> {
153
+ tk::EntryKeySelect %W 0
154
+ tk::EntrySeeInsert %W
155
+ }
156
+ bind Entry <<LineEnd>> {
157
+ tk::EntrySetCursor %W end
158
+ }
159
+ bind Entry <<SelectLineEnd>> {
160
+ tk::EntryKeySelect %W end
161
+ tk::EntrySeeInsert %W
162
+ }
163
+
164
+ bind Entry <Delete> {
165
+ if {[%W selection present]} {
166
+ %W delete sel.first sel.last
167
+ } else {
168
+ %W delete insert
169
+ }
170
+ }
171
+ bind Entry <BackSpace> {
172
+ tk::EntryBackspace %W
173
+ }
174
+
175
+ bind Entry <Control-space> {
176
+ %W selection from insert
177
+ }
178
+ bind Entry <Select> {
179
+ %W selection from insert
180
+ }
181
+ bind Entry <Control-Shift-space> {
182
+ %W selection adjust insert
183
+ }
184
+ bind Entry <Shift-Select> {
185
+ %W selection adjust insert
186
+ }
187
+ bind Entry <<SelectAll>> {
188
+ %W selection range 0 end
189
+ }
190
+ bind Entry <<SelectNone>> {
191
+ %W selection clear
192
+ }
193
+ bind Entry <Key> {
194
+ tk::CancelRepeat
195
+ tk::EntryInsert %W %A
196
+ }
197
+
198
+ # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
199
+ # Otherwise, if a widget binding for one of these is defined, the
200
+ # <Key> class binding will also fire and insert the character,
201
+ # which is wrong. Ditto for Escape, Return, and Tab.
202
+
203
+ bind Entry <Alt-Key> {# nothing}
204
+ bind Entry <Meta-Key> {# nothing}
205
+ bind Entry <Control-Key> {# nothing}
206
+ bind Entry <Escape> {# nothing}
207
+ bind Entry <Return> {# nothing}
208
+ bind Entry <KP_Enter> {# nothing}
209
+ bind Entry <Tab> {# nothing}
210
+ bind Entry <Prior> {# nothing}
211
+ bind Entry <Next> {# nothing}
212
+ if {[tk windowingsystem] eq "aqua"} {
213
+ bind Entry <Command-Key> {# nothing}
214
+ bind Entry <Mod4-Key> {# nothing}
215
+ }
216
+ # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
217
+ bind Entry <<NextLine>> {# nothing}
218
+ bind Entry <<PrevLine>> {# nothing}
219
+
220
+ # On Windows, paste is done using Shift-Insert. Shift-Insert already
221
+ # generates the <<Paste>> event, so we don't need to do anything here.
222
+ if {[tk windowingsystem] ne "win32"} {
223
+ bind Entry <Insert> {
224
+ catch {tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]}
225
+ }
226
+ }
227
+
228
+ # Additional emacs-like bindings:
229
+
230
+ bind Entry <Control-d> {
231
+ if {!$tk_strictMotif} {
232
+ %W delete insert
233
+ }
234
+ }
235
+ bind Entry <Control-h> {
236
+ if {!$tk_strictMotif} {
237
+ tk::EntryBackspace %W
238
+ }
239
+ }
240
+ bind Entry <Control-k> {
241
+ if {!$tk_strictMotif} {
242
+ %W delete insert end
243
+ }
244
+ }
245
+ bind Entry <Control-t> {
246
+ if {!$tk_strictMotif} {
247
+ tk::EntryTranspose %W
248
+ }
249
+ }
250
+ bind Entry <Meta-b> {
251
+ if {!$tk_strictMotif} {
252
+ tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert]
253
+ }
254
+ }
255
+ bind Entry <Meta-d> {
256
+ if {!$tk_strictMotif} {
257
+ %W delete insert [tk::EntryNextWord %W insert]
258
+ }
259
+ }
260
+ bind Entry <Meta-f> {
261
+ if {!$tk_strictMotif} {
262
+ tk::EntrySetCursor %W [tk::EntryNextWord %W insert]
263
+ }
264
+ }
265
+ bind Entry <Meta-BackSpace> {
266
+ if {!$tk_strictMotif} {
267
+ %W delete [tk::EntryPreviousWord %W insert] insert
268
+ }
269
+ }
270
+ bind Entry <Meta-Delete> {
271
+ if {!$tk_strictMotif} {
272
+ %W delete [tk::EntryPreviousWord %W insert] insert
273
+ }
274
+ }
275
+
276
+ # Bindings for IME text input and accents.
277
+
278
+ bind Entry <<TkStartIMEMarkedText>> {
279
+ dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
280
+ }
281
+ bind Entry <<TkEndIMEMarkedText>> {
282
+ if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} {
283
+ bell
284
+ } else {
285
+ %W selection range $mark insert
286
+ }
287
+ }
288
+ bind Entry <<TkClearIMEMarkedText>> {
289
+ %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
290
+ }
291
+ bind Entry <<TkAccentBackspace>> {
292
+ tk::EntryBackspace %W
293
+ }
294
+
295
+ # A few additional bindings of my own.
296
+
297
+ if {[tk windowingsystem] ne "aqua"} {
298
+ bind Entry <Button-2> {
299
+ if {!$tk_strictMotif} {
300
+ ::tk::EntryScanMark %W %x
301
+ }
302
+ }
303
+ bind Entry <B2-Motion> {
304
+ if {!$tk_strictMotif} {
305
+ ::tk::EntryScanDrag %W %x
306
+ }
307
+ }
308
+ } else {
309
+ bind Entry <Button-3> {
310
+ if {!$tk_strictMotif} {
311
+ ::tk::EntryScanMark %W %x
312
+ }
313
+ }
314
+ bind Entry <B3-Motion> {
315
+ if {!$tk_strictMotif} {
316
+ ::tk::EntryScanDrag %W %x
317
+ }
318
+ }
319
+ }
320
+
321
+ # ::tk::EntryClosestGap --
322
+ # Given x and y coordinates, this procedure finds the closest boundary
323
+ # between characters to the given coordinates and returns the index
324
+ # of the character just after the boundary.
325
+ #
326
+ # Arguments:
327
+ # w - The entry window.
328
+ # x - X-coordinate within the window.
329
+
330
+ proc ::tk::EntryClosestGap {w x} {
331
+ set pos [$w index @$x]
332
+ set bbox [$w bbox $pos]
333
+ if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} {
334
+ return $pos
335
+ }
336
+ incr pos
337
+ }
338
+
339
+ # ::tk::EntryButton1 --
340
+ # This procedure is invoked to handle button-1 presses in entry
341
+ # widgets. It moves the insertion cursor, sets the selection anchor,
342
+ # and claims the input focus.
343
+ #
344
+ # Arguments:
345
+ # w - The entry window in which the button was pressed.
346
+ # x - The x-coordinate of the button press.
347
+
348
+ proc ::tk::EntryButton1 {w x} {
349
+ variable ::tk::Priv
350
+
351
+ set Priv(selectMode) char
352
+ set Priv(mouseMoved) 0
353
+ set Priv(pressX) $x
354
+ $w icursor [EntryClosestGap $w $x]
355
+ $w selection from insert
356
+ if {"disabled" ne [$w cget -state]} {
357
+ focus $w
358
+ }
359
+ }
360
+
361
+ # ::tk::EntryMouseSelect --
362
+ # This procedure is invoked when dragging out a selection with
363
+ # the mouse. Depending on the selection mode (character, word,
364
+ # line) it selects in different-sized units. This procedure
365
+ # ignores mouse motions initially until the mouse has moved from
366
+ # one character to another or until there have been multiple clicks.
367
+ #
368
+ # Arguments:
369
+ # w - The entry window in which the button was pressed.
370
+ # x - The x-coordinate of the mouse.
371
+
372
+ proc ::tk::EntryMouseSelect {w x} {
373
+ variable ::tk::Priv
374
+
375
+ set cur [EntryClosestGap $w $x]
376
+ set anchor [$w index anchor]
377
+ if {($cur != $anchor) || (abs($Priv(pressX) - $x) >= 3)} {
378
+ set Priv(mouseMoved) 1
379
+ }
380
+ switch $Priv(selectMode) {
381
+ char {
382
+ if {$Priv(mouseMoved)} {
383
+ if {$cur < $anchor} {
384
+ $w selection range $cur $anchor
385
+ } elseif {$cur > $anchor} {
386
+ $w selection range $anchor $cur
387
+ } else {
388
+ $w selection clear
389
+ }
390
+ }
391
+ }
392
+ word {
393
+ if {$cur < $anchor} {
394
+ set before [tcl_wordBreakBefore [$w get] $cur]
395
+ set after [tcl_wordBreakAfter [$w get] $anchor-1]
396
+ } elseif {$cur > $anchor} {
397
+ set before [tcl_wordBreakBefore [$w get] $anchor]
398
+ set after [tcl_wordBreakAfter [$w get] $cur-1]
399
+ } else {
400
+ if {[$w index @$Priv(pressX)] < $anchor} {
401
+ incr anchor -1
402
+ }
403
+ set before [tcl_wordBreakBefore [$w get] $anchor]
404
+ set after [tcl_wordBreakAfter [$w get] $anchor]
405
+ }
406
+ if {$before < 0} {
407
+ set before 0
408
+ }
409
+ if {$after < 0} {
410
+ set after end
411
+ }
412
+ $w selection range $before $after
413
+ }
414
+ line {
415
+ $w selection range 0 end
416
+ }
417
+ }
418
+ if {$Priv(mouseMoved)} {
419
+ $w icursor $cur
420
+ }
421
+ update idletasks
422
+ }
423
+
424
+ # ::tk::EntryPaste --
425
+ # This procedure sets the insertion cursor to the current mouse position,
426
+ # pastes the selection there, and sets the focus to the window.
427
+ #
428
+ # Arguments:
429
+ # w - The entry window.
430
+ # x - X position of the mouse.
431
+
432
+ proc ::tk::EntryPaste {w x} {
433
+ $w icursor [EntryClosestGap $w $x]
434
+ catch {$w insert insert [::tk::GetSelection $w PRIMARY]}
435
+ if {"disabled" ne [$w cget -state]} {
436
+ focus $w
437
+ }
438
+ }
439
+
440
+ # ::tk::EntryAutoScan --
441
+ # This procedure is invoked when the mouse leaves an entry window
442
+ # with button 1 down. It scrolls the window left or right,
443
+ # depending on where the mouse is, and reschedules itself as an
444
+ # "after" command so that the window continues to scroll until the
445
+ # mouse moves back into the window or the mouse button is released.
446
+ #
447
+ # Arguments:
448
+ # w - The entry window.
449
+
450
+ proc ::tk::EntryAutoScan {w} {
451
+ variable ::tk::Priv
452
+ set x $Priv(x)
453
+ if {![winfo exists $w]} {
454
+ return
455
+ }
456
+ if {$x >= [winfo width $w]} {
457
+ $w xview scroll 2 units
458
+ EntryMouseSelect $w $x
459
+ } elseif {$x < 0} {
460
+ $w xview scroll -2 units
461
+ EntryMouseSelect $w $x
462
+ }
463
+ set Priv(afterId) [after 50 [list tk::EntryAutoScan $w]]
464
+ }
465
+
466
+ # ::tk::EntryKeySelect --
467
+ # This procedure is invoked when stroking out selections using the
468
+ # keyboard. It moves the cursor to a new position, then extends
469
+ # the selection to that position.
470
+ #
471
+ # Arguments:
472
+ # w - The entry window.
473
+ # new - A new position for the insertion cursor (the cursor hasn't
474
+ # actually been moved to this position yet).
475
+
476
+ proc ::tk::EntryKeySelect {w new} {
477
+ if {![$w selection present]} {
478
+ $w selection from insert
479
+ $w selection to $new
480
+ } else {
481
+ $w selection adjust $new
482
+ }
483
+ $w icursor $new
484
+ }
485
+
486
+ # ::tk::EntryInsert --
487
+ # Insert a string into an entry at the point of the insertion cursor.
488
+ # If there is a selection in the entry, and it covers the point of the
489
+ # insertion cursor, then delete the selection before inserting.
490
+ #
491
+ # Arguments:
492
+ # w - The entry window in which to insert the string
493
+ # s - The string to insert (usually just a single character)
494
+
495
+ proc ::tk::EntryInsert {w s} {
496
+ if {$s eq ""} {
497
+ return
498
+ }
499
+ catch {
500
+ set insert [$w index insert]
501
+ if {([$w index sel.first] <= $insert)
502
+ && ([$w index sel.last] >= $insert)} {
503
+ $w delete sel.first sel.last
504
+ }
505
+ }
506
+ $w insert insert $s
507
+ EntrySeeInsert $w
508
+ }
509
+
510
+ # ::tk::EntryBackspace --
511
+ # Backspace over the character just before the insertion cursor.
512
+ # If backspacing would move the cursor off the left edge of the
513
+ # window, reposition the cursor at about the middle of the window.
514
+ #
515
+ # Arguments:
516
+ # w - The entry window in which to backspace.
517
+
518
+ proc ::tk::EntryBackspace w {
519
+ if {[$w selection present]} {
520
+ $w delete sel.first sel.last
521
+ } else {
522
+ set x [$w index insert]
523
+ if {$x > 0} {
524
+ $w delete [expr {$x-1}]
525
+ }
526
+ if {[$w index @0] >= [$w index insert]} {
527
+ set range [$w xview]
528
+ set left [lindex $range 0]
529
+ set right [lindex $range 1]
530
+ $w xview moveto [expr {$left - ($right - $left)/2.0}]
531
+ }
532
+ }
533
+ }
534
+
535
+ # ::tk::EntrySeeInsert --
536
+ # Make sure that the insertion cursor is visible in the entry window.
537
+ # If not, adjust the view so that it is.
538
+ #
539
+ # Arguments:
540
+ # w - The entry window.
541
+
542
+ proc ::tk::EntrySeeInsert w {
543
+ set c [$w index insert]
544
+ if {($c < [$w index @0]) || ($c > [$w index @[winfo width $w]])} {
545
+ $w xview $c
546
+ }
547
+ }
548
+
549
+ # ::tk::EntrySetCursor -
550
+ # Move the insertion cursor to a given position in an entry. Also
551
+ # clears the selection, if there is one in the entry, and makes sure
552
+ # that the insertion cursor is visible.
553
+ #
554
+ # Arguments:
555
+ # w - The entry window.
556
+ # pos - The desired new position for the cursor in the window.
557
+
558
+ proc ::tk::EntrySetCursor {w pos} {
559
+ $w icursor $pos
560
+ $w selection clear
561
+ EntrySeeInsert $w
562
+ }
563
+
564
+ # ::tk::EntryTranspose -
565
+ # This procedure implements the "transpose" function for entry widgets.
566
+ # It tranposes the characters on either side of the insertion cursor,
567
+ # unless the cursor is at the end of the line. In this case it
568
+ # transposes the two characters to the left of the cursor. In either
569
+ # case, the cursor ends up to the right of the transposed characters.
570
+ #
571
+ # Arguments:
572
+ # w - The entry window.
573
+
574
+ proc ::tk::EntryTranspose w {
575
+ set i [$w index insert]
576
+ if {$i < [$w index end]} {
577
+ incr i
578
+ }
579
+ if {$i < 2} {
580
+ return
581
+ }
582
+ set first [expr {$i-2}]
583
+ set data [$w get]
584
+ set new [string index $data $i-1][string index $data $first]
585
+ $w delete $first $i
586
+ $w insert insert $new
587
+ EntrySeeInsert $w
588
+ }
589
+
590
+ # ::tk::EntryNextWord --
591
+ # Returns the index of the next word position after a given position in the
592
+ # entry. The next word is platform dependent and may be either the next
593
+ # end-of-word position or the next start-of-word position after the next
594
+ # end-of-word position.
595
+ #
596
+ # Arguments:
597
+ # w - The entry window in which the cursor is to move.
598
+ # start - Position at which to start search.
599
+
600
+ if {[tk windowingsystem] eq "win32"} {
601
+ proc ::tk::EntryNextWord {w start} {
602
+ # the check on [winfo class] is because the spinbox also uses this proc
603
+ if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
604
+ return end
605
+ }
606
+ set pos [tcl_endOfWord [$w get] [$w index $start]]
607
+ if {$pos >= 0} {
608
+ set pos [tcl_startOfNextWord [$w get] $pos]
609
+ }
610
+ if {$pos < 0} {
611
+ return end
612
+ }
613
+ return $pos
614
+ }
615
+ } else {
616
+ proc ::tk::EntryNextWord {w start} {
617
+ # the check on [winfo class] is because the spinbox also uses this proc
618
+ if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
619
+ return end
620
+ }
621
+ set pos [tcl_endOfWord [$w get] [$w index $start]]
622
+ if {$pos < 0} {
623
+ return end
624
+ }
625
+ return $pos
626
+ }
627
+ }
628
+
629
+ # ::tk::EntryPreviousWord --
630
+ #
631
+ # Returns the index of the previous word position before a given
632
+ # position in the entry.
633
+ #
634
+ # Arguments:
635
+ # w - The entry window in which the cursor is to move.
636
+ # start - Position at which to start search.
637
+
638
+ proc ::tk::EntryPreviousWord {w start} {
639
+ # the check on [winfo class] is because the spinbox also uses this proc
640
+ if {[winfo class $w] eq "Entry" && [$w cget -show] ne ""} {
641
+ return 0
642
+ }
643
+ set pos [tcl_startOfPreviousWord [$w get] [$w index $start]]
644
+ if {$pos < 0} {
645
+ return 0
646
+ }
647
+ return $pos
648
+ }
649
+
650
+ # ::tk::EntryScanMark --
651
+ #
652
+ # Marks the start of a possible scan drag operation
653
+ #
654
+ # Arguments:
655
+ # w - The entry window from which the text to get
656
+ # x - x location on screen
657
+
658
+ proc ::tk::EntryScanMark {w x} {
659
+ $w scan mark $x
660
+ set ::tk::Priv(x) $x
661
+ set ::tk::Priv(y) 0 ; # not used
662
+ set ::tk::Priv(mouseMoved) 0
663
+ }
664
+
665
+ # ::tk::EntryScanDrag --
666
+ #
667
+ # Marks the start of a possible scan drag operation
668
+ #
669
+ # Arguments:
670
+ # w - The entry window from which the text to get
671
+ # x - x location on screen
672
+
673
+ proc ::tk::EntryScanDrag {w x} {
674
+ # Make sure these exist, as some weird situations can trigger the
675
+ # motion binding without the initial press. [Bug #220269]
676
+ if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x}
677
+ # allow for a delta
678
+ if {abs($x-$::tk::Priv(x)) > 2} {
679
+ set ::tk::Priv(mouseMoved) 1
680
+ }
681
+ $w scan dragto $x
682
+ }
683
+
684
+ # ::tk::EntryGetSelection --
685
+ #
686
+ # Returns the selected text of the entry with respect to the -show option.
687
+ #
688
+ # Arguments:
689
+ # w - The entry window from which the text to get
690
+
691
+ proc ::tk::EntryGetSelection {w} {
692
+ set entryString [string range [$w get] [$w index sel.first] \
693
+ [$w index sel.last]-1]
694
+ if {[$w cget -show] ne ""} {
695
+ return [string repeat [string index [$w cget -show] 0] \
696
+ [string length $entryString]]
697
+ }
698
+ return $entryString
699
+ }
janus/lib/tk8.6/fontchooser.tcl ADDED
@@ -0,0 +1,515 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fontchooser.tcl -
2
+ #
3
+ # A themeable Tk font selection dialog. See TIP #324.
4
+ #
5
+ # Copyright (C) 2008 Keith Vetter
6
+ # Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+
11
+ namespace eval ::tk::fontchooser {
12
+ variable S
13
+
14
+ set S(W) .__tk__fontchooser
15
+ set S(fonts) [lsort -dictionary -unique [font families]]
16
+ set S(styles) [list \
17
+ [::msgcat::mc Regular] \
18
+ [::msgcat::mc Italic] \
19
+ [::msgcat::mc Bold] \
20
+ [::msgcat::mc {Bold Italic}] \
21
+ ]
22
+ set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72}
23
+ set S(strike) 0
24
+ set S(under) 0
25
+ set S(first) 1
26
+ set S(-parent) .
27
+ set S(-title) {}
28
+ set S(-command) ""
29
+ set S(-font) TkDefaultFont
30
+ set S(bad) [list ]
31
+ }
32
+
33
+ proc ::tk::fontchooser::Canonical {} {
34
+ variable S
35
+
36
+ foreach style $S(styles) {
37
+ lappend S(styles,lcase) [string tolower $style]
38
+ }
39
+ set S(sizes,lcase) $S(sizes)
40
+ set S(sampletext) [::msgcat::mc "AaBbYyZz01"]
41
+
42
+ # Canonical versions of font families, styles, etc. for easier searching
43
+ set S(fonts,lcase) {}
44
+ foreach font $S(fonts) {
45
+ lappend S(fonts,lcase) [string tolower $font]
46
+ }
47
+ set S(styles,lcase) {}
48
+ foreach style $S(styles) {
49
+ lappend S(styles,lcase) [string tolower $style]
50
+ }
51
+ }
52
+
53
+ proc ::tk::fontchooser::Setup {} {
54
+ variable S
55
+
56
+ Canonical
57
+
58
+ ::ttk::style layout FontchooserFrame {
59
+ Entry.field -sticky news -border true -children {
60
+ FontchooserFrame.padding -sticky news
61
+ }
62
+ }
63
+ bind [winfo class .] <<ThemeChanged>> \
64
+ [list +ttk::style layout FontchooserFrame \
65
+ [ttk::style layout FontchooserFrame]]
66
+
67
+ namespace ensemble create -map {
68
+ show ::tk::fontchooser::Show
69
+ hide ::tk::fontchooser::Hide
70
+ configure ::tk::fontchooser::Configure
71
+ }
72
+ }
73
+ ::tk::fontchooser::Setup
74
+
75
+ proc ::tk::fontchooser::Show {} {
76
+ variable S
77
+
78
+ Canonical
79
+
80
+ if {![winfo exists $S(W)]} {
81
+ Create
82
+ wm transient $S(W) [winfo toplevel $S(-parent)]
83
+ tk::PlaceWindow $S(W) widget $S(-parent)
84
+ if {[string trim $S(-title)] eq ""} {
85
+ wm title $S(W) [::msgcat::mc "Font"]
86
+ } else {
87
+ wm title $S(W) $S(-title)
88
+ }
89
+ }
90
+ set S(fonts) [lsort -dictionary -unique [font families]]
91
+ set S(fonts,lcase) {}
92
+ foreach font $S(fonts) {
93
+ lappend S(fonts,lcase) [string tolower $font]
94
+ }
95
+ wm deiconify $S(W)
96
+ }
97
+
98
+ proc ::tk::fontchooser::Hide {} {
99
+ variable S
100
+ wm withdraw $S(W)
101
+ }
102
+
103
+ proc ::tk::fontchooser::Configure {args} {
104
+ variable S
105
+
106
+ set specs {
107
+ {-parent "" "" . }
108
+ {-title "" "" ""}
109
+ {-font "" "" ""}
110
+ {-command "" "" ""}
111
+ }
112
+
113
+ if {[llength $args] == 0} {
114
+ set result {}
115
+ foreach spec $specs {
116
+ foreach {name xx yy default} $spec break
117
+ lappend result $name \
118
+ [expr {[info exists S($name)] ? $S($name) : $default}]
119
+ }
120
+ lappend result -visible \
121
+ [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}]
122
+ return $result
123
+ }
124
+ if {[llength $args] == 1} {
125
+ set option [lindex $args 0]
126
+ if {[string equal $option "-visible"]} {
127
+ return [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}]
128
+ } elseif {[info exists S($option)]} {
129
+ return $S($option)
130
+ }
131
+ return -code error -errorcode [list TK LOOKUP OPTION $option] \
132
+ "bad option \"$option\": must be\
133
+ -command, -font, -parent, -title or -visible"
134
+ }
135
+ set cache [dict create -parent $S(-parent) -title $S(-title) \
136
+ -font $S(-font) -command $S(-command)]
137
+ set r [tclParseConfigSpec [namespace which -variable S] $specs DONTSETDEFAULTS $args]
138
+ if {![winfo exists $S(-parent)]} {
139
+ set code [list TK LOOKUP WINDOW $S(-parent)]
140
+ set err "bad window path name \"$S(-parent)\""
141
+ array set S $cache
142
+ return -code error -errorcode $code $err
143
+ }
144
+
145
+ if {[winfo exists $S(W)]} {
146
+ if {{-font} in $args} {
147
+ Init $S(-font)
148
+ event generate $S(-parent) <<TkFontchooserFontChanged>>
149
+ }
150
+
151
+ if {[string trim $S(-title)] eq {}} {
152
+ wm title $S(W) [::msgcat::mc Font]
153
+ } else {
154
+ wm title $S(W) $S(-title)
155
+ }
156
+ $S(W).ok configure -state $S(nstate)
157
+ $S(W).apply configure -state $S(nstate)
158
+ }
159
+ return $r
160
+ }
161
+
162
+ proc ::tk::fontchooser::Create {} {
163
+ variable S
164
+ set windowName __tk__fontchooser
165
+ if {$S(-parent) eq "."} {
166
+ set S(W) .$windowName
167
+ } else {
168
+ set S(W) $S(-parent).$windowName
169
+ }
170
+
171
+ # Now build the dialog
172
+ if {![winfo exists $S(W)]} {
173
+ toplevel $S(W) -class TkFontDialog
174
+ if {[package provide tcltest] ne {}} {
175
+ set ::tk_dialog $S(W)
176
+ }
177
+ wm withdraw $S(W)
178
+ wm title $S(W) $S(-title)
179
+ wm transient $S(W) [winfo toplevel $S(-parent)]
180
+
181
+ set scaling [tk scaling]
182
+ set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}]
183
+
184
+ set outer [::ttk::frame $S(W).outer -padding {10 10}]
185
+ ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"]
186
+ ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"]
187
+ ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth
188
+ ttk::entry $S(W).efont -width 18 \
189
+ -textvariable [namespace which -variable S](font)
190
+ ttk::entry $S(W).estyle -width 10 \
191
+ -textvariable [namespace which -variable S](style)
192
+ ttk::entry $S(W).esize -textvariable [namespace which -variable S](size) \
193
+ -width 3 -validate key -validatecommand {regexp -- {^-*[0-9]*$} %P}
194
+
195
+ ttk_slistbox $S(W).lfonts -height 7 -exportselection 0 \
196
+ -selectmode browse -activestyle none \
197
+ -listvariable [namespace which -variable S](fonts)
198
+ ttk_slistbox $S(W).lstyles -width 5 -height 7 -exportselection 0 \
199
+ -selectmode browse -activestyle none \
200
+ -listvariable [namespace which -variable S](styles)
201
+ ttk_slistbox $S(W).lsizes -width 4 -height 7 -exportselection 0 \
202
+ -selectmode browse -activestyle none \
203
+ -listvariable [namespace which -variable S](sizes)
204
+
205
+ set WE $S(W).effects
206
+ ::ttk::labelframe $WE -text [::msgcat::mc "Effects"]
207
+ ::tk::AmpWidget ::ttk::checkbutton $WE.strike \
208
+ -variable [namespace which -variable S](strike) \
209
+ -text [::msgcat::mc "Stri&keout"] \
210
+ -command [namespace code [list Click strike]]
211
+ ::tk::AmpWidget ::ttk::checkbutton $WE.under \
212
+ -variable [namespace which -variable S](under) \
213
+ -text [::msgcat::mc "&Underline"] \
214
+ -command [namespace code [list Click under]]
215
+
216
+ set bbox [::ttk::frame $S(W).bbox]
217
+ ::ttk::button $S(W).ok -text [::msgcat::mc OK] -default active\
218
+ -command [namespace code [list Done 1]]
219
+ ::ttk::button $S(W).cancel -text [::msgcat::mc Cancel] \
220
+ -command [namespace code [list Done 0]]
221
+ ::tk::AmpWidget ::ttk::button $S(W).apply -text [::msgcat::mc "&Apply"] \
222
+ -command [namespace code [list Apply]]
223
+ wm protocol $S(W) WM_DELETE_WINDOW [namespace code [list Done 0]]
224
+
225
+ # Calculate minimum sizes
226
+ ttk::scrollbar $S(W).tmpvs
227
+ set scroll_width [winfo reqwidth $S(W).tmpvs]
228
+ destroy $S(W).tmpvs
229
+ set minsize(gap) 10
230
+ set minsize(bbox) [winfo reqwidth $S(W).ok]
231
+ set minsize(fonts) \
232
+ [expr {[font measure TkDefaultFont "Helvetica"] + $scroll_width}]
233
+ set minsize(styles) \
234
+ [expr {[font measure TkDefaultFont "Bold Italic"] + $scroll_width}]
235
+ set minsize(sizes) \
236
+ [expr {[font measure TkDefaultFont "-99"] + $scroll_width}]
237
+ set min [expr {$minsize(gap) * 4}]
238
+ foreach {what width} [array get minsize] {
239
+ incr min $width
240
+ }
241
+ wm minsize $S(W) $min 260
242
+
243
+ bind $S(W) <Return> [namespace code [list Done 1]]
244
+ bind $S(W) <Escape> [namespace code [list Done 0]]
245
+ bind $S(W) <Map> [namespace code [list Visibility %W 1]]
246
+ bind $S(W) <Unmap> [namespace code [list Visibility %W 0]]
247
+ bind $S(W) <Destroy> [namespace code [list Visibility %W 0]]
248
+ bind $S(W).lfonts.list <<ListboxSelect>> [namespace code [list Click font]]
249
+ bind $S(W).lstyles.list <<ListboxSelect>> [namespace code [list Click style]]
250
+ bind $S(W).lsizes.list <<ListboxSelect>> [namespace code [list Click size]]
251
+ bind $S(W) <Alt-Key> [list ::tk::AltKeyInDialog $S(W) %A]
252
+ bind $S(W).font <<AltUnderlined>> [list ::focus $S(W).efont]
253
+ bind $S(W).style <<AltUnderlined>> [list ::focus $S(W).estyle]
254
+ bind $S(W).size <<AltUnderlined>> [list ::focus $S(W).esize]
255
+ bind $S(W).apply <<AltUnderlined>> [namespace code [list Apply]]
256
+ bind $WE.strike <<AltUnderlined>> [list $WE.strike invoke]
257
+ bind $WE.under <<AltUnderlined>> [list $WE.under invoke]
258
+
259
+ set WS $S(W).sample
260
+ ::ttk::labelframe $WS -text [::msgcat::mc "Sample"]
261
+ ::ttk::label $WS.sample -relief sunken -anchor center \
262
+ -textvariable [namespace which -variable S](sampletext)
263
+ set S(sample) $WS.sample
264
+ grid $WS.sample -sticky news -padx 6 -pady 4
265
+ grid rowconfigure $WS 0 -weight 1
266
+ grid columnconfigure $WS 0 -weight 1
267
+ grid propagate $WS 0
268
+
269
+ grid $S(W).ok -in $bbox -sticky new -pady {0 2}
270
+ grid $S(W).cancel -in $bbox -sticky new -pady 2
271
+ grid $S(W).apply -in $bbox -sticky new -pady 2
272
+ grid columnconfigure $bbox 0 -weight 1
273
+
274
+ grid $WE.strike -sticky w -padx 10
275
+ grid $WE.under -sticky w -padx 10 -pady {0 30}
276
+ grid columnconfigure $WE 1 -weight 1
277
+
278
+ grid $S(W).font x $S(W).style x $S(W).size x -in $outer -sticky w
279
+ grid $S(W).efont x $S(W).estyle x $S(W).esize x $bbox -in $outer -sticky ew
280
+ grid $S(W).lfonts x $S(W).lstyles x $S(W).lsizes x ^ -in $outer -sticky news
281
+ grid $WE x $WS - - x ^ -in $outer -sticky news -pady {15 30}
282
+ grid configure $bbox -sticky n
283
+ grid rowconfigure $outer 2 -weight 1
284
+ grid columnconfigure $outer {1 3 5} -minsize $minsize(gap)
285
+ grid columnconfigure $outer {0 2 4} -weight 1
286
+ grid columnconfigure $outer 0 -minsize $minsize(fonts)
287
+ grid columnconfigure $outer 2 -minsize $minsize(styles)
288
+ grid columnconfigure $outer 4 -minsize $minsize(sizes)
289
+ grid columnconfigure $outer 6 -minsize $minsize(bbox)
290
+
291
+ grid $outer -sticky news
292
+ grid rowconfigure $S(W) 0 -weight 1
293
+ grid columnconfigure $S(W) 0 -weight 1
294
+
295
+ Init $S(-font)
296
+
297
+ trace add variable [namespace which -variable S](size) \
298
+ write [namespace code [list Tracer]]
299
+ trace add variable [namespace which -variable S](style) \
300
+ write [namespace code [list Tracer]]
301
+ trace add variable [namespace which -variable S](font) \
302
+ write [namespace code [list Tracer]]
303
+ trace add variable [namespace which -variable S](strike) \
304
+ write [namespace code [list Tracer]]
305
+ trace add variable [namespace which -variable S](under) \
306
+ write [namespace code [list Tracer]]
307
+ }
308
+
309
+ Init $S(-font)
310
+
311
+ return
312
+ }
313
+
314
+ # ::tk::fontchooser::Done --
315
+ #
316
+ # Handles teardown of the dialog, calling -command if needed
317
+ #
318
+ # Arguments:
319
+ # ok true if user pressed OK
320
+ #
321
+ proc ::tk::fontchooser::Done {ok} {
322
+ variable S
323
+
324
+ if {! $ok} {
325
+ set S(result) ""
326
+ }
327
+ trace remove variable S(size) write [namespace code [list Tracer]]
328
+ trace remove variable S(style) write [namespace code [list Tracer]]
329
+ trace remove variable S(font) write [namespace code [list Tracer]]
330
+ trace remove variable S(strike) write [namespace code [list Tracer]]
331
+ trace remove variable S(under) write [namespace code [list Tracer]]
332
+ destroy $S(W)
333
+ if {$ok} {
334
+ if {$S(-command) ne ""} {
335
+ uplevel #0 $S(-command) [list $S(result)]
336
+ }
337
+ event generate $S(-parent) <<TkFontchooserFontChanged>>
338
+ }
339
+ }
340
+
341
+ # ::tk::fontchooser::Apply --
342
+ #
343
+ # Call the -command procedure appending the current font
344
+ # Errors are reported via the background error mechanism
345
+ #
346
+ proc ::tk::fontchooser::Apply {} {
347
+ variable S
348
+ if {$S(-command) ne ""} {
349
+ if {[catch {uplevel #0 $S(-command) [list $S(result)]} err]} {
350
+ ::bgerror $err
351
+ }
352
+ }
353
+ event generate $S(-parent) <<TkFontchooserFontChanged>>
354
+ }
355
+
356
+ # ::tk::fontchooser::Init --
357
+ #
358
+ # Initializes dialog to a default font
359
+ #
360
+ # Arguments:
361
+ # defaultFont font to use as the default
362
+ #
363
+ proc ::tk::fontchooser::Init {{defaultFont ""}} {
364
+ variable S
365
+
366
+ if {$S(first) || $defaultFont ne ""} {
367
+ Canonical
368
+ if {$defaultFont eq ""} {
369
+ set defaultFont [[entry .___e] cget -font]
370
+ destroy .___e
371
+ }
372
+ array set F [font actual $defaultFont]
373
+ set S(font) $F(-family)
374
+ set S(style) [::msgcat::mc "Regular"]
375
+ set S(size) $F(-size)
376
+ set S(strike) $F(-overstrike)
377
+ set S(under) $F(-underline)
378
+ if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} {
379
+ set S(style) [::msgcat::mc "Bold Italic"]
380
+ } elseif {$F(-weight) eq "bold"} {
381
+ set S(style) [::msgcat::mc "Bold"]
382
+ } elseif {$F(-slant) eq "italic"} {
383
+ set S(style) [::msgcat::mc "Italic"]
384
+ }
385
+ set S(first) 0
386
+ }
387
+ }
388
+
389
+ # ::tk::fontchooser::Click --
390
+ #
391
+ # Handles all button clicks, updating the appropriate widgets
392
+ #
393
+ # Arguments:
394
+ # who which widget got pressed
395
+ #
396
+ proc ::tk::fontchooser::Click {who} {
397
+ variable S
398
+ if {$who eq "font"} {
399
+ set S(font) [$S(W).lfonts get [$S(W).lfonts curselection]]
400
+ } elseif {$who eq "style"} {
401
+ set S(style) [$S(W).lstyles get [$S(W).lstyles curselection]]
402
+ } elseif {$who eq "size"} {
403
+ set S(size) [$S(W).lsizes get [$S(W).lsizes curselection]]
404
+ }
405
+ }
406
+
407
+ # ::tk::fontchooser::Tracer --
408
+ #
409
+ # Handles traces on key variables, updating the appropriate widgets
410
+ #
411
+ # Arguments:
412
+ # standard trace arguments (not used)
413
+ #
414
+ proc ::tk::fontchooser::Tracer {var1 var2 op} {
415
+ variable S
416
+ # We don't need to process strike and under
417
+ if {$var2 ni [list strike under]} {
418
+ # Make selection in listbox
419
+ set value [string tolower $S($var2)]
420
+ $S(W).l${var2}s selection clear 0 end
421
+ set n [lsearch -exact $S(${var2}s,lcase) $value]
422
+ $S(W).l${var2}s selection set $n
423
+ if {$n >= 0} {
424
+ set S($var2) [lindex $S(${var2}s) $n]
425
+ $S(W).e$var2 icursor end
426
+ $S(W).e$var2 selection clear
427
+ if {[set i [lsearch $S(bad) $var2]] >= 0} {
428
+ set S(bad) [lreplace $S(bad) $i $i]
429
+ }
430
+ } else {
431
+ # No match, try prefix
432
+ set n [lsearch -glob $S(${var2}s,lcase) "$value*"]
433
+ if {$var2 ne "size" || !([regexp -- {^(-[0-9]+|[0-9]+)$} $value] && $value >= -4096 && $value <= 4096)} {
434
+ if {[lsearch $S(bad) $var2] < 0} {
435
+ lappend S(bad) $var2
436
+ }
437
+ } else {
438
+ if {[set i [lsearch $S(bad) $var2]] >= 0} {
439
+ set S(bad) [lreplace $S(bad) $i $i]
440
+ }
441
+ }
442
+ }
443
+ $S(W).l${var2}s see $n
444
+ }
445
+ if {[llength $S(bad)] == 0} {
446
+ set S(nstate) normal
447
+ Update
448
+ } else {
449
+ set S(nstate) disabled
450
+ }
451
+ $S(W).ok configure -state $S(nstate)
452
+ $S(W).apply configure -state $S(nstate)
453
+ }
454
+
455
+ # ::tk::fontchooser::Update --
456
+ #
457
+ # Shows a sample of the currently selected font
458
+ #
459
+ proc ::tk::fontchooser::Update {} {
460
+ variable S
461
+
462
+ set S(result) [list $S(font) $S(size)]
463
+ if {$S(style) eq [::msgcat::mc "Bold"]} {
464
+ lappend S(result) bold
465
+ }
466
+ if {$S(style) eq [::msgcat::mc "Italic"]} {
467
+ lappend S(result) italic
468
+ }
469
+ if {$S(style) eq [::msgcat::mc "Bold Italic"]} {
470
+ lappend S(result) bold italic
471
+ }
472
+ if {$S(strike)} {
473
+ lappend S(result) overstrike
474
+ }
475
+ if {$S(under)} {
476
+ lappend S(result) underline
477
+ }
478
+
479
+ $S(sample) configure -font $S(result)
480
+ set S(-font) $S(result)
481
+ }
482
+
483
+ # ::tk::fontchooser::Visibility --
484
+ #
485
+ # Notify the parent when the dialog visibility changes
486
+ #
487
+ proc ::tk::fontchooser::Visibility {w visible} {
488
+ variable S
489
+ if {$w eq $S(W)} {
490
+ event generate $S(-parent) <<TkFontchooserVisibility>>
491
+ }
492
+ }
493
+
494
+ # ::tk::fontchooser::ttk_slistbox --
495
+ #
496
+ # Create a properly themed scrolled listbox.
497
+ # This is exactly right on XP but may need adjusting on other platforms.
498
+ #
499
+ proc ::tk::fontchooser::ttk_slistbox {w args} {
500
+ set f [ttk::frame $w -style FontchooserFrame -padding 2]
501
+ if {[catch {
502
+ listbox $f.list -relief flat -highlightthickness 0 -borderwidth 0 {*}$args
503
+ ttk::scrollbar $f.vs -command [list $f.list yview]
504
+ $f.list configure -yscrollcommand [list $f.vs set]
505
+ grid $f.list $f.vs -sticky news
506
+ grid rowconfigure $f 0 -weight 1
507
+ grid columnconfigure $f 0 -weight 1
508
+ interp hide {} $w
509
+ interp alias {} $w {} $f.list
510
+ } err opt]} {
511
+ destroy $f
512
+ return -options $opt $err
513
+ }
514
+ return $w
515
+ }
janus/lib/tk8.6/listbox.tcl ADDED
@@ -0,0 +1,560 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # listbox.tcl --
2
+ #
3
+ # This file defines the default bindings for Tk listbox widgets
4
+ # and provides procedures that help in implementing those bindings.
5
+ #
6
+ # Copyright (c) 1994 The Regents of the University of California.
7
+ # Copyright (c) 1994-1995 Sun Microsystems, Inc.
8
+ # Copyright (c) 1998 by Scriptics Corporation.
9
+ #
10
+ # See the file "license.terms" for information on usage and redistribution
11
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
+
13
+ #--------------------------------------------------------------------------
14
+ # tk::Priv elements used in this file:
15
+ #
16
+ # afterId - Token returned by "after" for autoscanning.
17
+ # listboxPrev - The last element to be selected or deselected
18
+ # during a selection operation.
19
+ # listboxSelection - All of the items that were selected before the
20
+ # current selection operation (such as a mouse
21
+ # drag) started; used to cancel an operation.
22
+ #--------------------------------------------------------------------------
23
+
24
+ #-------------------------------------------------------------------------
25
+ # The code below creates the default class bindings for listboxes.
26
+ #-------------------------------------------------------------------------
27
+
28
+ # Note: the check for existence of %W below is because this binding
29
+ # is sometimes invoked after a window has been deleted (e.g. because
30
+ # there is a double-click binding on the widget that deletes it). Users
31
+ # can put "break"s in their bindings to avoid the error, but this check
32
+ # makes that unnecessary.
33
+
34
+ bind Listbox <1> {
35
+ if {[winfo exists %W]} {
36
+ tk::ListboxBeginSelect %W [%W index @%x,%y] 1
37
+ }
38
+ }
39
+
40
+ # Ignore double clicks so that users can define their own behaviors.
41
+ # Among other things, this prevents errors if the user deletes the
42
+ # listbox on a double click.
43
+
44
+ bind Listbox <Double-1> {
45
+ # Empty script
46
+ }
47
+
48
+ bind Listbox <B1-Motion> {
49
+ set tk::Priv(x) %x
50
+ set tk::Priv(y) %y
51
+ tk::ListboxMotion %W [%W index @%x,%y]
52
+ }
53
+ bind Listbox <ButtonRelease-1> {
54
+ tk::CancelRepeat
55
+ %W activate @%x,%y
56
+ }
57
+ bind Listbox <Shift-1> {
58
+ tk::ListboxBeginExtend %W [%W index @%x,%y]
59
+ }
60
+ bind Listbox <Control-1> {
61
+ tk::ListboxBeginToggle %W [%W index @%x,%y]
62
+ }
63
+ bind Listbox <B1-Leave> {
64
+ set tk::Priv(x) %x
65
+ set tk::Priv(y) %y
66
+ tk::ListboxAutoScan %W
67
+ }
68
+ bind Listbox <B1-Enter> {
69
+ tk::CancelRepeat
70
+ }
71
+
72
+ bind Listbox <<PrevLine>> {
73
+ tk::ListboxUpDown %W -1
74
+ }
75
+ bind Listbox <<SelectPrevLine>> {
76
+ tk::ListboxExtendUpDown %W -1
77
+ }
78
+ bind Listbox <<NextLine>> {
79
+ tk::ListboxUpDown %W 1
80
+ }
81
+ bind Listbox <<SelectNextLine>> {
82
+ tk::ListboxExtendUpDown %W 1
83
+ }
84
+ bind Listbox <<PrevChar>> {
85
+ %W xview scroll -1 units
86
+ }
87
+ bind Listbox <<PrevWord>> {
88
+ %W xview scroll -1 pages
89
+ }
90
+ bind Listbox <<NextChar>> {
91
+ %W xview scroll 1 units
92
+ }
93
+ bind Listbox <<NextWord>> {
94
+ %W xview scroll 1 pages
95
+ }
96
+ bind Listbox <Prior> {
97
+ %W yview scroll -1 pages
98
+ %W activate @0,0
99
+ }
100
+ bind Listbox <Next> {
101
+ %W yview scroll 1 pages
102
+ %W activate @0,0
103
+ }
104
+ bind Listbox <Control-Prior> {
105
+ %W xview scroll -1 pages
106
+ }
107
+ bind Listbox <Control-Next> {
108
+ %W xview scroll 1 pages
109
+ }
110
+ bind Listbox <<LineStart>> {
111
+ %W xview moveto 0
112
+ }
113
+ bind Listbox <<LineEnd>> {
114
+ %W xview moveto 1
115
+ }
116
+ bind Listbox <Control-Home> {
117
+ %W activate 0
118
+ %W see 0
119
+ %W selection clear 0 end
120
+ %W selection set 0
121
+ tk::FireListboxSelectEvent %W
122
+ }
123
+ bind Listbox <Control-Shift-Home> {
124
+ tk::ListboxDataExtend %W 0
125
+ }
126
+ bind Listbox <Control-End> {
127
+ %W activate end
128
+ %W see end
129
+ %W selection clear 0 end
130
+ %W selection set end
131
+ tk::FireListboxSelectEvent %W
132
+ }
133
+ bind Listbox <Control-Shift-End> {
134
+ tk::ListboxDataExtend %W [%W index end]
135
+ }
136
+ bind Listbox <<Copy>> {
137
+ if {[selection own -displayof %W] eq "%W"} {
138
+ clipboard clear -displayof %W
139
+ clipboard append -displayof %W [selection get -displayof %W]
140
+ }
141
+ }
142
+ bind Listbox <space> {
143
+ tk::ListboxBeginSelect %W [%W index active]
144
+ }
145
+ bind Listbox <<Invoke>> {
146
+ tk::ListboxBeginSelect %W [%W index active]
147
+ }
148
+ bind Listbox <Select> {
149
+ tk::ListboxBeginSelect %W [%W index active]
150
+ }
151
+ bind Listbox <Control-Shift-space> {
152
+ tk::ListboxBeginExtend %W [%W index active]
153
+ }
154
+ bind Listbox <Shift-Select> {
155
+ tk::ListboxBeginExtend %W [%W index active]
156
+ }
157
+ bind Listbox <Escape> {
158
+ tk::ListboxCancel %W
159
+ }
160
+ bind Listbox <<SelectAll>> {
161
+ tk::ListboxSelectAll %W
162
+ }
163
+ bind Listbox <<SelectNone>> {
164
+ if {[%W cget -selectmode] ne "browse"} {
165
+ %W selection clear 0 end
166
+ tk::FireListboxSelectEvent %W
167
+ }
168
+ }
169
+
170
+ # Additional Tk bindings that aren't part of the Motif look and feel:
171
+
172
+ bind Listbox <2> {
173
+ %W scan mark %x %y
174
+ }
175
+ bind Listbox <B2-Motion> {
176
+ %W scan dragto %x %y
177
+ }
178
+
179
+ # The MouseWheel will typically only fire on Windows and Mac OS X.
180
+ # However, someone could use the "event generate" command to produce
181
+ # one on other platforms.
182
+
183
+ if {[tk windowingsystem] eq "aqua"} {
184
+ bind Listbox <MouseWheel> {
185
+ %W yview scroll [expr {-(%D)}] units
186
+ }
187
+ bind Listbox <Option-MouseWheel> {
188
+ %W yview scroll [expr {-10 * (%D)}] units
189
+ }
190
+ bind Listbox <Shift-MouseWheel> {
191
+ %W xview scroll [expr {-(%D)}] units
192
+ }
193
+ bind Listbox <Shift-Option-MouseWheel> {
194
+ %W xview scroll [expr {-10 * (%D)}] units
195
+ }
196
+ } else {
197
+ bind Listbox <MouseWheel> {
198
+ if {%D >= 0} {
199
+ %W yview scroll [expr {-%D/30}] units
200
+ } else {
201
+ %W yview scroll [expr {(29-%D)/30}] units
202
+ }
203
+ }
204
+ bind Listbox <Shift-MouseWheel> {
205
+ if {%D >= 0} {
206
+ %W xview scroll [expr {-%D/30}] units
207
+ } else {
208
+ %W xview scroll [expr {(29-%D)/30}] units
209
+ }
210
+ }
211
+ }
212
+
213
+ if {[tk windowingsystem] eq "x11"} {
214
+ # Support for mousewheels on Linux/Unix commonly comes through mapping
215
+ # the wheel to the extended buttons. If you have a mousewheel, find
216
+ # Linux configuration info at:
217
+ # https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X
218
+ bind Listbox <4> {
219
+ if {!$tk_strictMotif} {
220
+ %W yview scroll -5 units
221
+ }
222
+ }
223
+ bind Listbox <Shift-4> {
224
+ if {!$tk_strictMotif} {
225
+ %W xview scroll -5 units
226
+ }
227
+ }
228
+ bind Listbox <5> {
229
+ if {!$tk_strictMotif} {
230
+ %W yview scroll 5 units
231
+ }
232
+ }
233
+ bind Listbox <Shift-5> {
234
+ if {!$tk_strictMotif} {
235
+ %W xview scroll 5 units
236
+ }
237
+ }
238
+ }
239
+
240
+ # ::tk::ListboxBeginSelect --
241
+ #
242
+ # This procedure is typically invoked on button-1 presses. It begins
243
+ # the process of making a selection in the listbox. Its exact behavior
244
+ # depends on the selection mode currently in effect for the listbox;
245
+ # see the Motif documentation for details.
246
+ #
247
+ # Arguments:
248
+ # w - The listbox widget.
249
+ # el - The element for the selection operation (typically the
250
+ # one under the pointer). Must be in numerical form.
251
+
252
+ proc ::tk::ListboxBeginSelect {w el {focus 1}} {
253
+ variable ::tk::Priv
254
+ if {[$w cget -selectmode] eq "multiple"} {
255
+ if {[$w selection includes $el]} {
256
+ $w selection clear $el
257
+ } else {
258
+ $w selection set $el
259
+ }
260
+ } else {
261
+ $w selection clear 0 end
262
+ $w selection set $el
263
+ $w selection anchor $el
264
+ set Priv(listboxSelection) {}
265
+ set Priv(listboxPrev) $el
266
+ }
267
+ tk::FireListboxSelectEvent $w
268
+ # check existence as ListboxSelect may destroy us
269
+ if {$focus && [winfo exists $w] && [$w cget -state] eq "normal"} {
270
+ focus $w
271
+ }
272
+ }
273
+
274
+ # ::tk::ListboxMotion --
275
+ #
276
+ # This procedure is called to process mouse motion events while
277
+ # button 1 is down. It may move or extend the selection, depending
278
+ # on the listbox's selection mode.
279
+ #
280
+ # Arguments:
281
+ # w - The listbox widget.
282
+ # el - The element under the pointer (must be a number).
283
+
284
+ proc ::tk::ListboxMotion {w el} {
285
+ variable ::tk::Priv
286
+ if {$el == $Priv(listboxPrev)} {
287
+ return
288
+ }
289
+ set anchor [$w index anchor]
290
+ switch [$w cget -selectmode] {
291
+ browse {
292
+ $w selection clear 0 end
293
+ $w selection set $el
294
+ set Priv(listboxPrev) $el
295
+ tk::FireListboxSelectEvent $w
296
+ }
297
+ extended {
298
+ set i $Priv(listboxPrev)
299
+ if {$i < 0} {
300
+ set i $el
301
+ $w selection set $el
302
+ }
303
+ if {[$w selection includes anchor]} {
304
+ $w selection clear $i $el
305
+ $w selection set anchor $el
306
+ } else {
307
+ $w selection clear $i $el
308
+ $w selection clear anchor $el
309
+ }
310
+ if {![info exists Priv(listboxSelection)]} {
311
+ set Priv(listboxSelection) [$w curselection]
312
+ }
313
+ while {($i < $el) && ($i < $anchor)} {
314
+ if {$i in $Priv(listboxSelection)} {
315
+ $w selection set $i
316
+ }
317
+ incr i
318
+ }
319
+ while {($i > $el) && ($i > $anchor)} {
320
+ if {$i in $Priv(listboxSelection)} {
321
+ $w selection set $i
322
+ }
323
+ incr i -1
324
+ }
325
+ set Priv(listboxPrev) $el
326
+ tk::FireListboxSelectEvent $w
327
+ }
328
+ }
329
+ }
330
+
331
+ # ::tk::ListboxBeginExtend --
332
+ #
333
+ # This procedure is typically invoked on shift-button-1 presses. It
334
+ # begins the process of extending a selection in the listbox. Its
335
+ # exact behavior depends on the selection mode currently in effect
336
+ # for the listbox; see the Motif documentation for details.
337
+ #
338
+ # Arguments:
339
+ # w - The listbox widget.
340
+ # el - The element for the selection operation (typically the
341
+ # one under the pointer). Must be in numerical form.
342
+
343
+ proc ::tk::ListboxBeginExtend {w el} {
344
+ if {[$w cget -selectmode] eq "extended"} {
345
+ if {[$w selection includes anchor]} {
346
+ ListboxMotion $w $el
347
+ } else {
348
+ # No selection yet; simulate the begin-select operation.
349
+ ListboxBeginSelect $w $el
350
+ }
351
+ }
352
+ }
353
+
354
+ # ::tk::ListboxBeginToggle --
355
+ #
356
+ # This procedure is typically invoked on control-button-1 presses. It
357
+ # begins the process of toggling a selection in the listbox. Its
358
+ # exact behavior depends on the selection mode currently in effect
359
+ # for the listbox; see the Motif documentation for details.
360
+ #
361
+ # Arguments:
362
+ # w - The listbox widget.
363
+ # el - The element for the selection operation (typically the
364
+ # one under the pointer). Must be in numerical form.
365
+
366
+ proc ::tk::ListboxBeginToggle {w el} {
367
+ variable ::tk::Priv
368
+ if {[$w cget -selectmode] eq "extended"} {
369
+ set Priv(listboxSelection) [$w curselection]
370
+ set Priv(listboxPrev) $el
371
+ $w selection anchor $el
372
+ if {[$w selection includes $el]} {
373
+ $w selection clear $el
374
+ } else {
375
+ $w selection set $el
376
+ }
377
+ tk::FireListboxSelectEvent $w
378
+ }
379
+ }
380
+
381
+ # ::tk::ListboxAutoScan --
382
+ # This procedure is invoked when the mouse leaves an entry window
383
+ # with button 1 down. It scrolls the window up, down, left, or
384
+ # right, depending on where the mouse left the window, and reschedules
385
+ # itself as an "after" command so that the window continues to scroll until
386
+ # the mouse moves back into the window or the mouse button is released.
387
+ #
388
+ # Arguments:
389
+ # w - The entry window.
390
+
391
+ proc ::tk::ListboxAutoScan {w} {
392
+ variable ::tk::Priv
393
+ if {![winfo exists $w]} return
394
+ set x $Priv(x)
395
+ set y $Priv(y)
396
+ if {$y >= [winfo height $w]} {
397
+ $w yview scroll 1 units
398
+ } elseif {$y < 0} {
399
+ $w yview scroll -1 units
400
+ } elseif {$x >= [winfo width $w]} {
401
+ $w xview scroll 2 units
402
+ } elseif {$x < 0} {
403
+ $w xview scroll -2 units
404
+ } else {
405
+ return
406
+ }
407
+ ListboxMotion $w [$w index @$x,$y]
408
+ set Priv(afterId) [after 50 [list tk::ListboxAutoScan $w]]
409
+ }
410
+
411
+ # ::tk::ListboxUpDown --
412
+ #
413
+ # Moves the location cursor (active element) up or down by one element,
414
+ # and changes the selection if we're in browse or extended selection
415
+ # mode.
416
+ #
417
+ # Arguments:
418
+ # w - The listbox widget.
419
+ # amount - +1 to move down one item, -1 to move back one item.
420
+
421
+ proc ::tk::ListboxUpDown {w amount} {
422
+ variable ::tk::Priv
423
+ $w activate [expr {[$w index active] + $amount}]
424
+ $w see active
425
+ switch [$w cget -selectmode] {
426
+ browse {
427
+ $w selection clear 0 end
428
+ $w selection set active
429
+ tk::FireListboxSelectEvent $w
430
+ }
431
+ extended {
432
+ $w selection clear 0 end
433
+ $w selection set active
434
+ $w selection anchor active
435
+ set Priv(listboxPrev) [$w index active]
436
+ set Priv(listboxSelection) {}
437
+ tk::FireListboxSelectEvent $w
438
+ }
439
+ }
440
+ }
441
+
442
+ # ::tk::ListboxExtendUpDown --
443
+ #
444
+ # Does nothing unless we're in extended selection mode; in this
445
+ # case it moves the location cursor (active element) up or down by
446
+ # one element, and extends the selection to that point.
447
+ #
448
+ # Arguments:
449
+ # w - The listbox widget.
450
+ # amount - +1 to move down one item, -1 to move back one item.
451
+
452
+ proc ::tk::ListboxExtendUpDown {w amount} {
453
+ variable ::tk::Priv
454
+ if {[$w cget -selectmode] ne "extended"} {
455
+ return
456
+ }
457
+ set active [$w index active]
458
+ if {![info exists Priv(listboxSelection)]} {
459
+ $w selection set $active
460
+ set Priv(listboxSelection) [$w curselection]
461
+ }
462
+ $w activate [expr {$active + $amount}]
463
+ $w see active
464
+ ListboxMotion $w [$w index active]
465
+ }
466
+
467
+ # ::tk::ListboxDataExtend
468
+ #
469
+ # This procedure is called for key-presses such as Shift-KEndData.
470
+ # If the selection mode isn't multiple or extend then it does nothing.
471
+ # Otherwise it moves the active element to el and, if we're in
472
+ # extended mode, extends the selection to that point.
473
+ #
474
+ # Arguments:
475
+ # w - The listbox widget.
476
+ # el - An integer element number.
477
+
478
+ proc ::tk::ListboxDataExtend {w el} {
479
+ set mode [$w cget -selectmode]
480
+ if {$mode eq "extended"} {
481
+ $w activate $el
482
+ $w see $el
483
+ if {[$w selection includes anchor]} {
484
+ ListboxMotion $w $el
485
+ }
486
+ } elseif {$mode eq "multiple"} {
487
+ $w activate $el
488
+ $w see $el
489
+ }
490
+ }
491
+
492
+ # ::tk::ListboxCancel
493
+ #
494
+ # This procedure is invoked to cancel an extended selection in
495
+ # progress. If there is an extended selection in progress, it
496
+ # restores all of the items between the active one and the anchor
497
+ # to their previous selection state.
498
+ #
499
+ # Arguments:
500
+ # w - The listbox widget.
501
+
502
+ proc ::tk::ListboxCancel w {
503
+ variable ::tk::Priv
504
+ if {[$w cget -selectmode] ne "extended"} {
505
+ return
506
+ }
507
+ set first [$w index anchor]
508
+ set last $Priv(listboxPrev)
509
+ if {$last eq ""} {
510
+ # Not actually doing any selection right now
511
+ return
512
+ }
513
+ if {$first > $last} {
514
+ set tmp $first
515
+ set first $last
516
+ set last $tmp
517
+ }
518
+ $w selection clear $first $last
519
+ while {$first <= $last} {
520
+ if {$first in $Priv(listboxSelection)} {
521
+ $w selection set $first
522
+ }
523
+ incr first
524
+ }
525
+ tk::FireListboxSelectEvent $w
526
+ }
527
+
528
+ # ::tk::ListboxSelectAll
529
+ #
530
+ # This procedure is invoked to handle the "select all" operation.
531
+ # For single and browse mode, it just selects the active element.
532
+ # Otherwise it selects everything in the widget.
533
+ #
534
+ # Arguments:
535
+ # w - The listbox widget.
536
+
537
+ proc ::tk::ListboxSelectAll w {
538
+ set mode [$w cget -selectmode]
539
+ if {$mode eq "single" || $mode eq "browse"} {
540
+ $w selection clear 0 end
541
+ $w selection set active
542
+ } else {
543
+ $w selection set 0 end
544
+ }
545
+ tk::FireListboxSelectEvent $w
546
+ }
547
+
548
+ # ::tk::FireListboxSelectEvent
549
+ #
550
+ # Fire the <<ListboxSelect>> event if the listbox is not in disabled
551
+ # state.
552
+ #
553
+ # Arguments:
554
+ # w - The listbox widget.
555
+
556
+ proc ::tk::FireListboxSelectEvent w {
557
+ if {[$w cget -state] eq "normal"} {
558
+ event generate $w <<ListboxSelect>>
559
+ }
560
+ }
janus/lib/tk8.6/mkpsenc.tcl ADDED
@@ -0,0 +1,1488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mkpsenc.tcl --
2
+ #
3
+ # This file generates the postscript prolog used by Tk.
4
+
5
+ namespace eval ::tk {
6
+ # Creates Postscript encoding vector for ISO-8859-1 (could theoretically
7
+ # handle any 8-bit encoding, but Tk never generates characters outside
8
+ # ASCII).
9
+ #
10
+ proc CreatePostscriptEncoding {} {
11
+ variable psglyphs
12
+ # Now check for known. Even if it is known, it can be other than we
13
+ # need. GhostScript seems to be happy with such approach
14
+ set result "\[\n"
15
+ for {set i 0} {$i<256} {incr i 8} {
16
+ for {set j 0} {$j<8} {incr j} {
17
+ set enc [encoding convertfrom "iso8859-1" \
18
+ [format %c [expr {$i+$j}]]]
19
+ catch {
20
+ set hexcode {}
21
+ set hexcode [format %04X [scan $enc %c]]
22
+ }
23
+ if {[info exists psglyphs($hexcode)]} {
24
+ append result "/$psglyphs($hexcode)"
25
+ } else {
26
+ append result "/space"
27
+ }
28
+ }
29
+ append result "\n"
30
+ }
31
+ append result "\]"
32
+ return $result
33
+ }
34
+
35
+ # List of adobe glyph names. Converted from glyphlist.txt, downloaded from
36
+ # Adobe.
37
+
38
+ variable psglyphs
39
+ array set psglyphs {
40
+ 0020 space
41
+ 0021 exclam
42
+ 0022 quotedbl
43
+ 0023 numbersign
44
+ 0024 dollar
45
+ 0025 percent
46
+ 0026 ampersand
47
+ 0027 quotesingle
48
+ 0028 parenleft
49
+ 0029 parenright
50
+ 002A asterisk
51
+ 002B plus
52
+ 002C comma
53
+ 002D hyphen
54
+ 002E period
55
+ 002F slash
56
+ 0030 zero
57
+ 0031 one
58
+ 0032 two
59
+ 0033 three
60
+ 0034 four
61
+ 0035 five
62
+ 0036 six
63
+ 0037 seven
64
+ 0038 eight
65
+ 0039 nine
66
+ 003A colon
67
+ 003B semicolon
68
+ 003C less
69
+ 003D equal
70
+ 003E greater
71
+ 003F question
72
+ 0040 at
73
+ 0041 A
74
+ 0042 B
75
+ 0043 C
76
+ 0044 D
77
+ 0045 E
78
+ 0046 F
79
+ 0047 G
80
+ 0048 H
81
+ 0049 I
82
+ 004A J
83
+ 004B K
84
+ 004C L
85
+ 004D M
86
+ 004E N
87
+ 004F O
88
+ 0050 P
89
+ 0051 Q
90
+ 0052 R
91
+ 0053 S
92
+ 0054 T
93
+ 0055 U
94
+ 0056 V
95
+ 0057 W
96
+ 0058 X
97
+ 0059 Y
98
+ 005A Z
99
+ 005B bracketleft
100
+ 005C backslash
101
+ 005D bracketright
102
+ 005E asciicircum
103
+ 005F underscore
104
+ 0060 grave
105
+ 0061 a
106
+ 0062 b
107
+ 0063 c
108
+ 0064 d
109
+ 0065 e
110
+ 0066 f
111
+ 0067 g
112
+ 0068 h
113
+ 0069 i
114
+ 006A j
115
+ 006B k
116
+ 006C l
117
+ 006D m
118
+ 006E n
119
+ 006F o
120
+ 0070 p
121
+ 0071 q
122
+ 0072 r
123
+ 0073 s
124
+ 0074 t
125
+ 0075 u
126
+ 0076 v
127
+ 0077 w
128
+ 0078 x
129
+ 0079 y
130
+ 007A z
131
+ 007B braceleft
132
+ 007C bar
133
+ 007D braceright
134
+ 007E asciitilde
135
+ 00A0 space
136
+ 00A1 exclamdown
137
+ 00A2 cent
138
+ 00A3 sterling
139
+ 00A4 currency
140
+ 00A5 yen
141
+ 00A6 brokenbar
142
+ 00A7 section
143
+ 00A8 dieresis
144
+ 00A9 copyright
145
+ 00AA ordfeminine
146
+ 00AB guillemotleft
147
+ 00AC logicalnot
148
+ 00AD hyphen
149
+ 00AE registered
150
+ 00AF macron
151
+ 00B0 degree
152
+ 00B1 plusminus
153
+ 00B2 twosuperior
154
+ 00B3 threesuperior
155
+ 00B4 acute
156
+ 00B5 mu
157
+ 00B6 paragraph
158
+ 00B7 periodcentered
159
+ 00B8 cedilla
160
+ 00B9 onesuperior
161
+ 00BA ordmasculine
162
+ 00BB guillemotright
163
+ 00BC onequarter
164
+ 00BD onehalf
165
+ 00BE threequarters
166
+ 00BF questiondown
167
+ 00C0 Agrave
168
+ 00C1 Aacute
169
+ 00C2 Acircumflex
170
+ 00C3 Atilde
171
+ 00C4 Adieresis
172
+ 00C5 Aring
173
+ 00C6 AE
174
+ 00C7 Ccedilla
175
+ 00C8 Egrave
176
+ 00C9 Eacute
177
+ 00CA Ecircumflex
178
+ 00CB Edieresis
179
+ 00CC Igrave
180
+ 00CD Iacute
181
+ 00CE Icircumflex
182
+ 00CF Idieresis
183
+ 00D0 Eth
184
+ 00D1 Ntilde
185
+ 00D2 Ograve
186
+ 00D3 Oacute
187
+ 00D4 Ocircumflex
188
+ 00D5 Otilde
189
+ 00D6 Odieresis
190
+ 00D7 multiply
191
+ 00D8 Oslash
192
+ 00D9 Ugrave
193
+ 00DA Uacute
194
+ 00DB Ucircumflex
195
+ 00DC Udieresis
196
+ 00DD Yacute
197
+ 00DE Thorn
198
+ 00DF germandbls
199
+ 00E0 agrave
200
+ 00E1 aacute
201
+ 00E2 acircumflex
202
+ 00E3 atilde
203
+ 00E4 adieresis
204
+ 00E5 aring
205
+ 00E6 ae
206
+ 00E7 ccedilla
207
+ 00E8 egrave
208
+ 00E9 eacute
209
+ 00EA ecircumflex
210
+ 00EB edieresis
211
+ 00EC igrave
212
+ 00ED iacute
213
+ 00EE icircumflex
214
+ 00EF idieresis
215
+ 00F0 eth
216
+ 00F1 ntilde
217
+ 00F2 ograve
218
+ 00F3 oacute
219
+ 00F4 ocircumflex
220
+ 00F5 otilde
221
+ 00F6 odieresis
222
+ 00F7 divide
223
+ 00F8 oslash
224
+ 00F9 ugrave
225
+ 00FA uacute
226
+ 00FB ucircumflex
227
+ 00FC udieresis
228
+ 00FD yacute
229
+ 00FE thorn
230
+ 00FF ydieresis
231
+ 0100 Amacron
232
+ 0101 amacron
233
+ 0102 Abreve
234
+ 0103 abreve
235
+ 0104 Aogonek
236
+ 0105 aogonek
237
+ 0106 Cacute
238
+ 0107 cacute
239
+ 0108 Ccircumflex
240
+ 0109 ccircumflex
241
+ 010A Cdotaccent
242
+ 010B cdotaccent
243
+ 010C Ccaron
244
+ 010D ccaron
245
+ 010E Dcaron
246
+ 010F dcaron
247
+ 0110 Dcroat
248
+ 0111 dcroat
249
+ 0112 Emacron
250
+ 0113 emacron
251
+ 0114 Ebreve
252
+ 0115 ebreve
253
+ 0116 Edotaccent
254
+ 0117 edotaccent
255
+ 0118 Eogonek
256
+ 0119 eogonek
257
+ 011A Ecaron
258
+ 011B ecaron
259
+ 011C Gcircumflex
260
+ 011D gcircumflex
261
+ 011E Gbreve
262
+ 011F gbreve
263
+ 0120 Gdotaccent
264
+ 0121 gdotaccent
265
+ 0122 Gcommaaccent
266
+ 0123 gcommaaccent
267
+ 0124 Hcircumflex
268
+ 0125 hcircumflex
269
+ 0126 Hbar
270
+ 0127 hbar
271
+ 0128 Itilde
272
+ 0129 itilde
273
+ 012A Imacron
274
+ 012B imacron
275
+ 012C Ibreve
276
+ 012D ibreve
277
+ 012E Iogonek
278
+ 012F iogonek
279
+ 0130 Idotaccent
280
+ 0131 dotlessi
281
+ 0132 IJ
282
+ 0133 ij
283
+ 0134 Jcircumflex
284
+ 0135 jcircumflex
285
+ 0136 Kcommaaccent
286
+ 0137 kcommaaccent
287
+ 0138 kgreenlandic
288
+ 0139 Lacute
289
+ 013A lacute
290
+ 013B Lcommaaccent
291
+ 013C lcommaaccent
292
+ 013D Lcaron
293
+ 013E lcaron
294
+ 013F Ldot
295
+ 0140 ldot
296
+ 0141 Lslash
297
+ 0142 lslash
298
+ 0143 Nacute
299
+ 0144 nacute
300
+ 0145 Ncommaaccent
301
+ 0146 ncommaaccent
302
+ 0147 Ncaron
303
+ 0148 ncaron
304
+ 0149 napostrophe
305
+ 014A Eng
306
+ 014B eng
307
+ 014C Omacron
308
+ 014D omacron
309
+ 014E Obreve
310
+ 014F obreve
311
+ 0150 Ohungarumlaut
312
+ 0151 ohungarumlaut
313
+ 0152 OE
314
+ 0153 oe
315
+ 0154 Racute
316
+ 0155 racute
317
+ 0156 Rcommaaccent
318
+ 0157 rcommaaccent
319
+ 0158 Rcaron
320
+ 0159 rcaron
321
+ 015A Sacute
322
+ 015B sacute
323
+ 015C Scircumflex
324
+ 015D scircumflex
325
+ 015E Scedilla
326
+ 015F scedilla
327
+ 0160 Scaron
328
+ 0161 scaron
329
+ 0162 Tcommaaccent
330
+ 0163 tcommaaccent
331
+ 0164 Tcaron
332
+ 0165 tcaron
333
+ 0166 Tbar
334
+ 0167 tbar
335
+ 0168 Utilde
336
+ 0169 utilde
337
+ 016A Umacron
338
+ 016B umacron
339
+ 016C Ubreve
340
+ 016D ubreve
341
+ 016E Uring
342
+ 016F uring
343
+ 0170 Uhungarumlaut
344
+ 0171 uhungarumlaut
345
+ 0172 Uogonek
346
+ 0173 uogonek
347
+ 0174 Wcircumflex
348
+ 0175 wcircumflex
349
+ 0176 Ycircumflex
350
+ 0177 ycircumflex
351
+ 0178 Ydieresis
352
+ 0179 Zacute
353
+ 017A zacute
354
+ 017B Zdotaccent
355
+ 017C zdotaccent
356
+ 017D Zcaron
357
+ 017E zcaron
358
+ 017F longs
359
+ 0192 florin
360
+ 01A0 Ohorn
361
+ 01A1 ohorn
362
+ 01AF Uhorn
363
+ 01B0 uhorn
364
+ 01E6 Gcaron
365
+ 01E7 gcaron
366
+ 01FA Aringacute
367
+ 01FB aringacute
368
+ 01FC AEacute
369
+ 01FD aeacute
370
+ 01FE Oslashacute
371
+ 01FF oslashacute
372
+ 0218 Scommaaccent
373
+ 0219 scommaaccent
374
+ 021A Tcommaaccent
375
+ 021B tcommaaccent
376
+ 02BC afii57929
377
+ 02BD afii64937
378
+ 02C6 circumflex
379
+ 02C7 caron
380
+ 02C9 macron
381
+ 02D8 breve
382
+ 02D9 dotaccent
383
+ 02DA ring
384
+ 02DB ogonek
385
+ 02DC tilde
386
+ 02DD hungarumlaut
387
+ 0300 gravecomb
388
+ 0301 acutecomb
389
+ 0303 tildecomb
390
+ 0309 hookabovecomb
391
+ 0323 dotbelowcomb
392
+ 0384 tonos
393
+ 0385 dieresistonos
394
+ 0386 Alphatonos
395
+ 0387 anoteleia
396
+ 0388 Epsilontonos
397
+ 0389 Etatonos
398
+ 038A Iotatonos
399
+ 038C Omicrontonos
400
+ 038E Upsilontonos
401
+ 038F Omegatonos
402
+ 0390 iotadieresistonos
403
+ 0391 Alpha
404
+ 0392 Beta
405
+ 0393 Gamma
406
+ 0394 Delta
407
+ 0395 Epsilon
408
+ 0396 Zeta
409
+ 0397 Eta
410
+ 0398 Theta
411
+ 0399 Iota
412
+ 039A Kappa
413
+ 039B Lambda
414
+ 039C Mu
415
+ 039D Nu
416
+ 039E Xi
417
+ 039F Omicron
418
+ 03A0 Pi
419
+ 03A1 Rho
420
+ 03A3 Sigma
421
+ 03A4 Tau
422
+ 03A5 Upsilon
423
+ 03A6 Phi
424
+ 03A7 Chi
425
+ 03A8 Psi
426
+ 03A9 Omega
427
+ 03AA Iotadieresis
428
+ 03AB Upsilondieresis
429
+ 03AC alphatonos
430
+ 03AD epsilontonos
431
+ 03AE etatonos
432
+ 03AF iotatonos
433
+ 03B0 upsilondieresistonos
434
+ 03B1 alpha
435
+ 03B2 beta
436
+ 03B3 gamma
437
+ 03B4 delta
438
+ 03B5 epsilon
439
+ 03B6 zeta
440
+ 03B7 eta
441
+ 03B8 theta
442
+ 03B9 iota
443
+ 03BA kappa
444
+ 03BB lambda
445
+ 03BC mu
446
+ 03BD nu
447
+ 03BE xi
448
+ 03BF omicron
449
+ 03C0 pi
450
+ 03C1 rho
451
+ 03C2 sigma1
452
+ 03C3 sigma
453
+ 03C4 tau
454
+ 03C5 upsilon
455
+ 03C6 phi
456
+ 03C7 chi
457
+ 03C8 psi
458
+ 03C9 omega
459
+ 03CA iotadieresis
460
+ 03CB upsilondieresis
461
+ 03CC omicrontonos
462
+ 03CD upsilontonos
463
+ 03CE omegatonos
464
+ 03D1 theta1
465
+ 03D2 Upsilon1
466
+ 03D5 phi1
467
+ 03D6 omega1
468
+ 0401 afii10023
469
+ 0402 afii10051
470
+ 0403 afii10052
471
+ 0404 afii10053
472
+ 0405 afii10054
473
+ 0406 afii10055
474
+ 0407 afii10056
475
+ 0408 afii10057
476
+ 0409 afii10058
477
+ 040A afii10059
478
+ 040B afii10060
479
+ 040C afii10061
480
+ 040E afii10062
481
+ 040F afii10145
482
+ 0410 afii10017
483
+ 0411 afii10018
484
+ 0412 afii10019
485
+ 0413 afii10020
486
+ 0414 afii10021
487
+ 0415 afii10022
488
+ 0416 afii10024
489
+ 0417 afii10025
490
+ 0418 afii10026
491
+ 0419 afii10027
492
+ 041A afii10028
493
+ 041B afii10029
494
+ 041C afii10030
495
+ 041D afii10031
496
+ 041E afii10032
497
+ 041F afii10033
498
+ 0420 afii10034
499
+ 0421 afii10035
500
+ 0422 afii10036
501
+ 0423 afii10037
502
+ 0424 afii10038
503
+ 0425 afii10039
504
+ 0426 afii10040
505
+ 0427 afii10041
506
+ 0428 afii10042
507
+ 0429 afii10043
508
+ 042A afii10044
509
+ 042B afii10045
510
+ 042C afii10046
511
+ 042D afii10047
512
+ 042E afii10048
513
+ 042F afii10049
514
+ 0430 afii10065
515
+ 0431 afii10066
516
+ 0432 afii10067
517
+ 0433 afii10068
518
+ 0434 afii10069
519
+ 0435 afii10070
520
+ 0436 afii10072
521
+ 0437 afii10073
522
+ 0438 afii10074
523
+ 0439 afii10075
524
+ 043A afii10076
525
+ 043B afii10077
526
+ 043C afii10078
527
+ 043D afii10079
528
+ 043E afii10080
529
+ 043F afii10081
530
+ 0440 afii10082
531
+ 0441 afii10083
532
+ 0442 afii10084
533
+ 0443 afii10085
534
+ 0444 afii10086
535
+ 0445 afii10087
536
+ 0446 afii10088
537
+ 0447 afii10089
538
+ 0448 afii10090
539
+ 0449 afii10091
540
+ 044A afii10092
541
+ 044B afii10093
542
+ 044C afii10094
543
+ 044D afii10095
544
+ 044E afii10096
545
+ 044F afii10097
546
+ 0451 afii10071
547
+ 0452 afii10099
548
+ 0453 afii10100
549
+ 0454 afii10101
550
+ 0455 afii10102
551
+ 0456 afii10103
552
+ 0457 afii10104
553
+ 0458 afii10105
554
+ 0459 afii10106
555
+ 045A afii10107
556
+ 045B afii10108
557
+ 045C afii10109
558
+ 045E afii10110
559
+ 045F afii10193
560
+ 0462 afii10146
561
+ 0463 afii10194
562
+ 0472 afii10147
563
+ 0473 afii10195
564
+ 0474 afii10148
565
+ 0475 afii10196
566
+ 0490 afii10050
567
+ 0491 afii10098
568
+ 04D9 afii10846
569
+ 05B0 afii57799
570
+ 05B1 afii57801
571
+ 05B2 afii57800
572
+ 05B3 afii57802
573
+ 05B4 afii57793
574
+ 05B5 afii57794
575
+ 05B6 afii57795
576
+ 05B7 afii57798
577
+ 05B8 afii57797
578
+ 05B9 afii57806
579
+ 05BB afii57796
580
+ 05BC afii57807
581
+ 05BD afii57839
582
+ 05BE afii57645
583
+ 05BF afii57841
584
+ 05C0 afii57842
585
+ 05C1 afii57804
586
+ 05C2 afii57803
587
+ 05C3 afii57658
588
+ 05D0 afii57664
589
+ 05D1 afii57665
590
+ 05D2 afii57666
591
+ 05D3 afii57667
592
+ 05D4 afii57668
593
+ 05D5 afii57669
594
+ 05D6 afii57670
595
+ 05D7 afii57671
596
+ 05D8 afii57672
597
+ 05D9 afii57673
598
+ 05DA afii57674
599
+ 05DB afii57675
600
+ 05DC afii57676
601
+ 05DD afii57677
602
+ 05DE afii57678
603
+ 05DF afii57679
604
+ 05E0 afii57680
605
+ 05E1 afii57681
606
+ 05E2 afii57682
607
+ 05E3 afii57683
608
+ 05E4 afii57684
609
+ 05E5 afii57685
610
+ 05E6 afii57686
611
+ 05E7 afii57687
612
+ 05E8 afii57688
613
+ 05E9 afii57689
614
+ 05EA afii57690
615
+ 05F0 afii57716
616
+ 05F1 afii57717
617
+ 05F2 afii57718
618
+ 060C afii57388
619
+ 061B afii57403
620
+ 061F afii57407
621
+ 0621 afii57409
622
+ 0622 afii57410
623
+ 0623 afii57411
624
+ 0624 afii57412
625
+ 0625 afii57413
626
+ 0626 afii57414
627
+ 0627 afii57415
628
+ 0628 afii57416
629
+ 0629 afii57417
630
+ 062A afii57418
631
+ 062B afii57419
632
+ 062C afii57420
633
+ 062D afii57421
634
+ 062E afii57422
635
+ 062F afii57423
636
+ 0630 afii57424
637
+ 0631 afii57425
638
+ 0632 afii57426
639
+ 0633 afii57427
640
+ 0634 afii57428
641
+ 0635 afii57429
642
+ 0636 afii57430
643
+ 0637 afii57431
644
+ 0638 afii57432
645
+ 0639 afii57433
646
+ 063A afii57434
647
+ 0640 afii57440
648
+ 0641 afii57441
649
+ 0642 afii57442
650
+ 0643 afii57443
651
+ 0644 afii57444
652
+ 0645 afii57445
653
+ 0646 afii57446
654
+ 0647 afii57470
655
+ 0648 afii57448
656
+ 0649 afii57449
657
+ 064A afii57450
658
+ 064B afii57451
659
+ 064C afii57452
660
+ 064D afii57453
661
+ 064E afii57454
662
+ 064F afii57455
663
+ 0650 afii57456
664
+ 0651 afii57457
665
+ 0652 afii57458
666
+ 0660 afii57392
667
+ 0661 afii57393
668
+ 0662 afii57394
669
+ 0663 afii57395
670
+ 0664 afii57396
671
+ 0665 afii57397
672
+ 0666 afii57398
673
+ 0667 afii57399
674
+ 0668 afii57400
675
+ 0669 afii57401
676
+ 066A afii57381
677
+ 066D afii63167
678
+ 0679 afii57511
679
+ 067E afii57506
680
+ 0686 afii57507
681
+ 0688 afii57512
682
+ 0691 afii57513
683
+ 0698 afii57508
684
+ 06A4 afii57505
685
+ 06AF afii57509
686
+ 06BA afii57514
687
+ 06D2 afii57519
688
+ 06D5 afii57534
689
+ 1E80 Wgrave
690
+ 1E81 wgrave
691
+ 1E82 Wacute
692
+ 1E83 wacute
693
+ 1E84 Wdieresis
694
+ 1E85 wdieresis
695
+ 1EF2 Ygrave
696
+ 1EF3 ygrave
697
+ 200C afii61664
698
+ 200D afii301
699
+ 200E afii299
700
+ 200F afii300
701
+ 2012 figuredash
702
+ 2013 endash
703
+ 2014 emdash
704
+ 2015 afii00208
705
+ 2017 underscoredbl
706
+ 2018 quoteleft
707
+ 2019 quoteright
708
+ 201A quotesinglbase
709
+ 201B quotereversed
710
+ 201C quotedblleft
711
+ 201D quotedblright
712
+ 201E quotedblbase
713
+ 2020 dagger
714
+ 2021 daggerdbl
715
+ 2022 bullet
716
+ 2024 onedotenleader
717
+ 2025 twodotenleader
718
+ 2026 ellipsis
719
+ 202C afii61573
720
+ 202D afii61574
721
+ 202E afii61575
722
+ 2030 perthousand
723
+ 2032 minute
724
+ 2033 second
725
+ 2039 guilsinglleft
726
+ 203A guilsinglright
727
+ 203C exclamdbl
728
+ 2044 fraction
729
+ 2070 zerosuperior
730
+ 2074 foursuperior
731
+ 2075 fivesuperior
732
+ 2076 sixsuperior
733
+ 2077 sevensuperior
734
+ 2078 eightsuperior
735
+ 2079 ninesuperior
736
+ 207D parenleftsuperior
737
+ 207E parenrightsuperior
738
+ 207F nsuperior
739
+ 2080 zeroinferior
740
+ 2081 oneinferior
741
+ 2082 twoinferior
742
+ 2083 threeinferior
743
+ 2084 fourinferior
744
+ 2085 fiveinferior
745
+ 2086 sixinferior
746
+ 2087 seveninferior
747
+ 2088 eightinferior
748
+ 2089 nineinferior
749
+ 208D parenleftinferior
750
+ 208E parenrightinferior
751
+ 20A1 colonmonetary
752
+ 20A3 franc
753
+ 20A4 lira
754
+ 20A7 peseta
755
+ 20AA afii57636
756
+ 20AB dong
757
+ 20AC Euro
758
+ 2105 afii61248
759
+ 2111 Ifraktur
760
+ 2113 afii61289
761
+ 2116 afii61352
762
+ 2118 weierstrass
763
+ 211C Rfraktur
764
+ 211E prescription
765
+ 2122 trademark
766
+ 2126 Omega
767
+ 212E estimated
768
+ 2135 aleph
769
+ 2153 onethird
770
+ 2154 twothirds
771
+ 215B oneeighth
772
+ 215C threeeighths
773
+ 215D fiveeighths
774
+ 215E seveneighths
775
+ 2190 arrowleft
776
+ 2191 arrowup
777
+ 2192 arrowright
778
+ 2193 arrowdown
779
+ 2194 arrowboth
780
+ 2195 arrowupdn
781
+ 21A8 arrowupdnbse
782
+ 21B5 carriagereturn
783
+ 21D0 arrowdblleft
784
+ 21D1 arrowdblup
785
+ 21D2 arrowdblright
786
+ 21D3 arrowdbldown
787
+ 21D4 arrowdblboth
788
+ 2200 universal
789
+ 2202 partialdiff
790
+ 2203 existential
791
+ 2205 emptyset
792
+ 2206 Delta
793
+ 2207 gradient
794
+ 2208 element
795
+ 2209 notelement
796
+ 220B suchthat
797
+ 220F product
798
+ 2211 summation
799
+ 2212 minus
800
+ 2215 fraction
801
+ 2217 asteriskmath
802
+ 2219 periodcentered
803
+ 221A radical
804
+ 221D proportional
805
+ 221E infinity
806
+ 221F orthogonal
807
+ 2220 angle
808
+ 2227 logicaland
809
+ 2228 logicalor
810
+ 2229 intersection
811
+ 222A union
812
+ 222B integral
813
+ 2234 therefore
814
+ 223C similar
815
+ 2245 congruent
816
+ 2248 approxequal
817
+ 2260 notequal
818
+ 2261 equivalence
819
+ 2264 lessequal
820
+ 2265 greaterequal
821
+ 2282 propersubset
822
+ 2283 propersuperset
823
+ 2284 notsubset
824
+ 2286 reflexsubset
825
+ 2287 reflexsuperset
826
+ 2295 circleplus
827
+ 2297 circlemultiply
828
+ 22A5 perpendicular
829
+ 22C5 dotmath
830
+ 2302 house
831
+ 2310 revlogicalnot
832
+ 2320 integraltp
833
+ 2321 integralbt
834
+ 2329 angleleft
835
+ 232A angleright
836
+ 2500 SF100000
837
+ 2502 SF110000
838
+ 250C SF010000
839
+ 2510 SF030000
840
+ 2514 SF020000
841
+ 2518 SF040000
842
+ 251C SF080000
843
+ 2524 SF090000
844
+ 252C SF060000
845
+ 2534 SF070000
846
+ 253C SF050000
847
+ 2550 SF430000
848
+ 2551 SF240000
849
+ 2552 SF510000
850
+ 2553 SF520000
851
+ 2554 SF390000
852
+ 2555 SF220000
853
+ 2556 SF210000
854
+ 2557 SF250000
855
+ 2558 SF500000
856
+ 2559 SF490000
857
+ 255A SF380000
858
+ 255B SF280000
859
+ 255C SF270000
860
+ 255D SF260000
861
+ 255E SF360000
862
+ 255F SF370000
863
+ 2560 SF420000
864
+ 2561 SF190000
865
+ 2562 SF200000
866
+ 2563 SF230000
867
+ 2564 SF470000
868
+ 2565 SF480000
869
+ 2566 SF410000
870
+ 2567 SF450000
871
+ 2568 SF460000
872
+ 2569 SF400000
873
+ 256A SF540000
874
+ 256B SF530000
875
+ 256C SF440000
876
+ 2580 upblock
877
+ 2584 dnblock
878
+ 2588 block
879
+ 258C lfblock
880
+ 2590 rtblock
881
+ 2591 ltshade
882
+ 2592 shade
883
+ 2593 dkshade
884
+ 25A0 filledbox
885
+ 25A1 H22073
886
+ 25AA H18543
887
+ 25AB H18551
888
+ 25AC filledrect
889
+ 25B2 triagup
890
+ 25BA triagrt
891
+ 25BC triagdn
892
+ 25C4 triaglf
893
+ 25CA lozenge
894
+ 25CB circle
895
+ 25CF H18533
896
+ 25D8 invbullet
897
+ 25D9 invcircle
898
+ 25E6 openbullet
899
+ 263A smileface
900
+ 263B invsmileface
901
+ 263C sun
902
+ 2640 female
903
+ 2642 male
904
+ 2660 spade
905
+ 2663 club
906
+ 2665 heart
907
+ 2666 diamond
908
+ 266A musicalnote
909
+ 266B musicalnotedbl
910
+ F6BE dotlessj
911
+ F6BF LL
912
+ F6C0 ll
913
+ F6C1 Scedilla
914
+ F6C2 scedilla
915
+ F6C3 commaaccent
916
+ F6C4 afii10063
917
+ F6C5 afii10064
918
+ F6C6 afii10192
919
+ F6C7 afii10831
920
+ F6C8 afii10832
921
+ F6C9 Acute
922
+ F6CA Caron
923
+ F6CB Dieresis
924
+ F6CC DieresisAcute
925
+ F6CD DieresisGrave
926
+ F6CE Grave
927
+ F6CF Hungarumlaut
928
+ F6D0 Macron
929
+ F6D1 cyrBreve
930
+ F6D2 cyrFlex
931
+ F6D3 dblGrave
932
+ F6D4 cyrbreve
933
+ F6D5 cyrflex
934
+ F6D6 dblgrave
935
+ F6D7 dieresisacute
936
+ F6D8 dieresisgrave
937
+ F6D9 copyrightserif
938
+ F6DA registerserif
939
+ F6DB trademarkserif
940
+ F6DC onefitted
941
+ F6DD rupiah
942
+ F6DE threequartersemdash
943
+ F6DF centinferior
944
+ F6E0 centsuperior
945
+ F6E1 commainferior
946
+ F6E2 commasuperior
947
+ F6E3 dollarinferior
948
+ F6E4 dollarsuperior
949
+ F6E5 hypheninferior
950
+ F6E6 hyphensuperior
951
+ F6E7 periodinferior
952
+ F6E8 periodsuperior
953
+ F6E9 asuperior
954
+ F6EA bsuperior
955
+ F6EB dsuperior
956
+ F6EC esuperior
957
+ F6ED isuperior
958
+ F6EE lsuperior
959
+ F6EF msuperior
960
+ F6F0 osuperior
961
+ F6F1 rsuperior
962
+ F6F2 ssuperior
963
+ F6F3 tsuperior
964
+ F6F4 Brevesmall
965
+ F6F5 Caronsmall
966
+ F6F6 Circumflexsmall
967
+ F6F7 Dotaccentsmall
968
+ F6F8 Hungarumlautsmall
969
+ F6F9 Lslashsmall
970
+ F6FA OEsmall
971
+ F6FB Ogoneksmall
972
+ F6FC Ringsmall
973
+ F6FD Scaronsmall
974
+ F6FE Tildesmall
975
+ F6FF Zcaronsmall
976
+ F721 exclamsmall
977
+ F724 dollaroldstyle
978
+ F726 ampersandsmall
979
+ F730 zerooldstyle
980
+ F731 oneoldstyle
981
+ F732 twooldstyle
982
+ F733 threeoldstyle
983
+ F734 fouroldstyle
984
+ F735 fiveoldstyle
985
+ F736 sixoldstyle
986
+ F737 sevenoldstyle
987
+ F738 eightoldstyle
988
+ F739 nineoldstyle
989
+ F73F questionsmall
990
+ F760 Gravesmall
991
+ F761 Asmall
992
+ F762 Bsmall
993
+ F763 Csmall
994
+ F764 Dsmall
995
+ F765 Esmall
996
+ F766 Fsmall
997
+ F767 Gsmall
998
+ F768 Hsmall
999
+ F769 Ismall
1000
+ F76A Jsmall
1001
+ F76B Ksmall
1002
+ F76C Lsmall
1003
+ F76D Msmall
1004
+ F76E Nsmall
1005
+ F76F Osmall
1006
+ F770 Psmall
1007
+ F771 Qsmall
1008
+ F772 Rsmall
1009
+ F773 Ssmall
1010
+ F774 Tsmall
1011
+ F775 Usmall
1012
+ F776 Vsmall
1013
+ F777 Wsmall
1014
+ F778 Xsmall
1015
+ F779 Ysmall
1016
+ F77A Zsmall
1017
+ F7A1 exclamdownsmall
1018
+ F7A2 centoldstyle
1019
+ F7A8 Dieresissmall
1020
+ F7AF Macronsmall
1021
+ F7B4 Acutesmall
1022
+ F7B8 Cedillasmall
1023
+ F7BF questiondownsmall
1024
+ F7E0 Agravesmall
1025
+ F7E1 Aacutesmall
1026
+ F7E2 Acircumflexsmall
1027
+ F7E3 Atildesmall
1028
+ F7E4 Adieresissmall
1029
+ F7E5 Aringsmall
1030
+ F7E6 AEsmall
1031
+ F7E7 Ccedillasmall
1032
+ F7E8 Egravesmall
1033
+ F7E9 Eacutesmall
1034
+ F7EA Ecircumflexsmall
1035
+ F7EB Edieresissmall
1036
+ F7EC Igravesmall
1037
+ F7ED Iacutesmall
1038
+ F7EE Icircumflexsmall
1039
+ F7EF Idieresissmall
1040
+ F7F0 Ethsmall
1041
+ F7F1 Ntildesmall
1042
+ F7F2 Ogravesmall
1043
+ F7F3 Oacutesmall
1044
+ F7F4 Ocircumflexsmall
1045
+ F7F5 Otildesmall
1046
+ F7F6 Odieresissmall
1047
+ F7F8 Oslashsmall
1048
+ F7F9 Ugravesmall
1049
+ F7FA Uacutesmall
1050
+ F7FB Ucircumflexsmall
1051
+ F7FC Udieresissmall
1052
+ F7FD Yacutesmall
1053
+ F7FE Thornsmall
1054
+ F7FF Ydieresissmall
1055
+ F8E5 radicalex
1056
+ F8E6 arrowvertex
1057
+ F8E7 arrowhorizex
1058
+ F8E8 registersans
1059
+ F8E9 copyrightsans
1060
+ F8EA trademarksans
1061
+ F8EB parenlefttp
1062
+ F8EC parenleftex
1063
+ F8ED parenleftbt
1064
+ F8EE bracketlefttp
1065
+ F8EF bracketleftex
1066
+ F8F0 bracketleftbt
1067
+ F8F1 bracelefttp
1068
+ F8F2 braceleftmid
1069
+ F8F3 braceleftbt
1070
+ F8F4 braceex
1071
+ F8F5 integralex
1072
+ F8F6 parenrighttp
1073
+ F8F7 parenrightex
1074
+ F8F8 parenrightbt
1075
+ F8F9 bracketrighttp
1076
+ F8FA bracketrightex
1077
+ F8FB bracketrightbt
1078
+ F8FC bracerighttp
1079
+ F8FD bracerightmid
1080
+ F8FE bracerightbt
1081
+ FB00 ff
1082
+ FB01 fi
1083
+ FB02 fl
1084
+ FB03 ffi
1085
+ FB04 ffl
1086
+ FB1F afii57705
1087
+ FB2A afii57694
1088
+ FB2B afii57695
1089
+ FB35 afii57723
1090
+ FB4B afii57700
1091
+ }
1092
+
1093
+ variable ps_preamble {}
1094
+
1095
+ namespace eval ps {
1096
+ namespace ensemble create
1097
+ namespace export {[a-z]*}
1098
+ proc literal {string} {
1099
+ upvar 0 ::tk::ps_preamble preamble
1100
+ foreach line [split $string \n] {
1101
+ set line [string trim $line]
1102
+ if {$line eq ""} continue
1103
+ append preamble $line \n
1104
+ }
1105
+ return
1106
+ }
1107
+ proc variable {name value} {
1108
+ upvar 0 ::tk::ps_preamble preamble
1109
+ append preamble "/$name $value def\n"
1110
+ return
1111
+ }
1112
+ proc function {name body} {
1113
+ upvar 0 ::tk::ps_preamble preamble
1114
+ append preamble "/$name \{"
1115
+ foreach line [split $body \n] {
1116
+ set line [string trim $line]
1117
+ # Strip blank lines and comments from the bodies of functions
1118
+ if {$line eq "" } continue
1119
+ if {[string match {[%#]*} $line]} continue
1120
+ append preamble $line " "
1121
+ }
1122
+ append preamble "\} bind def\n"
1123
+ return
1124
+ }
1125
+ }
1126
+
1127
+ ps literal {
1128
+ %%BeginProlog
1129
+ % This is a standard prolog for Postscript generated by Tk's canvas
1130
+ % widget.
1131
+ }
1132
+ ps variable CurrentEncoding [CreatePostscriptEncoding]
1133
+ ps literal {50 dict begin}
1134
+
1135
+ # The definitions below just define all of the variables used in any of
1136
+ # the procedures here. This is needed for obscure reasons explained on
1137
+ # p. 716 of the Postscript manual (Section H.2.7, "Initializing
1138
+ # Variables," in the section on Encapsulated Postscript).
1139
+ ps variable baseline 0
1140
+ ps variable stipimage 0
1141
+ ps variable height 0
1142
+ ps variable justify 0
1143
+ ps variable lineLength 0
1144
+ ps variable spacing 0
1145
+ ps variable stipple 0
1146
+ ps variable strings 0
1147
+ ps variable xoffset 0
1148
+ ps variable yoffset 0
1149
+ ps variable tmpstip null
1150
+ ps variable baselineSampler "( TXygqPZ)"
1151
+ # Put an extra-tall character in; done this way to avoid encoding trouble
1152
+ ps literal {baselineSampler 0 196 put}
1153
+
1154
+ ps function cstringshow {
1155
+ {
1156
+ dup type /stringtype eq
1157
+ { show } { glyphshow }
1158
+ ifelse
1159
+ } forall
1160
+ }
1161
+
1162
+ ps function cstringwidth {
1163
+ 0 exch 0 exch
1164
+ {
1165
+ dup type /stringtype eq
1166
+ { stringwidth } {
1167
+ currentfont /Encoding get exch 1 exch put (\001)
1168
+ stringwidth
1169
+ }
1170
+ ifelse
1171
+ exch 3 1 roll add 3 1 roll add exch
1172
+ } forall
1173
+ }
1174
+
1175
+ # font ISOEncode font
1176
+ #
1177
+ # This procedure changes the encoding of a font from the default
1178
+ # Postscript encoding to current system encoding. It's typically invoked
1179
+ # just before invoking "setfont". The body of this procedure comes from
1180
+ # Section 5.6.1 of the Postscript book.
1181
+ ps function ISOEncode {
1182
+ dup length dict begin
1183
+ {1 index /FID ne {def} {pop pop} ifelse} forall
1184
+ /Encoding CurrentEncoding def
1185
+ currentdict
1186
+ end
1187
+ % I'm not sure why it's necessary to use "definefont" on this new
1188
+ % font, but it seems to be important; just use the name "Temporary"
1189
+ % for the font.
1190
+ /Temporary exch definefont
1191
+ }
1192
+
1193
+ # StrokeClip
1194
+ #
1195
+ # This procedure converts the current path into a clip area under the
1196
+ # assumption of stroking. It's a bit tricky because some Postscript
1197
+ # interpreters get errors during strokepath for dashed lines. If this
1198
+ # happens then turn off dashes and try again.
1199
+ ps function StrokeClip {
1200
+ {strokepath} stopped {
1201
+ (This Postscript printer gets limitcheck overflows when) =
1202
+ (stippling dashed lines; lines will be printed solid instead.) =
1203
+ [] 0 setdash strokepath} if
1204
+ clip
1205
+ }
1206
+
1207
+ # desiredSize EvenPixels closestSize
1208
+ #
1209
+ # The procedure below is used for stippling. Given the optimal size of a
1210
+ # dot in a stipple pattern in the current user coordinate system, compute
1211
+ # the closest size that is an exact multiple of the device's pixel
1212
+ # size. This allows stipple patterns to be displayed without aliasing
1213
+ # effects.
1214
+ ps function EvenPixels {
1215
+ % Compute exact number of device pixels per stipple dot.
1216
+ dup 0 matrix currentmatrix dtransform
1217
+ dup mul exch dup mul add sqrt
1218
+ % Round to an integer, make sure the number is at least 1, and
1219
+ % compute user coord distance corresponding to this.
1220
+ dup round dup 1 lt {pop 1} if
1221
+ exch div mul
1222
+ }
1223
+
1224
+ # width height string StippleFill --
1225
+ #
1226
+ # Given a path already set up and a clipping region generated from it,
1227
+ # this procedure will fill the clipping region with a stipple pattern.
1228
+ # "String" contains a proper image description of the stipple pattern and
1229
+ # "width" and "height" give its dimensions. Each stipple dot is assumed to
1230
+ # be about one unit across in the current user coordinate system. This
1231
+ # procedure trashes the graphics state.
1232
+ ps function StippleFill {
1233
+ % The following code is needed to work around a NeWSprint bug.
1234
+ /tmpstip 1 index def
1235
+ % Change the scaling so that one user unit in user coordinates
1236
+ % corresponds to the size of one stipple dot.
1237
+ 1 EvenPixels dup scale
1238
+ % Compute the bounding box occupied by the path (which is now the
1239
+ % clipping region), and round the lower coordinates down to the
1240
+ % nearest starting point for the stipple pattern. Be careful about
1241
+ % negative numbers, since the rounding works differently on them.
1242
+ pathbbox
1243
+ 4 2 roll
1244
+ 5 index div dup 0 lt {1 sub} if cvi 5 index mul 4 1 roll
1245
+ 6 index div dup 0 lt {1 sub} if cvi 6 index mul 3 2 roll
1246
+ % Stack now: width height string y1 y2 x1 x2
1247
+ % Below is a doubly-nested for loop to iterate across this area
1248
+ % in units of the stipple pattern size, going up columns then
1249
+ % across rows, blasting out a stipple-pattern-sized rectangle at
1250
+ % each position
1251
+ 6 index exch {
1252
+ 2 index 5 index 3 index {
1253
+ % Stack now: width height string y1 y2 x y
1254
+ gsave
1255
+ 1 index exch translate
1256
+ 5 index 5 index true matrix tmpstip imagemask
1257
+ grestore
1258
+ } for
1259
+ pop
1260
+ } for
1261
+ pop pop pop pop pop
1262
+ }
1263
+
1264
+ # -- AdjustColor --
1265
+ #
1266
+ # Given a color value already set for output by the caller, adjusts that
1267
+ # value to a grayscale or mono value if requested by the CL variable.
1268
+ ps function AdjustColor {
1269
+ CL 2 lt {
1270
+ currentgray
1271
+ CL 0 eq {
1272
+ .5 lt {0} {1} ifelse
1273
+ } if
1274
+ setgray
1275
+ } if
1276
+ }
1277
+
1278
+ # x y strings spacing xoffset yoffset justify stipple DrawText --
1279
+ #
1280
+ # This procedure does all of the real work of drawing text. The color and
1281
+ # font must already have been set by the caller, and the following
1282
+ # arguments must be on the stack:
1283
+ #
1284
+ # x, y - Coordinates at which to draw text.
1285
+ # strings - An array of strings, one for each line of the text item, in
1286
+ # order from top to bottom.
1287
+ # spacing - Spacing between lines.
1288
+ # xoffset - Horizontal offset for text bbox relative to x and y: 0 for
1289
+ # nw/w/sw anchor, -0.5 for n/center/s, and -1.0 for ne/e/se.
1290
+ # yoffset - Vertical offset for text bbox relative to x and y: 0 for
1291
+ # nw/n/ne anchor, +0.5 for w/center/e, and +1.0 for sw/s/se.
1292
+ # justify - 0 for left justification, 0.5 for center, 1 for right justify.
1293
+ # stipple - Boolean value indicating whether or not text is to be drawn in
1294
+ # stippled fashion. If text is stippled, function StippleText
1295
+ # must have been defined to call StippleFill in the right way.
1296
+ #
1297
+ # Also, when this procedure is invoked, the color and font must already
1298
+ # have been set for the text.
1299
+ ps function DrawText {
1300
+ /stipple exch def
1301
+ /justify exch def
1302
+ /yoffset exch def
1303
+ /xoffset exch def
1304
+ /spacing exch def
1305
+ /strings exch def
1306
+ % First scan through all of the text to find the widest line.
1307
+ /lineLength 0 def
1308
+ strings {
1309
+ cstringwidth pop
1310
+ dup lineLength gt {/lineLength exch def} {pop} ifelse
1311
+ newpath
1312
+ } forall
1313
+ % Compute the baseline offset and the actual font height.
1314
+ 0 0 moveto baselineSampler false charpath
1315
+ pathbbox dup /baseline exch def
1316
+ exch pop exch sub /height exch def pop
1317
+ newpath
1318
+ % Translate and rotate coordinates first so that the origin is at
1319
+ % the upper-left corner of the text's bounding box. Remember that
1320
+ % angle for rotating, and x and y for positioning are still on the
1321
+ % stack.
1322
+ translate
1323
+ rotate
1324
+ lineLength xoffset mul
1325
+ strings length 1 sub spacing mul height add yoffset mul translate
1326
+ % Now use the baseline and justification information to translate
1327
+ % so that the origin is at the baseline and positioning point for
1328
+ % the first line of text.
1329
+ justify lineLength mul baseline neg translate
1330
+ % Iterate over each of the lines to output it. For each line,
1331
+ % compute its width again so it can be properly justified, then
1332
+ % display it.
1333
+ strings {
1334
+ dup cstringwidth pop
1335
+ justify neg mul 0 moveto
1336
+ stipple {
1337
+ % The text is stippled, so turn it into a path and print
1338
+ % by calling StippledText, which in turn calls
1339
+ % StippleFill. Unfortunately, many Postscript interpreters
1340
+ % will get overflow errors if we try to do the whole
1341
+ % string at once, so do it a character at a time.
1342
+ gsave
1343
+ /char (X) def
1344
+ {
1345
+ dup type /stringtype eq {
1346
+ % This segment is a string.
1347
+ {
1348
+ char 0 3 -1 roll put
1349
+ currentpoint
1350
+ gsave
1351
+ char true charpath clip StippleText
1352
+ grestore
1353
+ char stringwidth translate
1354
+ moveto
1355
+ } forall
1356
+ } {
1357
+ % This segment is glyph name
1358
+ % Temporary override
1359
+ currentfont /Encoding get exch 1 exch put
1360
+ currentpoint
1361
+ gsave (\001) true charpath clip StippleText
1362
+ grestore
1363
+ (\001) stringwidth translate
1364
+ moveto
1365
+ } ifelse
1366
+ } forall
1367
+ grestore
1368
+ } {cstringshow} ifelse
1369
+ 0 spacing neg translate
1370
+ } forall
1371
+ }
1372
+
1373
+ # Define the "TkPhoto" function variants, which are modified versions
1374
+ # of the original "transparentimage" function posted by ian@five-d.com
1375
+ # (Ian Kemmish) to comp.lang.postscript. For a monochrome colorLevel
1376
+ # this is a slightly different version that uses the imagemask command
1377
+ # instead of image.
1378
+
1379
+ ps function TkPhotoColor {
1380
+ gsave
1381
+ 32 dict begin
1382
+ /tinteger exch def
1383
+ /transparent 1 string def
1384
+ transparent 0 tinteger put
1385
+ /olddict exch def
1386
+ olddict /DataSource get dup type /filetype ne {
1387
+ olddict /DataSource 3 -1 roll
1388
+ 0 () /SubFileDecode filter put
1389
+ } {
1390
+ pop
1391
+ } ifelse
1392
+ /newdict olddict maxlength dict def
1393
+ olddict newdict copy pop
1394
+ /w newdict /Width get def
1395
+ /crpp newdict /Decode get length 2 idiv def
1396
+ /str w string def
1397
+ /pix w crpp mul string def
1398
+ /substrlen 2 w log 2 log div floor exp cvi def
1399
+ /substrs [ {
1400
+ substrlen string
1401
+ 0 1 substrlen 1 sub {
1402
+ 1 index exch tinteger put
1403
+ } for
1404
+ /substrlen substrlen 2 idiv def
1405
+ substrlen 0 eq {exit} if
1406
+ } loop ] def
1407
+ /h newdict /Height get def
1408
+ 1 w div 1 h div matrix scale
1409
+ olddict /ImageMatrix get exch matrix concatmatrix
1410
+ matrix invertmatrix concat
1411
+ newdict /Height 1 put
1412
+ newdict /DataSource pix put
1413
+ /mat [w 0 0 h 0 0] def
1414
+ newdict /ImageMatrix mat put
1415
+ 0 1 h 1 sub {
1416
+ mat 5 3 -1 roll neg put
1417
+ olddict /DataSource get str readstring pop pop
1418
+ /tail str def
1419
+ /x 0 def
1420
+ olddict /DataSource get pix readstring pop pop
1421
+ {
1422
+ tail transparent search dup /done exch not def
1423
+ {exch pop exch pop} if
1424
+ /w1 exch length def
1425
+ w1 0 ne {
1426
+ newdict /DataSource
1427
+ pix x crpp mul w1 crpp mul getinterval put
1428
+ newdict /Width w1 put
1429
+ mat 4 x neg put
1430
+ /x x w1 add def
1431
+ newdict image
1432
+ /tail tail w1 tail length w1 sub getinterval def
1433
+ } if
1434
+ done {exit} if
1435
+ tail substrs {
1436
+ anchorsearch {pop} if
1437
+ } forall
1438
+ /tail exch def
1439
+ tail length 0 eq {exit} if
1440
+ /x w tail length sub def
1441
+ } loop
1442
+ } for
1443
+ end
1444
+ grestore
1445
+ }
1446
+ ps function TkPhotoMono {
1447
+ gsave
1448
+ 32 dict begin
1449
+ /dummyInteger exch def
1450
+ /olddict exch def
1451
+ olddict /DataSource get dup type /filetype ne {
1452
+ olddict /DataSource 3 -1 roll
1453
+ 0 () /SubFileDecode filter put
1454
+ } {
1455
+ pop
1456
+ } ifelse
1457
+ /newdict olddict maxlength dict def
1458
+ olddict newdict copy pop
1459
+ /w newdict /Width get def
1460
+ /pix w 7 add 8 idiv string def
1461
+ /h newdict /Height get def
1462
+ 1 w div 1 h div matrix scale
1463
+ olddict /ImageMatrix get exch matrix concatmatrix
1464
+ matrix invertmatrix concat
1465
+ newdict /Height 1 put
1466
+ newdict /DataSource pix put
1467
+ /mat [w 0 0 h 0 0] def
1468
+ newdict /ImageMatrix mat put
1469
+ 0 1 h 1 sub {
1470
+ mat 5 3 -1 roll neg put
1471
+ 0.000 0.000 0.000 setrgbcolor
1472
+ olddict /DataSource get pix readstring pop pop
1473
+ newdict /DataSource pix put
1474
+ newdict imagemask
1475
+ 1.000 1.000 1.000 setrgbcolor
1476
+ olddict /DataSource get pix readstring pop pop
1477
+ newdict /DataSource pix put
1478
+ newdict imagemask
1479
+ } for
1480
+ end
1481
+ grestore
1482
+ }
1483
+
1484
+ ps literal %%EndProlog
1485
+ }
1486
+
1487
+ proc tk::ensure_psenc_is_loaded {} {
1488
+ }
janus/lib/tk8.6/msgbox.tcl ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # msgbox.tcl --
2
+ #
3
+ # Implements messageboxes for platforms that do not have native
4
+ # messagebox support.
5
+ #
6
+ # Copyright (c) 1994-1997 Sun Microsystems, Inc.
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+ #
11
+
12
+ # Ensure existence of ::tk::dialog namespace
13
+ #
14
+ namespace eval ::tk::dialog {}
15
+
16
+ image create bitmap ::tk::dialog::b1 -foreground black \
17
+ -data "#define b1_width 32\n#define b1_height 32
18
+ static unsigned char q1_bits[] = {
19
+ 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x07, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x03,
20
+ 0x20, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x10,
21
+ 0x04, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
22
+ 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80,
23
+ 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80,
24
+ 0x01, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
25
+ 0x04, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x08,
26
+ 0x60, 0x00, 0x00, 0x04, 0x80, 0x03, 0x80, 0x03, 0x00, 0x0c, 0x78, 0x00,
27
+ 0x00, 0x30, 0x04, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x40, 0x04, 0x00,
28
+ 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00,
29
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
30
+ image create bitmap ::tk::dialog::b2 -foreground white \
31
+ -data "#define b2_width 32\n#define b2_height 32
32
+ static unsigned char b2_bits[] = {
33
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x00,
34
+ 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f,
35
+ 0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
36
+ 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
37
+ 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
38
+ 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x3f,
39
+ 0xf8, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x07,
40
+ 0x80, 0xff, 0xff, 0x03, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf0, 0x07, 0x00,
41
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x80, 0x03, 0x00,
42
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
43
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
44
+ image create bitmap ::tk::dialog::q -foreground blue \
45
+ -data "#define q_width 32\n#define q_height 32
46
+ static unsigned char q_bits[] = {
47
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00,
49
+ 0x00, 0x10, 0x0f, 0x00, 0x00, 0x18, 0x1e, 0x00, 0x00, 0x38, 0x1e, 0x00,
50
+ 0x00, 0x38, 0x1e, 0x00, 0x00, 0x10, 0x0f, 0x00, 0x00, 0x80, 0x07, 0x00,
51
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
52
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00,
53
+ 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
58
+ image create bitmap ::tk::dialog::i -foreground blue \
59
+ -data "#define i_width 32\n#define i_height 32
60
+ static unsigned char i_bits[] = {
61
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62
+ 0x00, 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00,
63
+ 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64
+ 0x00, 0xf8, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xe0, 0x03, 0x00,
65
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xe0, 0x03, 0x00,
66
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
67
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
72
+ image create bitmap ::tk::dialog::w1 -foreground black \
73
+ -data "#define w1_width 32\n#define w1_height 32
74
+ static unsigned char w1_bits[] = {
75
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x20, 0x04, 0x00,
76
+ 0x00, 0x10, 0x04, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x08, 0x08, 0x00,
77
+ 0x00, 0x08, 0x10, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x04, 0x20, 0x00,
78
+ 0x00, 0x02, 0x20, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x40, 0x00,
79
+ 0x00, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x01,
80
+ 0x40, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x02, 0x20, 0x00, 0x00, 0x02,
81
+ 0x20, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x08,
82
+ 0x08, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x10, 0x04, 0x00, 0x00, 0x10,
83
+ 0x04, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x40,
84
+ 0x01, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x20,
85
+ 0xfc, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00};"
86
+ image create bitmap ::tk::dialog::w2 -foreground yellow \
87
+ -data "#define w2_width 32\n#define w2_height 32
88
+ static unsigned char w2_bits[] = {
89
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
90
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf0, 0x07, 0x00,
91
+ 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00,
92
+ 0x00, 0xfc, 0x1f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfe, 0x3f, 0x00,
93
+ 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00,
94
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff, 0x01,
95
+ 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
96
+ 0xf0, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0f,
97
+ 0xf8, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0x1f, 0xfe, 0xff, 0xff, 0x3f,
98
+ 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0x1f,
99
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
100
+ image create bitmap ::tk::dialog::w3 -foreground black \
101
+ -data "#define w3_width 32\n#define w3_height 32
102
+ static unsigned char w3_bits[] = {
103
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
104
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
107
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
108
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00,
109
+ 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0x01, 0x00,
110
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00,
111
+ 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
112
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
113
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};"
114
+
115
+ # ::tk::MessageBox --
116
+ #
117
+ # Pops up a messagebox with an application-supplied message with
118
+ # an icon and a list of buttons. This procedure will be called
119
+ # by tk_messageBox if the platform does not have native
120
+ # messagebox support, or if the particular type of messagebox is
121
+ # not supported natively.
122
+ #
123
+ # Color icons are used on Unix displays that have a color
124
+ # depth of 4 or more and $tk_strictMotif is not on.
125
+ #
126
+ # This procedure is a private procedure shouldn't be called
127
+ # directly. Call tk_messageBox instead.
128
+ #
129
+ # See the user documentation for details on what tk_messageBox does.
130
+ #
131
+ proc ::tk::MessageBox {args} {
132
+ global tk_strictMotif
133
+ variable ::tk::Priv
134
+
135
+ set w ::tk::PrivMsgBox
136
+ upvar $w data
137
+
138
+ #
139
+ # The default value of the title is space (" ") not the empty string
140
+ # because for some window managers, a
141
+ # wm title .foo ""
142
+ # causes the window title to be "foo" instead of the empty string.
143
+ #
144
+ set specs {
145
+ {-default "" "" ""}
146
+ {-detail "" "" ""}
147
+ {-icon "" "" "info"}
148
+ {-message "" "" ""}
149
+ {-parent "" "" .}
150
+ {-title "" "" " "}
151
+ {-type "" "" "ok"}
152
+ }
153
+
154
+ tclParseConfigSpec $w $specs "" $args
155
+
156
+ if {$data(-icon) ni {info warning error question}} {
157
+ return -code error -errorcode [list TK LOOKUP ICON $data(-icon)] \
158
+ "bad -icon value \"$data(-icon)\": must be error, info, question, or warning"
159
+ }
160
+ set windowingsystem [tk windowingsystem]
161
+ if {$windowingsystem eq "aqua"} {
162
+ switch -- $data(-icon) {
163
+ "error" {set data(-icon) "stop"}
164
+ "warning" {set data(-icon) "caution"}
165
+ "info" {set data(-icon) "note"}
166
+ }
167
+ }
168
+
169
+ if {![winfo exists $data(-parent)]} {
170
+ return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
171
+ "bad window path name \"$data(-parent)\""
172
+ }
173
+
174
+ switch -- $data(-type) {
175
+ abortretryignore {
176
+ set names [list abort retry ignore]
177
+ set labels [list &Abort &Retry &Ignore]
178
+ set cancel abort
179
+ }
180
+ ok {
181
+ set names [list ok]
182
+ set labels {&OK}
183
+ set cancel ok
184
+ }
185
+ okcancel {
186
+ set names [list ok cancel]
187
+ set labels [list &OK &Cancel]
188
+ set cancel cancel
189
+ }
190
+ retrycancel {
191
+ set names [list retry cancel]
192
+ set labels [list &Retry &Cancel]
193
+ set cancel cancel
194
+ }
195
+ yesno {
196
+ set names [list yes no]
197
+ set labels [list &Yes &No]
198
+ set cancel no
199
+ }
200
+ yesnocancel {
201
+ set names [list yes no cancel]
202
+ set labels [list &Yes &No &Cancel]
203
+ set cancel cancel
204
+ }
205
+ default {
206
+ return -code error -errorcode [list TK LOOKUP DLG_TYPE $data(-type)] \
207
+ "bad -type value \"$data(-type)\": must be\
208
+ abortretryignore, ok, okcancel, retrycancel,\
209
+ yesno, or yesnocancel"
210
+ }
211
+ }
212
+
213
+ set buttons {}
214
+ foreach name $names lab $labels {
215
+ lappend buttons [list $name -text [mc $lab]]
216
+ }
217
+
218
+ # If no default button was specified, the default default is the
219
+ # first button (Bug: 2218).
220
+
221
+ if {$data(-default) eq ""} {
222
+ set data(-default) [lindex [lindex $buttons 0] 0]
223
+ }
224
+
225
+ set valid 0
226
+ foreach btn $buttons {
227
+ if {[lindex $btn 0] eq $data(-default)} {
228
+ set valid 1
229
+ break
230
+ }
231
+ }
232
+ if {!$valid} {
233
+ return -code error -errorcode {TK MSGBOX DEFAULT} \
234
+ "bad -default value \"$data(-default)\": must be\
235
+ abort, retry, ignore, ok, cancel, no, or yes"
236
+ }
237
+
238
+ # 2. Set the dialog to be a child window of $parent
239
+ #
240
+ #
241
+ if {$data(-parent) ne "."} {
242
+ set w $data(-parent).__tk__messagebox
243
+ } else {
244
+ set w .__tk__messagebox
245
+ }
246
+
247
+ # There is only one background colour for the whole dialog
248
+ set bg [ttk::style lookup . -background]
249
+
250
+ # 3. Create the top-level window and divide it into top
251
+ # and bottom parts.
252
+
253
+ catch {destroy $w}
254
+ toplevel $w -class Dialog -bg $bg
255
+ wm title $w $data(-title)
256
+ wm iconname $w Dialog
257
+ wm protocol $w WM_DELETE_WINDOW [list $w.$cancel invoke]
258
+
259
+ # Message boxes should be transient with respect to their parent so that
260
+ # they always stay on top of the parent window. But some window managers
261
+ # will simply create the child window as withdrawn if the parent is not
262
+ # viewable (because it is withdrawn or iconified). This is not good for
263
+ # "grab"bed windows. So only make the message box transient if the parent
264
+ # is viewable.
265
+ #
266
+ if {[winfo viewable [winfo toplevel $data(-parent)]] } {
267
+ wm transient $w $data(-parent)
268
+ }
269
+
270
+ if {$windowingsystem eq "aqua"} {
271
+ ::tk::unsupported::MacWindowStyle style $w moveableModal {}
272
+ } elseif {$windowingsystem eq "x11"} {
273
+ wm attributes $w -type dialog
274
+ }
275
+
276
+ ttk::frame $w.bot
277
+ grid anchor $w.bot center
278
+ pack $w.bot -side bottom -fill both
279
+ ttk::frame $w.top
280
+ pack $w.top -side top -fill both -expand 1
281
+
282
+ # 4. Fill the top part with bitmap, message and detail (use the
283
+ # option database for -wraplength and -font so that they can be
284
+ # overridden by the caller).
285
+
286
+ option add *Dialog.msg.wrapLength 3i widgetDefault
287
+ option add *Dialog.dtl.wrapLength 3i widgetDefault
288
+ option add *Dialog.msg.font TkCaptionFont widgetDefault
289
+ option add *Dialog.dtl.font TkDefaultFont widgetDefault
290
+
291
+ ttk::label $w.msg -anchor nw -justify left -text $data(-message)
292
+ if {$data(-detail) ne ""} {
293
+ ttk::label $w.dtl -anchor nw -justify left -text $data(-detail)
294
+ }
295
+ if {$data(-icon) ne ""} {
296
+ if {([winfo depth $w] < 4) || $tk_strictMotif} {
297
+ # ttk::label has no -bitmap option
298
+ label $w.bitmap -bitmap $data(-icon) -background $bg
299
+ } else {
300
+ switch $data(-icon) {
301
+ error {
302
+ ttk::label $w.bitmap -image ::tk::icons::error
303
+ }
304
+ info {
305
+ ttk::label $w.bitmap -image ::tk::icons::information
306
+ }
307
+ question {
308
+ ttk::label $w.bitmap -image ::tk::icons::question
309
+ }
310
+ default {
311
+ ttk::label $w.bitmap -image ::tk::icons::warning
312
+ }
313
+ }
314
+ }
315
+ }
316
+ grid $w.bitmap $w.msg -in $w.top -sticky news -padx 2m -pady 2m
317
+ grid configure $w.bitmap -sticky nw
318
+ grid columnconfigure $w.top 1 -weight 1
319
+ if {$data(-detail) ne ""} {
320
+ grid ^ $w.dtl -in $w.top -sticky news -padx 2m -pady {0 2m}
321
+ grid rowconfigure $w.top 1 -weight 1
322
+ } else {
323
+ grid rowconfigure $w.top 0 -weight 1
324
+ }
325
+
326
+ # 5. Create a row of buttons at the bottom of the dialog.
327
+
328
+ set i 0
329
+ foreach but $buttons {
330
+ set name [lindex $but 0]
331
+ set opts [lrange $but 1 end]
332
+ if {![llength $opts]} {
333
+ # Capitalize the first letter of $name
334
+ set capName [string toupper $name 0]
335
+ set opts [list -text $capName]
336
+ }
337
+
338
+ eval [list tk::AmpWidget ttk::button $w.$name] $opts \
339
+ [list -command [list set tk::Priv(button) $name]]
340
+
341
+ if {$name eq $data(-default)} {
342
+ $w.$name configure -default active
343
+ } else {
344
+ $w.$name configure -default normal
345
+ }
346
+ grid $w.$name -in $w.bot -row 0 -column $i -padx 3m -pady 2m -sticky ew
347
+ grid columnconfigure $w.bot $i -uniform buttons
348
+ # We boost the size of some Mac buttons for l&f
349
+ if {$windowingsystem eq "aqua"} {
350
+ set tmp [string tolower $name]
351
+ if {$tmp eq "ok" || $tmp eq "cancel" || $tmp eq "yes" ||
352
+ $tmp eq "no" || $tmp eq "abort" || $tmp eq "retry" ||
353
+ $tmp eq "ignore"} {
354
+ grid columnconfigure $w.bot $i -minsize 90
355
+ }
356
+ grid configure $w.$name -pady 7
357
+ }
358
+ incr i
359
+
360
+ # create the binding for the key accelerator, based on the underline
361
+ #
362
+ # set underIdx [$w.$name cget -under]
363
+ # if {$underIdx >= 0} {
364
+ # set key [string index [$w.$name cget -text] $underIdx]
365
+ # bind $w <Alt-[string tolower $key]> [list $w.$name invoke]
366
+ # bind $w <Alt-[string toupper $key]> [list $w.$name invoke]
367
+ # }
368
+ }
369
+ bind $w <Alt-Key> [list ::tk::AltKeyInDialog $w %A]
370
+
371
+ if {$data(-default) ne ""} {
372
+ bind $w <FocusIn> {
373
+ if {[winfo class %W] in "Button TButton"} {
374
+ %W configure -default active
375
+ }
376
+ }
377
+ bind $w <FocusOut> {
378
+ if {[winfo class %W] in "Button TButton"} {
379
+ %W configure -default normal
380
+ }
381
+ }
382
+ }
383
+
384
+ # 6. Create bindings for <Return>, <Escape> and <Destroy> on the dialog
385
+
386
+ bind $w <Return> {
387
+ if {[winfo class %W] in "Button TButton"} {
388
+ %W invoke
389
+ }
390
+ }
391
+
392
+ # Invoke the designated cancelling operation
393
+ bind $w <Escape> [list $w.$cancel invoke]
394
+
395
+ # At <Destroy> the buttons have vanished, so must do this directly.
396
+ bind $w.msg <Destroy> [list set tk::Priv(button) $cancel]
397
+
398
+ # 7. Withdraw the window, then update all the geometry information
399
+ # so we know how big it wants to be, then center the window in the
400
+ # display (Motif style) and de-iconify it.
401
+
402
+ ::tk::PlaceWindow $w widget $data(-parent)
403
+
404
+ # 8. Set a grab and claim the focus too.
405
+
406
+ if {$data(-default) ne ""} {
407
+ set focus $w.$data(-default)
408
+ } else {
409
+ set focus $w
410
+ }
411
+ ::tk::SetFocusGrab $w $focus
412
+
413
+ # 9. Wait for the user to respond, then restore the focus and
414
+ # return the index of the selected button. Restore the focus
415
+ # before deleting the window, since otherwise the window manager
416
+ # may take the focus away so we can't redirect it. Finally,
417
+ # restore any grab that was in effect.
418
+
419
+ vwait ::tk::Priv(button)
420
+ # Copy the result now so any <Destroy> that happens won't cause
421
+ # trouble
422
+ set result $Priv(button)
423
+
424
+ ::tk::RestoreFocusGrab $w $focus
425
+
426
+ return $result
427
+ }
janus/lib/tk8.6/optMenu.tcl ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # optMenu.tcl --
2
+ #
3
+ # This file defines the procedure tk_optionMenu, which creates
4
+ # an option button and its associated menu.
5
+ #
6
+ # Copyright (c) 1994 The Regents of the University of California.
7
+ # Copyright (c) 1994 Sun Microsystems, Inc.
8
+ #
9
+ # See the file "license.terms" for information on usage and redistribution
10
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
+ #
12
+
13
+ # ::tk_optionMenu --
14
+ # This procedure creates an option button named $w and an associated
15
+ # menu. Together they provide the functionality of Motif option menus:
16
+ # they can be used to select one of many values, and the current value
17
+ # appears in the global variable varName, as well as in the text of
18
+ # the option menubutton. The name of the menu is returned as the
19
+ # procedure's result, so that the caller can use it to change configuration
20
+ # options on the menu or otherwise manipulate it.
21
+ #
22
+ # Arguments:
23
+ # w - The name to use for the menubutton.
24
+ # varName - Global variable to hold the currently selected value.
25
+ # firstValue - First of legal values for option (must be >= 1).
26
+ # args - Any number of additional values.
27
+
28
+ proc ::tk_optionMenu {w varName firstValue args} {
29
+ upvar #0 $varName var
30
+
31
+ if {![info exists var]} {
32
+ set var $firstValue
33
+ }
34
+ menubutton $w -textvariable $varName -indicatoron 1 -menu $w.menu \
35
+ -relief raised -highlightthickness 1 -anchor c \
36
+ -direction flush
37
+ menu $w.menu -tearoff 0
38
+ $w.menu add radiobutton -label $firstValue -variable $varName
39
+ foreach i $args {
40
+ $w.menu add radiobutton -label $i -variable $varName
41
+ }
42
+ return $w.menu
43
+ }
janus/lib/tk8.6/palette.tcl ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # palette.tcl --
2
+ #
3
+ # This file contains procedures that change the color palette used
4
+ # by Tk.
5
+ #
6
+ # Copyright (c) 1995-1997 Sun Microsystems, Inc.
7
+ #
8
+ # See the file "license.terms" for information on usage and redistribution
9
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10
+ #
11
+
12
+ # ::tk_setPalette --
13
+ # Changes the default color scheme for a Tk application by setting
14
+ # default colors in the option database and by modifying all of the
15
+ # color options for existing widgets that have the default value.
16
+ #
17
+ # Arguments:
18
+ # The arguments consist of either a single color name, which
19
+ # will be used as the new background color (all other colors will
20
+ # be computed from this) or an even number of values consisting of
21
+ # option names and values. The name for an option is the one used
22
+ # for the option database, such as activeForeground, not -activeforeground.
23
+
24
+ proc ::tk_setPalette {args} {
25
+ if {[winfo depth .] == 1} {
26
+ # Just return on monochrome displays, otherwise errors will occur
27
+ return
28
+ }
29
+
30
+ # Create an array that has the complete new palette. If some colors
31
+ # aren't specified, compute them from other colors that are specified.
32
+
33
+ if {[llength $args] == 1} {
34
+ set new(background) [lindex $args 0]
35
+ } else {
36
+ array set new $args
37
+ }
38
+ if {![info exists new(background)]} {
39
+ return -code error -errorcode {TK SET_PALETTE BACKGROUND} \
40
+ "must specify a background color"
41
+ }
42
+ set bg [winfo rgb . $new(background)]
43
+ if {![info exists new(foreground)]} {
44
+ # Note that the range of each value in the triple returned by
45
+ # [winfo rgb] is 0-65535, and your eyes are more sensitive to
46
+ # green than to red, and more to red than to blue.
47
+ foreach {r g b} $bg {break}
48
+ if {$r+1.5*$g+0.5*$b > 100000} {
49
+ set new(foreground) black
50
+ } else {
51
+ set new(foreground) white
52
+ }
53
+ }
54
+ lassign [winfo rgb . $new(foreground)] fg_r fg_g fg_b
55
+ lassign $bg bg_r bg_g bg_b
56
+ set darkerBg [format #%02x%02x%02x [expr {(9*$bg_r)/2560}] \
57
+ [expr {(9*$bg_g)/2560}] [expr {(9*$bg_b)/2560}]]
58
+
59
+ foreach i {activeForeground insertBackground selectForeground \
60
+ highlightColor} {
61
+ if {![info exists new($i)]} {
62
+ set new($i) $new(foreground)
63
+ }
64
+ }
65
+ if {![info exists new(disabledForeground)]} {
66
+ set new(disabledForeground) [format #%02x%02x%02x \
67
+ [expr {(3*$bg_r + $fg_r)/1024}] \
68
+ [expr {(3*$bg_g + $fg_g)/1024}] \
69
+ [expr {(3*$bg_b + $fg_b)/1024}]]
70
+ }
71
+ if {![info exists new(highlightBackground)]} {
72
+ set new(highlightBackground) $new(background)
73
+ }
74
+ if {![info exists new(activeBackground)]} {
75
+ # Pick a default active background that islighter than the
76
+ # normal background. To do this, round each color component
77
+ # up by 15% or 1/3 of the way to full white, whichever is
78
+ # greater.
79
+
80
+ foreach i {0 1 2} color $bg {
81
+ set light($i) [expr {$color/256}]
82
+ set inc1 [expr {($light($i)*15)/100}]
83
+ set inc2 [expr {(255-$light($i))/3}]
84
+ if {$inc1 > $inc2} {
85
+ incr light($i) $inc1
86
+ } else {
87
+ incr light($i) $inc2
88
+ }
89
+ if {$light($i) > 255} {
90
+ set light($i) 255
91
+ }
92
+ }
93
+ set new(activeBackground) [format #%02x%02x%02x $light(0) \
94
+ $light(1) $light(2)]
95
+ }
96
+ if {![info exists new(selectBackground)]} {
97
+ set new(selectBackground) $darkerBg
98
+ }
99
+ if {![info exists new(troughColor)]} {
100
+ set new(troughColor) $darkerBg
101
+ }
102
+
103
+ # let's make one of each of the widgets so we know what the
104
+ # defaults are currently for this platform.
105
+ toplevel .___tk_set_palette
106
+ wm withdraw .___tk_set_palette
107
+ foreach q {
108
+ button canvas checkbutton entry frame label labelframe
109
+ listbox menubutton menu message radiobutton scale scrollbar
110
+ spinbox text
111
+ } {
112
+ $q .___tk_set_palette.$q
113
+ }
114
+
115
+ # Walk the widget hierarchy, recoloring all existing windows.
116
+ # The option database must be set according to what we do here,
117
+ # but it breaks things if we set things in the database while
118
+ # we are changing colors...so, ::tk::RecolorTree now returns the
119
+ # option database changes that need to be made, and they
120
+ # need to be evalled here to take effect.
121
+ # We have to walk the whole widget tree instead of just
122
+ # relying on the widgets we've created above to do the work
123
+ # because different extensions may provide other kinds
124
+ # of widgets that we don't currently know about, so we'll
125
+ # walk the whole hierarchy just in case.
126
+
127
+ eval [tk::RecolorTree . new]
128
+
129
+ destroy .___tk_set_palette
130
+
131
+ # Change the option database so that future windows will get the
132
+ # same colors.
133
+
134
+ foreach option [array names new] {
135
+ option add *$option $new($option) widgetDefault
136
+ }
137
+
138
+ # Save the options in the variable ::tk::Palette, for use the
139
+ # next time we change the options.
140
+
141
+ array set ::tk::Palette [array get new]
142
+ }
143
+
144
+ # ::tk::RecolorTree --
145
+ # This procedure changes the colors in a window and all of its
146
+ # descendants, according to information provided by the colors
147
+ # argument. This looks at the defaults provided by the option
148
+ # database, if it exists, and if not, then it looks at the default
149
+ # value of the widget itself.
150
+ #
151
+ # Arguments:
152
+ # w - The name of a window. This window and all its
153
+ # descendants are recolored.
154
+ # colors - The name of an array variable in the caller,
155
+ # which contains color information. Each element
156
+ # is named after a widget configuration option, and
157
+ # each value is the value for that option.
158
+
159
+ proc ::tk::RecolorTree {w colors} {
160
+ upvar $colors c
161
+ set result {}
162
+ set prototype .___tk_set_palette.[string tolower [winfo class $w]]
163
+ if {![winfo exists $prototype]} {
164
+ unset prototype
165
+ }
166
+ foreach dbOption [array names c] {
167
+ set option -[string tolower $dbOption]
168
+ set class [string replace $dbOption 0 0 [string toupper \
169
+ [string index $dbOption 0]]]
170
+ if {![catch {$w configure $option} value]} {
171
+ # if the option database has a preference for this
172
+ # dbOption, then use it, otherwise use the defaults
173
+ # for the widget.
174
+ set defaultcolor [option get $w $dbOption $class]
175
+ if {$defaultcolor eq "" || \
176
+ ([info exists prototype] && \
177
+ [$prototype cget $option] ne "$defaultcolor")} {
178
+ set defaultcolor [lindex $value 3]
179
+ }
180
+ if {$defaultcolor ne ""} {
181
+ set defaultcolor [winfo rgb . $defaultcolor]
182
+ }
183
+ set chosencolor [lindex $value 4]
184
+ if {$chosencolor ne ""} {
185
+ set chosencolor [winfo rgb . $chosencolor]
186
+ }
187
+ if {[string match $defaultcolor $chosencolor]} {
188
+ # Change the option database so that future windows will get
189
+ # the same colors.
190
+ append result ";\noption add [list \
191
+ *[winfo class $w].$dbOption $c($dbOption) 60]"
192
+ $w configure $option $c($dbOption)
193
+ }
194
+ }
195
+ }
196
+ foreach child [winfo children $w] {
197
+ append result ";\n[::tk::RecolorTree $child c]"
198
+ }
199
+ return $result
200
+ }
201
+
202
+ # ::tk::Darken --
203
+ # Given a color name, computes a new color value that darkens (or
204
+ # brightens) the given color by a given percent.
205
+ #
206
+ # Arguments:
207
+ # color - Name of starting color.
208
+ # percent - Integer telling how much to brighten or darken as a
209
+ # percent: 50 means darken by 50%, 110 means brighten
210
+ # by 10%.
211
+
212
+ proc ::tk::Darken {color percent} {
213
+ if {$percent < 0} {
214
+ return #000000
215
+ } elseif {$percent > 200} {
216
+ return #ffffff
217
+ } elseif {$percent <= 100} {
218
+ lassign [winfo rgb . $color] r g b
219
+ set r [expr {($r/256)*$percent/100}]
220
+ set g [expr {($g/256)*$percent/100}]
221
+ set b [expr {($b/256)*$percent/100}]
222
+ } elseif {$percent > 100} {
223
+ lassign [winfo rgb . $color] r g b
224
+ set r [expr {255 - ((65535-$r)/256)*(200-$percent)/100}]
225
+ set g [expr {255 - ((65535-$g)/256)*(200-$percent)/100}]
226
+ set b [expr {255 - ((65535-$b)/256)*(200-$percent)/100}]
227
+ }
228
+ return [format #%02x%02x%02x $r $g $b]
229
+ }
230
+
231
+ # ::tk_bisque --
232
+ # Reset the Tk color palette to the old "bisque" colors.
233
+ #
234
+ # Arguments:
235
+ # None.
236
+
237
+ proc ::tk_bisque {} {
238
+ tk_setPalette activeBackground #e6ceb1 activeForeground black \
239
+ background #ffe4c4 disabledForeground #b0b0b0 foreground black \
240
+ highlightBackground #ffe4c4 highlightColor black \
241
+ insertBackground black \
242
+ selectBackground #e6ceb1 selectForeground black \
243
+ troughColor #cdb79e
244
+ }
janus/lib/tk8.6/pkgIndex.tcl ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ if {![package vsatisfies [package provide Tcl] 8.6.0]} return
2
+ package ifneeded Tk 8.6.14 [list load [file normalize [file join $dir .. libtk8.6.so]]]
janus/lib/tk8.6/safetk.tcl ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # safetk.tcl --
2
+ #
3
+ # Support procs to use Tk in safe interpreters.
4
+ #
5
+ # Copyright (c) 1997 Sun Microsystems, Inc.
6
+ #
7
+ # See the file "license.terms" for information on usage and redistribution
8
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9
+
10
+ # see safetk.n for documentation
11
+
12
+ #
13
+ #
14
+ # Note: It is now ok to let untrusted code being executed
15
+ # between the creation of the interp and the actual loading
16
+ # of Tk in that interp because the C side Tk_Init will
17
+ # now look up the parent interp and ask its safe::TkInit
18
+ # for the actual parameters to use for it's initialization (if allowed),
19
+ # not relying on the child state.
20
+ #
21
+
22
+ # We use opt (optional arguments parsing)
23
+ package require opt 0.4.1;
24
+
25
+ namespace eval ::safe {
26
+
27
+ # counter for safe toplevels
28
+ variable tkSafeId 0
29
+ }
30
+
31
+ #
32
+ # tkInterpInit : prepare the child interpreter for tk loading
33
+ # most of the real job is done by loadTk
34
+ # returns the child name (tkInterpInit does)
35
+ #
36
+ proc ::safe::tkInterpInit {child argv} {
37
+ global env tk_library
38
+
39
+ # We have to make sure that the tk_library variable is normalized.
40
+ set tk_library [file normalize $tk_library]
41
+
42
+ # Clear Tk's access for that interp (path).
43
+ allowTk $child $argv
44
+
45
+ # Ensure tk_library and subdirs (eg, ttk) are on the access path
46
+ ::interp eval $child [list set tk_library [::safe::interpAddToAccessPath $child $tk_library]]
47
+ foreach subdir [::safe::AddSubDirs [list $tk_library]] {
48
+ ::safe::interpAddToAccessPath $child $subdir
49
+ }
50
+ return $child
51
+ }
52
+
53
+
54
+ # tkInterpLoadTk:
55
+ # Do additional configuration as needed (calling tkInterpInit)
56
+ # and actually load Tk into the child.
57
+ #
58
+ # Either contained in the specified windowId (-use) or
59
+ # creating a decorated toplevel for it.
60
+
61
+ # empty definition for auto_mkIndex
62
+ proc ::safe::loadTk {} {}
63
+
64
+ ::tcl::OptProc ::safe::loadTk {
65
+ {child -interp "name of the child interpreter"}
66
+ {-use -windowId {} "window Id to use (new toplevel otherwise)"}
67
+ {-display -displayName {} "display name to use (current one otherwise)"}
68
+ } {
69
+ set displayGiven [::tcl::OptProcArgGiven "-display"]
70
+ if {!$displayGiven} {
71
+ # Try to get the current display from "."
72
+ # (which might not exist if the parent is tk-less)
73
+ if {[catch {set display [winfo screen .]}]} {
74
+ if {[info exists ::env(DISPLAY)]} {
75
+ set display $::env(DISPLAY)
76
+ } else {
77
+ Log $child "no winfo screen . nor env(DISPLAY)" WARNING
78
+ set display ":0.0"
79
+ }
80
+ }
81
+ }
82
+
83
+ # Get state for access to the cleanupHook.
84
+ namespace upvar ::safe S$child state
85
+
86
+ if {![::tcl::OptProcArgGiven "-use"]} {
87
+ # create a decorated toplevel
88
+ lassign [tkTopLevel $child $display] w use
89
+
90
+ # set our delete hook (child arg is added by interpDelete)
91
+ # to clean up both window related code and tkInit(child)
92
+ set state(cleanupHook) [list tkDelete {} $w]
93
+ } else {
94
+ # set our delete hook (child arg is added by interpDelete)
95
+ # to clean up tkInit(child)
96
+ set state(cleanupHook) [list disallowTk]
97
+
98
+ # Let's be nice and also accept tk window names instead of ids
99
+ if {[string match ".*" $use]} {
100
+ set windowName $use
101
+ set use [winfo id $windowName]
102
+ set nDisplay [winfo screen $windowName]
103
+ } else {
104
+ # Check for a better -display value
105
+ # (works only for multi screens on single host, but not
106
+ # cross hosts, for that a tk window name would be better
107
+ # but embeding is also usefull for non tk names)
108
+ if {![catch {winfo pathname $use} name]} {
109
+ set nDisplay [winfo screen $name]
110
+ } else {
111
+ # Can't have a better one
112
+ set nDisplay $display
113
+ }
114
+ }
115
+ if {$nDisplay ne $display} {
116
+ if {$displayGiven} {
117
+ return -code error -errorcode {TK DISPLAY SAFE} \
118
+ "conflicting -display $display and -use $use -> $nDisplay"
119
+ } else {
120
+ set display $nDisplay
121
+ }
122
+ }
123
+ }
124
+
125
+ # Prepares the child for tk with those parameters
126
+ tkInterpInit $child [list "-use" $use "-display" $display]
127
+
128
+ load {} Tk $child
129
+
130
+ return $child
131
+ }
132
+
133
+ proc ::safe::TkInit {interpPath} {
134
+ variable tkInit
135
+ if {[info exists tkInit($interpPath)]} {
136
+ set value $tkInit($interpPath)
137
+ Log $interpPath "TkInit called, returning \"$value\"" NOTICE
138
+ return $value
139
+ } else {
140
+ Log $interpPath "TkInit called for interp with clearance:\
141
+ preventing Tk init" ERROR
142
+ return -code error -errorcode {TK SAFE PERMISSION} "not allowed"
143
+ }
144
+ }
145
+
146
+ # safe::allowTk --
147
+ #
148
+ # Set tkInit(interpPath) to allow Tk to be initialized in
149
+ # safe::TkInit.
150
+ #
151
+ # Arguments:
152
+ # interpPath child interpreter handle
153
+ # argv arguments passed to safe::TkInterpInit
154
+ #
155
+ # Results:
156
+ # none.
157
+
158
+ proc ::safe::allowTk {interpPath argv} {
159
+ variable tkInit
160
+ set tkInit($interpPath) $argv
161
+ return
162
+ }
163
+
164
+
165
+ # safe::disallowTk --
166
+ #
167
+ # Unset tkInit(interpPath) to disallow Tk from getting initialized
168
+ # in safe::TkInit.
169
+ #
170
+ # Arguments:
171
+ # interpPath child interpreter handle
172
+ #
173
+ # Results:
174
+ # none.
175
+
176
+ proc ::safe::disallowTk {interpPath} {
177
+ variable tkInit
178
+ # This can already be deleted by the DeleteHook of the interp
179
+ if {[info exists tkInit($interpPath)]} {
180
+ unset tkInit($interpPath)
181
+ }
182
+ return
183
+ }
184
+
185
+
186
+ # safe::tkDelete --
187
+ #
188
+ # Clean up the window associated with the interp being deleted.
189
+ #
190
+ # Arguments:
191
+ # interpPath child interpreter handle
192
+ #
193
+ # Results:
194
+ # none.
195
+
196
+ proc ::safe::tkDelete {W window child} {
197
+
198
+ # we are going to be called for each widget... skip untill it's
199
+ # top level
200
+
201
+ Log $child "Called tkDelete $W $window" NOTICE
202
+ if {[::interp exists $child]} {
203
+ if {[catch {::safe::interpDelete $child} msg]} {
204
+ Log $child "Deletion error : $msg"
205
+ }
206
+ }
207
+ if {[winfo exists $window]} {
208
+ Log $child "Destroy toplevel $window" NOTICE
209
+ destroy $window
210
+ }
211
+
212
+ # clean up tkInit(child)
213
+ disallowTk $child
214
+ return
215
+ }
216
+
217
+ proc ::safe::tkTopLevel {child display} {
218
+ variable tkSafeId
219
+ incr tkSafeId
220
+ set w ".safe$tkSafeId"
221
+ if {[catch {toplevel $w -screen $display -class SafeTk} msg]} {
222
+ return -code error -errorcode {TK TOPLEVEL SAFE} \
223
+ "Unable to create toplevel for \"$child\" ($msg)"
224
+ }
225
+ Log $child "New toplevel $w" NOTICE
226
+
227
+ set msg "Untrusted Tcl applet ($child)"
228
+ wm title $w $msg
229
+
230
+ # Control frame (we must create a style for it)
231
+ ttk::style layout TWarningFrame {WarningFrame.border -sticky nswe}
232
+ ttk::style configure TWarningFrame -background red
233
+
234
+ set wc $w.fc
235
+ ttk::frame $wc -relief ridge -borderwidth 4 -style TWarningFrame
236
+
237
+ # We will destroy the interp when the window is destroyed
238
+ bindtags $wc [concat Safe$wc [bindtags $wc]]
239
+ bind Safe$wc <Destroy> [list ::safe::tkDelete %W $w $child]
240
+
241
+ ttk::label $wc.l -text $msg -anchor w
242
+
243
+ # We want the button to be the last visible item
244
+ # (so be packed first) and at the right and not resizing horizontally
245
+
246
+ # frame the button so it does not expand horizontally
247
+ # but still have the default background instead of red one from the parent
248
+ ttk::frame $wc.fb -borderwidth 0
249
+ ttk::button $wc.fb.b -text "Delete" \
250
+ -command [list ::safe::tkDelete $w $w $child]
251
+ pack $wc.fb.b -side right -fill both
252
+ pack $wc.fb -side right -fill both -expand 1
253
+ pack $wc.l -side left -fill both -expand 1 -ipady 2
254
+ pack $wc -side bottom -fill x
255
+
256
+ # Container frame
257
+ frame $w.c -container 1
258
+ pack $w.c -fill both -expand 1
259
+
260
+ # return both the toplevel window name and the id to use for embedding
261
+ list $w [winfo id $w.c]
262
+ }
janus/lib/tk8.6/scrlbar.tcl ADDED
@@ -0,0 +1,456 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # scrlbar.tcl --
2
+ #
3
+ # This file defines the default bindings for Tk scrollbar widgets.
4
+ # It also provides procedures that help in implementing the bindings.
5
+ #
6
+ # Copyright (c) 1994 The Regents of the University of California.
7
+ # Copyright (c) 1994-1996 Sun Microsystems, Inc.
8
+ #
9
+ # See the file "license.terms" for information on usage and redistribution
10
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11
+ #
12
+
13
+ #-------------------------------------------------------------------------
14
+ # The code below creates the default class bindings for scrollbars.
15
+ #-------------------------------------------------------------------------
16
+
17
+ # Standard Motif bindings:
18
+ if {[tk windowingsystem] eq "x11" || [tk windowingsystem] eq "aqua"} {
19
+
20
+ bind Scrollbar <Enter> {
21
+ if {$tk_strictMotif} {
22
+ set tk::Priv(activeBg) [%W cget -activebackground]
23
+ %W configure -activebackground [%W cget -background]
24
+ }
25
+ %W activate [%W identify %x %y]
26
+ }
27
+ bind Scrollbar <Motion> {
28
+ %W activate [%W identify %x %y]
29
+ }
30
+
31
+ # The "info exists" command in the following binding handles the
32
+ # situation where a Leave event occurs for a scrollbar without the Enter
33
+ # event. This seems to happen on some systems (such as Solaris 2.4) for
34
+ # unknown reasons.
35
+
36
+ bind Scrollbar <Leave> {
37
+ if {$tk_strictMotif && [info exists tk::Priv(activeBg)]} {
38
+ %W configure -activebackground $tk::Priv(activeBg)
39
+ }
40
+ %W activate {}
41
+ }
42
+ bind Scrollbar <1> {
43
+ tk::ScrollButtonDown %W %x %y
44
+ }
45
+ bind Scrollbar <B1-Motion> {
46
+ tk::ScrollDrag %W %x %y
47
+ }
48
+ bind Scrollbar <B1-B2-Motion> {
49
+ tk::ScrollDrag %W %x %y
50
+ }
51
+ bind Scrollbar <ButtonRelease-1> {
52
+ tk::ScrollButtonUp %W %x %y
53
+ }
54
+ bind Scrollbar <B1-Leave> {
55
+ # Prevents <Leave> binding from being invoked.
56
+ }
57
+ bind Scrollbar <B1-Enter> {
58
+ # Prevents <Enter> binding from being invoked.
59
+ }
60
+ bind Scrollbar <2> {
61
+ tk::ScrollButton2Down %W %x %y
62
+ }
63
+ bind Scrollbar <B1-2> {
64
+ # Do nothing, since button 1 is already down.
65
+ }
66
+ bind Scrollbar <B2-1> {
67
+ # Do nothing, since button 2 is already down.
68
+ }
69
+ bind Scrollbar <B2-Motion> {
70
+ tk::ScrollDrag %W %x %y
71
+ }
72
+ bind Scrollbar <ButtonRelease-2> {
73
+ tk::ScrollButtonUp %W %x %y
74
+ }
75
+ bind Scrollbar <B1-ButtonRelease-2> {
76
+ # Do nothing: B1 release will handle it.
77
+ }
78
+ bind Scrollbar <B2-ButtonRelease-1> {
79
+ # Do nothing: B2 release will handle it.
80
+ }
81
+ bind Scrollbar <B2-Leave> {
82
+ # Prevents <Leave> binding from being invoked.
83
+ }
84
+ bind Scrollbar <B2-Enter> {
85
+ # Prevents <Enter> binding from being invoked.
86
+ }
87
+ bind Scrollbar <Control-1> {
88
+ tk::ScrollTopBottom %W %x %y
89
+ }
90
+ bind Scrollbar <Control-2> {
91
+ tk::ScrollTopBottom %W %x %y
92
+ }
93
+
94
+ bind Scrollbar <<PrevLine>> {
95
+ tk::ScrollByUnits %W v -1
96
+ }
97
+ bind Scrollbar <<NextLine>> {
98
+ tk::ScrollByUnits %W v 1
99
+ }
100
+ bind Scrollbar <<PrevPara>> {
101
+ tk::ScrollByPages %W v -1
102
+ }
103
+ bind Scrollbar <<NextPara>> {
104
+ tk::ScrollByPages %W v 1
105
+ }
106
+ bind Scrollbar <<PrevChar>> {
107
+ tk::ScrollByUnits %W h -1
108
+ }
109
+ bind Scrollbar <<NextChar>> {
110
+ tk::ScrollByUnits %W h 1
111
+ }
112
+ bind Scrollbar <<PrevWord>> {
113
+ tk::ScrollByPages %W h -1
114
+ }
115
+ bind Scrollbar <<NextWord>> {
116
+ tk::ScrollByPages %W h 1
117
+ }
118
+ bind Scrollbar <Prior> {
119
+ tk::ScrollByPages %W hv -1
120
+ }
121
+ bind Scrollbar <Next> {
122
+ tk::ScrollByPages %W hv 1
123
+ }
124
+ bind Scrollbar <<LineStart>> {
125
+ tk::ScrollToPos %W 0
126
+ }
127
+ bind Scrollbar <<LineEnd>> {
128
+ tk::ScrollToPos %W 1
129
+ }
130
+ }
131
+
132
+ if {[tk windowingsystem] eq "aqua"} {
133
+ bind Scrollbar <MouseWheel> {
134
+ tk::ScrollByUnits %W v [expr {-(%D)}]
135
+ }
136
+ bind Scrollbar <Option-MouseWheel> {
137
+ tk::ScrollByUnits %W v [expr {-10 * (%D)}]
138
+ }
139
+ bind Scrollbar <Shift-MouseWheel> {
140
+ tk::ScrollByUnits %W h [expr {-(%D)}]
141
+ }
142
+ bind Scrollbar <Shift-Option-MouseWheel> {
143
+ tk::ScrollByUnits %W h [expr {-10 * (%D)}]
144
+ }
145
+ } else {
146
+ bind Scrollbar <MouseWheel> {
147
+ if {%D >= 0} {
148
+ tk::ScrollByUnits %W v [expr {-%D/30}]
149
+ } else {
150
+ tk::ScrollByUnits %W v [expr {(29-%D)/30}]
151
+ }
152
+ }
153
+ bind Scrollbar <Shift-MouseWheel> {
154
+ if {%D >= 0} {
155
+ tk::ScrollByUnits %W h [expr {-%D/30}]
156
+ } else {
157
+ tk::ScrollByUnits %W h [expr {(29-%D)/30}]
158
+ }
159
+ }
160
+ }
161
+
162
+ if {[tk windowingsystem] eq "x11"} {
163
+ bind Scrollbar <4> {tk::ScrollByUnits %W v -5}
164
+ bind Scrollbar <5> {tk::ScrollByUnits %W v 5}
165
+ bind Scrollbar <Shift-4> {tk::ScrollByUnits %W h -5}
166
+ bind Scrollbar <Shift-5> {tk::ScrollByUnits %W h 5}
167
+ }
168
+
169
+ # tk::ScrollButtonDown --
170
+ # This procedure is invoked when a button is pressed in a scrollbar.
171
+ # It changes the way the scrollbar is displayed and takes actions
172
+ # depending on where the mouse is.
173
+ #
174
+ # Arguments:
175
+ # w - The scrollbar widget.
176
+ # x, y - Mouse coordinates.
177
+
178
+ proc tk::ScrollButtonDown {w x y} {
179
+ variable ::tk::Priv
180
+ set Priv(relief) [$w cget -activerelief]
181
+ $w configure -activerelief sunken
182
+ set element [$w identify $x $y]
183
+ if {$element eq "slider"} {
184
+ ScrollStartDrag $w $x $y
185
+ } else {
186
+ ScrollSelect $w $element initial
187
+ }
188
+ }
189
+
190
+ # ::tk::ScrollButtonUp --
191
+ # This procedure is invoked when a button is released in a scrollbar.
192
+ # It cancels scans and auto-repeats that were in progress, and restores
193
+ # the way the active element is displayed.
194
+ #
195
+ # Arguments:
196
+ # w - The scrollbar widget.
197
+ # x, y - Mouse coordinates.
198
+
199
+ proc ::tk::ScrollButtonUp {w x y} {
200
+ variable ::tk::Priv
201
+ tk::CancelRepeat
202
+ if {[info exists Priv(relief)]} {
203
+ # Avoid error due to spurious release events
204
+ $w configure -activerelief $Priv(relief)
205
+ ScrollEndDrag $w $x $y
206
+ $w activate [$w identify $x $y]
207
+ }
208
+ }
209
+
210
+ # ::tk::ScrollSelect --
211
+ # This procedure is invoked when a button is pressed over the scrollbar.
212
+ # It invokes one of several scrolling actions depending on where in
213
+ # the scrollbar the button was pressed.
214
+ #
215
+ # Arguments:
216
+ # w - The scrollbar widget.
217
+ # element - The element of the scrollbar that was selected, such
218
+ # as "arrow1" or "trough2". Shouldn't be "slider".
219
+ # repeat - Whether and how to auto-repeat the action: "noRepeat"
220
+ # means don't auto-repeat, "initial" means this is the
221
+ # first action in an auto-repeat sequence, and "again"
222
+ # means this is the second repetition or later.
223
+
224
+ proc ::tk::ScrollSelect {w element repeat} {
225
+ variable ::tk::Priv
226
+ if {![winfo exists $w]} return
227
+ switch -- $element {
228
+ "arrow1" {ScrollByUnits $w hv -1}
229
+ "trough1" {ScrollByPages $w hv -1}
230
+ "trough2" {ScrollByPages $w hv 1}
231
+ "arrow2" {ScrollByUnits $w hv 1}
232
+ default {return}
233
+ }
234
+ if {$repeat eq "again"} {
235
+ set Priv(afterId) [after [$w cget -repeatinterval] \
236
+ [list tk::ScrollSelect $w $element again]]
237
+ } elseif {$repeat eq "initial"} {
238
+ set delay [$w cget -repeatdelay]
239
+ if {$delay > 0} {
240
+ set Priv(afterId) [after $delay \
241
+ [list tk::ScrollSelect $w $element again]]
242
+ }
243
+ }
244
+ }
245
+
246
+ # ::tk::ScrollStartDrag --
247
+ # This procedure is called to initiate a drag of the slider. It just
248
+ # remembers the starting position of the mouse and slider.
249
+ #
250
+ # Arguments:
251
+ # w - The scrollbar widget.
252
+ # x, y - The mouse position at the start of the drag operation.
253
+
254
+ proc ::tk::ScrollStartDrag {w x y} {
255
+ variable ::tk::Priv
256
+
257
+ if {[$w cget -command] eq ""} {
258
+ return
259
+ }
260
+ set Priv(pressX) $x
261
+ set Priv(pressY) $y
262
+ set Priv(initValues) [$w get]
263
+ set iv0 [lindex $Priv(initValues) 0]
264
+ if {[llength $Priv(initValues)] == 2} {
265
+ set Priv(initPos) $iv0
266
+ } elseif {$iv0 == 0} {
267
+ set Priv(initPos) 0.0
268
+ } else {
269
+ set Priv(initPos) [expr {(double([lindex $Priv(initValues) 2])) \
270
+ / [lindex $Priv(initValues) 0]}]
271
+ }
272
+ }
273
+
274
+ # ::tk::ScrollDrag --
275
+ # This procedure is called for each mouse motion even when the slider
276
+ # is being dragged. It notifies the associated widget if we're not
277
+ # jump scrolling, and it just updates the scrollbar if we are jump
278
+ # scrolling.
279
+ #
280
+ # Arguments:
281
+ # w - The scrollbar widget.
282
+ # x, y - The current mouse position.
283
+
284
+ proc ::tk::ScrollDrag {w x y} {
285
+ variable ::tk::Priv
286
+
287
+ if {$Priv(initPos) eq ""} {
288
+ return
289
+ }
290
+ set delta [$w delta [expr {$x - $Priv(pressX)}] [expr {$y - $Priv(pressY)}]]
291
+ if {[$w cget -jump]} {
292
+ if {[llength $Priv(initValues)] == 2} {
293
+ $w set [expr {[lindex $Priv(initValues) 0] + $delta}] \
294
+ [expr {[lindex $Priv(initValues) 1] + $delta}]
295
+ } else {
296
+ set delta [expr {round($delta * [lindex $Priv(initValues) 0])}]
297
+ eval [list $w] set [lreplace $Priv(initValues) 2 3 \
298
+ [expr {[lindex $Priv(initValues) 2] + $delta}] \
299
+ [expr {[lindex $Priv(initValues) 3] + $delta}]]
300
+ }
301
+ } else {
302
+ ScrollToPos $w [expr {$Priv(initPos) + $delta}]
303
+ }
304
+ }
305
+
306
+ # ::tk::ScrollEndDrag --
307
+ # This procedure is called to end an interactive drag of the slider.
308
+ # It scrolls the window if we're in jump mode, otherwise it does nothing.
309
+ #
310
+ # Arguments:
311
+ # w - The scrollbar widget.
312
+ # x, y - The mouse position at the end of the drag operation.
313
+
314
+ proc ::tk::ScrollEndDrag {w x y} {
315
+ variable ::tk::Priv
316
+
317
+ if {$Priv(initPos) eq ""} {
318
+ return
319
+ }
320
+ if {[$w cget -jump]} {
321
+ set delta [$w delta [expr {$x - $Priv(pressX)}] \
322
+ [expr {$y - $Priv(pressY)}]]
323
+ ScrollToPos $w [expr {$Priv(initPos) + $delta}]
324
+ }
325
+ set Priv(initPos) ""
326
+ }
327
+
328
+ # ::tk::ScrollByUnits --
329
+ # This procedure tells the scrollbar's associated widget to scroll up
330
+ # or down by a given number of units. It notifies the associated widget
331
+ # in different ways for old and new command syntaxes.
332
+ #
333
+ # Arguments:
334
+ # w - The scrollbar widget.
335
+ # orient - Which kinds of scrollbars this applies to: "h" for
336
+ # horizontal, "v" for vertical, "hv" for both.
337
+ # amount - How many units to scroll: typically 1 or -1.
338
+
339
+ proc ::tk::ScrollByUnits {w orient amount} {
340
+ set cmd [$w cget -command]
341
+ if {$cmd eq "" || ([string first \
342
+ [string index [$w cget -orient] 0] $orient] < 0)} {
343
+ return
344
+ }
345
+ set info [$w get]
346
+ if {[llength $info] == 2} {
347
+ uplevel #0 $cmd scroll $amount units
348
+ } else {
349
+ uplevel #0 $cmd [expr {[lindex $info 2] + $amount}]
350
+ }
351
+ }
352
+
353
+ # ::tk::ScrollByPages --
354
+ # This procedure tells the scrollbar's associated widget to scroll up
355
+ # or down by a given number of screenfuls. It notifies the associated
356
+ # widget in different ways for old and new command syntaxes.
357
+ #
358
+ # Arguments:
359
+ # w - The scrollbar widget.
360
+ # orient - Which kinds of scrollbars this applies to: "h" for
361
+ # horizontal, "v" for vertical, "hv" for both.
362
+ # amount - How many screens to scroll: typically 1 or -1.
363
+
364
+ proc ::tk::ScrollByPages {w orient amount} {
365
+ set cmd [$w cget -command]
366
+ if {$cmd eq "" || ([string first \
367
+ [string index [$w cget -orient] 0] $orient] < 0)} {
368
+ return
369
+ }
370
+ set info [$w get]
371
+ if {[llength $info] == 2} {
372
+ uplevel #0 $cmd scroll $amount pages
373
+ } else {
374
+ uplevel #0 $cmd [expr {[lindex $info 2] + $amount*([lindex $info 1] - 1)}]
375
+ }
376
+ }
377
+
378
+ # ::tk::ScrollToPos --
379
+ # This procedure tells the scrollbar's associated widget to scroll to
380
+ # a particular location, given by a fraction between 0 and 1. It notifies
381
+ # the associated widget in different ways for old and new command syntaxes.
382
+ #
383
+ # Arguments:
384
+ # w - The scrollbar widget.
385
+ # pos - A fraction between 0 and 1 indicating a desired position
386
+ # in the document.
387
+
388
+ proc ::tk::ScrollToPos {w pos} {
389
+ set cmd [$w cget -command]
390
+ if {$cmd eq ""} {
391
+ return
392
+ }
393
+ set info [$w get]
394
+ if {[llength $info] == 2} {
395
+ uplevel #0 $cmd moveto $pos
396
+ } else {
397
+ uplevel #0 $cmd [expr {round([lindex $info 0]*$pos)}]
398
+ }
399
+ }
400
+
401
+ # ::tk::ScrollTopBottom
402
+ # Scroll to the top or bottom of the document, depending on the mouse
403
+ # position.
404
+ #
405
+ # Arguments:
406
+ # w - The scrollbar widget.
407
+ # x, y - Mouse coordinates within the widget.
408
+
409
+ proc ::tk::ScrollTopBottom {w x y} {
410
+ variable ::tk::Priv
411
+ set element [$w identify $x $y]
412
+ if {[string match *1 $element]} {
413
+ ScrollToPos $w 0
414
+ } elseif {[string match *2 $element]} {
415
+ ScrollToPos $w 1
416
+ }
417
+
418
+ # Set Priv(relief), since it's needed by tk::ScrollButtonUp.
419
+
420
+ set Priv(relief) [$w cget -activerelief]
421
+ }
422
+
423
+ # ::tk::ScrollButton2Down
424
+ # This procedure is invoked when button 2 is pressed over a scrollbar.
425
+ # If the button is over the trough or slider, it sets the scrollbar to
426
+ # the mouse position and starts a slider drag. Otherwise it just
427
+ # behaves the same as button 1.
428
+ #
429
+ # Arguments:
430
+ # w - The scrollbar widget.
431
+ # x, y - Mouse coordinates within the widget.
432
+
433
+ proc ::tk::ScrollButton2Down {w x y} {
434
+ variable ::tk::Priv
435
+ if {![winfo exists $w]} {
436
+ return
437
+ }
438
+ set element [$w identify $x $y]
439
+ if {[string match {arrow[12]} $element]} {
440
+ ScrollButtonDown $w $x $y
441
+ return
442
+ }
443
+ ScrollToPos $w [$w fraction $x $y]
444
+ set Priv(relief) [$w cget -activerelief]
445
+
446
+ # Need the "update idletasks" below so that the widget calls us
447
+ # back to reset the actual scrollbar position before we start the
448
+ # slider drag.
449
+
450
+ update idletasks
451
+ if {[winfo exists $w]} {
452
+ $w configure -activerelief sunken
453
+ $w activate slider
454
+ ScrollStartDrag $w $x $y
455
+ }
456
+ }
janus/lib/tk8.6/tclIndex ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(::tk::dialog::error::Return) [list source [file join $dir bgerror.tcl]]
10
+ set auto_index(::tk::dialog::error::Details) [list source [file join $dir bgerror.tcl]]
11
+ set auto_index(::tk::dialog::error::SaveToLog) [list source [file join $dir bgerror.tcl]]
12
+ set auto_index(::tk::dialog::error::Destroy) [list source [file join $dir bgerror.tcl]]
13
+ set auto_index(::tk::dialog::error::bgerror) [list source [file join $dir bgerror.tcl]]
14
+ set auto_index(bgerror) [list source [file join $dir bgerror.tcl]]
15
+ set auto_index(::tk::ButtonInvoke) [list source [file join $dir button.tcl]]
16
+ set auto_index(::tk::ButtonAutoInvoke) [list source [file join $dir button.tcl]]
17
+ set auto_index(::tk::CheckRadioInvoke) [list source [file join $dir button.tcl]]
18
+ set auto_index(::tk::dialog::file::chooseDir::) [list source [file join $dir choosedir.tcl]]
19
+ set auto_index(::tk::dialog::file::chooseDir::Config) [list source [file join $dir choosedir.tcl]]
20
+ set auto_index(::tk::dialog::file::chooseDir::OkCmd) [list source [file join $dir choosedir.tcl]]
21
+ set auto_index(::tk::dialog::file::chooseDir::DblClick) [list source [file join $dir choosedir.tcl]]
22
+ set auto_index(::tk::dialog::file::chooseDir::ListBrowse) [list source [file join $dir choosedir.tcl]]
23
+ set auto_index(::tk::dialog::file::chooseDir::Done) [list source [file join $dir choosedir.tcl]]
24
+ set auto_index(::tk::dialog::color::) [list source [file join $dir clrpick.tcl]]
25
+ set auto_index(::tk::dialog::color::InitValues) [list source [file join $dir clrpick.tcl]]
26
+ set auto_index(::tk::dialog::color::Config) [list source [file join $dir clrpick.tcl]]
27
+ set auto_index(::tk::dialog::color::BuildDialog) [list source [file join $dir clrpick.tcl]]
28
+ set auto_index(::tk::dialog::color::SetRGBValue) [list source [file join $dir clrpick.tcl]]
29
+ set auto_index(::tk::dialog::color::XToRgb) [list source [file join $dir clrpick.tcl]]
30
+ set auto_index(::tk::dialog::color::RgbToX) [list source [file join $dir clrpick.tcl]]
31
+ set auto_index(::tk::dialog::color::DrawColorScale) [list source [file join $dir clrpick.tcl]]
32
+ set auto_index(::tk::dialog::color::CreateSelector) [list source [file join $dir clrpick.tcl]]
33
+ set auto_index(::tk::dialog::color::RedrawFinalColor) [list source [file join $dir clrpick.tcl]]
34
+ set auto_index(::tk::dialog::color::RedrawColorBars) [list source [file join $dir clrpick.tcl]]
35
+ set auto_index(::tk::dialog::color::StartMove) [list source [file join $dir clrpick.tcl]]
36
+ set auto_index(::tk::dialog::color::MoveSelector) [list source [file join $dir clrpick.tcl]]
37
+ set auto_index(::tk::dialog::color::ReleaseMouse) [list source [file join $dir clrpick.tcl]]
38
+ set auto_index(::tk::dialog::color::ResizeColorBars) [list source [file join $dir clrpick.tcl]]
39
+ set auto_index(::tk::dialog::color::HandleSelEntry) [list source [file join $dir clrpick.tcl]]
40
+ set auto_index(::tk::dialog::color::HandleRGBEntry) [list source [file join $dir clrpick.tcl]]
41
+ set auto_index(::tk::dialog::color::EnterColorBar) [list source [file join $dir clrpick.tcl]]
42
+ set auto_index(::tk::dialog::color::LeaveColorBar) [list source [file join $dir clrpick.tcl]]
43
+ set auto_index(::tk::dialog::color::OkCmd) [list source [file join $dir clrpick.tcl]]
44
+ set auto_index(::tk::dialog::color::CancelCmd) [list source [file join $dir clrpick.tcl]]
45
+ set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]]
46
+ set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]]
47
+ set auto_index(::tk::FocusGroup_Create) [list source [file join $dir comdlg.tcl]]
48
+ set auto_index(::tk::FocusGroup_BindIn) [list source [file join $dir comdlg.tcl]]
49
+ set auto_index(::tk::FocusGroup_BindOut) [list source [file join $dir comdlg.tcl]]
50
+ set auto_index(::tk::FocusGroup_Destroy) [list source [file join $dir comdlg.tcl]]
51
+ set auto_index(::tk::FocusGroup_In) [list source [file join $dir comdlg.tcl]]
52
+ set auto_index(::tk::FocusGroup_Out) [list source [file join $dir comdlg.tcl]]
53
+ set auto_index(::tk::FDGetFileTypes) [list source [file join $dir comdlg.tcl]]
54
+ set auto_index(::tk::ConsoleInit) [list source [file join $dir console.tcl]]
55
+ set auto_index(::tk::ConsoleSource) [list source [file join $dir console.tcl]]
56
+ set auto_index(::tk::ConsoleInvoke) [list source [file join $dir console.tcl]]
57
+ set auto_index(::tk::ConsoleHistory) [list source [file join $dir console.tcl]]
58
+ set auto_index(::tk::ConsolePrompt) [list source [file join $dir console.tcl]]
59
+ set auto_index(::tk::ConsoleBind) [list source [file join $dir console.tcl]]
60
+ set auto_index(::tk::ConsoleInsert) [list source [file join $dir console.tcl]]
61
+ set auto_index(::tk::ConsoleOutput) [list source [file join $dir console.tcl]]
62
+ set auto_index(::tk::ConsoleExit) [list source [file join $dir console.tcl]]
63
+ set auto_index(::tk::ConsoleAbout) [list source [file join $dir console.tcl]]
64
+ set auto_index(tk_dialog) [list source [file join $dir dialog.tcl]]
65
+ set auto_index(::tk::EntryClosestGap) [list source [file join $dir entry.tcl]]
66
+ set auto_index(::tk::EntryButton1) [list source [file join $dir entry.tcl]]
67
+ set auto_index(::tk::EntryMouseSelect) [list source [file join $dir entry.tcl]]
68
+ set auto_index(::tk::EntryPaste) [list source [file join $dir entry.tcl]]
69
+ set auto_index(::tk::EntryAutoScan) [list source [file join $dir entry.tcl]]
70
+ set auto_index(::tk::EntryKeySelect) [list source [file join $dir entry.tcl]]
71
+ set auto_index(::tk::EntryInsert) [list source [file join $dir entry.tcl]]
72
+ set auto_index(::tk::EntryBackspace) [list source [file join $dir entry.tcl]]
73
+ set auto_index(::tk::EntrySeeInsert) [list source [file join $dir entry.tcl]]
74
+ set auto_index(::tk::EntrySetCursor) [list source [file join $dir entry.tcl]]
75
+ set auto_index(::tk::EntryTranspose) [list source [file join $dir entry.tcl]]
76
+ set auto_index(::tk::EntryPreviousWord) [list source [file join $dir entry.tcl]]
77
+ set auto_index(::tk::EntryGetSelection) [list source [file join $dir entry.tcl]]
78
+ set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]]
79
+ set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]]
80
+ set auto_index(::tk::FocusOK) [list source [file join $dir focus.tcl]]
81
+ set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]]
82
+ set auto_index(::tk::IconList) [list source [file join $dir iconlist.tcl]]
83
+ set auto_index(::tk::ListboxBeginSelect) [list source [file join $dir listbox.tcl]]
84
+ set auto_index(::tk::ListboxMotion) [list source [file join $dir listbox.tcl]]
85
+ set auto_index(::tk::ListboxBeginExtend) [list source [file join $dir listbox.tcl]]
86
+ set auto_index(::tk::ListboxBeginToggle) [list source [file join $dir listbox.tcl]]
87
+ set auto_index(::tk::ListboxAutoScan) [list source [file join $dir listbox.tcl]]
88
+ set auto_index(::tk::ListboxUpDown) [list source [file join $dir listbox.tcl]]
89
+ set auto_index(::tk::ListboxExtendUpDown) [list source [file join $dir listbox.tcl]]
90
+ set auto_index(::tk::ListboxDataExtend) [list source [file join $dir listbox.tcl]]
91
+ set auto_index(::tk::ListboxCancel) [list source [file join $dir listbox.tcl]]
92
+ set auto_index(::tk::ListboxSelectAll) [list source [file join $dir listbox.tcl]]
93
+ set auto_index(::tk::Megawidget) [list source [file join $dir megawidget.tcl]]
94
+ set auto_index(::tk::MbEnter) [list source [file join $dir menu.tcl]]
95
+ set auto_index(::tk::MbLeave) [list source [file join $dir menu.tcl]]
96
+ set auto_index(::tk::MbPost) [list source [file join $dir menu.tcl]]
97
+ set auto_index(::tk::MenuUnpost) [list source [file join $dir menu.tcl]]
98
+ set auto_index(::tk::MbMotion) [list source [file join $dir menu.tcl]]
99
+ set auto_index(::tk::MbButtonUp) [list source [file join $dir menu.tcl]]
100
+ set auto_index(::tk::MenuMotion) [list source [file join $dir menu.tcl]]
101
+ set auto_index(::tk::MenuButtonDown) [list source [file join $dir menu.tcl]]
102
+ set auto_index(::tk::MenuLeave) [list source [file join $dir menu.tcl]]
103
+ set auto_index(::tk::MenuInvoke) [list source [file join $dir menu.tcl]]
104
+ set auto_index(::tk::MenuEscape) [list source [file join $dir menu.tcl]]
105
+ set auto_index(::tk::MenuUpArrow) [list source [file join $dir menu.tcl]]
106
+ set auto_index(::tk::MenuDownArrow) [list source [file join $dir menu.tcl]]
107
+ set auto_index(::tk::MenuLeftArrow) [list source [file join $dir menu.tcl]]
108
+ set auto_index(::tk::MenuRightArrow) [list source [file join $dir menu.tcl]]
109
+ set auto_index(::tk::MenuNextMenu) [list source [file join $dir menu.tcl]]
110
+ set auto_index(::tk::MenuNextEntry) [list source [file join $dir menu.tcl]]
111
+ set auto_index(::tk::MenuFind) [list source [file join $dir menu.tcl]]
112
+ set auto_index(::tk::TraverseToMenu) [list source [file join $dir menu.tcl]]
113
+ set auto_index(::tk::FirstMenu) [list source [file join $dir menu.tcl]]
114
+ set auto_index(::tk::TraverseWithinMenu) [list source [file join $dir menu.tcl]]
115
+ set auto_index(::tk::MenuFirstEntry) [list source [file join $dir menu.tcl]]
116
+ set auto_index(::tk::MenuFindName) [list source [file join $dir menu.tcl]]
117
+ set auto_index(::tk::PostOverPoint) [list source [file join $dir menu.tcl]]
118
+ set auto_index(::tk::SaveGrabInfo) [list source [file join $dir menu.tcl]]
119
+ set auto_index(::tk::RestoreOldGrab) [list source [file join $dir menu.tcl]]
120
+ set auto_index(tk_menuSetFocus) [list source [file join $dir menu.tcl]]
121
+ set auto_index(::tk::GenerateMenuSelect) [list source [file join $dir menu.tcl]]
122
+ set auto_index(tk_popup) [list source [file join $dir menu.tcl]]
123
+ set auto_index(::tk::ensure_psenc_is_loaded) [list source [file join $dir mkpsenc.tcl]]
124
+ set auto_index(::tk::MessageBox) [list source [file join $dir msgbox.tcl]]
125
+ set auto_index(tk_menuBar) [list source [file join $dir obsolete.tcl]]
126
+ set auto_index(tk_bindForTraversal) [list source [file join $dir obsolete.tcl]]
127
+ set auto_index(::tk::classic::restore) [list source [file join $dir obsolete.tcl]]
128
+ set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]]
129
+ set auto_index(tk_setPalette) [list source [file join $dir palette.tcl]]
130
+ set auto_index(::tk::RecolorTree) [list source [file join $dir palette.tcl]]
131
+ set auto_index(::tk::Darken) [list source [file join $dir palette.tcl]]
132
+ set auto_index(tk_bisque) [list source [file join $dir palette.tcl]]
133
+ set auto_index(::safe::tkInterpInit) [list source [file join $dir safetk.tcl]]
134
+ set auto_index(::safe::loadTk) [list source [file join $dir safetk.tcl]]
135
+ set auto_index(::safe::TkInit) [list source [file join $dir safetk.tcl]]
136
+ set auto_index(::safe::allowTk) [list source [file join $dir safetk.tcl]]
137
+ set auto_index(::safe::disallowTk) [list source [file join $dir safetk.tcl]]
138
+ set auto_index(::safe::tkDelete) [list source [file join $dir safetk.tcl]]
139
+ set auto_index(::safe::tkTopLevel) [list source [file join $dir safetk.tcl]]
140
+ set auto_index(::tk::ScaleActivate) [list source [file join $dir scale.tcl]]
141
+ set auto_index(::tk::ScaleButtonDown) [list source [file join $dir scale.tcl]]
142
+ set auto_index(::tk::ScaleDrag) [list source [file join $dir scale.tcl]]
143
+ set auto_index(::tk::ScaleEndDrag) [list source [file join $dir scale.tcl]]
144
+ set auto_index(::tk::ScaleIncrement) [list source [file join $dir scale.tcl]]
145
+ set auto_index(::tk::ScaleControlPress) [list source [file join $dir scale.tcl]]
146
+ set auto_index(::tk::ScaleButton2Down) [list source [file join $dir scale.tcl]]
147
+ set auto_index(::tk::ScrollButtonDown) [list source [file join $dir scrlbar.tcl]]
148
+ set auto_index(::tk::ScrollButtonUp) [list source [file join $dir scrlbar.tcl]]
149
+ set auto_index(::tk::ScrollSelect) [list source [file join $dir scrlbar.tcl]]
150
+ set auto_index(::tk::ScrollStartDrag) [list source [file join $dir scrlbar.tcl]]
151
+ set auto_index(::tk::ScrollDrag) [list source [file join $dir scrlbar.tcl]]
152
+ set auto_index(::tk::ScrollEndDrag) [list source [file join $dir scrlbar.tcl]]
153
+ set auto_index(::tk::ScrollByUnits) [list source [file join $dir scrlbar.tcl]]
154
+ set auto_index(::tk::ScrollByPages) [list source [file join $dir scrlbar.tcl]]
155
+ set auto_index(::tk::ScrollToPos) [list source [file join $dir scrlbar.tcl]]
156
+ set auto_index(::tk::ScrollTopBottom) [list source [file join $dir scrlbar.tcl]]
157
+ set auto_index(::tk::ScrollButton2Down) [list source [file join $dir scrlbar.tcl]]
158
+ set auto_index(::tk::spinbox::Invoke) [list source [file join $dir spinbox.tcl]]
159
+ set auto_index(::tk::spinbox::ClosestGap) [list source [file join $dir spinbox.tcl]]
160
+ set auto_index(::tk::spinbox::ButtonDown) [list source [file join $dir spinbox.tcl]]
161
+ set auto_index(::tk::spinbox::ButtonUp) [list source [file join $dir spinbox.tcl]]
162
+ set auto_index(::tk::spinbox::MouseSelect) [list source [file join $dir spinbox.tcl]]
163
+ set auto_index(::tk::spinbox::Paste) [list source [file join $dir spinbox.tcl]]
164
+ set auto_index(::tk::spinbox::Motion) [list source [file join $dir spinbox.tcl]]
165
+ set auto_index(::tk::spinbox::AutoScan) [list source [file join $dir spinbox.tcl]]
166
+ set auto_index(::tk::spinbox::KeySelect) [list source [file join $dir spinbox.tcl]]
167
+ set auto_index(::tk::spinbox::Insert) [list source [file join $dir spinbox.tcl]]
168
+ set auto_index(::tk::spinbox::Backspace) [list source [file join $dir spinbox.tcl]]
169
+ set auto_index(::tk::spinbox::SeeInsert) [list source [file join $dir spinbox.tcl]]
170
+ set auto_index(::tk::spinbox::SetCursor) [list source [file join $dir spinbox.tcl]]
171
+ set auto_index(::tk::spinbox::Transpose) [list source [file join $dir spinbox.tcl]]
172
+ set auto_index(::tk::spinbox::PreviousWord) [list source [file join $dir spinbox.tcl]]
173
+ set auto_index(::tk::spinbox::GetSelection) [list source [file join $dir spinbox.tcl]]
174
+ set auto_index(::tk::TearOffMenu) [list source [file join $dir tearoff.tcl]]
175
+ set auto_index(::tk::MenuDup) [list source [file join $dir tearoff.tcl]]
176
+ set auto_index(::tk::TextClosestGap) [list source [file join $dir text.tcl]]
177
+ set auto_index(::tk::TextButton1) [list source [file join $dir text.tcl]]
178
+ set auto_index(::tk::TextSelectTo) [list source [file join $dir text.tcl]]
179
+ set auto_index(::tk::TextKeyExtend) [list source [file join $dir text.tcl]]
180
+ set auto_index(::tk::TextPaste) [list source [file join $dir text.tcl]]
181
+ set auto_index(::tk::TextAutoScan) [list source [file join $dir text.tcl]]
182
+ set auto_index(::tk::TextSetCursor) [list source [file join $dir text.tcl]]
183
+ set auto_index(::tk::TextKeySelect) [list source [file join $dir text.tcl]]
184
+ set auto_index(::tk::TextResetAnchor) [list source [file join $dir text.tcl]]
185
+ set auto_index(::tk::TextInsert) [list source [file join $dir text.tcl]]
186
+ set auto_index(::tk::TextUpDownLine) [list source [file join $dir text.tcl]]
187
+ set auto_index(::tk::TextPrevPara) [list source [file join $dir text.tcl]]
188
+ set auto_index(::tk::TextNextPara) [list source [file join $dir text.tcl]]
189
+ set auto_index(::tk::TextScrollPages) [list source [file join $dir text.tcl]]
190
+ set auto_index(::tk::TextTranspose) [list source [file join $dir text.tcl]]
191
+ set auto_index(tk_textCopy) [list source [file join $dir text.tcl]]
192
+ set auto_index(tk_textCut) [list source [file join $dir text.tcl]]
193
+ set auto_index(tk_textPaste) [list source [file join $dir text.tcl]]
194
+ set auto_index(::tk::TextNextPos) [list source [file join $dir text.tcl]]
195
+ set auto_index(::tk::TextPrevPos) [list source [file join $dir text.tcl]]
196
+ set auto_index(::tk::PlaceWindow) [list source [file join $dir tk.tcl]]
197
+ set auto_index(::tk::SetFocusGrab) [list source [file join $dir tk.tcl]]
198
+ set auto_index(::tk::RestoreFocusGrab) [list source [file join $dir tk.tcl]]
199
+ set auto_index(::tk::ScreenChanged) [list source [file join $dir tk.tcl]]
200
+ set auto_index(::tk::EventMotifBindings) [list source [file join $dir tk.tcl]]
201
+ set auto_index(::tk::CancelRepeat) [list source [file join $dir tk.tcl]]
202
+ set auto_index(::tk::TabToWindow) [list source [file join $dir tk.tcl]]
203
+ set auto_index(::tk::dialog::file::) [list source [file join $dir tkfbox.tcl]]
204
+ set auto_index(::tk::dialog::file::Config) [list source [file join $dir tkfbox.tcl]]
205
+ set auto_index(::tk::dialog::file::Create) [list source [file join $dir tkfbox.tcl]]
206
+ set auto_index(::tk::dialog::file::SetSelectMode) [list source [file join $dir tkfbox.tcl]]
207
+ set auto_index(::tk::dialog::file::UpdateWhenIdle) [list source [file join $dir tkfbox.tcl]]
208
+ set auto_index(::tk::dialog::file::Update) [list source [file join $dir tkfbox.tcl]]
209
+ set auto_index(::tk::dialog::file::SetPathSilently) [list source [file join $dir tkfbox.tcl]]
210
+ set auto_index(::tk::dialog::file::SetPath) [list source [file join $dir tkfbox.tcl]]
211
+ set auto_index(::tk::dialog::file::SetFilter) [list source [file join $dir tkfbox.tcl]]
212
+ set auto_index(::tk::dialog::file::ResolveFile) [list source [file join $dir tkfbox.tcl]]
213
+ set auto_index(::tk::dialog::file::EntFocusIn) [list source [file join $dir tkfbox.tcl]]
214
+ set auto_index(::tk::dialog::file::EntFocusOut) [list source [file join $dir tkfbox.tcl]]
215
+ set auto_index(::tk::dialog::file::ActivateEnt) [list source [file join $dir tkfbox.tcl]]
216
+ set auto_index(::tk::dialog::file::VerifyFileName) [list source [file join $dir tkfbox.tcl]]
217
+ set auto_index(::tk::dialog::file::InvokeBtn) [list source [file join $dir tkfbox.tcl]]
218
+ set auto_index(::tk::dialog::file::UpDirCmd) [list source [file join $dir tkfbox.tcl]]
219
+ set auto_index(::tk::dialog::file::JoinFile) [list source [file join $dir tkfbox.tcl]]
220
+ set auto_index(::tk::dialog::file::OkCmd) [list source [file join $dir tkfbox.tcl]]
221
+ set auto_index(::tk::dialog::file::CancelCmd) [list source [file join $dir tkfbox.tcl]]
222
+ set auto_index(::tk::dialog::file::ListBrowse) [list source [file join $dir tkfbox.tcl]]
223
+ set auto_index(::tk::dialog::file::ListInvoke) [list source [file join $dir tkfbox.tcl]]
224
+ set auto_index(::tk::dialog::file::Done) [list source [file join $dir tkfbox.tcl]]
225
+ set auto_index(::tk::MotifFDialog) [list source [file join $dir xmfbox.tcl]]
226
+ set auto_index(::tk::MotifFDialog_Create) [list source [file join $dir xmfbox.tcl]]
227
+ set auto_index(::tk::MotifFDialog_FileTypes) [list source [file join $dir xmfbox.tcl]]
228
+ set auto_index(::tk::MotifFDialog_SetFilter) [list source [file join $dir xmfbox.tcl]]
229
+ set auto_index(::tk::MotifFDialog_Config) [list source [file join $dir xmfbox.tcl]]
230
+ set auto_index(::tk::MotifFDialog_BuildUI) [list source [file join $dir xmfbox.tcl]]
231
+ set auto_index(::tk::MotifFDialog_SetListMode) [list source [file join $dir xmfbox.tcl]]
232
+ set auto_index(::tk::MotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]]
233
+ set auto_index(::tk::MotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]]
234
+ set auto_index(::tk::MotifFDialog_Update) [list source [file join $dir xmfbox.tcl]]
235
+ set auto_index(::tk::MotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]]
236
+ set auto_index(::tk::MotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]]
237
+ set auto_index(::tk::MotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]]
238
+ set auto_index(::tk::MotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]]
239
+ set auto_index(::tk::MotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]]
240
+ set auto_index(::tk::MotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]]
241
+ set auto_index(::tk::MotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]]
242
+ set auto_index(::tk::MotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]]
243
+ set auto_index(::tk::MotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]]
244
+ set auto_index(::tk::MotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]]
245
+ set auto_index(::tk::ListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]]
246
+ set auto_index(::tk::ListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]]
247
+ set auto_index(::tk::ListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]]
248
+ set auto_index(::tk::ListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]]
249
+ set auto_index(::tk::ListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]]
250
+ set auto_index(tk_getFileType) [list source [file join $dir xmfbox.tcl]]
251
+ set auto_index(::tk::unsupported::ExposePrivateCommand) [list source [file join $dir unsupported.tcl]]
252
+ set auto_index(::tk::unsupported::ExposePrivateVariable) [list source [file join $dir unsupported.tcl]]
253
+ set auto_index(::tk::fontchooser) [list source [file join $dir fontchooser.tcl]]
janus/lib/tk8.6/text.tcl ADDED
@@ -0,0 +1,1242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # text.tcl --
2
+ #
3
+ # This file defines the default bindings for Tk text widgets and provides
4
+ # procedures that help in implementing the bindings.
5
+ #
6
+ # Copyright (c) 1992-1994 The Regents of the University of California.
7
+ # Copyright (c) 1994-1997 Sun Microsystems, Inc.
8
+ # Copyright (c) 1998 by Scriptics Corporation.
9
+ #
10
+ # See the file "license.terms" for information on usage and redistribution
11
+ # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
+ #
13
+
14
+ #-------------------------------------------------------------------------
15
+ # Elements of ::tk::Priv that are used in this file:
16
+ #
17
+ # afterId - If non-null, it means that auto-scanning is underway
18
+ # and it gives the "after" id for the next auto-scan
19
+ # command to be executed.
20
+ # char - Character position on the line; kept in order
21
+ # to allow moving up or down past short lines while
22
+ # still remembering the desired position.
23
+ # mouseMoved - Non-zero means the mouse has moved a significant
24
+ # amount since the button went down (so, for example,
25
+ # start dragging out a selection).
26
+ # prevPos - Used when moving up or down lines via the keyboard.
27
+ # Keeps track of the previous insert position, so
28
+ # we can distinguish a series of ups and downs, all
29
+ # in a row, from a new up or down.
30
+ # selectMode - The style of selection currently underway:
31
+ # char, word, or line.
32
+ # x, y - Last known mouse coordinates for scanning
33
+ # and auto-scanning.
34
+ #
35
+ #-------------------------------------------------------------------------
36
+
37
+ #-------------------------------------------------------------------------
38
+ # The code below creates the default class bindings for text widgets.
39
+ #-------------------------------------------------------------------------
40
+
41
+
42
+
43
+ # Standard Motif bindings:
44
+
45
+ bind Text <1> {
46
+ tk::TextButton1 %W %x %y
47
+ %W tag remove sel 0.0 end
48
+ }
49
+ bind Text <B1-Motion> {
50
+ set tk::Priv(x) %x
51
+ set tk::Priv(y) %y
52
+ tk::TextSelectTo %W %x %y
53
+ }
54
+ bind Text <Double-1> {
55
+ set tk::Priv(selectMode) word
56
+ tk::TextSelectTo %W %x %y
57
+ catch {%W mark set insert sel.first}
58
+ }
59
+ bind Text <Triple-1> {
60
+ set tk::Priv(selectMode) line
61
+ tk::TextSelectTo %W %x %y
62
+ catch {%W mark set insert sel.first}
63
+ }
64
+ bind Text <Shift-1> {
65
+ tk::TextResetAnchor %W @%x,%y
66
+ set tk::Priv(selectMode) char
67
+ tk::TextSelectTo %W %x %y
68
+ }
69
+ bind Text <Double-Shift-1> {
70
+ set tk::Priv(selectMode) word
71
+ tk::TextSelectTo %W %x %y 1
72
+ }
73
+ bind Text <Triple-Shift-1> {
74
+ set tk::Priv(selectMode) line
75
+ tk::TextSelectTo %W %x %y
76
+ }
77
+ bind Text <B1-Leave> {
78
+ set tk::Priv(x) %x
79
+ set tk::Priv(y) %y
80
+ tk::TextAutoScan %W
81
+ }
82
+ bind Text <B1-Enter> {
83
+ tk::CancelRepeat
84
+ }
85
+ bind Text <ButtonRelease-1> {
86
+ tk::CancelRepeat
87
+ }
88
+
89
+ bind Text <Control-1> {
90
+ %W mark set insert @%x,%y
91
+ # An operation that moves the insert mark without making it
92
+ # one end of the selection must insert an autoseparator
93
+ if {[%W cget -autoseparators]} {
94
+ %W edit separator
95
+ }
96
+ }
97
+ # stop an accidental double click triggering <Double-Button-1>
98
+ bind Text <Double-Control-1> { # nothing }
99
+ # stop an accidental movement triggering <B1-Motion>
100
+ bind Text <Control-B1-Motion> { # nothing }
101
+ bind Text <<PrevChar>> {
102
+ tk::TextSetCursor %W insert-1displayindices
103
+ }
104
+ bind Text <<NextChar>> {
105
+ tk::TextSetCursor %W insert+1displayindices
106
+ }
107
+ bind Text <<PrevLine>> {
108
+ tk::TextSetCursor %W [tk::TextUpDownLine %W -1]
109
+ }
110
+ bind Text <<NextLine>> {
111
+ tk::TextSetCursor %W [tk::TextUpDownLine %W 1]
112
+ }
113
+ bind Text <<SelectPrevChar>> {
114
+ tk::TextKeySelect %W [%W index {insert - 1displayindices}]
115
+ }
116
+ bind Text <<SelectNextChar>> {
117
+ tk::TextKeySelect %W [%W index {insert + 1displayindices}]
118
+ }
119
+ bind Text <<SelectPrevLine>> {
120
+ tk::TextKeySelect %W [tk::TextUpDownLine %W -1]
121
+ }
122
+ bind Text <<SelectNextLine>> {
123
+ tk::TextKeySelect %W [tk::TextUpDownLine %W 1]
124
+ }
125
+ bind Text <<PrevWord>> {
126
+ tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
127
+ }
128
+ bind Text <<NextWord>> {
129
+ tk::TextSetCursor %W [tk::TextNextWord %W insert]
130
+ }
131
+ bind Text <<PrevPara>> {
132
+ tk::TextSetCursor %W [tk::TextPrevPara %W insert]
133
+ }
134
+ bind Text <<NextPara>> {
135
+ tk::TextSetCursor %W [tk::TextNextPara %W insert]
136
+ }
137
+ bind Text <<SelectPrevWord>> {
138
+ tk::TextKeySelect %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
139
+ }
140
+ bind Text <<SelectNextWord>> {
141
+ tk::TextKeySelect %W [tk::TextNextWord %W insert]
142
+ }
143
+ bind Text <<SelectPrevPara>> {
144
+ tk::TextKeySelect %W [tk::TextPrevPara %W insert]
145
+ }
146
+ bind Text <<SelectNextPara>> {
147
+ tk::TextKeySelect %W [tk::TextNextPara %W insert]
148
+ }
149
+ bind Text <Prior> {
150
+ tk::TextSetCursor %W [tk::TextScrollPages %W -1]
151
+ }
152
+ bind Text <Shift-Prior> {
153
+ tk::TextKeySelect %W [tk::TextScrollPages %W -1]
154
+ }
155
+ bind Text <Next> {
156
+ tk::TextSetCursor %W [tk::TextScrollPages %W 1]
157
+ }
158
+ bind Text <Shift-Next> {
159
+ tk::TextKeySelect %W [tk::TextScrollPages %W 1]
160
+ }
161
+ bind Text <Control-Prior> {
162
+ %W xview scroll -1 page
163
+ }
164
+ bind Text <Control-Next> {
165
+ %W xview scroll 1 page
166
+ }
167
+
168
+ bind Text <<LineStart>> {
169
+ tk::TextSetCursor %W {insert display linestart}
170
+ }
171
+ bind Text <<SelectLineStart>> {
172
+ tk::TextKeySelect %W {insert display linestart}
173
+ }
174
+ bind Text <<LineEnd>> {
175
+ tk::TextSetCursor %W {insert display lineend}
176
+ }
177
+ bind Text <<SelectLineEnd>> {
178
+ tk::TextKeySelect %W {insert display lineend}
179
+ }
180
+ bind Text <Control-Home> {
181
+ tk::TextSetCursor %W 1.0
182
+ }
183
+ bind Text <Control-Shift-Home> {
184
+ tk::TextKeySelect %W 1.0
185
+ }
186
+ bind Text <Control-End> {
187
+ tk::TextSetCursor %W {end - 1 indices}
188
+ }
189
+ bind Text <Control-Shift-End> {
190
+ tk::TextKeySelect %W {end - 1 indices}
191
+ }
192
+
193
+ bind Text <Tab> {
194
+ if {[%W cget -state] eq "normal"} {
195
+ tk::TextInsert %W \t
196
+ focus %W
197
+ break
198
+ }
199
+ }
200
+ bind Text <Shift-Tab> {
201
+ # Needed only to keep <Tab> binding from triggering; doesn't
202
+ # have to actually do anything.
203
+ break
204
+ }
205
+ bind Text <Control-Tab> {
206
+ focus [tk_focusNext %W]
207
+ }
208
+ bind Text <Control-Shift-Tab> {
209
+ focus [tk_focusPrev %W]
210
+ }
211
+ bind Text <Control-i> {
212
+ tk::TextInsert %W \t
213
+ }
214
+ bind Text <Return> {
215
+ tk::TextInsert %W \n
216
+ if {[%W cget -autoseparators]} {
217
+ %W edit separator
218
+ }
219
+ }
220
+ bind Text <Delete> {
221
+ if {[tk::TextCursorInSelection %W]} {
222
+ %W delete sel.first sel.last
223
+ } else {
224
+ if {[%W compare end != insert+1c]} {
225
+ %W delete insert
226
+ }
227
+ %W see insert
228
+ }
229
+ }
230
+ bind Text <BackSpace> {
231
+ if {[tk::TextCursorInSelection %W]} {
232
+ %W delete sel.first sel.last
233
+ } else {
234
+ if {[%W compare insert != 1.0]} {
235
+ %W delete insert-1c
236
+ }
237
+ %W see insert
238
+ }
239
+ }
240
+
241
+ bind Text <Control-space> {
242
+ %W mark set [tk::TextAnchor %W] insert
243
+ }
244
+ bind Text <Select> {
245
+ %W mark set [tk::TextAnchor %W] insert
246
+ }
247
+ bind Text <Control-Shift-space> {
248
+ set tk::Priv(selectMode) char
249
+ tk::TextKeyExtend %W insert
250
+ }
251
+ bind Text <Shift-Select> {
252
+ set tk::Priv(selectMode) char
253
+ tk::TextKeyExtend %W insert
254
+ }
255
+ bind Text <<SelectAll>> {
256
+ %W tag add sel 1.0 end
257
+ }
258
+ bind Text <<SelectNone>> {
259
+ %W tag remove sel 1.0 end
260
+ # An operation that clears the selection must insert an autoseparator,
261
+ # because the selection operation may have moved the insert mark
262
+ if {[%W cget -autoseparators]} {
263
+ %W edit separator
264
+ }
265
+ }
266
+ bind Text <<Cut>> {
267
+ tk_textCut %W
268
+ }
269
+ bind Text <<Copy>> {
270
+ tk_textCopy %W
271
+ }
272
+ bind Text <<Paste>> {
273
+ tk_textPaste %W
274
+ }
275
+ bind Text <<Clear>> {
276
+ # Make <<Clear>> an atomic operation on the Undo stack,
277
+ # i.e. separate it from other delete operations on either side
278
+ if {[%W cget -autoseparators]} {
279
+ %W edit separator
280
+ }
281
+ catch {%W delete sel.first sel.last}
282
+ if {[%W cget -autoseparators]} {
283
+ %W edit separator
284
+ }
285
+ }
286
+ bind Text <<PasteSelection>> {
287
+ if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
288
+ || !$tk::Priv(mouseMoved)} {
289
+ tk::TextPasteSelection %W %x %y
290
+ }
291
+ }
292
+ bind Text <Insert> {
293
+ catch {tk::TextInsert %W [::tk::GetSelection %W PRIMARY]}
294
+ }
295
+ bind Text <Key> {
296
+ tk::TextInsert %W %A
297
+ }
298
+
299
+ # Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
300
+ # Otherwise, if a widget binding for one of these is defined, the
301
+ # <Key> class binding will also fire and insert the character,
302
+ # which is wrong. Ditto for <Escape>.
303
+
304
+ bind Text <Alt-Key> {# nothing }
305
+ bind Text <Meta-Key> {# nothing}
306
+ bind Text <Control-Key> {# nothing}
307
+ bind Text <Escape> {# nothing}
308
+ bind Text <KP_Enter> {# nothing}
309
+ if {[tk windowingsystem] eq "aqua"} {
310
+ bind Text <Command-Key> {# nothing}
311
+ bind Text <Mod4-Key> {# nothing}
312
+ }
313
+
314
+ # Additional emacs-like bindings:
315
+
316
+ bind Text <Control-d> {
317
+ if {!$tk_strictMotif && [%W compare end != insert+1c]} {
318
+ %W delete insert
319
+ }
320
+ }
321
+ bind Text <Control-k> {
322
+ if {!$tk_strictMotif && [%W compare end != insert+1c]} {
323
+ if {[%W compare insert == {insert lineend}]} {
324
+ %W delete insert
325
+ } else {
326
+ %W delete insert {insert lineend}
327
+ }
328
+ }
329
+ }
330
+ bind Text <Control-o> {
331
+ if {!$tk_strictMotif} {
332
+ %W insert insert \n
333
+ %W mark set insert insert-1c
334
+ }
335
+ }
336
+ bind Text <Control-t> {
337
+ if {!$tk_strictMotif} {
338
+ tk::TextTranspose %W
339
+ }
340
+ }
341
+
342
+ bind Text <<Undo>> {
343
+ # An Undo operation may remove the separator at the top of the Undo stack.
344
+ # Then the item at the top of the stack gets merged with the subsequent changes.
345
+ # Place separators before and after Undo to prevent this.
346
+ if {[%W cget -autoseparators]} {
347
+ %W edit separator
348
+ }
349
+ catch { %W edit undo }
350
+ if {[%W cget -autoseparators]} {
351
+ %W edit separator
352
+ }
353
+ }
354
+
355
+ bind Text <<Redo>> {
356
+ catch { %W edit redo }
357
+ }
358
+
359
+ bind Text <Meta-b> {
360
+ if {!$tk_strictMotif} {
361
+ tk::TextSetCursor %W [tk::TextPrevPos %W insert tcl_startOfPreviousWord]
362
+ }
363
+ }
364
+ bind Text <Meta-d> {
365
+ if {!$tk_strictMotif && [%W compare end != insert+1c]} {
366
+ %W delete insert [tk::TextNextWord %W insert]
367
+ }
368
+ }
369
+ bind Text <Meta-f> {
370
+ if {!$tk_strictMotif} {
371
+ tk::TextSetCursor %W [tk::TextNextWord %W insert]
372
+ }
373
+ }
374
+ bind Text <Meta-less> {
375
+ if {!$tk_strictMotif} {
376
+ tk::TextSetCursor %W 1.0
377
+ }
378
+ }
379
+ bind Text <Meta-greater> {
380
+ if {!$tk_strictMotif} {
381
+ tk::TextSetCursor %W end-1c
382
+ }
383
+ }
384
+ bind Text <Meta-BackSpace> {
385
+ if {!$tk_strictMotif} {
386
+ %W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert
387
+ }
388
+ }
389
+ bind Text <Meta-Delete> {
390
+ if {!$tk_strictMotif} {
391
+ %W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert
392
+ }
393
+ }
394
+
395
+ # Bindings for IME text input.
396
+
397
+ bind Text <<TkStartIMEMarkedText>> {
398
+ dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
399
+ }
400
+ bind Text <<TkEndIMEMarkedText>> {
401
+ if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
402
+ bell
403
+ } else {
404
+ %W tag add IMEmarkedtext $mark insert
405
+ %W tag configure IMEmarkedtext -underline on
406
+ }
407
+ }
408
+ bind Text <<TkClearIMEMarkedText>> {
409
+ %W delete IMEmarkedtext.first IMEmarkedtext.last
410
+ }
411
+ bind Text <<TkAccentBackspace>> {
412
+ %W delete insert-1c
413
+ }
414
+
415
+ # Macintosh only bindings:
416
+
417
+ if {[tk windowingsystem] eq "aqua"} {
418
+ bind Text <Control-v> {
419
+ tk::TextScrollPages %W 1
420
+ }
421
+
422
+ # End of Mac only bindings
423
+ }
424
+
425
+ # A few additional bindings of my own.
426
+
427
+ bind Text <Control-h> {
428
+ if {!$tk_strictMotif && [%W compare insert != 1.0]} {
429
+ %W delete insert-1c
430
+ %W see insert
431
+ }
432
+ }
433
+ if {[tk windowingsystem] ne "aqua"} {
434
+ bind Text <2> {
435
+ if {!$tk_strictMotif} {
436
+ tk::TextScanMark %W %x %y
437
+ }
438
+ }
439
+ bind Text <B2-Motion> {
440
+ if {!$tk_strictMotif} {
441
+ tk::TextScanDrag %W %x %y
442
+ }
443
+ }
444
+ } else {
445
+ bind Text <3> {
446
+ if {!$tk_strictMotif} {
447
+ tk::TextScanMark %W %x %y
448
+ }
449
+ }
450
+ bind Text <B3-Motion> {
451
+ if {!$tk_strictMotif} {
452
+ tk::TextScanDrag %W %x %y
453
+ }
454
+ }
455
+ }
456
+ set ::tk::Priv(prevPos) {}
457
+
458
+ # The MouseWheel will typically only fire on Windows and MacOS X.
459
+ # However, someone could use the "event generate" command to produce one
460
+ # on other platforms. We must be careful not to round -ve values of %D
461
+ # down to zero.
462
+
463
+ if {[tk windowingsystem] eq "aqua"} {
464
+ bind Text <MouseWheel> {
465
+ %W yview scroll [expr {-15 * (%D)}] pixels
466
+ }
467
+ bind Text <Option-MouseWheel> {
468
+ %W yview scroll [expr {-150 * (%D)}] pixels
469
+ }
470
+ bind Text <Shift-MouseWheel> {
471
+ %W xview scroll [expr {-15 * (%D)}] pixels
472
+ }
473
+ bind Text <Shift-Option-MouseWheel> {
474
+ %W xview scroll [expr {-150 * (%D)}] pixels
475
+ }
476
+ } else {
477
+ # We must make sure that positive and negative movements are rounded
478
+ # equally to integers, avoiding the problem that
479
+ # (int)1/3 = 0,
480
+ # but
481
+ # (int)-1/3 = -1
482
+ # The following code ensure equal +/- behaviour.
483
+ bind Text <MouseWheel> {
484
+ if {%D >= 0} {
485
+ %W yview scroll [expr {-%D/3}] pixels
486
+ } else {
487
+ %W yview scroll [expr {(2-%D)/3}] pixels
488
+ }
489
+ }
490
+ bind Text <Shift-MouseWheel> {
491
+ if {%D >= 0} {
492
+ %W xview scroll [expr {-%D/3}] pixels
493
+ } else {
494
+ %W xview scroll [expr {(2-%D)/3}] pixels
495
+ }
496
+ }
497
+ }
498
+
499
+ if {[tk windowingsystem] eq "x11"} {
500
+ # Support for mousewheels on Linux/Unix commonly comes through mapping
501
+ # the wheel to the extended buttons. If you have a mousewheel, find
502
+ # Linux configuration info at:
503
+ # https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X
504
+ bind Text <4> {
505
+ if {!$tk_strictMotif} {
506
+ %W yview scroll -50 pixels
507
+ }
508
+ }
509
+ bind Text <5> {
510
+ if {!$tk_strictMotif} {
511
+ %W yview scroll 50 pixels
512
+ }
513
+ }
514
+ bind Text <Shift-4> {
515
+ if {!$tk_strictMotif} {
516
+ %W xview scroll -50 pixels
517
+ }
518
+ }
519
+ bind Text <Shift-5> {
520
+ if {!$tk_strictMotif} {
521
+ %W xview scroll 50 pixels
522
+ }
523
+ }
524
+ }
525
+
526
+ # ::tk::TextClosestGap --
527
+ # Given x and y coordinates, this procedure finds the closest boundary
528
+ # between characters to the given coordinates and returns the index
529
+ # of the character just after the boundary.
530
+ #
531
+ # Arguments:
532
+ # w - The text window.
533
+ # x - X-coordinate within the window.
534
+ # y - Y-coordinate within the window.
535
+
536
+ proc ::tk::TextClosestGap {w x y} {
537
+ set pos [$w index @$x,$y]
538
+ set bbox [$w bbox $pos]
539
+ if {$bbox eq ""} {
540
+ return $pos
541
+ }
542
+ # The check on y coord of the line bbox with dlineinfo is to fix
543
+ # [a9cf210a42] to properly handle selecting and moving the mouse
544
+ # out of the widget.
545
+ if {$y < [lindex [$w dlineinfo $pos] 1] ||
546
+ $x - [lindex $bbox 0] < [lindex $bbox 2]/2} {
547
+ return $pos
548
+ }
549
+ $w index "$pos + 1 char"
550
+ }
551
+
552
+ # ::tk::TextButton1 --
553
+ # This procedure is invoked to handle button-1 presses in text
554
+ # widgets. It moves the insertion cursor, sets the selection anchor,
555
+ # and claims the input focus.
556
+ #
557
+ # Arguments:
558
+ # w - The text window in which the button was pressed.
559
+ # x - The x-coordinate of the button press.
560
+ # y - The x-coordinate of the button press.
561
+
562
+ proc ::tk::TextButton1 {w x y} {
563
+ variable ::tk::Priv
564
+
565
+ set Priv(selectMode) char
566
+ set Priv(mouseMoved) 0
567
+ set Priv(pressX) $x
568
+ set anchorname [tk::TextAnchor $w]
569
+ $w mark set insert [TextClosestGap $w $x $y]
570
+ $w mark set $anchorname insert
571
+ # Set the anchor mark's gravity depending on the click position
572
+ # relative to the gap
573
+ set bbox [$w bbox [$w index $anchorname]]
574
+ if {$x > [lindex $bbox 0]} {
575
+ $w mark gravity $anchorname right
576
+ } else {
577
+ $w mark gravity $anchorname left
578
+ }
579
+ focus $w
580
+ if {[$w cget -autoseparators]} {
581
+ $w edit separator
582
+ }
583
+ }
584
+
585
+ # ::tk::TextSelectTo --
586
+ # This procedure is invoked to extend the selection, typically when
587
+ # dragging it with the mouse. Depending on the selection mode (character,
588
+ # word, line) it selects in different-sized units. This procedure
589
+ # ignores mouse motions initially until the mouse has moved from
590
+ # one character to another or until there have been multiple clicks.
591
+ #
592
+ # Note that the 'anchor' is implemented programmatically using
593
+ # a text widget mark, and uses a name that will be unique for each
594
+ # text widget (even when there are multiple peers). Currently the
595
+ # anchor is considered private to Tk, hence the name 'tk::anchor$w'.
596
+ #
597
+ # Arguments:
598
+ # w - The text window in which the button was pressed.
599
+ # x - Mouse x position.
600
+ # y - Mouse y position.
601
+
602
+ set ::tk::Priv(textanchoruid) 0
603
+
604
+ proc ::tk::TextAnchor {w} {
605
+ variable Priv
606
+ if {![info exists Priv(textanchor,$w)]} {
607
+ set Priv(textanchor,$w) tk::anchor[incr Priv(textanchoruid)]
608
+ }
609
+ return $Priv(textanchor,$w)
610
+ }
611
+
612
+ proc ::tk::TextSelectTo {w x y {extend 0}} {
613
+ variable ::tk::Priv
614
+
615
+ set anchorname [tk::TextAnchor $w]
616
+ set cur [TextClosestGap $w $x $y]
617
+ if {[catch {$w index $anchorname}]} {
618
+ $w mark set $anchorname $cur
619
+ }
620
+ set anchor [$w index $anchorname]
621
+ if {[$w compare $cur != $anchor] || (abs($Priv(pressX) - $x) >= 3)} {
622
+ set Priv(mouseMoved) 1
623
+ }
624
+ switch -- $Priv(selectMode) {
625
+ char {
626
+ if {[$w compare $cur < $anchorname]} {
627
+ set first $cur
628
+ set last $anchorname
629
+ } else {
630
+ set first $anchorname
631
+ set last $cur
632
+ }
633
+ }
634
+ word {
635
+ # Set initial range based only on the anchor (1 char min width)
636
+ if {[$w mark gravity $anchorname] eq "right"} {
637
+ set first $anchorname
638
+ set last "$anchorname + 1c"
639
+ } else {
640
+ set first "$anchorname - 1c"
641
+ set last $anchorname
642
+ }
643
+ # Extend range (if necessary) based on the current point
644
+ if {[$w compare $cur < $first]} {
645
+ set first $cur
646
+ } elseif {[$w compare $cur > $last]} {
647
+ set last $cur
648
+ }
649
+
650
+ # Now find word boundaries
651
+ set first [TextPrevPos $w "$first + 1c" tcl_wordBreakBefore]
652
+ set last [TextNextPos $w "$last - 1c" tcl_wordBreakAfter]
653
+ }
654
+ line {
655
+ # Set initial range based only on the anchor
656
+ set first "$anchorname linestart"
657
+ set last "$anchorname lineend"
658
+
659
+ # Extend range (if necessary) based on the current point
660
+ if {[$w compare $cur < $first]} {
661
+ set first "$cur linestart"
662
+ } elseif {[$w compare $cur > $last]} {
663
+ set last "$cur lineend"
664
+ }
665
+ set first [$w index $first]
666
+ set last [$w index "$last + 1c"]
667
+ }
668
+ }
669
+ if {$Priv(mouseMoved) || ($Priv(selectMode) ne "char")} {
670
+ $w tag remove sel 0.0 end
671
+ $w mark set insert $cur
672
+ $w tag add sel $first $last
673
+ $w tag remove sel $last end
674
+ update idletasks
675
+ }
676
+ }
677
+
678
+ # ::tk::TextKeyExtend --
679
+ # This procedure handles extending the selection from the keyboard,
680
+ # where the point to extend to is really the boundary between two
681
+ # characters rather than a particular character.
682
+ #
683
+ # Arguments:
684
+ # w - The text window.
685
+ # index - The point to which the selection is to be extended.
686
+
687
+ proc ::tk::TextKeyExtend {w index} {
688
+
689
+ set anchorname [tk::TextAnchor $w]
690
+ set cur [$w index $index]
691
+ if {[catch {$w index $anchorname}]} {
692
+ $w mark set $anchorname $cur
693
+ }
694
+ set anchor [$w index $anchorname]
695
+ if {[$w compare $cur < $anchorname]} {
696
+ set first $cur
697
+ set last $anchorname
698
+ } else {
699
+ set first $anchorname
700
+ set last $cur
701
+ }
702
+ $w tag remove sel 0.0 $first
703
+ $w tag add sel $first $last
704
+ $w tag remove sel $last end
705
+ }
706
+
707
+ # ::tk::TextPasteSelection --
708
+ # This procedure sets the insertion cursor to the mouse position,
709
+ # inserts the selection, and sets the focus to the window.
710
+ #
711
+ # Arguments:
712
+ # w - The text window.
713
+ # x, y - Position of the mouse.
714
+
715
+ proc ::tk::TextPasteSelection {w x y} {
716
+ $w mark set insert [TextClosestGap $w $x $y]
717
+ if {![catch {::tk::GetSelection $w PRIMARY} sel]} {
718
+ set oldSeparator [$w cget -autoseparators]
719
+ if {$oldSeparator} {
720
+ $w configure -autoseparators 0
721
+ $w edit separator
722
+ }
723
+ $w insert insert $sel
724
+ if {$oldSeparator} {
725
+ $w edit separator
726
+ $w configure -autoseparators 1
727
+ }
728
+ }
729
+ if {[$w cget -state] eq "normal"} {
730
+ focus $w
731
+ }
732
+ }
733
+
734
+ # ::tk::TextAutoScan --
735
+ # This procedure is invoked when the mouse leaves a text window
736
+ # with button 1 down. It scrolls the window up, down, left, or right,
737
+ # depending on where the mouse is (this information was saved in
738
+ # ::tk::Priv(x) and ::tk::Priv(y)), and reschedules itself as an "after"
739
+ # command so that the window continues to scroll until the mouse
740
+ # moves back into the window or the mouse button is released.
741
+ #
742
+ # Arguments:
743
+ # w - The text window.
744
+
745
+ proc ::tk::TextAutoScan {w} {
746
+ variable ::tk::Priv
747
+ if {![winfo exists $w]} {
748
+ return
749
+ }
750
+ if {$Priv(y) >= [winfo height $w]} {
751
+ $w yview scroll [expr {1 + $Priv(y) - [winfo height $w]}] pixels
752
+ } elseif {$Priv(y) < 0} {
753
+ $w yview scroll [expr {-1 + $Priv(y)}] pixels
754
+ } elseif {$Priv(x) >= [winfo width $w]} {
755
+ $w xview scroll 2 units
756
+ } elseif {$Priv(x) < 0} {
757
+ $w xview scroll -2 units
758
+ } else {
759
+ return
760
+ }
761
+ TextSelectTo $w $Priv(x) $Priv(y)
762
+ set Priv(afterId) [after 50 [list tk::TextAutoScan $w]]
763
+ }
764
+
765
+ # ::tk::TextSetCursor
766
+ # Move the insertion cursor to a given position in a text. Also
767
+ # clears the selection, if there is one in the text, and makes sure
768
+ # that the insertion cursor is visible. Also, don't let the insertion
769
+ # cursor appear on the dummy last line of the text.
770
+ #
771
+ # Arguments:
772
+ # w - The text window.
773
+ # pos - The desired new position for the cursor in the window.
774
+
775
+ proc ::tk::TextSetCursor {w pos} {
776
+ if {[$w compare $pos == end]} {
777
+ set pos {end - 1 chars}
778
+ }
779
+ $w mark set insert $pos
780
+ $w tag remove sel 1.0 end
781
+ $w see insert
782
+ if {[$w cget -autoseparators]} {
783
+ $w edit separator
784
+ }
785
+ }
786
+
787
+ # ::tk::TextKeySelect
788
+ # This procedure is invoked when stroking out selections using the
789
+ # keyboard. It moves the cursor to a new position, then extends
790
+ # the selection to that position.
791
+ #
792
+ # Arguments:
793
+ # w - The text window.
794
+ # new - A new position for the insertion cursor (the cursor hasn't
795
+ # actually been moved to this position yet).
796
+
797
+ proc ::tk::TextKeySelect {w new} {
798
+ set anchorname [tk::TextAnchor $w]
799
+ if {[$w tag nextrange sel 1.0 end] eq ""} {
800
+ if {[$w compare $new < insert]} {
801
+ $w tag add sel $new insert
802
+ } else {
803
+ $w tag add sel insert $new
804
+ }
805
+ $w mark set $anchorname insert
806
+ } else {
807
+ if {[catch {$w index $anchorname}]} {
808
+ $w mark set $anchorname insert
809
+ }
810
+ if {[$w compare $new < $anchorname]} {
811
+ set first $new
812
+ set last $anchorname
813
+ } else {
814
+ set first $anchorname
815
+ set last $new
816
+ }
817
+ $w tag remove sel 1.0 $first
818
+ $w tag add sel $first $last
819
+ $w tag remove sel $last end
820
+ }
821
+ $w mark set insert $new
822
+ $w see insert
823
+ update idletasks
824
+ }
825
+
826
+ # ::tk::TextResetAnchor --
827
+ # Set the selection anchor to whichever end is farthest from the
828
+ # index argument. One special trick: if the selection has two or
829
+ # fewer characters, just leave the anchor where it is. In this
830
+ # case it doesn't matter which point gets chosen for the anchor,
831
+ # and for the things like Shift-Left and Shift-Right this produces
832
+ # better behavior when the cursor moves back and forth across the
833
+ # anchor.
834
+ #
835
+ # Arguments:
836
+ # w - The text widget.
837
+ # index - Position at which mouse button was pressed, which determines
838
+ # which end of selection should be used as anchor point.
839
+
840
+ proc ::tk::TextResetAnchor {w index} {
841
+ if {[$w tag ranges sel] eq ""} {
842
+ # Don't move the anchor if there is no selection now; this
843
+ # makes the widget behave "correctly" when the user clicks
844
+ # once, then shift-clicks somewhere -- ie, the area between
845
+ # the two clicks will be selected. [Bug: 5929].
846
+ return
847
+ }
848
+ set anchorname [tk::TextAnchor $w]
849
+ set a [$w index $index]
850
+ set b [$w index sel.first]
851
+ set c [$w index sel.last]
852
+ if {[$w compare $a < $b]} {
853
+ $w mark set $anchorname sel.last
854
+ return
855
+ }
856
+ if {[$w compare $a > $c]} {
857
+ $w mark set $anchorname sel.first
858
+ return
859
+ }
860
+ scan $a "%d.%d" lineA chA
861
+ scan $b "%d.%d" lineB chB
862
+ scan $c "%d.%d" lineC chC
863
+ if {$lineB < $lineC+2} {
864
+ set total [string length [$w get $b $c]]
865
+ if {$total <= 2} {
866
+ return
867
+ }
868
+ if {[string length [$w get $b $a]] < ($total/2)} {
869
+ $w mark set $anchorname sel.last
870
+ } else {
871
+ $w mark set $anchorname sel.first
872
+ }
873
+ return
874
+ }
875
+ if {($lineA-$lineB) < ($lineC-$lineA)} {
876
+ $w mark set $anchorname sel.last
877
+ } else {
878
+ $w mark set $anchorname sel.first
879
+ }
880
+ }
881
+
882
+ # ::tk::TextCursorInSelection --
883
+ # Check whether the selection exists and contains the insertion cursor. Note
884
+ # that it assumes that the selection is contiguous.
885
+ #
886
+ # Arguments:
887
+ # w - The text widget whose selection is to be checked
888
+
889
+ proc ::tk::TextCursorInSelection {w} {
890
+ expr {
891
+ [llength [$w tag ranges sel]]
892
+ && [$w compare sel.first <= insert]
893
+ && [$w compare sel.last >= insert]
894
+ }
895
+ }
896
+
897
+ # ::tk::TextInsert --
898
+ # Insert a string into a text at the point of the insertion cursor.
899
+ # If there is a selection in the text, and it covers the point of the
900
+ # insertion cursor, then delete the selection before inserting.
901
+ #
902
+ # Arguments:
903
+ # w - The text window in which to insert the string
904
+ # s - The string to insert (usually just a single character)
905
+
906
+ proc ::tk::TextInsert {w s} {
907
+ if {$s eq "" || [$w cget -state] eq "disabled"} {
908
+ return
909
+ }
910
+ set compound 0
911
+ if {[TextCursorInSelection $w]} {
912
+ set oldSeparator [$w cget -autoseparators]
913
+ if {$oldSeparator} {
914
+ $w configure -autoseparators 0
915
+ $w edit separator
916
+ set compound 1
917
+ }
918
+ $w delete sel.first sel.last
919
+ }
920
+ $w insert insert $s
921
+ $w see insert
922
+ if {$compound && $oldSeparator} {
923
+ $w edit separator
924
+ $w configure -autoseparators 1
925
+ }
926
+ }
927
+
928
+ # ::tk::TextUpDownLine --
929
+ # Returns the index of the character one display line above or below the
930
+ # insertion cursor. There is a tricky thing here: we want to maintain the
931
+ # original x position across repeated operations, even though some lines
932
+ # that will get passed through don't have enough characters to cover the
933
+ # original column.
934
+ #
935
+ # Arguments:
936
+ # w - The text window in which the cursor is to move.
937
+ # n - The number of display lines to move: -1 for up one line,
938
+ # +1 for down one line.
939
+
940
+ proc ::tk::TextUpDownLine {w n} {
941
+ variable ::tk::Priv
942
+
943
+ set i [$w index insert]
944
+ if {$Priv(prevPos) ne $i} {
945
+ set Priv(textPosOrig) $i
946
+ }
947
+ set lines [$w count -displaylines $Priv(textPosOrig) $i]
948
+ set new [$w index \
949
+ "$Priv(textPosOrig) + [expr {$lines + $n}] displaylines"]
950
+ set Priv(prevPos) $new
951
+ if {[$w compare $new == "end display lineend"] \
952
+ || [$w compare $new == "insert display linestart"]} {
953
+ set Priv(textPosOrig) $new
954
+ }
955
+ return $new
956
+ }
957
+
958
+ # ::tk::TextPrevPara --
959
+ # Returns the index of the beginning of the paragraph just before a given
960
+ # position in the text (the beginning of a paragraph is the first non-blank
961
+ # character after a blank line).
962
+ #
963
+ # Arguments:
964
+ # w - The text window in which the cursor is to move.
965
+ # pos - Position at which to start search.
966
+
967
+ proc ::tk::TextPrevPara {w pos} {
968
+ set pos [$w index "$pos linestart"]
969
+ while {1} {
970
+ if {([$w get "$pos - 1 line"] eq "\n" && ([$w get $pos] ne "\n")) \
971
+ || $pos eq "1.0"} {
972
+ if {[regexp -indices -- {^[ \t]+(.)} \
973
+ [$w get $pos "$pos lineend"] -> index]} {
974
+ set pos [$w index "$pos + [lindex $index 0] chars"]
975
+ }
976
+ if {[$w compare $pos != insert] || [lindex [split $pos .] 0]==1} {
977
+ return $pos
978
+ }
979
+ }
980
+ set pos [$w index "$pos - 1 line"]
981
+ }
982
+ }
983
+
984
+ # ::tk::TextNextPara --
985
+ # Returns the index of the beginning of the paragraph just after a given
986
+ # position in the text (the beginning of a paragraph is the first non-blank
987
+ # character after a blank line).
988
+ #
989
+ # Arguments:
990
+ # w - The text window in which the cursor is to move.
991
+ # start - Position at which to start search.
992
+
993
+ proc ::tk::TextNextPara {w start} {
994
+ set pos [$w index "$start linestart + 1 line"]
995
+ while {[$w get $pos] ne "\n"} {
996
+ if {[$w compare $pos == end]} {
997
+ return [$w index "end - 1c"]
998
+ }
999
+ set pos [$w index "$pos + 1 line"]
1000
+ }
1001
+ while {[$w get $pos] eq "\n"} {
1002
+ set pos [$w index "$pos + 1 line"]
1003
+ if {[$w compare $pos == end]} {
1004
+ return [$w index "end - 1c"]
1005
+ }
1006
+ }
1007
+ if {[regexp -indices -- {^[ \t]+(.)} \
1008
+ [$w get $pos "$pos lineend"] -> index]} {
1009
+ return [$w index "$pos + [lindex $index 0] chars"]
1010
+ }
1011
+ return $pos
1012
+ }
1013
+
1014
+ # ::tk::TextScrollPages --
1015
+ # This is a utility procedure used in bindings for moving up and down
1016
+ # pages and possibly extending the selection along the way. It scrolls
1017
+ # the view in the widget by the number of pages, and it returns the
1018
+ # index of the character that is at the same position in the new view
1019
+ # as the insertion cursor used to be in the old view.
1020
+ #
1021
+ # Arguments:
1022
+ # w - The text window in which the cursor is to move.
1023
+ # count - Number of pages forward to scroll; may be negative
1024
+ # to scroll backwards.
1025
+
1026
+ proc ::tk::TextScrollPages {w count} {
1027
+ set bbox [$w bbox insert]
1028
+ $w yview scroll $count pages
1029
+ if {$bbox eq ""} {
1030
+ return [$w index @[expr {[winfo height $w]/2}],0]
1031
+ }
1032
+ return [$w index @[lindex $bbox 0],[lindex $bbox 1]]
1033
+ }
1034
+
1035
+ # ::tk::TextTranspose --
1036
+ # This procedure implements the "transpose" function for text widgets.
1037
+ # It tranposes the characters on either side of the insertion cursor,
1038
+ # unless the cursor is at the end of the line. In this case it
1039
+ # transposes the two characters to the left of the cursor. In either
1040
+ # case, the cursor ends up to the right of the transposed characters.
1041
+ #
1042
+ # Arguments:
1043
+ # w - Text window in which to transpose.
1044
+
1045
+ proc ::tk::TextTranspose w {
1046
+ set pos insert
1047
+ if {[$w compare $pos != "$pos lineend"]} {
1048
+ set pos [$w index "$pos + 1 char"]
1049
+ }
1050
+ set new [$w get "$pos - 1 char"][$w get "$pos - 2 char"]
1051
+ if {[$w compare "$pos - 1 char" == 1.0]} {
1052
+ return
1053
+ }
1054
+ # ensure this is seen as an atomic op to undo
1055
+ set autosep [$w cget -autoseparators]
1056
+ if {$autosep} {
1057
+ $w configure -autoseparators 0
1058
+ $w edit separator
1059
+ }
1060
+ $w delete "$pos - 2 char" $pos
1061
+ $w insert insert $new
1062
+ $w see insert
1063
+ if {$autosep} {
1064
+ $w edit separator
1065
+ $w configure -autoseparators $autosep
1066
+ }
1067
+ }
1068
+
1069
+ # ::tk_textCopy --
1070
+ # This procedure copies the selection from a text widget into the
1071
+ # clipboard.
1072
+ #
1073
+ # Arguments:
1074
+ # w - Name of a text widget.
1075
+
1076
+ proc ::tk_textCopy w {
1077
+ if {![catch {set data [$w get sel.first sel.last]}]} {
1078
+ clipboard clear -displayof $w
1079
+ clipboard append -displayof $w $data
1080
+ }
1081
+ }
1082
+
1083
+ # ::tk_textCut --
1084
+ # This procedure copies the selection from a text widget into the
1085
+ # clipboard, then deletes the selection (if it exists in the given
1086
+ # widget).
1087
+ #
1088
+ # Arguments:
1089
+ # w - Name of a text widget.
1090
+
1091
+ proc ::tk_textCut w {
1092
+ if {![catch {set data [$w get sel.first sel.last]}]} {
1093
+ # make <<Cut>> an atomic operation on the Undo stack,
1094
+ # i.e. separate it from other delete operations on either side
1095
+ set oldSeparator [$w cget -autoseparators]
1096
+ if {([$w cget -state] eq "normal") && $oldSeparator} {
1097
+ $w edit separator
1098
+ }
1099
+ clipboard clear -displayof $w
1100
+ clipboard append -displayof $w $data
1101
+ $w delete sel.first sel.last
1102
+ if {([$w cget -state] eq "normal") && $oldSeparator} {
1103
+ $w edit separator
1104
+ }
1105
+ }
1106
+ }
1107
+
1108
+ # ::tk_textPaste --
1109
+ # This procedure pastes the contents of the clipboard to the insertion
1110
+ # point in a text widget.
1111
+ #
1112
+ # Arguments:
1113
+ # w - Name of a text widget.
1114
+
1115
+ proc ::tk_textPaste w {
1116
+ if {![catch {::tk::GetSelection $w CLIPBOARD} sel]} {
1117
+ set oldSeparator [$w cget -autoseparators]
1118
+ if {$oldSeparator} {
1119
+ $w configure -autoseparators 0
1120
+ $w edit separator
1121
+ }
1122
+ if {[tk windowingsystem] ne "x11"} {
1123
+ catch { $w delete sel.first sel.last }
1124
+ }
1125
+ $w insert insert $sel
1126
+ if {$oldSeparator} {
1127
+ $w edit separator
1128
+ $w configure -autoseparators 1
1129
+ }
1130
+ }
1131
+ }
1132
+
1133
+ # ::tk::TextNextWord --
1134
+ # Returns the index of the next word position after a given position in the
1135
+ # text. The next word is platform dependent and may be either the next
1136
+ # end-of-word position or the next start-of-word position after the next
1137
+ # end-of-word position.
1138
+ #
1139
+ # Arguments:
1140
+ # w - The text window in which the cursor is to move.
1141
+ # start - Position at which to start search.
1142
+
1143
+ if {[tk windowingsystem] eq "win32"} {
1144
+ proc ::tk::TextNextWord {w start} {
1145
+ TextNextPos $w [TextNextPos $w $start tcl_endOfWord] \
1146
+ tcl_startOfNextWord
1147
+ }
1148
+ } else {
1149
+ proc ::tk::TextNextWord {w start} {
1150
+ TextNextPos $w $start tcl_endOfWord
1151
+ }
1152
+ }
1153
+
1154
+ # ::tk::TextNextPos --
1155
+ # Returns the index of the next position after the given starting
1156
+ # position in the text as computed by a specified function.
1157
+ #
1158
+ # Arguments:
1159
+ # w - The text window in which the cursor is to move.
1160
+ # start - Position at which to start search.
1161
+ # op - Function to use to find next position.
1162
+
1163
+ proc ::tk::TextNextPos {w start op} {
1164
+ set text ""
1165
+ set cur $start
1166
+ while {[$w compare $cur < end]} {
1167
+ set text $text[$w get -displaychars $cur "$cur lineend + 1c"]
1168
+ set pos [$op $text 0]
1169
+ if {$pos >= 0} {
1170
+ return [$w index "$start + $pos display chars"]
1171
+ }
1172
+ set cur [$w index "$cur lineend +1c"]
1173
+ }
1174
+ return end
1175
+ }
1176
+
1177
+ # ::tk::TextPrevPos --
1178
+ # Returns the index of the previous position before the given starting
1179
+ # position in the text as computed by a specified function.
1180
+ #
1181
+ # Arguments:
1182
+ # w - The text window in which the cursor is to move.
1183
+ # start - Position at which to start search.
1184
+ # op - Function to use to find next position.
1185
+
1186
+ proc ::tk::TextPrevPos {w start op} {
1187
+ set text ""
1188
+ set cur $start
1189
+ while {[$w compare $cur > 0.0]} {
1190
+ set text [$w get -displaychars "$cur linestart - 1c" $cur]$text
1191
+ set pos [$op $text end]
1192
+ if {$pos >= 0} {
1193
+ return [$w index "$cur linestart - 1c + $pos display chars"]
1194
+ }
1195
+ set cur [$w index "$cur linestart - 1c"]
1196
+ }
1197
+ return 0.0
1198
+ }
1199
+
1200
+ # ::tk::TextScanMark --
1201
+ #
1202
+ # Marks the start of a possible scan drag operation
1203
+ #
1204
+ # Arguments:
1205
+ # w - The text window from which the text to get
1206
+ # x - x location on screen
1207
+ # y - y location on screen
1208
+
1209
+ proc ::tk::TextScanMark {w x y} {
1210
+ variable ::tk::Priv
1211
+ $w scan mark $x $y
1212
+ set Priv(x) $x
1213
+ set Priv(y) $y
1214
+ set Priv(mouseMoved) 0
1215
+ }
1216
+
1217
+ # ::tk::TextScanDrag --
1218
+ #
1219
+ # Marks the start of a possible scan drag operation
1220
+ #
1221
+ # Arguments:
1222
+ # w - The text window from which the text to get
1223
+ # x - x location on screen
1224
+ # y - y location on screen
1225
+
1226
+ proc ::tk::TextScanDrag {w x y} {
1227
+ variable ::tk::Priv
1228
+ # Make sure these exist, as some weird situations can trigger the
1229
+ # motion binding without the initial press. [Bug #220269]
1230
+ if {![info exists Priv(x)]} {
1231
+ set Priv(x) $x
1232
+ }
1233
+ if {![info exists Priv(y)]} {
1234
+ set Priv(y) $y
1235
+ }
1236
+ if {($x != $Priv(x)) || ($y != $Priv(y))} {
1237
+ set Priv(mouseMoved) 1
1238
+ }
1239
+ if {[info exists Priv(mouseMoved)] && $Priv(mouseMoved)} {
1240
+ $w scan dragto $x $y
1241
+ }
1242
+ }