Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +3 -0
- mplug_owl2/lib/engines-3/afalg.so +0 -0
- mplug_owl2/lib/engines-3/loader_attic.so +0 -0
- mplug_owl2/lib/itcl4.2.4/libitcl4.2.4.so +3 -0
- mplug_owl2/lib/ossl-modules/legacy.so +3 -0
- mplug_owl2/lib/sqlite3.44.2/libsqlite3.44.2.so +3 -0
- mplug_owl2/lib/tcl8/8.4/platform-1.0.19.tm +450 -0
- mplug_owl2/lib/tcl8/8.4/platform/shell-1.1.4.tm +241 -0
- mplug_owl2/lib/tcl8/8.5/msgcat-1.6.1.tm +1210 -0
- mplug_owl2/lib/tcl8/8.5/tcltest-2.5.7.tm +0 -0
- mplug_owl2/lib/tcl8/8.6/http-2.9.8.tm +0 -0
- mplug_owl2/lib/tcl8/8.6/tdbc/sqlite3-1.1.7.tm +723 -0
- mplug_owl2/lib/tdbc1.1.7/tdbc.tcl +922 -0
- mplug_owl2/lib/tdbcodbc1.1.7/libtdbcodbc1.1.7.so +0 -0
- mplug_owl2/lib/tdbcodbc1.1.7/pkgIndex.tcl +14 -0
- mplug_owl2/lib/tdbcodbc1.1.7/tdbcodbc.tcl +554 -0
- mplug_owl2/lib/tk8.6/bgerror.tcl +272 -0
- mplug_owl2/lib/tk8.6/button.tcl +782 -0
- mplug_owl2/lib/tk8.6/choosedir.tcl +310 -0
- mplug_owl2/lib/tk8.6/clrpick.tcl +694 -0
- mplug_owl2/lib/tk8.6/comdlg.tcl +322 -0
- mplug_owl2/lib/tk8.6/console.tcl +1154 -0
- mplug_owl2/lib/tk8.6/dialog.tcl +175 -0
- mplug_owl2/lib/tk8.6/entry.tcl +699 -0
- mplug_owl2/lib/tk8.6/focus.tcl +178 -0
- mplug_owl2/lib/tk8.6/fontchooser.tcl +515 -0
- mplug_owl2/lib/tk8.6/iconlist.tcl +715 -0
- mplug_owl2/lib/tk8.6/icons.tcl +153 -0
- mplug_owl2/lib/tk8.6/listbox.tcl +560 -0
- mplug_owl2/lib/tk8.6/megawidget.tcl +297 -0
- mplug_owl2/lib/tk8.6/menu.tcl +1387 -0
- mplug_owl2/lib/tk8.6/mkpsenc.tcl +1488 -0
- mplug_owl2/lib/tk8.6/msgbox.tcl +427 -0
- mplug_owl2/lib/tk8.6/obsolete.tcl +178 -0
- mplug_owl2/lib/tk8.6/optMenu.tcl +43 -0
- mplug_owl2/lib/tk8.6/palette.tcl +244 -0
- mplug_owl2/lib/tk8.6/panedwindow.tcl +194 -0
- mplug_owl2/lib/tk8.6/pkgIndex.tcl +2 -0
- mplug_owl2/lib/tk8.6/safetk.tcl +262 -0
- mplug_owl2/lib/tk8.6/scale.tcl +307 -0
- mplug_owl2/lib/tk8.6/scrlbar.tcl +456 -0
- mplug_owl2/lib/tk8.6/spinbox.tcl +594 -0
- mplug_owl2/lib/tk8.6/tclIndex +253 -0
- mplug_owl2/lib/tk8.6/tearoff.tcl +157 -0
- mplug_owl2/lib/tk8.6/text.tcl +1242 -0
- mplug_owl2/lib/tk8.6/tk.tcl +708 -0
- mplug_owl2/lib/tk8.6/tkAppInit.c +177 -0
- mplug_owl2/lib/tk8.6/tkfbox.tcl +1241 -0
- mplug_owl2/lib/tk8.6/ttk/combobox.tcl +448 -0
- mplug_owl2/lib/tk8.6/ttk/cursors.tcl +205 -0
.gitattributes
CHANGED
|
@@ -724,3 +724,6 @@ mplug_owl2/lib/python3.10/site-packages/scipy/sparse/_csparsetools.cpython-310-x
|
|
| 724 |
openflamingo/lib/python3.10/site-packages/transformers/models/oneformer/__pycache__/modeling_oneformer.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 725 |
mplug_owl2/lib/python3.10/site-packages/matplotlib/__pycache__/figure.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 726 |
mplug_owl2/lib/python3.10/lib-dynload/_hashlib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 724 |
openflamingo/lib/python3.10/site-packages/transformers/models/oneformer/__pycache__/modeling_oneformer.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 725 |
mplug_owl2/lib/python3.10/site-packages/matplotlib/__pycache__/figure.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 726 |
mplug_owl2/lib/python3.10/lib-dynload/_hashlib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 727 |
+
mplug_owl2/lib/itcl4.2.4/libitcl4.2.4.so filter=lfs diff=lfs merge=lfs -text
|
| 728 |
+
mplug_owl2/lib/sqlite3.44.2/libsqlite3.44.2.so filter=lfs diff=lfs merge=lfs -text
|
| 729 |
+
mplug_owl2/lib/ossl-modules/legacy.so filter=lfs diff=lfs merge=lfs -text
|
mplug_owl2/lib/engines-3/afalg.so
ADDED
|
Binary file (15 kB). View file
|
|
|
mplug_owl2/lib/engines-3/loader_attic.so
ADDED
|
Binary file (60.5 kB). View file
|
|
|
mplug_owl2/lib/itcl4.2.4/libitcl4.2.4.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4dec209d072b6ea25863993f95c4fcf0023974e0d01d06a5705173db1313379
|
| 3 |
+
size 318912
|
mplug_owl2/lib/ossl-modules/legacy.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8b8163a4a4cea7693a8d64c064788cc830bfb72e5aae56e9432fee32f5f45a0
|
| 3 |
+
size 158976
|
mplug_owl2/lib/sqlite3.44.2/libsqlite3.44.2.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ccfe88e9e8b573a4d312a3cf85f51de60783ab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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tcl8/8.4/platform/shell-1.1.4.tm
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# -*- tcl -*-
|
| 3 |
+
# ### ### ### ######### ######### #########
|
| 4 |
+
## Overview
|
| 5 |
+
|
| 6 |
+
# Higher-level commands which invoke the functionality of this package
|
| 7 |
+
# for an arbitrary tcl shell (tclsh, wish, ...). This is required by a
|
| 8 |
+
# repository as while the tcl shell executing packages uses the same
|
| 9 |
+
# platform in general as a repository application there can be
|
| 10 |
+
# differences in detail (i.e. 32/64 bit builds).
|
| 11 |
+
|
| 12 |
+
# ### ### ### ######### ######### #########
|
| 13 |
+
## Requirements
|
| 14 |
+
|
| 15 |
+
package require platform
|
| 16 |
+
namespace eval ::platform::shell {}
|
| 17 |
+
|
| 18 |
+
# ### ### ### ######### ######### #########
|
| 19 |
+
## Implementation
|
| 20 |
+
|
| 21 |
+
# -- platform::shell::generic
|
| 22 |
+
|
| 23 |
+
proc ::platform::shell::generic {shell} {
|
| 24 |
+
# Argument is the path to a tcl shell.
|
| 25 |
+
|
| 26 |
+
CHECK $shell
|
| 27 |
+
LOCATE base out
|
| 28 |
+
|
| 29 |
+
set code {}
|
| 30 |
+
# Forget any preexisting platform package, it might be in
|
| 31 |
+
# conflict with this one.
|
| 32 |
+
lappend code {package forget platform}
|
| 33 |
+
# Inject our platform package
|
| 34 |
+
lappend code [list source $base]
|
| 35 |
+
# Query and print the architecture
|
| 36 |
+
lappend code {puts [platform::generic]}
|
| 37 |
+
# And done
|
| 38 |
+
lappend code {exit 0}
|
| 39 |
+
|
| 40 |
+
set arch [RUN $shell [join $code \n]]
|
| 41 |
+
|
| 42 |
+
if {$out} {file delete -force $base}
|
| 43 |
+
return $arch
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# -- platform::shell::identify
|
| 47 |
+
|
| 48 |
+
proc ::platform::shell::identify {shell} {
|
| 49 |
+
# Argument is the path to a tcl shell.
|
| 50 |
+
|
| 51 |
+
CHECK $shell
|
| 52 |
+
LOCATE base out
|
| 53 |
+
|
| 54 |
+
set code {}
|
| 55 |
+
# Forget any preexisting platform package, it might be in
|
| 56 |
+
# conflict with this one.
|
| 57 |
+
lappend code {package forget platform}
|
| 58 |
+
# Inject our platform package
|
| 59 |
+
lappend code [list source $base]
|
| 60 |
+
# Query and print the architecture
|
| 61 |
+
lappend code {puts [platform::identify]}
|
| 62 |
+
# And done
|
| 63 |
+
lappend code {exit 0}
|
| 64 |
+
|
| 65 |
+
set arch [RUN $shell [join $code \n]]
|
| 66 |
+
|
| 67 |
+
if {$out} {file delete -force $base}
|
| 68 |
+
return $arch
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
# -- platform::shell::platform
|
| 72 |
+
|
| 73 |
+
proc ::platform::shell::platform {shell} {
|
| 74 |
+
# Argument is the path to a tcl shell.
|
| 75 |
+
|
| 76 |
+
CHECK $shell
|
| 77 |
+
|
| 78 |
+
set code {}
|
| 79 |
+
lappend code {puts $tcl_platform(platform)}
|
| 80 |
+
lappend code {exit 0}
|
| 81 |
+
|
| 82 |
+
return [RUN $shell [join $code \n]]
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
# ### ### ### ######### ######### #########
|
| 86 |
+
## Internal helper commands.
|
| 87 |
+
|
| 88 |
+
proc ::platform::shell::CHECK {shell} {
|
| 89 |
+
if {![file exists $shell]} {
|
| 90 |
+
return -code error "Shell \"$shell\" does not exist"
|
| 91 |
+
}
|
| 92 |
+
if {![file executable $shell]} {
|
| 93 |
+
return -code error "Shell \"$shell\" is not executable (permissions)"
|
| 94 |
+
}
|
| 95 |
+
return
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
proc ::platform::shell::LOCATE {bv ov} {
|
| 99 |
+
upvar 1 $bv base $ov out
|
| 100 |
+
|
| 101 |
+
# Locate the platform package for injection into the specified
|
| 102 |
+
# shell. We are using package management to find it, wherever it
|
| 103 |
+
# is, instead of using hardwired relative paths. This allows us to
|
| 104 |
+
# install the two packages as TMs without breaking the code
|
| 105 |
+
# here. If the found package is wrapped we copy the code somewhere
|
| 106 |
+
# where the spawned shell will be able to read it.
|
| 107 |
+
|
| 108 |
+
# This code is brittle, it needs has to adapt to whatever changes
|
| 109 |
+
# are made to the TM code, i.e. the "provide" statement generated by
|
| 110 |
+
# tm.tcl
|
| 111 |
+
|
| 112 |
+
set pl [package ifneeded platform [package require platform]]
|
| 113 |
+
set base [lindex $pl end]
|
| 114 |
+
|
| 115 |
+
set out 0
|
| 116 |
+
if {[lindex [file system $base]] ne "native"} {
|
| 117 |
+
set temp [TEMP]
|
| 118 |
+
file copy -force $base $temp
|
| 119 |
+
set base $temp
|
| 120 |
+
set out 1
|
| 121 |
+
}
|
| 122 |
+
return
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
proc ::platform::shell::RUN {shell code} {
|
| 126 |
+
set c [TEMP]
|
| 127 |
+
set cc [open $c w]
|
| 128 |
+
puts $cc $code
|
| 129 |
+
close $cc
|
| 130 |
+
|
| 131 |
+
set e [TEMP]
|
| 132 |
+
|
| 133 |
+
set code [catch {
|
| 134 |
+
exec $shell $c 2> $e
|
| 135 |
+
} res]
|
| 136 |
+
|
| 137 |
+
file delete $c
|
| 138 |
+
|
| 139 |
+
if {$code} {
|
| 140 |
+
append res \n[read [set chan [open $e r]]][close $chan]
|
| 141 |
+
file delete $e
|
| 142 |
+
return -code error "Shell \"$shell\" is not executable ($res)"
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
file delete $e
|
| 146 |
+
return $res
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
proc ::platform::shell::TEMP {} {
|
| 150 |
+
set prefix platform
|
| 151 |
+
|
| 152 |
+
# This code is copied out of Tcllib's fileutil package.
|
| 153 |
+
# (TempFile/tempfile)
|
| 154 |
+
|
| 155 |
+
set tmpdir [DIR]
|
| 156 |
+
|
| 157 |
+
set chars "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
| 158 |
+
set nrand_chars 10
|
| 159 |
+
set maxtries 10
|
| 160 |
+
set access [list RDWR CREAT EXCL TRUNC]
|
| 161 |
+
set permission 0600
|
| 162 |
+
set channel ""
|
| 163 |
+
set checked_dir_writable 0
|
| 164 |
+
set mypid [pid]
|
| 165 |
+
for {set i 0} {$i < $maxtries} {incr i} {
|
| 166 |
+
set newname $prefix
|
| 167 |
+
for {set j 0} {$j < $nrand_chars} {incr j} {
|
| 168 |
+
append newname [string index $chars \
|
| 169 |
+
[expr {int(rand()*62)}]]
|
| 170 |
+
}
|
| 171 |
+
set newname [file join $tmpdir $newname]
|
| 172 |
+
if {[file exists $newname]} {
|
| 173 |
+
after 1
|
| 174 |
+
} else {
|
| 175 |
+
if {[catch {open $newname $access $permission} channel]} {
|
| 176 |
+
if {!$checked_dir_writable} {
|
| 177 |
+
set dirname [file dirname $newname]
|
| 178 |
+
if {![file writable $dirname]} {
|
| 179 |
+
return -code error "Directory $dirname is not writable"
|
| 180 |
+
}
|
| 181 |
+
set checked_dir_writable 1
|
| 182 |
+
}
|
| 183 |
+
} else {
|
| 184 |
+
# Success
|
| 185 |
+
close $channel
|
| 186 |
+
return [file normalize $newname]
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
if {$channel ne ""} {
|
| 191 |
+
return -code error "Failed to open a temporary file: $channel"
|
| 192 |
+
} else {
|
| 193 |
+
return -code error "Failed to find an unused temporary file name"
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
proc ::platform::shell::DIR {} {
|
| 198 |
+
# This code is copied out of Tcllib's fileutil package.
|
| 199 |
+
# (TempDir/tempdir)
|
| 200 |
+
|
| 201 |
+
global tcl_platform env
|
| 202 |
+
|
| 203 |
+
set attempdirs [list]
|
| 204 |
+
|
| 205 |
+
foreach tmp {TMPDIR TEMP TMP} {
|
| 206 |
+
if { [info exists env($tmp)] } {
|
| 207 |
+
lappend attempdirs $env($tmp)
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
switch $tcl_platform(platform) {
|
| 212 |
+
windows {
|
| 213 |
+
lappend attempdirs "C:\\TEMP" "C:\\TMP" "\\TEMP" "\\TMP"
|
| 214 |
+
}
|
| 215 |
+
macintosh {
|
| 216 |
+
set tmpdir $env(TRASH_FOLDER) ;# a better place?
|
| 217 |
+
}
|
| 218 |
+
default {
|
| 219 |
+
lappend attempdirs \
|
| 220 |
+
[file join / tmp] \
|
| 221 |
+
[file join / var tmp] \
|
| 222 |
+
[file join / usr tmp]
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
lappend attempdirs [pwd]
|
| 227 |
+
|
| 228 |
+
foreach tmp $attempdirs {
|
| 229 |
+
if { [file isdirectory $tmp] && [file writable $tmp] } {
|
| 230 |
+
return [file normalize $tmp]
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
# Fail if nothing worked.
|
| 235 |
+
return -code error "Unable to determine a proper directory for temporary files"
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
# ### ### ### ######### ######### #########
|
| 239 |
+
## Ready
|
| 240 |
+
|
| 241 |
+
package provide platform::shell 1.1.4
|
mplug_owl2/lib/tcl8/8.5/msgcat-1.6.1.tm
ADDED
|
@@ -0,0 +1,1210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# msgcat.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines various procedures which implement a
|
| 4 |
+
# message catalog facility for Tcl programs. It should be
|
| 5 |
+
# loaded with the command "package require msgcat".
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 2010-2015 Harald Oehlmann.
|
| 8 |
+
# Copyright (c) 1998-2000 Ajuba Solutions.
|
| 9 |
+
# Copyright (c) 1998 Mark Harrison.
|
| 10 |
+
#
|
| 11 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 12 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 13 |
+
|
| 14 |
+
package require Tcl 8.5-
|
| 15 |
+
# When the version number changes, be sure to update the pkgIndex.tcl file,
|
| 16 |
+
# and the installation directory in the Makefiles.
|
| 17 |
+
package provide msgcat 1.6.1
|
| 18 |
+
|
| 19 |
+
namespace eval msgcat {
|
| 20 |
+
namespace export mc mcexists mcload mclocale mcmax mcmset mcpreferences mcset\
|
| 21 |
+
mcunknown mcflset mcflmset mcloadedlocales mcforgetpackage\
|
| 22 |
+
mcpackageconfig mcpackagelocale
|
| 23 |
+
|
| 24 |
+
# Records the list of locales to search
|
| 25 |
+
variable Loclist {}
|
| 26 |
+
|
| 27 |
+
# List of currently loaded locales
|
| 28 |
+
variable LoadedLocales {}
|
| 29 |
+
|
| 30 |
+
# Records the locale of the currently sourced message catalogue file
|
| 31 |
+
variable FileLocale
|
| 32 |
+
|
| 33 |
+
# Configuration values per Package (e.g. client namespace).
|
| 34 |
+
# The dict key is of the form "<option> <namespace>" and the value is the
|
| 35 |
+
# configuration option. A non-existing key is an unset option.
|
| 36 |
+
variable PackageConfig [dict create mcfolder {} loadcmd {} changecmd {}\
|
| 37 |
+
unknowncmd {} loadedlocales {} loclist {}]
|
| 38 |
+
|
| 39 |
+
# Records the mapping between source strings and translated strings. The
|
| 40 |
+
# dict key is of the form "<namespace> <locale> <src>", where locale and
|
| 41 |
+
# namespace should be themselves dict values and the value is
|
| 42 |
+
# the translated string.
|
| 43 |
+
variable Msgs [dict create]
|
| 44 |
+
|
| 45 |
+
# Map of language codes used in Windows registry to those of ISO-639
|
| 46 |
+
if {[info sharedlibextension] eq ".dll"} {
|
| 47 |
+
variable WinRegToISO639 [dict create {*}{
|
| 48 |
+
01 ar 0401 ar_SA 0801 ar_IQ 0c01 ar_EG 1001 ar_LY 1401 ar_DZ
|
| 49 |
+
1801 ar_MA 1c01 ar_TN 2001 ar_OM 2401 ar_YE 2801 ar_SY
|
| 50 |
+
2c01 ar_JO 3001 ar_LB 3401 ar_KW 3801 ar_AE 3c01 ar_BH
|
| 51 |
+
4001 ar_QA
|
| 52 |
+
02 bg 0402 bg_BG
|
| 53 |
+
03 ca 0403 ca_ES
|
| 54 |
+
04 zh 0404 zh_TW 0804 zh_CN 0c04 zh_HK 1004 zh_SG 1404 zh_MO
|
| 55 |
+
05 cs 0405 cs_CZ
|
| 56 |
+
06 da 0406 da_DK
|
| 57 |
+
07 de 0407 de_DE 0807 de_CH 0c07 de_AT 1007 de_LU 1407 de_LI
|
| 58 |
+
08 el 0408 el_GR
|
| 59 |
+
09 en 0409 en_US 0809 en_GB 0c09 en_AU 1009 en_CA 1409 en_NZ
|
| 60 |
+
1809 en_IE 1c09 en_ZA 2009 en_JM 2409 en_GD 2809 en_BZ
|
| 61 |
+
2c09 en_TT 3009 en_ZW 3409 en_PH
|
| 62 |
+
0a es 040a es_ES 080a es_MX 0c0a es_ES@modern 100a es_GT 140a es_CR
|
| 63 |
+
180a es_PA 1c0a es_DO 200a es_VE 240a es_CO 280a es_PE
|
| 64 |
+
2c0a es_AR 300a es_EC 340a es_CL 380a es_UY 3c0a es_PY
|
| 65 |
+
400a es_BO 440a es_SV 480a es_HN 4c0a es_NI 500a es_PR
|
| 66 |
+
0b fi 040b fi_FI
|
| 67 |
+
0c fr 040c fr_FR 080c fr_BE 0c0c fr_CA 100c fr_CH 140c fr_LU
|
| 68 |
+
180c fr_MC
|
| 69 |
+
0d he 040d he_IL
|
| 70 |
+
0e hu 040e hu_HU
|
| 71 |
+
0f is 040f is_IS
|
| 72 |
+
10 it 0410 it_IT 0810 it_CH
|
| 73 |
+
11 ja 0411 ja_JP
|
| 74 |
+
12 ko 0412 ko_KR
|
| 75 |
+
13 nl 0413 nl_NL 0813 nl_BE
|
| 76 |
+
14 no 0414 no_NO 0814 nn_NO
|
| 77 |
+
15 pl 0415 pl_PL
|
| 78 |
+
16 pt 0416 pt_BR 0816 pt_PT
|
| 79 |
+
17 rm 0417 rm_CH
|
| 80 |
+
18 ro 0418 ro_RO 0818 ro_MO
|
| 81 |
+
19 ru 0819 ru_MO
|
| 82 |
+
1a hr 041a hr_HR 081a sr_YU 0c1a sr_YU@cyrillic
|
| 83 |
+
1b sk 041b sk_SK
|
| 84 |
+
1c sq 041c sq_AL
|
| 85 |
+
1d sv 041d sv_SE 081d sv_FI
|
| 86 |
+
1e th 041e th_TH
|
| 87 |
+
1f tr 041f tr_TR
|
| 88 |
+
20 ur 0420 ur_PK 0820 ur_IN
|
| 89 |
+
21 id 0421 id_ID
|
| 90 |
+
22 uk 0422 uk_UA
|
| 91 |
+
23 be 0423 be_BY
|
| 92 |
+
24 sl 0424 sl_SI
|
| 93 |
+
25 et 0425 et_EE
|
| 94 |
+
26 lv 0426 lv_LV
|
| 95 |
+
27 lt 0427 lt_LT
|
| 96 |
+
28 tg 0428 tg_TJ
|
| 97 |
+
29 fa 0429 fa_IR
|
| 98 |
+
2a vi 042a vi_VN
|
| 99 |
+
2b hy 042b hy_AM
|
| 100 |
+
2c az 042c az_AZ@latin 082c az_AZ@cyrillic
|
| 101 |
+
2d eu
|
| 102 |
+
2e wen 042e wen_DE
|
| 103 |
+
2f mk 042f mk_MK
|
| 104 |
+
30 bnt 0430 bnt_TZ
|
| 105 |
+
31 ts 0431 ts_ZA
|
| 106 |
+
32 tn
|
| 107 |
+
33 ven 0433 ven_ZA
|
| 108 |
+
34 xh 0434 xh_ZA
|
| 109 |
+
35 zu 0435 zu_ZA
|
| 110 |
+
36 af 0436 af_ZA
|
| 111 |
+
37 ka 0437 ka_GE
|
| 112 |
+
38 fo 0438 fo_FO
|
| 113 |
+
39 hi 0439 hi_IN
|
| 114 |
+
3a mt 043a mt_MT
|
| 115 |
+
3b se 043b se_NO
|
| 116 |
+
043c gd_UK 083c ga_IE
|
| 117 |
+
3d yi 043d yi_IL
|
| 118 |
+
3e ms 043e ms_MY 083e ms_BN
|
| 119 |
+
3f kk 043f kk_KZ
|
| 120 |
+
40 ky 0440 ky_KG
|
| 121 |
+
41 sw 0441 sw_KE
|
| 122 |
+
42 tk 0442 tk_TM
|
| 123 |
+
43 uz 0443 uz_UZ@latin 0843 uz_UZ@cyrillic
|
| 124 |
+
44 tt 0444 tt_RU
|
| 125 |
+
45 bn 0445 bn_IN
|
| 126 |
+
46 pa 0446 pa_IN
|
| 127 |
+
47 gu 0447 gu_IN
|
| 128 |
+
48 or 0448 or_IN
|
| 129 |
+
49 ta
|
| 130 |
+
4a te 044a te_IN
|
| 131 |
+
4b kn 044b kn_IN
|
| 132 |
+
4c ml 044c ml_IN
|
| 133 |
+
4d as 044d as_IN
|
| 134 |
+
4e mr 044e mr_IN
|
| 135 |
+
4f sa 044f sa_IN
|
| 136 |
+
50 mn
|
| 137 |
+
51 bo 0451 bo_CN
|
| 138 |
+
52 cy 0452 cy_GB
|
| 139 |
+
53 km 0453 km_KH
|
| 140 |
+
54 lo 0454 lo_LA
|
| 141 |
+
55 my 0455 my_MM
|
| 142 |
+
56 gl 0456 gl_ES
|
| 143 |
+
57 kok 0457 kok_IN
|
| 144 |
+
58 mni 0458 mni_IN
|
| 145 |
+
59 sd
|
| 146 |
+
5a syr 045a syr_TR
|
| 147 |
+
5b si 045b si_LK
|
| 148 |
+
5c chr 045c chr_US
|
| 149 |
+
5d iu 045d iu_CA
|
| 150 |
+
5e am 045e am_ET
|
| 151 |
+
5f ber 045f ber_MA
|
| 152 |
+
60 ks 0460 ks_PK 0860 ks_IN
|
| 153 |
+
61 ne 0461 ne_NP 0861 ne_IN
|
| 154 |
+
62 fy 0462 fy_NL
|
| 155 |
+
63 ps
|
| 156 |
+
64 tl 0464 tl_PH
|
| 157 |
+
65 div 0465 div_MV
|
| 158 |
+
66 bin 0466 bin_NG
|
| 159 |
+
67 ful 0467 ful_NG
|
| 160 |
+
68 ha 0468 ha_NG
|
| 161 |
+
69 nic 0469 nic_NG
|
| 162 |
+
6a yo 046a yo_NG
|
| 163 |
+
70 ibo 0470 ibo_NG
|
| 164 |
+
71 kau 0471 kau_NG
|
| 165 |
+
72 om 0472 om_ET
|
| 166 |
+
73 ti 0473 ti_ET
|
| 167 |
+
74 gn 0474 gn_PY
|
| 168 |
+
75 cpe 0475 cpe_US
|
| 169 |
+
76 la 0476 la_VA
|
| 170 |
+
77 so 0477 so_SO
|
| 171 |
+
78 sit 0478 sit_CN
|
| 172 |
+
79 pap 0479 pap_AN
|
| 173 |
+
}]
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
# msgcat::mc --
|
| 178 |
+
#
|
| 179 |
+
# Find the translation for the given string based on the current
|
| 180 |
+
# locale setting. Check the local namespace first, then look in each
|
| 181 |
+
# parent namespace until the source is found. If additional args are
|
| 182 |
+
# specified, use the format command to work them into the translated
|
| 183 |
+
# string.
|
| 184 |
+
# If no catalog item is found, mcunknown is called in the caller frame
|
| 185 |
+
# and its result is returned.
|
| 186 |
+
#
|
| 187 |
+
# Arguments:
|
| 188 |
+
# src The string to translate.
|
| 189 |
+
# args Args to pass to the format command
|
| 190 |
+
#
|
| 191 |
+
# Results:
|
| 192 |
+
# Returns the translated string. Propagates errors thrown by the
|
| 193 |
+
# format command.
|
| 194 |
+
|
| 195 |
+
proc msgcat::mc {src args} {
|
| 196 |
+
# this may be replaced by:
|
| 197 |
+
# return [mcget -namespace [uplevel 1 [list ::namespace current]] --\
|
| 198 |
+
# $src {*}$args]
|
| 199 |
+
|
| 200 |
+
# Check for the src in each namespace starting from the local and
|
| 201 |
+
# ending in the global.
|
| 202 |
+
|
| 203 |
+
variable Msgs
|
| 204 |
+
variable Loclist
|
| 205 |
+
|
| 206 |
+
set ns [uplevel 1 [list ::namespace current]]
|
| 207 |
+
set loclist [PackagePreferences $ns]
|
| 208 |
+
|
| 209 |
+
set nscur $ns
|
| 210 |
+
while {$nscur != ""} {
|
| 211 |
+
foreach loc $loclist {
|
| 212 |
+
if {[dict exists $Msgs $nscur $loc $src]} {
|
| 213 |
+
return [DefaultUnknown "" [dict get $Msgs $nscur $loc $src]\
|
| 214 |
+
{*}$args]
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
set nscur [namespace parent $nscur]
|
| 218 |
+
}
|
| 219 |
+
# call package local or default unknown command
|
| 220 |
+
set args [linsert $args 0 [lindex $loclist 0] $src]
|
| 221 |
+
switch -exact -- [Invoke unknowncmd $args $ns result 1] {
|
| 222 |
+
0 { return [uplevel 1 [linsert $args 0 [namespace origin mcunknown]]] }
|
| 223 |
+
1 { return [DefaultUnknown {*}$args] }
|
| 224 |
+
default { return $result }
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
# msgcat::mcexists --
|
| 229 |
+
#
|
| 230 |
+
# Check if a catalog item is set or if mc would invoke mcunknown.
|
| 231 |
+
#
|
| 232 |
+
# Arguments:
|
| 233 |
+
# -exactnamespace Only check the exact namespace and no
|
| 234 |
+
# parent namespaces
|
| 235 |
+
# -exactlocale Only check the exact locale and not all members
|
| 236 |
+
# of the preferences list
|
| 237 |
+
# src Message catalog key
|
| 238 |
+
#
|
| 239 |
+
# Results:
|
| 240 |
+
# true if an adequate catalog key was found
|
| 241 |
+
|
| 242 |
+
proc msgcat::mcexists {args} {
|
| 243 |
+
|
| 244 |
+
variable Msgs
|
| 245 |
+
variable Loclist
|
| 246 |
+
variable PackageConfig
|
| 247 |
+
|
| 248 |
+
set ns [uplevel 1 [list ::namespace current]]
|
| 249 |
+
set loclist [PackagePreferences $ns]
|
| 250 |
+
|
| 251 |
+
while {[llength $args] != 1} {
|
| 252 |
+
set args [lassign $args option]
|
| 253 |
+
switch -glob -- $option {
|
| 254 |
+
-exactnamespace { set exactnamespace 1 }
|
| 255 |
+
-exactlocale { set loclist [lrange $loclist 0 0] }
|
| 256 |
+
-* { return -code error "unknown option \"$option\"" }
|
| 257 |
+
default {
|
| 258 |
+
return -code error "wrong # args: should be\
|
| 259 |
+
\"[lindex [info level 0] 0] ?-exactnamespace?\
|
| 260 |
+
?-exactlocale? src\""
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
set src [lindex $args 0]
|
| 265 |
+
|
| 266 |
+
while {$ns ne ""} {
|
| 267 |
+
foreach loc $loclist {
|
| 268 |
+
if {[dict exists $Msgs $ns $loc $src]} {
|
| 269 |
+
return 1
|
| 270 |
+
}
|
| 271 |
+
}
|
| 272 |
+
if {[info exists exactnamespace]} {return 0}
|
| 273 |
+
set ns [namespace parent $ns]
|
| 274 |
+
}
|
| 275 |
+
return 0
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
# msgcat::mclocale --
|
| 279 |
+
#
|
| 280 |
+
# Query or set the current locale.
|
| 281 |
+
#
|
| 282 |
+
# Arguments:
|
| 283 |
+
# newLocale (Optional) The new locale string. Locale strings
|
| 284 |
+
# should be composed of one or more sublocale parts
|
| 285 |
+
# separated by underscores (e.g. en_US).
|
| 286 |
+
#
|
| 287 |
+
# Results:
|
| 288 |
+
# Returns the normalized set locale.
|
| 289 |
+
|
| 290 |
+
proc msgcat::mclocale {args} {
|
| 291 |
+
variable Loclist
|
| 292 |
+
variable LoadedLocales
|
| 293 |
+
set len [llength $args]
|
| 294 |
+
|
| 295 |
+
if {$len > 1} {
|
| 296 |
+
return -code error "wrong # args: should be\
|
| 297 |
+
\"[lindex [info level 0] 0] ?newLocale?\""
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
if {$len == 1} {
|
| 301 |
+
set newLocale [string tolower [lindex $args 0]]
|
| 302 |
+
if {$newLocale ne [file tail $newLocale]} {
|
| 303 |
+
return -code error "invalid newLocale value \"$newLocale\":\
|
| 304 |
+
could be path to unsafe code."
|
| 305 |
+
}
|
| 306 |
+
if {[lindex $Loclist 0] ne $newLocale} {
|
| 307 |
+
set Loclist [GetPreferences $newLocale]
|
| 308 |
+
|
| 309 |
+
# locale not loaded jet
|
| 310 |
+
LoadAll $Loclist
|
| 311 |
+
# Invoke callback
|
| 312 |
+
Invoke changecmd $Loclist
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
return [lindex $Loclist 0]
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
# msgcat::GetPreferences --
|
| 319 |
+
#
|
| 320 |
+
# Get list of locales from a locale.
|
| 321 |
+
# The first element is always the lowercase locale.
|
| 322 |
+
# Other elements have one component separated by "_" less.
|
| 323 |
+
# Multiple "_" are seen as one separator: de__ch_spec de__ch de {}
|
| 324 |
+
#
|
| 325 |
+
# Arguments:
|
| 326 |
+
# Locale.
|
| 327 |
+
#
|
| 328 |
+
# Results:
|
| 329 |
+
# Locale list
|
| 330 |
+
|
| 331 |
+
proc msgcat::GetPreferences {locale} {
|
| 332 |
+
set locale [string tolower $locale]
|
| 333 |
+
set loclist [list $locale]
|
| 334 |
+
while {-1 !=[set pos [string last "_" $locale]]} {
|
| 335 |
+
set locale [string range $locale 0 $pos-1]
|
| 336 |
+
if { "_" ne [string index $locale end] } {
|
| 337 |
+
lappend loclist $locale
|
| 338 |
+
}
|
| 339 |
+
}
|
| 340 |
+
if {"" ne [lindex $loclist end]} {
|
| 341 |
+
lappend loclist {}
|
| 342 |
+
}
|
| 343 |
+
return $loclist
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
# msgcat::mcpreferences --
|
| 347 |
+
#
|
| 348 |
+
# Fetch the list of locales used to look up strings, ordered from
|
| 349 |
+
# most preferred to least preferred.
|
| 350 |
+
#
|
| 351 |
+
# Arguments:
|
| 352 |
+
# None.
|
| 353 |
+
#
|
| 354 |
+
# Results:
|
| 355 |
+
# Returns an ordered list of the locales preferred by the user.
|
| 356 |
+
|
| 357 |
+
proc msgcat::mcpreferences {} {
|
| 358 |
+
variable Loclist
|
| 359 |
+
return $Loclist
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
# msgcat::mcloadedlocales --
|
| 363 |
+
#
|
| 364 |
+
# Get or change the list of currently loaded default locales
|
| 365 |
+
#
|
| 366 |
+
# The following subcommands are available:
|
| 367 |
+
# loaded
|
| 368 |
+
# Get the current list of loaded locales
|
| 369 |
+
# clear
|
| 370 |
+
# Remove all loaded locales not present in mcpreferences.
|
| 371 |
+
#
|
| 372 |
+
# Arguments:
|
| 373 |
+
# subcommand One of loaded or clear
|
| 374 |
+
#
|
| 375 |
+
# Results:
|
| 376 |
+
# Empty string, if not stated differently for the subcommand
|
| 377 |
+
|
| 378 |
+
proc msgcat::mcloadedlocales {subcommand} {
|
| 379 |
+
variable Loclist
|
| 380 |
+
variable LoadedLocales
|
| 381 |
+
variable Msgs
|
| 382 |
+
variable PackageConfig
|
| 383 |
+
switch -exact -- $subcommand {
|
| 384 |
+
clear {
|
| 385 |
+
# Remove all locales not contained in Loclist
|
| 386 |
+
# skip any packages with package locale
|
| 387 |
+
set LoadedLocales $Loclist
|
| 388 |
+
foreach ns [dict keys $Msgs] {
|
| 389 |
+
if {![dict exists $PackageConfig loclist $ns]} {
|
| 390 |
+
foreach locale [dict keys [dict get $Msgs $ns]] {
|
| 391 |
+
if {$locale ni $Loclist} {
|
| 392 |
+
dict unset Msgs $ns $locale
|
| 393 |
+
}
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
}
|
| 397 |
+
}
|
| 398 |
+
loaded { return $LoadedLocales }
|
| 399 |
+
default {
|
| 400 |
+
return -code error "unknown subcommand \"$subcommand\": must be\
|
| 401 |
+
clear, or loaded"
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
return
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
# msgcat::mcpackagelocale --
|
| 408 |
+
#
|
| 409 |
+
# Get or change the package locale of the calling package.
|
| 410 |
+
#
|
| 411 |
+
# The following subcommands are available:
|
| 412 |
+
# set
|
| 413 |
+
# Set a package locale.
|
| 414 |
+
# This may load message catalog files and may clear message catalog
|
| 415 |
+
# items, if the former locale was the default locale.
|
| 416 |
+
# Returns the normalized set locale.
|
| 417 |
+
# The default locale is taken, if locale is not given.
|
| 418 |
+
# get
|
| 419 |
+
# Get the locale valid for this package.
|
| 420 |
+
# isset
|
| 421 |
+
# Returns true, if a package locale is set
|
| 422 |
+
# unset
|
| 423 |
+
# Unset the package locale and activate the default locale.
|
| 424 |
+
# This loads message catalog file which where missing in the package
|
| 425 |
+
# locale.
|
| 426 |
+
# preferences
|
| 427 |
+
# Return locale preference list valid for the package.
|
| 428 |
+
# loaded
|
| 429 |
+
# Return loaded locale list valid for the current package.
|
| 430 |
+
# clear
|
| 431 |
+
# If the current package has a package locale, remove all package
|
| 432 |
+
# locales not containes in package mcpreferences.
|
| 433 |
+
# It is an error to call this without a package locale set.
|
| 434 |
+
#
|
| 435 |
+
# The subcommands get, preferences and loaded return the corresponding
|
| 436 |
+
# default data, if no package locale is set.
|
| 437 |
+
#
|
| 438 |
+
# Arguments:
|
| 439 |
+
# subcommand see list above
|
| 440 |
+
# locale package locale (only set subcommand)
|
| 441 |
+
#
|
| 442 |
+
# Results:
|
| 443 |
+
# Empty string, if not stated differently for the subcommand
|
| 444 |
+
|
| 445 |
+
proc msgcat::mcpackagelocale {subcommand {locale ""}} {
|
| 446 |
+
# todo: implement using an ensemble
|
| 447 |
+
variable Loclist
|
| 448 |
+
variable LoadedLocales
|
| 449 |
+
variable Msgs
|
| 450 |
+
variable PackageConfig
|
| 451 |
+
# Check option
|
| 452 |
+
# check if required item is exactly provided
|
| 453 |
+
if {[llength [info level 0]] == 2} {
|
| 454 |
+
# locale not given
|
| 455 |
+
unset locale
|
| 456 |
+
} else {
|
| 457 |
+
# locale given
|
| 458 |
+
if {$subcommand in
|
| 459 |
+
{"get" "isset" "unset" "preferences" "loaded" "clear"} } {
|
| 460 |
+
return -code error "wrong # args: should be\
|
| 461 |
+
\"[lrange [info level 0] 0 1]\""
|
| 462 |
+
}
|
| 463 |
+
set locale [string tolower $locale]
|
| 464 |
+
}
|
| 465 |
+
set ns [uplevel 1 {::namespace current}]
|
| 466 |
+
|
| 467 |
+
switch -exact -- $subcommand {
|
| 468 |
+
get { return [lindex [PackagePreferences $ns] 0] }
|
| 469 |
+
preferences { return [PackagePreferences $ns] }
|
| 470 |
+
loaded { return [PackageLocales $ns] }
|
| 471 |
+
present { return [expr {$locale in [PackageLocales $ns]} ]}
|
| 472 |
+
isset { return [dict exists $PackageConfig loclist $ns] }
|
| 473 |
+
set { # set a package locale or add a package locale
|
| 474 |
+
|
| 475 |
+
# Copy the default locale if no package locale set so far
|
| 476 |
+
if {![dict exists $PackageConfig loclist $ns]} {
|
| 477 |
+
dict set PackageConfig loclist $ns $Loclist
|
| 478 |
+
dict set PackageConfig loadedlocales $ns $LoadedLocales
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
# Check if changed
|
| 482 |
+
set loclist [dict get $PackageConfig loclist $ns]
|
| 483 |
+
if {! [info exists locale] || $locale eq [lindex $loclist 0] } {
|
| 484 |
+
return [lindex $loclist 0]
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
# Change loclist
|
| 488 |
+
set loclist [GetPreferences $locale]
|
| 489 |
+
set locale [lindex $loclist 0]
|
| 490 |
+
dict set PackageConfig loclist $ns $loclist
|
| 491 |
+
|
| 492 |
+
# load eventual missing locales
|
| 493 |
+
set loadedLocales [dict get $PackageConfig loadedlocales $ns]
|
| 494 |
+
if {$locale in $loadedLocales} { return $locale }
|
| 495 |
+
set loadLocales [ListComplement $loadedLocales $loclist]
|
| 496 |
+
dict set PackageConfig loadedlocales $ns\
|
| 497 |
+
[concat $loadedLocales $loadLocales]
|
| 498 |
+
Load $ns $loadLocales
|
| 499 |
+
return $locale
|
| 500 |
+
}
|
| 501 |
+
clear { # Remove all locales not contained in Loclist
|
| 502 |
+
if {![dict exists $PackageConfig loclist $ns]} {
|
| 503 |
+
return -code error "clear only when package locale set"
|
| 504 |
+
}
|
| 505 |
+
set loclist [dict get $PackageConfig loclist $ns]
|
| 506 |
+
dict set PackageConfig loadedlocales $ns $loclist
|
| 507 |
+
if {[dict exists $Msgs $ns]} {
|
| 508 |
+
foreach locale [dict keys [dict get $Msgs $ns]] {
|
| 509 |
+
if {$locale ni $loclist} {
|
| 510 |
+
dict unset Msgs $ns $locale
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
}
|
| 515 |
+
unset { # unset package locale and restore default locales
|
| 516 |
+
|
| 517 |
+
if { ![dict exists $PackageConfig loclist $ns] } { return }
|
| 518 |
+
|
| 519 |
+
# unset package locale
|
| 520 |
+
set loadLocales [ListComplement\
|
| 521 |
+
[dict get $PackageConfig loadedlocales $ns] $LoadedLocales]
|
| 522 |
+
dict unset PackageConfig loadedlocales $ns
|
| 523 |
+
dict unset PackageConfig loclist $ns
|
| 524 |
+
|
| 525 |
+
# unset keys not in global loaded locales
|
| 526 |
+
if {[dict exists $Msgs $ns]} {
|
| 527 |
+
foreach locale [dict keys [dict get $Msgs $ns]] {
|
| 528 |
+
if {$locale ni $LoadedLocales} {
|
| 529 |
+
dict unset Msgs $ns $locale
|
| 530 |
+
}
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
# Add missing locales
|
| 535 |
+
Load $ns $loadLocales
|
| 536 |
+
}
|
| 537 |
+
default {
|
| 538 |
+
return -code error "unknown subcommand \"$subcommand\": must be\
|
| 539 |
+
clear, get, isset, loaded, present, set, or unset"
|
| 540 |
+
}
|
| 541 |
+
}
|
| 542 |
+
return
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
# msgcat::mcforgetpackage --
|
| 546 |
+
#
|
| 547 |
+
# Remove any data of the calling package from msgcat
|
| 548 |
+
#
|
| 549 |
+
|
| 550 |
+
proc msgcat::mcforgetpackage {} {
|
| 551 |
+
# todo: this may be implemented using an ensemble
|
| 552 |
+
variable PackageConfig
|
| 553 |
+
variable Msgs
|
| 554 |
+
set ns [uplevel 1 {::namespace current}]
|
| 555 |
+
# Remove MC items
|
| 556 |
+
dict unset Msgs $ns
|
| 557 |
+
# Remove config items
|
| 558 |
+
foreach key [dict keys $PackageConfig] {
|
| 559 |
+
dict unset PackageConfig $key $ns
|
| 560 |
+
}
|
| 561 |
+
return
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
# msgcat::mcpackageconfig --
|
| 565 |
+
#
|
| 566 |
+
# Get or modify the per caller namespace (e.g. packages) config options.
|
| 567 |
+
#
|
| 568 |
+
# Available subcommands are:
|
| 569 |
+
#
|
| 570 |
+
# get get the current value or an error if not set.
|
| 571 |
+
# isset return true, if the option is set
|
| 572 |
+
# set set the value (see also distinct option).
|
| 573 |
+
# Returns the number of loaded message files.
|
| 574 |
+
# unset Clear option. return "".
|
| 575 |
+
#
|
| 576 |
+
# Available options are:
|
| 577 |
+
#
|
| 578 |
+
# mcfolder
|
| 579 |
+
# The message catalog folder of the package.
|
| 580 |
+
# This is automatically set by mcload.
|
| 581 |
+
# If the value is changed using the set subcommand, an eventual
|
| 582 |
+
# loadcmd is invoked and all message files of the package locale are
|
| 583 |
+
# loaded.
|
| 584 |
+
#
|
| 585 |
+
# loadcmd
|
| 586 |
+
# The command gets executed before a message file would be
|
| 587 |
+
# sourced for this module.
|
| 588 |
+
# The command is invoked with the expanded locale list to load.
|
| 589 |
+
# The command is not invoked if the registering package namespace
|
| 590 |
+
# is not present.
|
| 591 |
+
# This callback might also be used as an alternative to message
|
| 592 |
+
# files.
|
| 593 |
+
# If the value is changed using the set subcommand, the callback is
|
| 594 |
+
# directly invoked with the current file locale list. No file load is
|
| 595 |
+
# executed.
|
| 596 |
+
#
|
| 597 |
+
# changecmd
|
| 598 |
+
# The command is invoked, after an executed locale change.
|
| 599 |
+
# Appended argument is expanded mcpreferences.
|
| 600 |
+
#
|
| 601 |
+
# unknowncmd
|
| 602 |
+
# Use a package locale mcunknown procedure instead the global one.
|
| 603 |
+
# The appended arguments are identical to mcunknown.
|
| 604 |
+
# A default unknown handler is used if set to the empty string.
|
| 605 |
+
# This consists in returning the key if no arguments are given.
|
| 606 |
+
# With given arguments, format is used to process the arguments.
|
| 607 |
+
#
|
| 608 |
+
# Arguments:
|
| 609 |
+
# subcommand Operation on the package
|
| 610 |
+
# option The package option to get or set.
|
| 611 |
+
# ?value? Eventual value for the subcommand
|
| 612 |
+
#
|
| 613 |
+
# Results:
|
| 614 |
+
# Depends on the subcommand and option and is described there
|
| 615 |
+
|
| 616 |
+
proc msgcat::mcpackageconfig {subcommand option {value ""}} {
|
| 617 |
+
variable PackageConfig
|
| 618 |
+
# get namespace
|
| 619 |
+
set ns [uplevel 1 {::namespace current}]
|
| 620 |
+
|
| 621 |
+
if {$option ni {"mcfolder" "loadcmd" "changecmd" "unknowncmd"}} {
|
| 622 |
+
return -code error "bad option \"$option\": must be mcfolder, loadcmd,\
|
| 623 |
+
changecmd, or unknowncmd"
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
# check if value argument is exactly provided
|
| 627 |
+
if {[llength [info level 0]] == 4 } {
|
| 628 |
+
# value provided
|
| 629 |
+
if {$subcommand in {"get" "isset" "unset"}} {
|
| 630 |
+
return -code error "wrong # args: should be\
|
| 631 |
+
\"[lrange [info level 0] 0 2] value\""
|
| 632 |
+
}
|
| 633 |
+
} elseif {$subcommand eq "set"} {
|
| 634 |
+
return -code error\
|
| 635 |
+
"wrong # args: should be \"[lrange [info level 0] 0 2]\""
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
# Execute subcommands
|
| 639 |
+
switch -exact -- $subcommand {
|
| 640 |
+
get { # Operation get return current value
|
| 641 |
+
if {![dict exists $PackageConfig $option $ns]} {
|
| 642 |
+
return -code error "package option \"$option\" not set"
|
| 643 |
+
}
|
| 644 |
+
return [dict get $PackageConfig $option $ns]
|
| 645 |
+
}
|
| 646 |
+
isset { return [dict exists $PackageConfig $option $ns] }
|
| 647 |
+
unset { dict unset PackageConfig $option $ns }
|
| 648 |
+
set { # Set option
|
| 649 |
+
|
| 650 |
+
if {$option eq "mcfolder"} {
|
| 651 |
+
set value [file normalize $value]
|
| 652 |
+
}
|
| 653 |
+
# Check if changed
|
| 654 |
+
if { [dict exists $PackageConfig $option $ns]
|
| 655 |
+
&& $value eq [dict get $PackageConfig $option $ns] } {
|
| 656 |
+
return 0
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
# set new value
|
| 660 |
+
dict set PackageConfig $option $ns $value
|
| 661 |
+
|
| 662 |
+
# Reload pending message catalogs
|
| 663 |
+
switch -exact -- $option {
|
| 664 |
+
mcfolder { return [Load $ns [PackageLocales $ns]] }
|
| 665 |
+
loadcmd { return [Load $ns [PackageLocales $ns] 1] }
|
| 666 |
+
}
|
| 667 |
+
return 0
|
| 668 |
+
}
|
| 669 |
+
default {
|
| 670 |
+
return -code error "unknown subcommand \"$subcommand\":\
|
| 671 |
+
must be get, isset, set, or unset"
|
| 672 |
+
}
|
| 673 |
+
}
|
| 674 |
+
return
|
| 675 |
+
}
|
| 676 |
+
|
| 677 |
+
# msgcat::PackagePreferences --
|
| 678 |
+
#
|
| 679 |
+
# Return eventual present package preferences or the default list if not
|
| 680 |
+
# present.
|
| 681 |
+
#
|
| 682 |
+
# Arguments:
|
| 683 |
+
# ns Package namespace
|
| 684 |
+
#
|
| 685 |
+
# Results:
|
| 686 |
+
# locale list
|
| 687 |
+
|
| 688 |
+
proc msgcat::PackagePreferences {ns} {
|
| 689 |
+
variable PackageConfig
|
| 690 |
+
if {[dict exists $PackageConfig loclist $ns]} {
|
| 691 |
+
return [dict get $PackageConfig loclist $ns]
|
| 692 |
+
}
|
| 693 |
+
variable Loclist
|
| 694 |
+
return $Loclist
|
| 695 |
+
}
|
| 696 |
+
|
| 697 |
+
# msgcat::PackageLocales --
|
| 698 |
+
#
|
| 699 |
+
# Return eventual present package locales or the default list if not
|
| 700 |
+
# present.
|
| 701 |
+
#
|
| 702 |
+
# Arguments:
|
| 703 |
+
# ns Package namespace
|
| 704 |
+
#
|
| 705 |
+
# Results:
|
| 706 |
+
# locale list
|
| 707 |
+
|
| 708 |
+
proc msgcat::PackageLocales {ns} {
|
| 709 |
+
variable PackageConfig
|
| 710 |
+
if {[dict exists $PackageConfig loadedlocales $ns]} {
|
| 711 |
+
return [dict get $PackageConfig loadedlocales $ns]
|
| 712 |
+
}
|
| 713 |
+
variable LoadedLocales
|
| 714 |
+
return $LoadedLocales
|
| 715 |
+
}
|
| 716 |
+
|
| 717 |
+
# msgcat::ListComplement --
|
| 718 |
+
#
|
| 719 |
+
# Build the complement of two lists.
|
| 720 |
+
# Return a list with all elements in list2 but not in list1.
|
| 721 |
+
# Optionally return the intersection.
|
| 722 |
+
#
|
| 723 |
+
# Arguments:
|
| 724 |
+
# list1 excluded list
|
| 725 |
+
# list2 included list
|
| 726 |
+
# inlistname If not "", write in this variable the intersection list
|
| 727 |
+
#
|
| 728 |
+
# Results:
|
| 729 |
+
# list with all elements in list2 but not in list1
|
| 730 |
+
|
| 731 |
+
proc msgcat::ListComplement {list1 list2 {inlistname ""}} {
|
| 732 |
+
if {"" ne $inlistname} {
|
| 733 |
+
upvar 1 $inlistname inlist
|
| 734 |
+
}
|
| 735 |
+
set inlist {}
|
| 736 |
+
set outlist {}
|
| 737 |
+
foreach item $list2 {
|
| 738 |
+
if {$item in $list1} {
|
| 739 |
+
lappend inlist $item
|
| 740 |
+
} else {
|
| 741 |
+
lappend outlist $item
|
| 742 |
+
}
|
| 743 |
+
}
|
| 744 |
+
return $outlist
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
# msgcat::mcload --
|
| 748 |
+
#
|
| 749 |
+
# Attempt to load message catalogs for each locale in the
|
| 750 |
+
# preference list from the specified directory.
|
| 751 |
+
#
|
| 752 |
+
# Arguments:
|
| 753 |
+
# langdir The directory to search.
|
| 754 |
+
#
|
| 755 |
+
# Results:
|
| 756 |
+
# Returns the number of message catalogs that were loaded.
|
| 757 |
+
|
| 758 |
+
proc msgcat::mcload {langdir} {
|
| 759 |
+
return [uplevel 1 [list\
|
| 760 |
+
[namespace origin mcpackageconfig] set mcfolder $langdir]]
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
# msgcat::LoadAll --
|
| 764 |
+
#
|
| 765 |
+
# Load a list of locales for all packages not having a package locale
|
| 766 |
+
# list.
|
| 767 |
+
#
|
| 768 |
+
# Arguments:
|
| 769 |
+
# langdir The directory to search.
|
| 770 |
+
#
|
| 771 |
+
# Results:
|
| 772 |
+
# Returns the number of message catalogs that were loaded.
|
| 773 |
+
|
| 774 |
+
proc msgcat::LoadAll {locales} {
|
| 775 |
+
variable PackageConfig
|
| 776 |
+
variable LoadedLocales
|
| 777 |
+
if {0 == [llength $locales]} { return {} }
|
| 778 |
+
# filter jet unloaded locales
|
| 779 |
+
set locales [ListComplement $LoadedLocales $locales]
|
| 780 |
+
if {0 == [llength $locales]} { return {} }
|
| 781 |
+
lappend LoadedLocales {*}$locales
|
| 782 |
+
|
| 783 |
+
set packages [lsort -unique [concat\
|
| 784 |
+
[dict keys [dict get $PackageConfig loadcmd]]\
|
| 785 |
+
[dict keys [dict get $PackageConfig mcfolder]]]]
|
| 786 |
+
foreach ns $packages {
|
| 787 |
+
if {! [dict exists $PackageConfig loclist $ns] } {
|
| 788 |
+
Load $ns $locales
|
| 789 |
+
}
|
| 790 |
+
}
|
| 791 |
+
return $locales
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
# msgcat::Load --
|
| 795 |
+
#
|
| 796 |
+
# Invoke message load callback and load message catalog files.
|
| 797 |
+
#
|
| 798 |
+
# Arguments:
|
| 799 |
+
# ns Namespace (equal package) to load the message catalog.
|
| 800 |
+
# locales List of locales to load.
|
| 801 |
+
# callbackonly true if only callback should be invoked
|
| 802 |
+
#
|
| 803 |
+
# Results:
|
| 804 |
+
# Returns the number of message catalogs that were loaded.
|
| 805 |
+
|
| 806 |
+
proc msgcat::Load {ns locales {callbackonly 0}} {
|
| 807 |
+
variable FileLocale
|
| 808 |
+
variable PackageConfig
|
| 809 |
+
variable LoadedLocals
|
| 810 |
+
|
| 811 |
+
if {0 == [llength $locales]} { return 0 }
|
| 812 |
+
|
| 813 |
+
# Invoke callback
|
| 814 |
+
Invoke loadcmd $locales $ns
|
| 815 |
+
|
| 816 |
+
if {$callbackonly || ![dict exists $PackageConfig mcfolder $ns]} {
|
| 817 |
+
return 0
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
# Invoke file load
|
| 821 |
+
set langdir [dict get $PackageConfig mcfolder $ns]
|
| 822 |
+
|
| 823 |
+
# Save the file locale if we are recursively called
|
| 824 |
+
if {[info exists FileLocale]} {
|
| 825 |
+
set nestedFileLocale $FileLocale
|
| 826 |
+
}
|
| 827 |
+
set x 0
|
| 828 |
+
foreach p $locales {
|
| 829 |
+
if {$p eq {}} {
|
| 830 |
+
set p ROOT
|
| 831 |
+
}
|
| 832 |
+
set langfile [file join $langdir $p.msg]
|
| 833 |
+
if {[file exists $langfile]} {
|
| 834 |
+
incr x
|
| 835 |
+
set FileLocale [string tolower\
|
| 836 |
+
[file tail [file rootname $langfile]]]
|
| 837 |
+
if {"root" eq $FileLocale} {
|
| 838 |
+
set FileLocale ""
|
| 839 |
+
}
|
| 840 |
+
namespace inscope $ns [list ::source -encoding utf-8 $langfile]
|
| 841 |
+
unset FileLocale
|
| 842 |
+
}
|
| 843 |
+
}
|
| 844 |
+
if {[info exists nestedFileLocale]} {
|
| 845 |
+
set FileLocale $nestedFileLocale
|
| 846 |
+
}
|
| 847 |
+
return $x
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
# msgcat::Invoke --
|
| 851 |
+
#
|
| 852 |
+
# Invoke a set of registered callbacks.
|
| 853 |
+
# The callback is only invoked, if its registered namespace exists.
|
| 854 |
+
#
|
| 855 |
+
# Arguments:
|
| 856 |
+
# index Index into PackageConfig to get callback command
|
| 857 |
+
# arglist parameters to the callback invocation
|
| 858 |
+
# ns (Optional) package to call.
|
| 859 |
+
# If not given or empty, check all registered packages.
|
| 860 |
+
# resultname Variable to save the callback result of the last called
|
| 861 |
+
# callback to. May be set to "" to discard the result.
|
| 862 |
+
# failerror (0) Fail on error if true. Otherwise call bgerror.
|
| 863 |
+
#
|
| 864 |
+
# Results:
|
| 865 |
+
# Possible values:
|
| 866 |
+
# - 0: no valid command registered
|
| 867 |
+
# - 1: registered command was the empty string
|
| 868 |
+
# - 2: registered command called, resultname is set
|
| 869 |
+
# - 3: registered command failed
|
| 870 |
+
# If multiple commands are called, the maximum of all results is returned.
|
| 871 |
+
|
| 872 |
+
proc msgcat::Invoke {index arglist {ns ""} {resultname ""} {failerror 0}} {
|
| 873 |
+
variable PackageConfig
|
| 874 |
+
variable Config
|
| 875 |
+
if {"" ne $resultname} {
|
| 876 |
+
upvar 1 $resultname result
|
| 877 |
+
}
|
| 878 |
+
if {"" eq $ns} {
|
| 879 |
+
set packageList [dict keys [dict get $PackageConfig $index]]
|
| 880 |
+
} else {
|
| 881 |
+
set packageList [list $ns]
|
| 882 |
+
}
|
| 883 |
+
set ret 0
|
| 884 |
+
foreach ns $packageList {
|
| 885 |
+
if {[dict exists $PackageConfig $index $ns] && [namespace exists $ns]} {
|
| 886 |
+
set cmd [dict get $PackageConfig $index $ns]
|
| 887 |
+
if {"" eq $cmd} {
|
| 888 |
+
if {$ret == 0} {set ret 1}
|
| 889 |
+
} else {
|
| 890 |
+
if {$failerror} {
|
| 891 |
+
set result [namespace inscope $ns $cmd {*}$arglist]
|
| 892 |
+
set ret 2
|
| 893 |
+
} elseif {1 == [catch {
|
| 894 |
+
set result [namespace inscope $ns $cmd {*}$arglist]
|
| 895 |
+
if {$ret < 2} {set ret 2}
|
| 896 |
+
} err derr]} {
|
| 897 |
+
after idle [concat [::interp bgerror ""]\
|
| 898 |
+
[list $err $derr]]
|
| 899 |
+
set ret 3
|
| 900 |
+
}
|
| 901 |
+
}
|
| 902 |
+
}
|
| 903 |
+
}
|
| 904 |
+
return $ret
|
| 905 |
+
}
|
| 906 |
+
|
| 907 |
+
# msgcat::mcset --
|
| 908 |
+
#
|
| 909 |
+
# Set the translation for a given string in a specified locale.
|
| 910 |
+
#
|
| 911 |
+
# Arguments:
|
| 912 |
+
# locale The locale to use.
|
| 913 |
+
# src The source string.
|
| 914 |
+
# dest (Optional) The translated string. If omitted,
|
| 915 |
+
# the source string is used.
|
| 916 |
+
#
|
| 917 |
+
# Results:
|
| 918 |
+
# Returns the new locale.
|
| 919 |
+
|
| 920 |
+
proc msgcat::mcset {locale src {dest ""}} {
|
| 921 |
+
variable Msgs
|
| 922 |
+
if {[llength [info level 0]] == 3} { ;# dest not specified
|
| 923 |
+
set dest $src
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
set ns [uplevel 1 [list ::namespace current]]
|
| 927 |
+
|
| 928 |
+
set locale [string tolower $locale]
|
| 929 |
+
|
| 930 |
+
dict set Msgs $ns $locale $src $dest
|
| 931 |
+
return $dest
|
| 932 |
+
}
|
| 933 |
+
|
| 934 |
+
# msgcat::mcflset --
|
| 935 |
+
#
|
| 936 |
+
# Set the translation for a given string in the current file locale.
|
| 937 |
+
#
|
| 938 |
+
# Arguments:
|
| 939 |
+
# src The source string.
|
| 940 |
+
# dest (Optional) The translated string. If omitted,
|
| 941 |
+
# the source string is used.
|
| 942 |
+
#
|
| 943 |
+
# Results:
|
| 944 |
+
# Returns the new locale.
|
| 945 |
+
|
| 946 |
+
proc msgcat::mcflset {src {dest ""}} {
|
| 947 |
+
variable FileLocale
|
| 948 |
+
variable Msgs
|
| 949 |
+
|
| 950 |
+
if {![info exists FileLocale]} {
|
| 951 |
+
return -code error "must only be used inside a message catalog loaded\
|
| 952 |
+
with ::msgcat::mcload"
|
| 953 |
+
}
|
| 954 |
+
return [uplevel 1 [list [namespace origin mcset] $FileLocale $src $dest]]
|
| 955 |
+
}
|
| 956 |
+
|
| 957 |
+
# msgcat::mcmset --
|
| 958 |
+
#
|
| 959 |
+
# Set the translation for multiple strings in a specified locale.
|
| 960 |
+
#
|
| 961 |
+
# Arguments:
|
| 962 |
+
# locale The locale to use.
|
| 963 |
+
# pairs One or more src/dest pairs (must be even length)
|
| 964 |
+
#
|
| 965 |
+
# Results:
|
| 966 |
+
# Returns the number of pairs processed
|
| 967 |
+
|
| 968 |
+
proc msgcat::mcmset {locale pairs} {
|
| 969 |
+
variable Msgs
|
| 970 |
+
|
| 971 |
+
set length [llength $pairs]
|
| 972 |
+
if {$length % 2} {
|
| 973 |
+
return -code error "bad translation list:\
|
| 974 |
+
should be \"[lindex [info level 0] 0] locale {src dest ...}\""
|
| 975 |
+
}
|
| 976 |
+
|
| 977 |
+
set locale [string tolower $locale]
|
| 978 |
+
set ns [uplevel 1 [list ::namespace current]]
|
| 979 |
+
|
| 980 |
+
foreach {src dest} $pairs {
|
| 981 |
+
dict set Msgs $ns $locale $src $dest
|
| 982 |
+
}
|
| 983 |
+
|
| 984 |
+
return [expr {$length / 2}]
|
| 985 |
+
}
|
| 986 |
+
|
| 987 |
+
# msgcat::mcflmset --
|
| 988 |
+
#
|
| 989 |
+
# Set the translation for multiple strings in the mc file locale.
|
| 990 |
+
#
|
| 991 |
+
# Arguments:
|
| 992 |
+
# pairs One or more src/dest pairs (must be even length)
|
| 993 |
+
#
|
| 994 |
+
# Results:
|
| 995 |
+
# Returns the number of pairs processed
|
| 996 |
+
|
| 997 |
+
proc msgcat::mcflmset {pairs} {
|
| 998 |
+
variable FileLocale
|
| 999 |
+
variable Msgs
|
| 1000 |
+
|
| 1001 |
+
if {![info exists FileLocale]} {
|
| 1002 |
+
return -code error "must only be used inside a message catalog loaded\
|
| 1003 |
+
with ::msgcat::mcload"
|
| 1004 |
+
}
|
| 1005 |
+
return [uplevel 1 [list [namespace origin mcmset] $FileLocale $pairs]]
|
| 1006 |
+
}
|
| 1007 |
+
|
| 1008 |
+
# msgcat::mcunknown --
|
| 1009 |
+
#
|
| 1010 |
+
# This routine is called by msgcat::mc if a translation cannot
|
| 1011 |
+
# be found for a string and no unknowncmd is set for the current
|
| 1012 |
+
# package. This routine is intended to be replaced
|
| 1013 |
+
# by an application specific routine for error reporting
|
| 1014 |
+
# purposes. The default behavior is to return the source string.
|
| 1015 |
+
# If additional args are specified, the format command will be used
|
| 1016 |
+
# to work them into the translated string.
|
| 1017 |
+
#
|
| 1018 |
+
# Arguments:
|
| 1019 |
+
# locale The current locale.
|
| 1020 |
+
# src The string to be translated.
|
| 1021 |
+
# args Args to pass to the format command
|
| 1022 |
+
#
|
| 1023 |
+
# Results:
|
| 1024 |
+
# Returns the translated value.
|
| 1025 |
+
|
| 1026 |
+
proc msgcat::mcunknown {args} {
|
| 1027 |
+
return [uplevel 1 [list [namespace origin DefaultUnknown] {*}$args]]
|
| 1028 |
+
}
|
| 1029 |
+
|
| 1030 |
+
# msgcat::DefaultUnknown --
|
| 1031 |
+
#
|
| 1032 |
+
# This routine is called by msgcat::mc if a translation cannot
|
| 1033 |
+
# be found for a string in the following circumstances:
|
| 1034 |
+
# - Default global handler, if mcunknown is not redefined.
|
| 1035 |
+
# - Per package handler, if the package sets unknowncmd to the empty
|
| 1036 |
+
# string.
|
| 1037 |
+
# It returns the source string if the argument list is empty.
|
| 1038 |
+
# If additional args are specified, the format command will be used
|
| 1039 |
+
# to work them into the translated string.
|
| 1040 |
+
#
|
| 1041 |
+
# Arguments:
|
| 1042 |
+
# locale (unused) The current locale.
|
| 1043 |
+
# src The string to be translated.
|
| 1044 |
+
# args Args to pass to the format command
|
| 1045 |
+
#
|
| 1046 |
+
# Results:
|
| 1047 |
+
# Returns the translated value.
|
| 1048 |
+
|
| 1049 |
+
proc msgcat::DefaultUnknown {locale src args} {
|
| 1050 |
+
if {[llength $args]} {
|
| 1051 |
+
return [format $src {*}$args]
|
| 1052 |
+
} else {
|
| 1053 |
+
return $src
|
| 1054 |
+
}
|
| 1055 |
+
}
|
| 1056 |
+
|
| 1057 |
+
# msgcat::mcmax --
|
| 1058 |
+
#
|
| 1059 |
+
# Calculates the maximum length of the translated strings of the given
|
| 1060 |
+
# list.
|
| 1061 |
+
#
|
| 1062 |
+
# Arguments:
|
| 1063 |
+
# args strings to translate.
|
| 1064 |
+
#
|
| 1065 |
+
# Results:
|
| 1066 |
+
# Returns the length of the longest translated string.
|
| 1067 |
+
|
| 1068 |
+
proc msgcat::mcmax {args} {
|
| 1069 |
+
set max 0
|
| 1070 |
+
foreach string $args {
|
| 1071 |
+
set translated [uplevel 1 [list [namespace origin mc] $string]]
|
| 1072 |
+
set len [string length $translated]
|
| 1073 |
+
if {$len>$max} {
|
| 1074 |
+
set max $len
|
| 1075 |
+
}
|
| 1076 |
+
}
|
| 1077 |
+
return $max
|
| 1078 |
+
}
|
| 1079 |
+
|
| 1080 |
+
# Convert the locale values stored in environment variables to a form
|
| 1081 |
+
# suitable for passing to [mclocale]
|
| 1082 |
+
proc msgcat::ConvertLocale {value} {
|
| 1083 |
+
# Assume $value is of form: $language[_$territory][.$codeset][@modifier]
|
| 1084 |
+
# Convert to form: $language[_$territory][_$modifier]
|
| 1085 |
+
#
|
| 1086 |
+
# Comment out expanded RE version -- bugs alleged
|
| 1087 |
+
# regexp -expanded {
|
| 1088 |
+
# ^ # Match all the way to the beginning
|
| 1089 |
+
# ([^_.@]*) # Match "lanugage"; ends with _, ., or @
|
| 1090 |
+
# (_([^.@]*))? # Match (optional) "territory"; starts with _
|
| 1091 |
+
# ([.]([^@]*))? # Match (optional) "codeset"; starts with .
|
| 1092 |
+
# (@(.*))? # Match (optional) "modifier"; starts with @
|
| 1093 |
+
# $ # Match all the way to the end
|
| 1094 |
+
# } $value -> language _ territory _ codeset _ modifier
|
| 1095 |
+
if {![regexp {^([^_.@]+)(_([^.@]*))?([.]([^@]*))?(@(.*))?$} $value \
|
| 1096 |
+
-> language _ territory _ codeset _ modifier]} {
|
| 1097 |
+
return -code error "invalid locale '$value': empty language part"
|
| 1098 |
+
}
|
| 1099 |
+
set ret $language
|
| 1100 |
+
if {[string length $territory]} {
|
| 1101 |
+
append ret _$territory
|
| 1102 |
+
}
|
| 1103 |
+
if {[string length $modifier]} {
|
| 1104 |
+
append ret _$modifier
|
| 1105 |
+
}
|
| 1106 |
+
return $ret
|
| 1107 |
+
}
|
| 1108 |
+
|
| 1109 |
+
# Initialize the default locale
|
| 1110 |
+
proc msgcat::Init {} {
|
| 1111 |
+
global env
|
| 1112 |
+
|
| 1113 |
+
#
|
| 1114 |
+
# set default locale, try to get from environment
|
| 1115 |
+
#
|
| 1116 |
+
foreach varName {LC_ALL LC_MESSAGES LANG} {
|
| 1117 |
+
if {[info exists env($varName)] && ("" ne $env($varName))} {
|
| 1118 |
+
if {![catch {
|
| 1119 |
+
mclocale [ConvertLocale $env($varName)]
|
| 1120 |
+
}]} {
|
| 1121 |
+
return
|
| 1122 |
+
}
|
| 1123 |
+
}
|
| 1124 |
+
}
|
| 1125 |
+
#
|
| 1126 |
+
# On Darwin, fallback to current CFLocale identifier if available.
|
| 1127 |
+
#
|
| 1128 |
+
if {[info exists ::tcl::mac::locale] && $::tcl::mac::locale ne ""} {
|
| 1129 |
+
if {![catch {
|
| 1130 |
+
mclocale [ConvertLocale $::tcl::mac::locale]
|
| 1131 |
+
}]} {
|
| 1132 |
+
return
|
| 1133 |
+
}
|
| 1134 |
+
}
|
| 1135 |
+
#
|
| 1136 |
+
# The rest of this routine is special processing for Windows or
|
| 1137 |
+
# Cygwin. All other platforms, get out now.
|
| 1138 |
+
#
|
| 1139 |
+
if {([info sharedlibextension] ne ".dll")
|
| 1140 |
+
|| [catch {package require registry}]} {
|
| 1141 |
+
mclocale C
|
| 1142 |
+
return
|
| 1143 |
+
}
|
| 1144 |
+
#
|
| 1145 |
+
# On Windows or Cygwin, try to set locale depending on registry
|
| 1146 |
+
# settings, or fall back on locale of "C".
|
| 1147 |
+
#
|
| 1148 |
+
|
| 1149 |
+
# On Vista and later:
|
| 1150 |
+
# HCU/Control Panel/Desktop : PreferredUILanguages is for language packs,
|
| 1151 |
+
# HCU/Control Pannel/International : localName is the default locale.
|
| 1152 |
+
#
|
| 1153 |
+
# They contain the local string as RFC5646, composed of:
|
| 1154 |
+
# [a-z]{2,3} : language
|
| 1155 |
+
# -[a-z]{4} : script (optional, translated by table Latn->latin)
|
| 1156 |
+
# -[a-z]{2}|[0-9]{3} : territory (optional, numerical region codes not used)
|
| 1157 |
+
# (-.*)* : variant, extension, private use (optional, not used)
|
| 1158 |
+
# Those are translated to local strings.
|
| 1159 |
+
# Examples: de-CH -> de_ch, sr-Latn-CS -> sr_cs@latin, es-419 -> es
|
| 1160 |
+
#
|
| 1161 |
+
foreach key {{HKEY_CURRENT_USER\Control Panel\Desktop} {HKEY_CURRENT_USER\Control Panel\International}}\
|
| 1162 |
+
value {PreferredUILanguages localeName} {
|
| 1163 |
+
if {![catch {registry get $key $value} localeName]
|
| 1164 |
+
&& [regexp {^([a-z]{2,3})(?:-([a-z]{4}))?(?:-([a-z]{2}))?(?:-.+)?$}\
|
| 1165 |
+
[string tolower $localeName] match locale script territory]} {
|
| 1166 |
+
if {"" ne $territory} {
|
| 1167 |
+
append locale _ $territory
|
| 1168 |
+
}
|
| 1169 |
+
set modifierDict [dict create latn latin cyrl cyrillic]
|
| 1170 |
+
if {[dict exists $modifierDict $script]} {
|
| 1171 |
+
append locale @ [dict get $modifierDict $script]
|
| 1172 |
+
}
|
| 1173 |
+
if {![catch {mclocale [ConvertLocale $locale]}]} {
|
| 1174 |
+
return
|
| 1175 |
+
}
|
| 1176 |
+
}
|
| 1177 |
+
}
|
| 1178 |
+
|
| 1179 |
+
# then check value locale which contains a numerical language ID
|
| 1180 |
+
if {[catch {
|
| 1181 |
+
set locale [registry get $key "locale"]
|
| 1182 |
+
}]} {
|
| 1183 |
+
mclocale C
|
| 1184 |
+
return
|
| 1185 |
+
}
|
| 1186 |
+
#
|
| 1187 |
+
# Keep trying to match against smaller and smaller suffixes
|
| 1188 |
+
# of the registry value, since the latter hexadigits appear
|
| 1189 |
+
# to determine general language and earlier hexadigits determine
|
| 1190 |
+
# more precise information, such as territory. For example,
|
| 1191 |
+
# 0409 - English - United States
|
| 1192 |
+
# 0809 - English - United Kingdom
|
| 1193 |
+
# Add more translations to the WinRegToISO639 array above.
|
| 1194 |
+
#
|
| 1195 |
+
variable WinRegToISO639
|
| 1196 |
+
set locale [string tolower $locale]
|
| 1197 |
+
while {[string length $locale]} {
|
| 1198 |
+
if {![catch {
|
| 1199 |
+
mclocale [ConvertLocale [dict get $WinRegToISO639 $locale]]
|
| 1200 |
+
}]} {
|
| 1201 |
+
return
|
| 1202 |
+
}
|
| 1203 |
+
set locale [string range $locale 1 end]
|
| 1204 |
+
}
|
| 1205 |
+
#
|
| 1206 |
+
# No translation known. Fall back on "C" locale
|
| 1207 |
+
#
|
| 1208 |
+
mclocale C
|
| 1209 |
+
}
|
| 1210 |
+
msgcat::Init
|
mplug_owl2/lib/tcl8/8.5/tcltest-2.5.7.tm
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
mplug_owl2/lib/tcl8/8.6/http-2.9.8.tm
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
mplug_owl2/lib/tcl8/8.6/tdbc/sqlite3-1.1.7.tm
ADDED
|
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tdbc1.1.7/tdbc.tcl
ADDED
|
@@ -0,0 +1,922 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tdbc.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Definitions of base classes from which TDBC drivers' connections,
|
| 4 |
+
# statements and result sets may inherit.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 2008 by Kevin B. Kenny
|
| 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 |
+
# RCS: @(#) $Id$
|
| 11 |
+
#
|
| 12 |
+
#------------------------------------------------------------------------------
|
| 13 |
+
|
| 14 |
+
package require TclOO
|
| 15 |
+
|
| 16 |
+
namespace eval ::tdbc {
|
| 17 |
+
namespace export connection statement resultset
|
| 18 |
+
variable generalError [list TDBC GENERAL_ERROR HY000 {}]
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
#------------------------------------------------------------------------------
|
| 22 |
+
#
|
| 23 |
+
# tdbc::ParseConvenienceArgs --
|
| 24 |
+
#
|
| 25 |
+
# Parse the convenience arguments to a TDBC 'execute',
|
| 26 |
+
# 'executewithdictionary', or 'foreach' call.
|
| 27 |
+
#
|
| 28 |
+
# Parameters:
|
| 29 |
+
# argv - Arguments to the call
|
| 30 |
+
# optsVar -- Name of a variable in caller's scope that will receive
|
| 31 |
+
# a dictionary of the supplied options
|
| 32 |
+
#
|
| 33 |
+
# Results:
|
| 34 |
+
# Returns any args remaining after parsing the options.
|
| 35 |
+
#
|
| 36 |
+
# Side effects:
|
| 37 |
+
# Sets the 'opts' dictionary to the options.
|
| 38 |
+
#
|
| 39 |
+
#------------------------------------------------------------------------------
|
| 40 |
+
|
| 41 |
+
proc tdbc::ParseConvenienceArgs {argv optsVar} {
|
| 42 |
+
|
| 43 |
+
variable generalError
|
| 44 |
+
upvar 1 $optsVar opts
|
| 45 |
+
|
| 46 |
+
set opts [dict create -as dicts]
|
| 47 |
+
set i 0
|
| 48 |
+
|
| 49 |
+
# Munch keyword options off the front of the command arguments
|
| 50 |
+
|
| 51 |
+
foreach {key value} $argv {
|
| 52 |
+
if {[string index $key 0] eq {-}} {
|
| 53 |
+
switch -regexp -- $key {
|
| 54 |
+
-as? {
|
| 55 |
+
if {$value ne {dicts} && $value ne {lists}} {
|
| 56 |
+
set errorcode $generalError
|
| 57 |
+
lappend errorcode badVarType $value
|
| 58 |
+
return -code error \
|
| 59 |
+
-errorcode $errorcode \
|
| 60 |
+
"bad variable type \"$value\":\
|
| 61 |
+
must be lists or dicts"
|
| 62 |
+
}
|
| 63 |
+
dict set opts -as $value
|
| 64 |
+
}
|
| 65 |
+
-c(?:o(?:l(?:u(?:m(?:n(?:s(?:v(?:a(?:r(?:i(?:a(?:b(?:le?)?)?)?)?)?)?)?)?)?)?)?)?) {
|
| 66 |
+
dict set opts -columnsvariable $value
|
| 67 |
+
}
|
| 68 |
+
-- {
|
| 69 |
+
incr i
|
| 70 |
+
break
|
| 71 |
+
}
|
| 72 |
+
default {
|
| 73 |
+
set errorcode $generalError
|
| 74 |
+
lappend errorcode badOption $key
|
| 75 |
+
return -code error \
|
| 76 |
+
-errorcode $errorcode \
|
| 77 |
+
"bad option \"$key\":\
|
| 78 |
+
must be -as or -columnsvariable"
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
} else {
|
| 82 |
+
break
|
| 83 |
+
}
|
| 84 |
+
incr i 2
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
return [lrange $argv[set argv {}] $i end]
|
| 88 |
+
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
#------------------------------------------------------------------------------
|
| 94 |
+
#
|
| 95 |
+
# tdbc::connection --
|
| 96 |
+
#
|
| 97 |
+
# Class that represents a generic connection to a database.
|
| 98 |
+
#
|
| 99 |
+
#-----------------------------------------------------------------------------
|
| 100 |
+
|
| 101 |
+
oo::class create ::tdbc::connection {
|
| 102 |
+
|
| 103 |
+
# statementSeq is the sequence number of the last statement created.
|
| 104 |
+
# statementClass is the name of the class that implements the
|
| 105 |
+
# 'statement' API.
|
| 106 |
+
# primaryKeysStatement is the statement that queries primary keys
|
| 107 |
+
# foreignKeysStatement is the statement that queries foreign keys
|
| 108 |
+
|
| 109 |
+
variable statementSeq primaryKeysStatement foreignKeysStatement
|
| 110 |
+
|
| 111 |
+
# The base class constructor accepts no arguments. It sets up the
|
| 112 |
+
# machinery to do the bookkeeping to keep track of what statements
|
| 113 |
+
# are associated with the connection. The derived class constructor
|
| 114 |
+
# is expected to set the variable, 'statementClass' to the name
|
| 115 |
+
# of the class that represents statements, so that the 'prepare'
|
| 116 |
+
# method can invoke it.
|
| 117 |
+
|
| 118 |
+
constructor {} {
|
| 119 |
+
set statementSeq 0
|
| 120 |
+
namespace eval Stmt {}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
# The 'close' method is simply an alternative syntax for destroying
|
| 124 |
+
# the connection.
|
| 125 |
+
|
| 126 |
+
method close {} {
|
| 127 |
+
my destroy
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
# The 'prepare' method creates a new statement against the connection,
|
| 131 |
+
# giving its constructor the current statement and the SQL code to
|
| 132 |
+
# prepare. It uses the 'statementClass' variable set by the constructor
|
| 133 |
+
# to get the class to instantiate.
|
| 134 |
+
|
| 135 |
+
method prepare {sqlcode} {
|
| 136 |
+
return [my statementCreate Stmt::[incr statementSeq] [self] $sqlcode]
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
# The 'statementCreate' method delegates to the constructor
|
| 140 |
+
# of the class specified by the 'statementClass' variable. It's
|
| 141 |
+
# intended for drivers designed before tdbc 1.0b10. Current ones
|
| 142 |
+
# should forward this method to the constructor directly.
|
| 143 |
+
|
| 144 |
+
method statementCreate {name instance sqlcode} {
|
| 145 |
+
my variable statementClass
|
| 146 |
+
return [$statementClass create $name $instance $sqlcode]
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
# Derived classes are expected to implement the 'prepareCall' method,
|
| 150 |
+
# and have it call 'prepare' as needed (or do something else and
|
| 151 |
+
# install the resulting statement)
|
| 152 |
+
|
| 153 |
+
# The 'statements' method lists the statements active against this
|
| 154 |
+
# connection.
|
| 155 |
+
|
| 156 |
+
method statements {} {
|
| 157 |
+
info commands Stmt::*
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
# The 'resultsets' method lists the result sets active against this
|
| 161 |
+
# connection.
|
| 162 |
+
|
| 163 |
+
method resultsets {} {
|
| 164 |
+
set retval {}
|
| 165 |
+
foreach statement [my statements] {
|
| 166 |
+
foreach resultset [$statement resultsets] {
|
| 167 |
+
lappend retval $resultset
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
return $retval
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
# The 'transaction' method executes a block of Tcl code as an
|
| 174 |
+
# ACID transaction against the database.
|
| 175 |
+
|
| 176 |
+
method transaction {script} {
|
| 177 |
+
my begintransaction
|
| 178 |
+
set status [catch {uplevel 1 $script} result options]
|
| 179 |
+
if {$status in {0 2 3 4}} {
|
| 180 |
+
set status2 [catch {my commit} result2 options2]
|
| 181 |
+
if {$status2 == 1} {
|
| 182 |
+
set status 1
|
| 183 |
+
set result $result2
|
| 184 |
+
set options $options2
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
switch -exact -- $status {
|
| 188 |
+
0 {
|
| 189 |
+
# do nothing
|
| 190 |
+
}
|
| 191 |
+
2 - 3 - 4 {
|
| 192 |
+
set options [dict merge {-level 1} $options[set options {}]]
|
| 193 |
+
dict incr options -level
|
| 194 |
+
}
|
| 195 |
+
default {
|
| 196 |
+
my rollback
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
return -options $options $result
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
# The 'allrows' method prepares a statement, then executes it with
|
| 203 |
+
# a given set of substituents, returning a list of all the rows
|
| 204 |
+
# that the statement returns. Optionally, it stores the names of
|
| 205 |
+
# the columns in '-columnsvariable'.
|
| 206 |
+
# Usage:
|
| 207 |
+
# $db allrows ?-as lists|dicts? ?-columnsvariable varName? ?--?
|
| 208 |
+
# sql ?dictionary?
|
| 209 |
+
|
| 210 |
+
method allrows args {
|
| 211 |
+
|
| 212 |
+
variable ::tdbc::generalError
|
| 213 |
+
|
| 214 |
+
# Grab keyword-value parameters
|
| 215 |
+
|
| 216 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 217 |
+
|
| 218 |
+
# Check postitional parameters
|
| 219 |
+
|
| 220 |
+
set cmd [list [self] prepare]
|
| 221 |
+
if {[llength $args] == 1} {
|
| 222 |
+
set sqlcode [lindex $args 0]
|
| 223 |
+
} elseif {[llength $args] == 2} {
|
| 224 |
+
lassign $args sqlcode dict
|
| 225 |
+
} else {
|
| 226 |
+
set errorcode $generalError
|
| 227 |
+
lappend errorcode wrongNumArgs
|
| 228 |
+
return -code error -errorcode $errorcode \
|
| 229 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 230 |
+
?-option value?... ?--? sqlcode ?dictionary?"
|
| 231 |
+
}
|
| 232 |
+
lappend cmd $sqlcode
|
| 233 |
+
|
| 234 |
+
# Prepare the statement
|
| 235 |
+
|
| 236 |
+
set stmt [uplevel 1 $cmd]
|
| 237 |
+
|
| 238 |
+
# Delegate to the statement to accumulate the results
|
| 239 |
+
|
| 240 |
+
set cmd [list $stmt allrows {*}$opts --]
|
| 241 |
+
if {[info exists dict]} {
|
| 242 |
+
lappend cmd $dict
|
| 243 |
+
}
|
| 244 |
+
set status [catch {
|
| 245 |
+
uplevel 1 $cmd
|
| 246 |
+
} result options]
|
| 247 |
+
|
| 248 |
+
# Destroy the statement
|
| 249 |
+
|
| 250 |
+
catch {
|
| 251 |
+
$stmt close
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
return -options $options $result
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
# The 'foreach' method prepares a statement, then executes it with
|
| 258 |
+
# a supplied set of substituents. For each row of the result,
|
| 259 |
+
# it sets a variable to the row and invokes a script in the caller's
|
| 260 |
+
# scope.
|
| 261 |
+
#
|
| 262 |
+
# Usage:
|
| 263 |
+
# $db foreach ?-as lists|dicts? ?-columnsVariable varName? ?--?
|
| 264 |
+
# varName sql ?dictionary? script
|
| 265 |
+
|
| 266 |
+
method foreach args {
|
| 267 |
+
|
| 268 |
+
variable ::tdbc::generalError
|
| 269 |
+
|
| 270 |
+
# Grab keyword-value parameters
|
| 271 |
+
|
| 272 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 273 |
+
|
| 274 |
+
# Check postitional parameters
|
| 275 |
+
|
| 276 |
+
set cmd [list [self] prepare]
|
| 277 |
+
if {[llength $args] == 3} {
|
| 278 |
+
lassign $args varname sqlcode script
|
| 279 |
+
} elseif {[llength $args] == 4} {
|
| 280 |
+
lassign $args varname sqlcode dict script
|
| 281 |
+
} else {
|
| 282 |
+
set errorcode $generalError
|
| 283 |
+
lappend errorcode wrongNumArgs
|
| 284 |
+
return -code error -errorcode $errorcode \
|
| 285 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 286 |
+
?-option value?... ?--? varname sqlcode ?dictionary? script"
|
| 287 |
+
}
|
| 288 |
+
lappend cmd $sqlcode
|
| 289 |
+
|
| 290 |
+
# Prepare the statement
|
| 291 |
+
|
| 292 |
+
set stmt [uplevel 1 $cmd]
|
| 293 |
+
|
| 294 |
+
# Delegate to the statement to iterate over the results
|
| 295 |
+
|
| 296 |
+
set cmd [list $stmt foreach {*}$opts -- $varname]
|
| 297 |
+
if {[info exists dict]} {
|
| 298 |
+
lappend cmd $dict
|
| 299 |
+
}
|
| 300 |
+
lappend cmd $script
|
| 301 |
+
set status [catch {
|
| 302 |
+
uplevel 1 $cmd
|
| 303 |
+
} result options]
|
| 304 |
+
|
| 305 |
+
# Destroy the statement
|
| 306 |
+
|
| 307 |
+
catch {
|
| 308 |
+
$stmt close
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
# Adjust return level in the case that the script [return]s
|
| 312 |
+
|
| 313 |
+
if {$status == 2} {
|
| 314 |
+
set options [dict merge {-level 1} $options[set options {}]]
|
| 315 |
+
dict incr options -level
|
| 316 |
+
}
|
| 317 |
+
return -options $options $result
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
# The 'BuildPrimaryKeysStatement' method builds a SQL statement to
|
| 321 |
+
# retrieve the primary keys from a database. (It executes once the
|
| 322 |
+
# first time the 'primaryKeys' method is executed, and retains the
|
| 323 |
+
# prepared statement for reuse.)
|
| 324 |
+
|
| 325 |
+
method BuildPrimaryKeysStatement {} {
|
| 326 |
+
|
| 327 |
+
# On some databases, CONSTRAINT_CATALOG is always NULL and
|
| 328 |
+
# JOINing to it fails. Check for this case and include that
|
| 329 |
+
# JOIN only if catalog names are supplied.
|
| 330 |
+
|
| 331 |
+
set catalogClause {}
|
| 332 |
+
if {[lindex [set count [my allrows -as lists {
|
| 333 |
+
SELECT COUNT(*)
|
| 334 |
+
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
|
| 335 |
+
WHERE CONSTRAINT_CATALOG IS NOT NULL}]] 0 0] != 0} {
|
| 336 |
+
set catalogClause \
|
| 337 |
+
{AND xtable.CONSTRAINT_CATALOG = xcolumn.CONSTRAINT_CATALOG}
|
| 338 |
+
}
|
| 339 |
+
set primaryKeysStatement [my prepare "
|
| 340 |
+
SELECT xtable.TABLE_SCHEMA AS \"tableSchema\",
|
| 341 |
+
xtable.TABLE_NAME AS \"tableName\",
|
| 342 |
+
xtable.CONSTRAINT_CATALOG AS \"constraintCatalog\",
|
| 343 |
+
xtable.CONSTRAINT_SCHEMA AS \"constraintSchema\",
|
| 344 |
+
xtable.CONSTRAINT_NAME AS \"constraintName\",
|
| 345 |
+
xcolumn.COLUMN_NAME AS \"columnName\",
|
| 346 |
+
xcolumn.ORDINAL_POSITION AS \"ordinalPosition\"
|
| 347 |
+
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS xtable
|
| 348 |
+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE xcolumn
|
| 349 |
+
ON xtable.CONSTRAINT_SCHEMA = xcolumn.CONSTRAINT_SCHEMA
|
| 350 |
+
AND xtable.TABLE_NAME = xcolumn.TABLE_NAME
|
| 351 |
+
AND xtable.CONSTRAINT_NAME = xcolumn.CONSTRAINT_NAME
|
| 352 |
+
$catalogClause
|
| 353 |
+
WHERE xtable.TABLE_NAME = :tableName
|
| 354 |
+
AND xtable.CONSTRAINT_TYPE = 'PRIMARY KEY'
|
| 355 |
+
"]
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
# The default implementation of the 'primarykeys' method uses the
|
| 359 |
+
# SQL INFORMATION_SCHEMA to retrieve primary key information. Databases
|
| 360 |
+
# that might not have INFORMATION_SCHEMA must overload this method.
|
| 361 |
+
|
| 362 |
+
method primarykeys {tableName} {
|
| 363 |
+
if {![info exists primaryKeysStatement]} {
|
| 364 |
+
my BuildPrimaryKeysStatement
|
| 365 |
+
}
|
| 366 |
+
tailcall $primaryKeysStatement allrows [list tableName $tableName]
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
# The 'BuildForeignKeysStatements' method builds a SQL statement to
|
| 370 |
+
# retrieve the foreign keys from a database. (It executes once the
|
| 371 |
+
# first time the 'foreignKeys' method is executed, and retains the
|
| 372 |
+
# prepared statements for reuse.)
|
| 373 |
+
|
| 374 |
+
method BuildForeignKeysStatement {} {
|
| 375 |
+
|
| 376 |
+
# On some databases, CONSTRAINT_CATALOG is always NULL and
|
| 377 |
+
# JOINing to it fails. Check for this case and include that
|
| 378 |
+
# JOIN only if catalog names are supplied.
|
| 379 |
+
|
| 380 |
+
set catalogClause1 {}
|
| 381 |
+
set catalogClause2 {}
|
| 382 |
+
if {[lindex [set count [my allrows -as lists {
|
| 383 |
+
SELECT COUNT(*)
|
| 384 |
+
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
|
| 385 |
+
WHERE CONSTRAINT_CATALOG IS NOT NULL}]] 0 0] != 0} {
|
| 386 |
+
set catalogClause1 \
|
| 387 |
+
{AND fkc.CONSTRAINT_CATALOG = rc.CONSTRAINT_CATALOG}
|
| 388 |
+
set catalogClause2 \
|
| 389 |
+
{AND pkc.CONSTRAINT_CATALOG = rc.CONSTRAINT_CATALOG}
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
foreach {exists1 clause1} {
|
| 393 |
+
0 {}
|
| 394 |
+
1 { AND pkc.TABLE_NAME = :primary}
|
| 395 |
+
} {
|
| 396 |
+
foreach {exists2 clause2} {
|
| 397 |
+
0 {}
|
| 398 |
+
1 { AND fkc.TABLE_NAME = :foreign}
|
| 399 |
+
} {
|
| 400 |
+
set stmt [my prepare "
|
| 401 |
+
SELECT rc.CONSTRAINT_CATALOG AS \"foreignConstraintCatalog\",
|
| 402 |
+
rc.CONSTRAINT_SCHEMA AS \"foreignConstraintSchema\",
|
| 403 |
+
rc.CONSTRAINT_NAME AS \"foreignConstraintName\",
|
| 404 |
+
rc.UNIQUE_CONSTRAINT_CATALOG
|
| 405 |
+
AS \"primaryConstraintCatalog\",
|
| 406 |
+
rc.UNIQUE_CONSTRAINT_SCHEMA AS \"primaryConstraintSchema\",
|
| 407 |
+
rc.UNIQUE_CONSTRAINT_NAME AS \"primaryConstraintName\",
|
| 408 |
+
rc.UPDATE_RULE AS \"updateAction\",
|
| 409 |
+
rc.DELETE_RULE AS \"deleteAction\",
|
| 410 |
+
pkc.TABLE_CATALOG AS \"primaryCatalog\",
|
| 411 |
+
pkc.TABLE_SCHEMA AS \"primarySchema\",
|
| 412 |
+
pkc.TABLE_NAME AS \"primaryTable\",
|
| 413 |
+
pkc.COLUMN_NAME AS \"primaryColumn\",
|
| 414 |
+
fkc.TABLE_CATALOG AS \"foreignCatalog\",
|
| 415 |
+
fkc.TABLE_SCHEMA AS \"foreignSchema\",
|
| 416 |
+
fkc.TABLE_NAME AS \"foreignTable\",
|
| 417 |
+
fkc.COLUMN_NAME AS \"foreignColumn\",
|
| 418 |
+
pkc.ORDINAL_POSITION AS \"ordinalPosition\"
|
| 419 |
+
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc
|
| 420 |
+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE fkc
|
| 421 |
+
ON fkc.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
|
| 422 |
+
AND fkc.CONSTRAINT_SCHEMA = rc.CONSTRAINT_SCHEMA
|
| 423 |
+
$catalogClause1
|
| 424 |
+
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE pkc
|
| 425 |
+
ON pkc.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME
|
| 426 |
+
AND pkc.CONSTRAINT_SCHEMA = rc.UNIQUE_CONSTRAINT_SCHEMA
|
| 427 |
+
$catalogClause2
|
| 428 |
+
AND pkc.ORDINAL_POSITION = fkc.ORDINAL_POSITION
|
| 429 |
+
WHERE 1=1
|
| 430 |
+
$clause1
|
| 431 |
+
$clause2
|
| 432 |
+
ORDER BY \"foreignConstraintCatalog\", \"foreignConstraintSchema\", \"foreignConstraintName\", \"ordinalPosition\"
|
| 433 |
+
"]
|
| 434 |
+
dict set foreignKeysStatement $exists1 $exists2 $stmt
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
# The default implementation of the 'foreignkeys' method uses the
|
| 440 |
+
# SQL INFORMATION_SCHEMA to retrieve primary key information. Databases
|
| 441 |
+
# that might not have INFORMATION_SCHEMA must overload this method.
|
| 442 |
+
|
| 443 |
+
method foreignkeys {args} {
|
| 444 |
+
|
| 445 |
+
variable ::tdbc::generalError
|
| 446 |
+
|
| 447 |
+
# Check arguments
|
| 448 |
+
|
| 449 |
+
set argdict {}
|
| 450 |
+
if {[llength $args] % 2 != 0} {
|
| 451 |
+
set errorcode $generalError
|
| 452 |
+
lappend errorcode wrongNumArgs
|
| 453 |
+
return -code error -errorcode $errorcode \
|
| 454 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 455 |
+
?-option value?..."
|
| 456 |
+
}
|
| 457 |
+
foreach {key value} $args {
|
| 458 |
+
if {$key ni {-primary -foreign}} {
|
| 459 |
+
set errorcode $generalError
|
| 460 |
+
lappend errorcode badOption
|
| 461 |
+
return -code error -errorcode $errorcode \
|
| 462 |
+
"bad option \"$key\", must be -primary or -foreign"
|
| 463 |
+
}
|
| 464 |
+
set key [string range $key 1 end]
|
| 465 |
+
if {[dict exists $argdict $key]} {
|
| 466 |
+
set errorcode $generalError
|
| 467 |
+
lappend errorcode dupOption
|
| 468 |
+
return -code error -errorcode $errorcode \
|
| 469 |
+
"duplicate option \"$key\" supplied"
|
| 470 |
+
}
|
| 471 |
+
dict set argdict $key $value
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
# Build the statements that query foreign keys. There are four
|
| 475 |
+
# of them, one for each combination of whether -primary
|
| 476 |
+
# and -foreign is specified.
|
| 477 |
+
|
| 478 |
+
if {![info exists foreignKeysStatement]} {
|
| 479 |
+
my BuildForeignKeysStatement
|
| 480 |
+
}
|
| 481 |
+
set stmt [dict get $foreignKeysStatement \
|
| 482 |
+
[dict exists $argdict primary] \
|
| 483 |
+
[dict exists $argdict foreign]]
|
| 484 |
+
tailcall $stmt allrows $argdict
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
# Derived classes are expected to implement the 'begintransaction',
|
| 488 |
+
# 'commit', and 'rollback' methods.
|
| 489 |
+
|
| 490 |
+
# Derived classes are expected to implement 'tables' and 'columns' method.
|
| 491 |
+
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
#------------------------------------------------------------------------------
|
| 495 |
+
#
|
| 496 |
+
# Class: tdbc::statement
|
| 497 |
+
#
|
| 498 |
+
# Class that represents a SQL statement in a generic database
|
| 499 |
+
#
|
| 500 |
+
#------------------------------------------------------------------------------
|
| 501 |
+
|
| 502 |
+
oo::class create tdbc::statement {
|
| 503 |
+
|
| 504 |
+
# resultSetSeq is the sequence number of the last result set created.
|
| 505 |
+
# resultSetClass is the name of the class that implements the 'resultset'
|
| 506 |
+
# API.
|
| 507 |
+
|
| 508 |
+
variable resultSetClass resultSetSeq
|
| 509 |
+
|
| 510 |
+
# The base class constructor accepts no arguments. It initializes
|
| 511 |
+
# the machinery for tracking the ownership of result sets. The derived
|
| 512 |
+
# constructor is expected to invoke the base constructor, and to
|
| 513 |
+
# set a variable 'resultSetClass' to the fully-qualified name of the
|
| 514 |
+
# class that represents result sets.
|
| 515 |
+
|
| 516 |
+
constructor {} {
|
| 517 |
+
set resultSetSeq 0
|
| 518 |
+
namespace eval ResultSet {}
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
# The 'execute' method on a statement runs the statement with
|
| 522 |
+
# a particular set of substituted variables. It actually works
|
| 523 |
+
# by creating the result set object and letting that objects
|
| 524 |
+
# constructor do the work of running the statement. The creation
|
| 525 |
+
# is wrapped in an [uplevel] call because the substitution proces
|
| 526 |
+
# may need to access variables in the caller's scope.
|
| 527 |
+
|
| 528 |
+
# WORKAROUND: Take out the '0 &&' from the next line when
|
| 529 |
+
# Bug 2649975 is fixed
|
| 530 |
+
if {0 && [package vsatisfies [package provide Tcl] 8.6]} {
|
| 531 |
+
method execute args {
|
| 532 |
+
tailcall my resultSetCreate \
|
| 533 |
+
[namespace current]::ResultSet::[incr resultSetSeq] \
|
| 534 |
+
[self] {*}$args
|
| 535 |
+
}
|
| 536 |
+
} else {
|
| 537 |
+
method execute args {
|
| 538 |
+
return \
|
| 539 |
+
[uplevel 1 \
|
| 540 |
+
[list \
|
| 541 |
+
[self] resultSetCreate \
|
| 542 |
+
[namespace current]::ResultSet::[incr resultSetSeq] \
|
| 543 |
+
[self] {*}$args]]
|
| 544 |
+
}
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
# The 'ResultSetCreate' method is expected to be a forward to the
|
| 548 |
+
# appropriate result set constructor. If it's missing, the driver must
|
| 549 |
+
# have been designed for tdbc 1.0b9 and earlier, and the 'resultSetClass'
|
| 550 |
+
# variable holds the class name.
|
| 551 |
+
|
| 552 |
+
method resultSetCreate {name instance args} {
|
| 553 |
+
return [uplevel 1 [list $resultSetClass create \
|
| 554 |
+
$name $instance {*}$args]]
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
# The 'resultsets' method returns a list of result sets produced by
|
| 558 |
+
# the current statement
|
| 559 |
+
|
| 560 |
+
method resultsets {} {
|
| 561 |
+
info commands ResultSet::*
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
# The 'allrows' method executes a statement with a given set of
|
| 565 |
+
# substituents, and returns a list of all the rows that the statement
|
| 566 |
+
# returns. Optionally, it stores the names of columns in
|
| 567 |
+
# '-columnsvariable'.
|
| 568 |
+
#
|
| 569 |
+
# Usage:
|
| 570 |
+
# $statement allrows ?-as lists|dicts? ?-columnsvariable varName? ?--?
|
| 571 |
+
# ?dictionary?
|
| 572 |
+
|
| 573 |
+
|
| 574 |
+
method allrows args {
|
| 575 |
+
|
| 576 |
+
variable ::tdbc::generalError
|
| 577 |
+
|
| 578 |
+
# Grab keyword-value parameters
|
| 579 |
+
|
| 580 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 581 |
+
|
| 582 |
+
# Check postitional parameters
|
| 583 |
+
|
| 584 |
+
set cmd [list [self] execute]
|
| 585 |
+
if {[llength $args] == 0} {
|
| 586 |
+
# do nothing
|
| 587 |
+
} elseif {[llength $args] == 1} {
|
| 588 |
+
lappend cmd [lindex $args 0]
|
| 589 |
+
} else {
|
| 590 |
+
set errorcode $generalError
|
| 591 |
+
lappend errorcode wrongNumArgs
|
| 592 |
+
return -code error -errorcode $errorcode \
|
| 593 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 594 |
+
?-option value?... ?--? ?dictionary?"
|
| 595 |
+
}
|
| 596 |
+
|
| 597 |
+
# Get the result set
|
| 598 |
+
|
| 599 |
+
set resultSet [uplevel 1 $cmd]
|
| 600 |
+
|
| 601 |
+
# Delegate to the result set's [allrows] method to accumulate
|
| 602 |
+
# the rows of the result.
|
| 603 |
+
|
| 604 |
+
set cmd [list $resultSet allrows {*}$opts]
|
| 605 |
+
set status [catch {
|
| 606 |
+
uplevel 1 $cmd
|
| 607 |
+
} result options]
|
| 608 |
+
|
| 609 |
+
# Destroy the result set
|
| 610 |
+
|
| 611 |
+
catch {
|
| 612 |
+
rename $resultSet {}
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
# Adjust return level in the case that the script [return]s
|
| 616 |
+
|
| 617 |
+
if {$status == 2} {
|
| 618 |
+
set options [dict merge {-level 1} $options[set options {}]]
|
| 619 |
+
dict incr options -level
|
| 620 |
+
}
|
| 621 |
+
return -options $options $result
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
# The 'foreach' method executes a statement with a given set of
|
| 625 |
+
# substituents. It runs the supplied script, substituting the supplied
|
| 626 |
+
# named variable. Optionally, it stores the names of columns in
|
| 627 |
+
# '-columnsvariable'.
|
| 628 |
+
#
|
| 629 |
+
# Usage:
|
| 630 |
+
# $statement foreach ?-as lists|dicts? ?-columnsvariable varName? ?--?
|
| 631 |
+
# variableName ?dictionary? script
|
| 632 |
+
|
| 633 |
+
method foreach args {
|
| 634 |
+
|
| 635 |
+
variable ::tdbc::generalError
|
| 636 |
+
|
| 637 |
+
# Grab keyword-value parameters
|
| 638 |
+
|
| 639 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 640 |
+
|
| 641 |
+
# Check positional parameters
|
| 642 |
+
|
| 643 |
+
set cmd [list [self] execute]
|
| 644 |
+
if {[llength $args] == 2} {
|
| 645 |
+
lassign $args varname script
|
| 646 |
+
} elseif {[llength $args] == 3} {
|
| 647 |
+
lassign $args varname dict script
|
| 648 |
+
lappend cmd $dict
|
| 649 |
+
} else {
|
| 650 |
+
set errorcode $generalError
|
| 651 |
+
lappend errorcode wrongNumArgs
|
| 652 |
+
return -code error -errorcode $errorcode \
|
| 653 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 654 |
+
?-option value?... ?--? varName ?dictionary? script"
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
# Get the result set
|
| 658 |
+
|
| 659 |
+
set resultSet [uplevel 1 $cmd]
|
| 660 |
+
|
| 661 |
+
# Delegate to the result set's [foreach] method to evaluate
|
| 662 |
+
# the script for each row of the result.
|
| 663 |
+
|
| 664 |
+
set cmd [list $resultSet foreach {*}$opts -- $varname $script]
|
| 665 |
+
set status [catch {
|
| 666 |
+
uplevel 1 $cmd
|
| 667 |
+
} result options]
|
| 668 |
+
|
| 669 |
+
# Destroy the result set
|
| 670 |
+
|
| 671 |
+
catch {
|
| 672 |
+
rename $resultSet {}
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
# Adjust return level in the case that the script [return]s
|
| 676 |
+
|
| 677 |
+
if {$status == 2} {
|
| 678 |
+
set options [dict merge {-level 1} $options[set options {}]]
|
| 679 |
+
dict incr options -level
|
| 680 |
+
}
|
| 681 |
+
return -options $options $result
|
| 682 |
+
}
|
| 683 |
+
|
| 684 |
+
# The 'close' method is syntactic sugar for invoking the destructor
|
| 685 |
+
|
| 686 |
+
method close {} {
|
| 687 |
+
my destroy
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
# Derived classes are expected to implement their own constructors,
|
| 691 |
+
# plus the following methods:
|
| 692 |
+
|
| 693 |
+
# paramtype paramName ?direction? type ?scale ?precision??
|
| 694 |
+
# Declares the type of a parameter in the statement
|
| 695 |
+
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
#------------------------------------------------------------------------------
|
| 699 |
+
#
|
| 700 |
+
# Class: tdbc::resultset
|
| 701 |
+
#
|
| 702 |
+
# Class that represents a result set in a generic database.
|
| 703 |
+
#
|
| 704 |
+
#------------------------------------------------------------------------------
|
| 705 |
+
|
| 706 |
+
oo::class create tdbc::resultset {
|
| 707 |
+
|
| 708 |
+
constructor {} { }
|
| 709 |
+
|
| 710 |
+
# The 'allrows' method returns a list of all rows that a given
|
| 711 |
+
# result set returns.
|
| 712 |
+
|
| 713 |
+
method allrows args {
|
| 714 |
+
|
| 715 |
+
variable ::tdbc::generalError
|
| 716 |
+
|
| 717 |
+
# Parse args
|
| 718 |
+
|
| 719 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 720 |
+
if {[llength $args] != 0} {
|
| 721 |
+
set errorcode $generalError
|
| 722 |
+
lappend errorcode wrongNumArgs
|
| 723 |
+
return -code error -errorcode $errorcode \
|
| 724 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 725 |
+
?-option value?... ?--? varName script"
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
# Do -columnsvariable if requested
|
| 729 |
+
|
| 730 |
+
if {[dict exists $opts -columnsvariable]} {
|
| 731 |
+
upvar 1 [dict get $opts -columnsvariable] columns
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
# Assemble the results
|
| 735 |
+
|
| 736 |
+
if {[dict get $opts -as] eq {lists}} {
|
| 737 |
+
set delegate nextlist
|
| 738 |
+
} else {
|
| 739 |
+
set delegate nextdict
|
| 740 |
+
}
|
| 741 |
+
set results [list]
|
| 742 |
+
while {1} {
|
| 743 |
+
set columns [my columns]
|
| 744 |
+
while {[my $delegate row]} {
|
| 745 |
+
lappend results $row
|
| 746 |
+
}
|
| 747 |
+
if {![my nextresults]} break
|
| 748 |
+
}
|
| 749 |
+
return $results
|
| 750 |
+
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
+
# The 'foreach' method runs a script on each row from a result set.
|
| 754 |
+
|
| 755 |
+
method foreach args {
|
| 756 |
+
|
| 757 |
+
variable ::tdbc::generalError
|
| 758 |
+
|
| 759 |
+
# Grab keyword-value parameters
|
| 760 |
+
|
| 761 |
+
set args [::tdbc::ParseConvenienceArgs $args[set args {}] opts]
|
| 762 |
+
|
| 763 |
+
# Check positional parameters
|
| 764 |
+
|
| 765 |
+
if {[llength $args] != 2} {
|
| 766 |
+
set errorcode $generalError
|
| 767 |
+
lappend errorcode wrongNumArgs
|
| 768 |
+
return -code error -errorcode $errorcode \
|
| 769 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 770 |
+
?-option value?... ?--? varName script"
|
| 771 |
+
}
|
| 772 |
+
|
| 773 |
+
# Do -columnsvariable if requested
|
| 774 |
+
|
| 775 |
+
if {[dict exists $opts -columnsvariable]} {
|
| 776 |
+
upvar 1 [dict get $opts -columnsvariable] columns
|
| 777 |
+
}
|
| 778 |
+
|
| 779 |
+
# Iterate over the groups of results
|
| 780 |
+
while {1} {
|
| 781 |
+
|
| 782 |
+
# Export column names to caller
|
| 783 |
+
|
| 784 |
+
set columns [my columns]
|
| 785 |
+
|
| 786 |
+
# Iterate over the rows of one group of results
|
| 787 |
+
|
| 788 |
+
upvar 1 [lindex $args 0] row
|
| 789 |
+
if {[dict get $opts -as] eq {lists}} {
|
| 790 |
+
set delegate nextlist
|
| 791 |
+
} else {
|
| 792 |
+
set delegate nextdict
|
| 793 |
+
}
|
| 794 |
+
while {[my $delegate row]} {
|
| 795 |
+
set status [catch {
|
| 796 |
+
uplevel 1 [lindex $args 1]
|
| 797 |
+
} result options]
|
| 798 |
+
switch -exact -- $status {
|
| 799 |
+
0 - 4 { # OK or CONTINUE
|
| 800 |
+
}
|
| 801 |
+
2 { # RETURN
|
| 802 |
+
set options \
|
| 803 |
+
[dict merge {-level 1} $options[set options {}]]
|
| 804 |
+
dict incr options -level
|
| 805 |
+
return -options $options $result
|
| 806 |
+
}
|
| 807 |
+
3 { # BREAK
|
| 808 |
+
set broken 1
|
| 809 |
+
break
|
| 810 |
+
}
|
| 811 |
+
default { # ERROR or unknown status
|
| 812 |
+
return -options $options $result
|
| 813 |
+
}
|
| 814 |
+
}
|
| 815 |
+
}
|
| 816 |
+
|
| 817 |
+
# Advance to the next group of results if there is one
|
| 818 |
+
|
| 819 |
+
if {[info exists broken] || ![my nextresults]} {
|
| 820 |
+
break
|
| 821 |
+
}
|
| 822 |
+
}
|
| 823 |
+
|
| 824 |
+
return
|
| 825 |
+
}
|
| 826 |
+
|
| 827 |
+
|
| 828 |
+
# The 'nextrow' method retrieves a row in the form of either
|
| 829 |
+
# a list or a dictionary.
|
| 830 |
+
|
| 831 |
+
method nextrow {args} {
|
| 832 |
+
|
| 833 |
+
variable ::tdbc::generalError
|
| 834 |
+
|
| 835 |
+
set opts [dict create -as dicts]
|
| 836 |
+
set i 0
|
| 837 |
+
|
| 838 |
+
# Munch keyword options off the front of the command arguments
|
| 839 |
+
|
| 840 |
+
foreach {key value} $args {
|
| 841 |
+
if {[string index $key 0] eq {-}} {
|
| 842 |
+
switch -regexp -- $key {
|
| 843 |
+
-as? {
|
| 844 |
+
dict set opts -as $value
|
| 845 |
+
}
|
| 846 |
+
-- {
|
| 847 |
+
incr i
|
| 848 |
+
break
|
| 849 |
+
}
|
| 850 |
+
default {
|
| 851 |
+
set errorcode $generalError
|
| 852 |
+
lappend errorcode badOption $key
|
| 853 |
+
return -code error -errorcode $errorcode \
|
| 854 |
+
"bad option \"$key\":\
|
| 855 |
+
must be -as or -columnsvariable"
|
| 856 |
+
}
|
| 857 |
+
}
|
| 858 |
+
} else {
|
| 859 |
+
break
|
| 860 |
+
}
|
| 861 |
+
incr i 2
|
| 862 |
+
}
|
| 863 |
+
|
| 864 |
+
set args [lrange $args $i end]
|
| 865 |
+
if {[llength $args] != 1} {
|
| 866 |
+
set errorcode $generalError
|
| 867 |
+
lappend errorcode wrongNumArgs
|
| 868 |
+
return -code error -errorcode $errorcode \
|
| 869 |
+
"wrong # args: should be [lrange [info level 0] 0 1]\
|
| 870 |
+
?-option value?... ?--? varName"
|
| 871 |
+
}
|
| 872 |
+
upvar 1 [lindex $args 0] row
|
| 873 |
+
if {[dict get $opts -as] eq {lists}} {
|
| 874 |
+
set delegate nextlist
|
| 875 |
+
} else {
|
| 876 |
+
set delegate nextdict
|
| 877 |
+
}
|
| 878 |
+
return [my $delegate row]
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
# Derived classes must override 'nextresults' if a single
|
| 882 |
+
# statement execution can yield multiple sets of results
|
| 883 |
+
|
| 884 |
+
method nextresults {} {
|
| 885 |
+
return 0
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
# Derived classes must override 'outputparams' if statements can
|
| 889 |
+
# have output parameters.
|
| 890 |
+
|
| 891 |
+
method outputparams {} {
|
| 892 |
+
return {}
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
# The 'close' method is syntactic sugar for destroying the result set.
|
| 896 |
+
|
| 897 |
+
method close {} {
|
| 898 |
+
my destroy
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
# Derived classes are expected to implement the following methods:
|
| 902 |
+
|
| 903 |
+
# constructor and destructor.
|
| 904 |
+
# Constructor accepts a statement and an optional
|
| 905 |
+
# a dictionary of substituted parameters and
|
| 906 |
+
# executes the statement against the database. If
|
| 907 |
+
# the dictionary is not supplied, then the default
|
| 908 |
+
# is to get params from variables in the caller's scope).
|
| 909 |
+
# columns
|
| 910 |
+
# -- Returns a list of the names of the columns in the result.
|
| 911 |
+
# nextdict variableName
|
| 912 |
+
# -- Stores the next row of the result set in the given variable
|
| 913 |
+
# in caller's scope, in the form of a dictionary that maps
|
| 914 |
+
# column names to values.
|
| 915 |
+
# nextlist variableName
|
| 916 |
+
# -- Stores the next row of the result set in the given variable
|
| 917 |
+
# in caller's scope, in the form of a list of cells.
|
| 918 |
+
# rowcount
|
| 919 |
+
# -- Returns a count of rows affected by the statement, or -1
|
| 920 |
+
# if the count of rows has not been determined.
|
| 921 |
+
|
| 922 |
+
}
|
mplug_owl2/lib/tdbcodbc1.1.7/libtdbcodbc1.1.7.so
ADDED
|
Binary file (66 kB). View file
|
|
|
mplug_owl2/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 |
+
}
|
mplug_owl2/lib/tdbcodbc1.1.7/tdbcodbc.tcl
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tdbcodbc.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Class definitions and Tcl-level methods for the tdbc::odbc bridge.
|
| 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 |
+
|
| 15 |
+
::namespace eval ::tdbc::odbc {
|
| 16 |
+
|
| 17 |
+
namespace export connection datasources drivers
|
| 18 |
+
|
| 19 |
+
# Data types that are predefined in ODBC
|
| 20 |
+
|
| 21 |
+
variable sqltypes [dict create \
|
| 22 |
+
1 char \
|
| 23 |
+
2 numeric \
|
| 24 |
+
3 decimal \
|
| 25 |
+
4 integer \
|
| 26 |
+
5 smallint \
|
| 27 |
+
6 float \
|
| 28 |
+
7 real \
|
| 29 |
+
8 double \
|
| 30 |
+
9 datetime \
|
| 31 |
+
12 varchar \
|
| 32 |
+
91 date \
|
| 33 |
+
92 time \
|
| 34 |
+
93 timestamp \
|
| 35 |
+
-1 longvarchar \
|
| 36 |
+
-2 binary \
|
| 37 |
+
-3 varbinary \
|
| 38 |
+
-4 longvarbinary \
|
| 39 |
+
-5 bigint \
|
| 40 |
+
-6 tinyint \
|
| 41 |
+
-7 bit \
|
| 42 |
+
-8 wchar \
|
| 43 |
+
-9 wvarchar \
|
| 44 |
+
-10 wlongvarchar \
|
| 45 |
+
-11 guid]
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#------------------------------------------------------------------------------
|
| 49 |
+
#
|
| 50 |
+
# tdbc::odbc::connection --
|
| 51 |
+
#
|
| 52 |
+
# Class representing a connection to a database through ODBC.
|
| 53 |
+
#
|
| 54 |
+
#-------------------------------------------------------------------------------
|
| 55 |
+
|
| 56 |
+
::oo::class create ::tdbc::odbc::connection {
|
| 57 |
+
|
| 58 |
+
superclass ::tdbc::connection
|
| 59 |
+
|
| 60 |
+
variable statementSeq typemap
|
| 61 |
+
|
| 62 |
+
# The constructor is written in C. It takes the connection string
|
| 63 |
+
# as its argument It sets up a namespace to hold the statements
|
| 64 |
+
# associated with the connection, and then delegates to the 'init'
|
| 65 |
+
# method (written in C) to do the actual work of attaching to the
|
| 66 |
+
# database. When that comes back, it sets up a statement to query
|
| 67 |
+
# the support types, makes a dictionary to enumerate them, and
|
| 68 |
+
# calls back to set a flag if WVARCHAR is seen (If WVARCHAR is
|
| 69 |
+
# seen, the database supports Unicode.)
|
| 70 |
+
|
| 71 |
+
# The 'statementCreate' method forwards to the constructor of the
|
| 72 |
+
# statement class
|
| 73 |
+
|
| 74 |
+
forward statementCreate ::tdbc::odbc::statement create
|
| 75 |
+
|
| 76 |
+
# The 'tables' method returns a dictionary describing the tables
|
| 77 |
+
# in the database
|
| 78 |
+
|
| 79 |
+
method tables {{pattern %}} {
|
| 80 |
+
set stmt [::tdbc::odbc::tablesStatement create \
|
| 81 |
+
Stmt::[incr statementSeq] [self] $pattern]
|
| 82 |
+
set status [catch {
|
| 83 |
+
set retval {}
|
| 84 |
+
$stmt foreach -as dicts row {
|
| 85 |
+
if {[dict exists $row TABLE_NAME]} {
|
| 86 |
+
dict set retval [dict get $row TABLE_NAME] $row
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
set retval
|
| 90 |
+
} result options]
|
| 91 |
+
catch {rename $stmt {}}
|
| 92 |
+
return -level 0 -options $options $result
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
# The 'columns' method returns a dictionary describing the tables
|
| 96 |
+
# in the database
|
| 97 |
+
|
| 98 |
+
method columns {table {pattern %}} {
|
| 99 |
+
# Make sure that the type map is initialized
|
| 100 |
+
my typemap
|
| 101 |
+
|
| 102 |
+
# Query the columns from the database
|
| 103 |
+
|
| 104 |
+
set stmt [::tdbc::odbc::columnsStatement create \
|
| 105 |
+
Stmt::[incr statementSeq] [self] $table $pattern]
|
| 106 |
+
set status [catch {
|
| 107 |
+
set retval {}
|
| 108 |
+
$stmt foreach -as dicts origrow {
|
| 109 |
+
|
| 110 |
+
# Map the type, precision, scale and nullable indicators
|
| 111 |
+
# to tdbc's notation
|
| 112 |
+
|
| 113 |
+
set row {}
|
| 114 |
+
dict for {key value} $origrow {
|
| 115 |
+
dict set row [string tolower $key] $value
|
| 116 |
+
}
|
| 117 |
+
if {[dict exists $row column_name]} {
|
| 118 |
+
if {[dict exists $typemap \
|
| 119 |
+
[dict get $row data_type]]} {
|
| 120 |
+
dict set row type \
|
| 121 |
+
[dict get $typemap \
|
| 122 |
+
[dict get $row data_type]]
|
| 123 |
+
} else {
|
| 124 |
+
dict set row type [dict get $row type_name]
|
| 125 |
+
}
|
| 126 |
+
if {[dict exists $row column_size]} {
|
| 127 |
+
dict set row precision \
|
| 128 |
+
[dict get $row column_size]
|
| 129 |
+
}
|
| 130 |
+
if {[dict exists $row decimal_digits]} {
|
| 131 |
+
dict set row scale \
|
| 132 |
+
[dict get $row decimal_digits]
|
| 133 |
+
}
|
| 134 |
+
if {![dict exists $row nullable]} {
|
| 135 |
+
dict set row nullable \
|
| 136 |
+
[expr {!![string trim [dict get $row is_nullable]]}]
|
| 137 |
+
}
|
| 138 |
+
dict set retval [dict get $row column_name] $row
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
set retval
|
| 142 |
+
} result options]
|
| 143 |
+
catch {rename $stmt {}}
|
| 144 |
+
return -level 0 -options $options $result
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
# The 'primarykeys' method returns a dictionary describing the primary
|
| 148 |
+
# keys of a table
|
| 149 |
+
|
| 150 |
+
method primarykeys {tableName} {
|
| 151 |
+
set stmt [::tdbc::odbc::primarykeysStatement create \
|
| 152 |
+
Stmt::[incr statementSeq] [self] $tableName]
|
| 153 |
+
set status [catch {
|
| 154 |
+
set retval {}
|
| 155 |
+
$stmt foreach -as dicts row {
|
| 156 |
+
foreach {odbcKey tdbcKey} {
|
| 157 |
+
TABLE_CAT tableCatalog
|
| 158 |
+
TABLE_SCHEM tableSchema
|
| 159 |
+
TABLE_NAME tableName
|
| 160 |
+
COLUMN_NAME columnName
|
| 161 |
+
KEY_SEQ ordinalPosition
|
| 162 |
+
PK_NAME constraintName
|
| 163 |
+
} {
|
| 164 |
+
if {[dict exists $row $odbcKey]} {
|
| 165 |
+
dict set row $tdbcKey [dict get $row $odbcKey]
|
| 166 |
+
dict unset row $odbcKey
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
lappend retval $row
|
| 170 |
+
}
|
| 171 |
+
set retval
|
| 172 |
+
} result options]
|
| 173 |
+
catch {rename $stmt {}}
|
| 174 |
+
return -level 0 -options $options $result
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
# The 'foreignkeys' method returns a dictionary describing the foreign
|
| 178 |
+
# keys of a table
|
| 179 |
+
|
| 180 |
+
method foreignkeys {args} {
|
| 181 |
+
set stmt [::tdbc::odbc::foreignkeysStatement create \
|
| 182 |
+
Stmt::[incr statementSeq] [self] {*}$args]
|
| 183 |
+
set status [catch {
|
| 184 |
+
set fkseq 0
|
| 185 |
+
set retval {}
|
| 186 |
+
$stmt foreach -as dicts row {
|
| 187 |
+
foreach {odbcKey tdbcKey} {
|
| 188 |
+
PKTABLE_CAT primaryCatalog
|
| 189 |
+
PKTABLE_SCHEM primarySchema
|
| 190 |
+
PKTABLE_NAME primaryTable
|
| 191 |
+
PKCOLUMN_NAME primaryColumn
|
| 192 |
+
FKTABLE_CAT foreignCatalog
|
| 193 |
+
FKTABLE_SCHEM foreignSchema
|
| 194 |
+
FKTABLE_NAME foreignTable
|
| 195 |
+
FKCOLUMN_NAME foreignColumn
|
| 196 |
+
UPDATE_RULE updateRule
|
| 197 |
+
DELETE_RULE deleteRule
|
| 198 |
+
DEFERRABILITY deferrable
|
| 199 |
+
KEY_SEQ ordinalPosition
|
| 200 |
+
FK_NAME foreignConstraintName
|
| 201 |
+
} {
|
| 202 |
+
if {[dict exists $row $odbcKey]} {
|
| 203 |
+
dict set row $tdbcKey [dict get $row $odbcKey]
|
| 204 |
+
dict unset row $odbcKey
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
# Horrible kludge: If the driver doesn't report FK_NAME,
|
| 208 |
+
# make one up.
|
| 209 |
+
if {![dict exists $row foreignConstraintName]} {
|
| 210 |
+
if {![dict exists $row ordinalPosition]
|
| 211 |
+
|| [dict get $row ordinalPosition] == 1} {
|
| 212 |
+
set fkname ?[dict get $row foreignTable]?[incr fkseq]
|
| 213 |
+
}
|
| 214 |
+
dict set row foreignConstraintName $fkname
|
| 215 |
+
}
|
| 216 |
+
lappend retval $row
|
| 217 |
+
}
|
| 218 |
+
set retval
|
| 219 |
+
} result options]
|
| 220 |
+
catch {rename $stmt {}}
|
| 221 |
+
return -level 0 -options $options $result
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
# The 'evaldirect' evaluates driver-native SQL code without preparing it,
|
| 225 |
+
# and returns a list of dicts (similar to '$connection allrows -as dicts').
|
| 226 |
+
|
| 227 |
+
method evaldirect {sqlStatement} {
|
| 228 |
+
set stmt [::tdbc::odbc::evaldirectStatement create \
|
| 229 |
+
Stmt::[incr statementSeq] [self] $sqlStatement]
|
| 230 |
+
set status [catch {
|
| 231 |
+
$stmt allrows -as dicts
|
| 232 |
+
} result options]
|
| 233 |
+
catch {rename $stmt {}}
|
| 234 |
+
return -level 0 -options $options $result
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
# The 'prepareCall' method gives a portable interface to prepare
|
| 238 |
+
# calls to stored procedures. It delegates to 'prepare' to do the
|
| 239 |
+
# actual work.
|
| 240 |
+
|
| 241 |
+
method preparecall {call} {
|
| 242 |
+
|
| 243 |
+
regexp {^[[:space:]]*(?:([A-Za-z_][A-Za-z_0-9]*)[[:space:]]*=)?(.*)} \
|
| 244 |
+
$call -> varName rest
|
| 245 |
+
if {$varName eq {}} {
|
| 246 |
+
my prepare \\{CALL $rest\\}
|
| 247 |
+
} else {
|
| 248 |
+
my prepare \\{:$varName=CALL $rest\\}
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
if 0 {
|
| 252 |
+
# Kevin thinks this is going to be
|
| 253 |
+
|
| 254 |
+
if {![regexp -expanded {
|
| 255 |
+
^\s* # leading whitespace
|
| 256 |
+
(?::([[:alpha:]_][[:alnum:]_]*)\s*=\s*) # possible variable name
|
| 257 |
+
(?:(?:([[:alpha:]_][[:alnum:]_]*)\s*[.]\s*)? # catalog
|
| 258 |
+
([[:alpha:]_][[:alnum:]_]*)\s*[.]\s*)? # schema
|
| 259 |
+
([[:alpha:]_][[:alnum:]_]*)\s* # procedure
|
| 260 |
+
(.*)$ # argument list
|
| 261 |
+
} $call -> varName catalog schema procedure arglist]} {
|
| 262 |
+
return -code error \
|
| 263 |
+
-errorCode [list TDBC \
|
| 264 |
+
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION \
|
| 265 |
+
42000 ODBC -1] \
|
| 266 |
+
"Syntax error in stored procedure call"
|
| 267 |
+
} else {
|
| 268 |
+
my PrepareCall $varName $catalog $schema $procedure $arglist
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
# at least if making all parameters 'inout' doesn't work.
|
| 272 |
+
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
# The 'typemap' method returns the type map
|
| 278 |
+
|
| 279 |
+
method typemap {} {
|
| 280 |
+
if {![info exists typemap]} {
|
| 281 |
+
set typemap $::tdbc::odbc::sqltypes
|
| 282 |
+
set typesStmt [tdbc::odbc::typesStatement new [self]]
|
| 283 |
+
$typesStmt foreach row {
|
| 284 |
+
set typeNum [dict get $row DATA_TYPE]
|
| 285 |
+
if {![dict exists $typemap $typeNum]} {
|
| 286 |
+
dict set typemap $typeNum [string tolower \
|
| 287 |
+
[dict get $row TYPE_NAME]]
|
| 288 |
+
}
|
| 289 |
+
switch -exact -- $typeNum {
|
| 290 |
+
-9 {
|
| 291 |
+
[self] HasWvarchar 1
|
| 292 |
+
}
|
| 293 |
+
-5 {
|
| 294 |
+
[self] HasBigint 1
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
rename $typesStmt {}
|
| 299 |
+
}
|
| 300 |
+
return $typemap
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
# The 'begintransaction', 'commit' and 'rollback' methods are
|
| 304 |
+
# implemented in C.
|
| 305 |
+
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
#-------------------------------------------------------------------------------
|
| 309 |
+
#
|
| 310 |
+
# tdbc::odbc::statement --
|
| 311 |
+
#
|
| 312 |
+
# The class 'tdbc::odbc::statement' models one statement against a
|
| 313 |
+
# database accessed through an ODBC connection
|
| 314 |
+
#
|
| 315 |
+
#-------------------------------------------------------------------------------
|
| 316 |
+
|
| 317 |
+
::oo::class create ::tdbc::odbc::statement {
|
| 318 |
+
|
| 319 |
+
superclass ::tdbc::statement
|
| 320 |
+
|
| 321 |
+
# The constructor is implemented in C. It accepts the handle to
|
| 322 |
+
# the connection and the SQL code for the statement to prepare.
|
| 323 |
+
# It creates a subordinate namespace to hold the statement's
|
| 324 |
+
# active result sets, and then delegates to the 'init' method,
|
| 325 |
+
# written in C, to do the actual work of preparing the statement.
|
| 326 |
+
|
| 327 |
+
# The 'resultSetCreate' method forwards to the result set constructor
|
| 328 |
+
|
| 329 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 330 |
+
|
| 331 |
+
# The 'params' method describes the parameters to the statement
|
| 332 |
+
|
| 333 |
+
method params {} {
|
| 334 |
+
set typemap [[my connection] typemap]
|
| 335 |
+
set result {}
|
| 336 |
+
foreach {name flags typeNum precision scale nullable} [my ParamList] {
|
| 337 |
+
set lst [dict create \
|
| 338 |
+
name $name \
|
| 339 |
+
direction [lindex {unknown in out inout} \
|
| 340 |
+
[expr {($flags & 0x06) >> 1}]] \
|
| 341 |
+
type [dict get $typemap $typeNum] \
|
| 342 |
+
precision $precision \
|
| 343 |
+
scale $scale]
|
| 344 |
+
if {$nullable in {0 1}} {
|
| 345 |
+
dict set list nullable $nullable
|
| 346 |
+
}
|
| 347 |
+
dict set result $name $lst
|
| 348 |
+
}
|
| 349 |
+
return $result
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
# Methods implemented in C:
|
| 353 |
+
# init statement ?dictionary?
|
| 354 |
+
# Does the heavy lifting for the constructor
|
| 355 |
+
# connection
|
| 356 |
+
# Returns the connection handle to which this statement belongs
|
| 357 |
+
# paramtype paramname ?direction? type ?precision ?scale??
|
| 358 |
+
# Declares the type of a parameter in the statement
|
| 359 |
+
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
#------------------------------------------------------------------------------
|
| 363 |
+
#
|
| 364 |
+
# tdbc::odbc::tablesStatement --
|
| 365 |
+
#
|
| 366 |
+
# The class 'tdbc::odbc::tablesStatement' represents the special
|
| 367 |
+
# statement that queries the tables in a database through an ODBC
|
| 368 |
+
# connection.
|
| 369 |
+
#
|
| 370 |
+
#------------------------------------------------------------------------------
|
| 371 |
+
|
| 372 |
+
oo::class create ::tdbc::odbc::tablesStatement {
|
| 373 |
+
|
| 374 |
+
superclass ::tdbc::statement
|
| 375 |
+
|
| 376 |
+
# The constructor is written in C. It accepts the handle to the
|
| 377 |
+
# connection and a pattern to match table names. It works in all
|
| 378 |
+
# ways like the constructor of the 'statement' class except that
|
| 379 |
+
# its 'init' method sets up to enumerate tables and not run a SQL
|
| 380 |
+
# query.
|
| 381 |
+
|
| 382 |
+
# The 'resultSetCreate' method forwards to the result set constructor
|
| 383 |
+
|
| 384 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 385 |
+
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
#------------------------------------------------------------------------------
|
| 389 |
+
#
|
| 390 |
+
# tdbc::odbc::columnsStatement --
|
| 391 |
+
#
|
| 392 |
+
# The class 'tdbc::odbc::tablesStatement' represents the special
|
| 393 |
+
# statement that queries the columns of a table or view
|
| 394 |
+
# in a database through an ODBC connection.
|
| 395 |
+
#
|
| 396 |
+
#------------------------------------------------------------------------------
|
| 397 |
+
|
| 398 |
+
oo::class create ::tdbc::odbc::columnsStatement {
|
| 399 |
+
|
| 400 |
+
superclass ::tdbc::statement
|
| 401 |
+
|
| 402 |
+
# The constructor is written in C. It accepts the handle to the
|
| 403 |
+
# connection, a table name, and a pattern to match column
|
| 404 |
+
# names. It works in all ways like the constructor of the
|
| 405 |
+
# 'statement' class except that its 'init' method sets up to
|
| 406 |
+
# enumerate tables and not run a SQL query.
|
| 407 |
+
|
| 408 |
+
# The 'resultSetCreate' class forwards to the constructor of the
|
| 409 |
+
# result set
|
| 410 |
+
|
| 411 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 412 |
+
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
#------------------------------------------------------------------------------
|
| 416 |
+
#
|
| 417 |
+
# tdbc::odbc::primarykeysStatement --
|
| 418 |
+
#
|
| 419 |
+
# The class 'tdbc::odbc::primarykeysStatement' represents the special
|
| 420 |
+
# statement that queries the primary keys on a table through an ODBC
|
| 421 |
+
# connection.
|
| 422 |
+
#
|
| 423 |
+
#------------------------------------------------------------------------------
|
| 424 |
+
|
| 425 |
+
oo::class create ::tdbc::odbc::primarykeysStatement {
|
| 426 |
+
|
| 427 |
+
superclass ::tdbc::statement
|
| 428 |
+
|
| 429 |
+
# The constructor is written in C. It accepts the handle to the
|
| 430 |
+
# connection and a table name. It works in all
|
| 431 |
+
# ways like the constructor of the 'statement' class except that
|
| 432 |
+
# its 'init' method sets up to enumerate primary keys and not run a SQL
|
| 433 |
+
# query.
|
| 434 |
+
|
| 435 |
+
# The 'resultSetCreate' method forwards to the result set constructor
|
| 436 |
+
|
| 437 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 438 |
+
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
#------------------------------------------------------------------------------
|
| 442 |
+
#
|
| 443 |
+
# tdbc::odbc::foreignkeysStatement --
|
| 444 |
+
#
|
| 445 |
+
# The class 'tdbc::odbc::foreignkeysStatement' represents the special
|
| 446 |
+
# statement that queries the foreign keys on a table through an ODBC
|
| 447 |
+
# connection.
|
| 448 |
+
#
|
| 449 |
+
#------------------------------------------------------------------------------
|
| 450 |
+
|
| 451 |
+
oo::class create ::tdbc::odbc::foreignkeysStatement {
|
| 452 |
+
|
| 453 |
+
superclass ::tdbc::statement
|
| 454 |
+
|
| 455 |
+
# The constructor is written in C. It accepts the handle to the
|
| 456 |
+
# connection and the -primary and -foreign options. It works in all
|
| 457 |
+
# ways like the constructor of the 'statement' class except that
|
| 458 |
+
# its 'init' method sets up to enumerate foreign keys and not run a SQL
|
| 459 |
+
# query.
|
| 460 |
+
|
| 461 |
+
# The 'resultSetCreate' method forwards to the result set constructor
|
| 462 |
+
|
| 463 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 464 |
+
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
#------------------------------------------------------------------------------
|
| 468 |
+
#
|
| 469 |
+
# tdbc::odbc::evaldirectStatement --
|
| 470 |
+
#
|
| 471 |
+
# The class 'tdbc::odbc::evaldirectStatement' provides a mechanism to
|
| 472 |
+
# execute driver-name SQL code through an ODBC connection. The SQL code
|
| 473 |
+
# is not prepared and no tokenization or variable substitution is done.
|
| 474 |
+
#
|
| 475 |
+
#------------------------------------------------------------------------------
|
| 476 |
+
|
| 477 |
+
oo::class create ::tdbc::odbc::evaldirectStatement {
|
| 478 |
+
|
| 479 |
+
superclass ::tdbc::statement
|
| 480 |
+
|
| 481 |
+
# The constructor is written in C. It accepts the handle to the
|
| 482 |
+
# connection and a SQL statement. It works in all
|
| 483 |
+
# ways like the constructor of the 'statement' class except that
|
| 484 |
+
# its 'init' method does not tokenize or prepare the SQL statement, and
|
| 485 |
+
# sets up to run the SQL query without performing variable substitution.
|
| 486 |
+
|
| 487 |
+
# The 'resultSetCreate' method forwards to the result set constructor
|
| 488 |
+
|
| 489 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 490 |
+
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
#------------------------------------------------------------------------------
|
| 494 |
+
#
|
| 495 |
+
# tdbc::odbc::typesStatement --
|
| 496 |
+
#
|
| 497 |
+
# The class 'tdbc::odbc::typesStatement' represents the special
|
| 498 |
+
# statement that queries the types available in a database through
|
| 499 |
+
# an ODBC connection.
|
| 500 |
+
#
|
| 501 |
+
#------------------------------------------------------------------------------
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
oo::class create ::tdbc::odbc::typesStatement {
|
| 505 |
+
|
| 506 |
+
superclass ::tdbc::statement
|
| 507 |
+
|
| 508 |
+
# The constructor is written in C. It accepts the handle to the
|
| 509 |
+
# connection, and (optionally) a data type number. It works in all
|
| 510 |
+
# ways like the constructor of the 'statement' class except that
|
| 511 |
+
# its 'init' method sets up to enumerate types and not run a SQL
|
| 512 |
+
# query.
|
| 513 |
+
|
| 514 |
+
# The 'resultSetCreate' method forwards to the constructor of result sets
|
| 515 |
+
|
| 516 |
+
forward resultSetCreate ::tdbc::odbc::resultset create
|
| 517 |
+
|
| 518 |
+
# The C code contains a variant implementation of the 'init' method.
|
| 519 |
+
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
#------------------------------------------------------------------------------
|
| 523 |
+
#
|
| 524 |
+
# tdbc::odbc::resultset --
|
| 525 |
+
#
|
| 526 |
+
# The class 'tdbc::odbc::resultset' models the result set that is
|
| 527 |
+
# produced by executing a statement against an ODBC database.
|
| 528 |
+
#
|
| 529 |
+
#------------------------------------------------------------------------------
|
| 530 |
+
|
| 531 |
+
::oo::class create ::tdbc::odbc::resultset {
|
| 532 |
+
|
| 533 |
+
superclass ::tdbc::resultset
|
| 534 |
+
|
| 535 |
+
# Methods implemented in C include:
|
| 536 |
+
|
| 537 |
+
# constructor statement ?dictionary?
|
| 538 |
+
# -- Executes the statement against the database, optionally providing
|
| 539 |
+
# a dictionary of substituted parameters (default is to get params
|
| 540 |
+
# from variables in the caller's scope).
|
| 541 |
+
# columns
|
| 542 |
+
# -- Returns a list of the names of the columns in the result.
|
| 543 |
+
# nextdict
|
| 544 |
+
# -- Stores the next row of the result set in the given variable in
|
| 545 |
+
# the caller's scope as a dictionary whose keys are
|
| 546 |
+
# column names and whose values are column values.
|
| 547 |
+
# nextlist
|
| 548 |
+
# -- Stores the next row of the result set in the given variable in
|
| 549 |
+
# the caller's scope as a list of cells.
|
| 550 |
+
# rowcount
|
| 551 |
+
# -- Returns a count of rows affected by the statement, or -1
|
| 552 |
+
# if the count of rows has not been determined.
|
| 553 |
+
|
| 554 |
+
}
|
mplug_owl2/lib/tk8.6/bgerror.tcl
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/button.tcl
ADDED
|
@@ -0,0 +1,782 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# button.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the default bindings for Tk label, button,
|
| 4 |
+
# checkbutton, and radiobutton widgets and provides procedures
|
| 5 |
+
# that help in implementing those bindings.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 1992-1994 The Regents of the University of California.
|
| 8 |
+
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
| 9 |
+
# Copyright (c) 2002 ActiveState Corporation.
|
| 10 |
+
#
|
| 11 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 12 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
#-------------------------------------------------------------------------
|
| 16 |
+
# The code below creates the default class bindings for buttons.
|
| 17 |
+
#-------------------------------------------------------------------------
|
| 18 |
+
|
| 19 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 20 |
+
|
| 21 |
+
bind Radiobutton <Enter> {
|
| 22 |
+
tk::ButtonEnter %W
|
| 23 |
+
}
|
| 24 |
+
bind Radiobutton <1> {
|
| 25 |
+
tk::ButtonDown %W
|
| 26 |
+
}
|
| 27 |
+
bind Radiobutton <ButtonRelease-1> {
|
| 28 |
+
tk::ButtonUp %W
|
| 29 |
+
}
|
| 30 |
+
bind Checkbutton <Enter> {
|
| 31 |
+
tk::ButtonEnter %W
|
| 32 |
+
}
|
| 33 |
+
bind Checkbutton <1> {
|
| 34 |
+
tk::ButtonDown %W
|
| 35 |
+
}
|
| 36 |
+
bind Checkbutton <ButtonRelease-1> {
|
| 37 |
+
tk::ButtonUp %W
|
| 38 |
+
}
|
| 39 |
+
bind Checkbutton <Leave> {
|
| 40 |
+
tk::ButtonLeave %W
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
if {"win32" eq [tk windowingsystem]} {
|
| 44 |
+
bind Checkbutton <equal> {
|
| 45 |
+
tk::CheckRadioInvoke %W select
|
| 46 |
+
}
|
| 47 |
+
bind Checkbutton <plus> {
|
| 48 |
+
tk::CheckRadioInvoke %W select
|
| 49 |
+
}
|
| 50 |
+
bind Checkbutton <minus> {
|
| 51 |
+
tk::CheckRadioInvoke %W deselect
|
| 52 |
+
}
|
| 53 |
+
bind Checkbutton <1> {
|
| 54 |
+
tk::CheckRadioDown %W
|
| 55 |
+
}
|
| 56 |
+
bind Checkbutton <ButtonRelease-1> {
|
| 57 |
+
tk::ButtonUp %W
|
| 58 |
+
}
|
| 59 |
+
bind Checkbutton <Enter> {
|
| 60 |
+
tk::CheckRadioEnter %W
|
| 61 |
+
}
|
| 62 |
+
bind Checkbutton <Leave> {
|
| 63 |
+
tk::ButtonLeave %W
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
bind Radiobutton <1> {
|
| 67 |
+
tk::CheckRadioDown %W
|
| 68 |
+
}
|
| 69 |
+
bind Radiobutton <ButtonRelease-1> {
|
| 70 |
+
tk::ButtonUp %W
|
| 71 |
+
}
|
| 72 |
+
bind Radiobutton <Enter> {
|
| 73 |
+
tk::CheckRadioEnter %W
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
if {"x11" eq [tk windowingsystem]} {
|
| 77 |
+
bind Checkbutton <Return> {
|
| 78 |
+
if {!$tk_strictMotif} {
|
| 79 |
+
tk::CheckInvoke %W
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
bind Radiobutton <Return> {
|
| 83 |
+
if {!$tk_strictMotif} {
|
| 84 |
+
tk::CheckRadioInvoke %W
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
bind Checkbutton <1> {
|
| 88 |
+
tk::CheckInvoke %W
|
| 89 |
+
}
|
| 90 |
+
bind Radiobutton <1> {
|
| 91 |
+
tk::CheckRadioInvoke %W
|
| 92 |
+
}
|
| 93 |
+
bind Checkbutton <Enter> {
|
| 94 |
+
tk::CheckEnter %W
|
| 95 |
+
}
|
| 96 |
+
bind Radiobutton <Enter> {
|
| 97 |
+
tk::ButtonEnter %W
|
| 98 |
+
}
|
| 99 |
+
bind Checkbutton <Leave> {
|
| 100 |
+
tk::CheckLeave %W
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
bind Button <space> {
|
| 105 |
+
tk::ButtonInvoke %W
|
| 106 |
+
}
|
| 107 |
+
bind Checkbutton <space> {
|
| 108 |
+
tk::CheckRadioInvoke %W
|
| 109 |
+
}
|
| 110 |
+
bind Radiobutton <space> {
|
| 111 |
+
tk::CheckRadioInvoke %W
|
| 112 |
+
}
|
| 113 |
+
bind Button <<Invoke>> {
|
| 114 |
+
tk::ButtonInvoke %W
|
| 115 |
+
}
|
| 116 |
+
bind Checkbutton <<Invoke>> {
|
| 117 |
+
tk::CheckRadioInvoke %W
|
| 118 |
+
}
|
| 119 |
+
bind Radiobutton <<Invoke>> {
|
| 120 |
+
tk::CheckRadioInvoke %W
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
bind Button <FocusIn> {}
|
| 124 |
+
bind Button <Enter> {
|
| 125 |
+
tk::ButtonEnter %W
|
| 126 |
+
}
|
| 127 |
+
bind Button <Leave> {
|
| 128 |
+
tk::ButtonLeave %W
|
| 129 |
+
}
|
| 130 |
+
bind Button <1> {
|
| 131 |
+
tk::ButtonDown %W
|
| 132 |
+
}
|
| 133 |
+
bind Button <ButtonRelease-1> {
|
| 134 |
+
tk::ButtonUp %W
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
bind Checkbutton <FocusIn> {}
|
| 138 |
+
|
| 139 |
+
bind Radiobutton <FocusIn> {}
|
| 140 |
+
bind Radiobutton <Leave> {
|
| 141 |
+
tk::ButtonLeave %W
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
if {"win32" eq [tk windowingsystem]} {
|
| 145 |
+
|
| 146 |
+
#########################
|
| 147 |
+
# Windows implementation
|
| 148 |
+
#########################
|
| 149 |
+
|
| 150 |
+
# ::tk::ButtonEnter --
|
| 151 |
+
# The procedure below is invoked when the mouse pointer enters a
|
| 152 |
+
# button widget. It records the button we're in and changes the
|
| 153 |
+
# state of the button to active unless the button is disabled.
|
| 154 |
+
#
|
| 155 |
+
# Arguments:
|
| 156 |
+
# w - The name of the widget.
|
| 157 |
+
|
| 158 |
+
proc ::tk::ButtonEnter w {
|
| 159 |
+
variable ::tk::Priv
|
| 160 |
+
if {[$w cget -state] ne "disabled"} {
|
| 161 |
+
|
| 162 |
+
# If the mouse button is down, set the relief to sunken on entry.
|
| 163 |
+
# Overwise, if there's an -overrelief value, set the relief to that.
|
| 164 |
+
|
| 165 |
+
set Priv($w,relief) [$w cget -relief]
|
| 166 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 167 |
+
$w configure -relief sunken -state active
|
| 168 |
+
set Priv($w,prelief) sunken
|
| 169 |
+
} elseif {[set over [$w cget -overrelief]] ne ""} {
|
| 170 |
+
$w configure -relief $over
|
| 171 |
+
set Priv($w,prelief) $over
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
set Priv(window) $w
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
# ::tk::ButtonLeave --
|
| 178 |
+
# The procedure below is invoked when the mouse pointer leaves a
|
| 179 |
+
# button widget. It changes the state of the button back to inactive.
|
| 180 |
+
# Restore any modified relief too.
|
| 181 |
+
#
|
| 182 |
+
# Arguments:
|
| 183 |
+
# w - The name of the widget.
|
| 184 |
+
|
| 185 |
+
proc ::tk::ButtonLeave w {
|
| 186 |
+
variable ::tk::Priv
|
| 187 |
+
if {[$w cget -state] ne "disabled"} {
|
| 188 |
+
$w configure -state normal
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
# Restore the original button relief if it was changed by Tk.
|
| 192 |
+
# That is signaled by the existence of Priv($w,prelief).
|
| 193 |
+
|
| 194 |
+
if {[info exists Priv($w,relief)]} {
|
| 195 |
+
if {[info exists Priv($w,prelief)] && \
|
| 196 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 197 |
+
$w configure -relief $Priv($w,relief)
|
| 198 |
+
}
|
| 199 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
set Priv(window) ""
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
# ::tk::ButtonDown --
|
| 206 |
+
# The procedure below is invoked when the mouse button is pressed in
|
| 207 |
+
# a button widget. It records the fact that the mouse is in the button,
|
| 208 |
+
# saves the button's relief so it can be restored later, and changes
|
| 209 |
+
# the relief to sunken.
|
| 210 |
+
#
|
| 211 |
+
# Arguments:
|
| 212 |
+
# w - The name of the widget.
|
| 213 |
+
|
| 214 |
+
proc ::tk::ButtonDown w {
|
| 215 |
+
variable ::tk::Priv
|
| 216 |
+
|
| 217 |
+
# Only save the button's relief if it does not yet exist. If there
|
| 218 |
+
# is an overrelief setting, Priv($w,relief) will already have been set,
|
| 219 |
+
# and the current value of the -relief option will be incorrect.
|
| 220 |
+
|
| 221 |
+
if {![info exists Priv($w,relief)]} {
|
| 222 |
+
set Priv($w,relief) [$w cget -relief]
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
if {[$w cget -state] ne "disabled"} {
|
| 226 |
+
set Priv(buttonWindow) $w
|
| 227 |
+
$w configure -relief sunken -state active
|
| 228 |
+
set Priv($w,prelief) sunken
|
| 229 |
+
|
| 230 |
+
# If this button has a repeatdelay set up, get it going with an after
|
| 231 |
+
after cancel $Priv(afterId)
|
| 232 |
+
set delay [$w cget -repeatdelay]
|
| 233 |
+
set Priv(repeated) 0
|
| 234 |
+
if {$delay > 0} {
|
| 235 |
+
set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
# ::tk::ButtonUp --
|
| 241 |
+
# The procedure below is invoked when the mouse button is released
|
| 242 |
+
# in a button widget. It restores the button's relief and invokes
|
| 243 |
+
# the command as long as the mouse hasn't left the button.
|
| 244 |
+
#
|
| 245 |
+
# Arguments:
|
| 246 |
+
# w - The name of the widget.
|
| 247 |
+
|
| 248 |
+
proc ::tk::ButtonUp w {
|
| 249 |
+
variable ::tk::Priv
|
| 250 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 251 |
+
set Priv(buttonWindow) ""
|
| 252 |
+
|
| 253 |
+
# Restore the button's relief if it was cached.
|
| 254 |
+
|
| 255 |
+
if {[info exists Priv($w,relief)]} {
|
| 256 |
+
if {[info exists Priv($w,prelief)] && \
|
| 257 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 258 |
+
$w configure -relief $Priv($w,relief)
|
| 259 |
+
}
|
| 260 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
# Clean up the after event from the auto-repeater
|
| 264 |
+
after cancel $Priv(afterId)
|
| 265 |
+
|
| 266 |
+
if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
|
| 267 |
+
$w configure -state normal
|
| 268 |
+
|
| 269 |
+
# Only invoke the command if it wasn't already invoked by the
|
| 270 |
+
# auto-repeater functionality
|
| 271 |
+
if { $Priv(repeated) == 0 } {
|
| 272 |
+
uplevel #0 [list $w invoke]
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
# ::tk::CheckRadioEnter --
|
| 279 |
+
# The procedure below is invoked when the mouse pointer enters a
|
| 280 |
+
# checkbutton or radiobutton widget. It records the button we're in
|
| 281 |
+
# and changes the state of the button to active unless the button is
|
| 282 |
+
# disabled.
|
| 283 |
+
#
|
| 284 |
+
# Arguments:
|
| 285 |
+
# w - The name of the widget.
|
| 286 |
+
|
| 287 |
+
proc ::tk::CheckRadioEnter w {
|
| 288 |
+
variable ::tk::Priv
|
| 289 |
+
if {[$w cget -state] ne "disabled"} {
|
| 290 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 291 |
+
$w configure -state active
|
| 292 |
+
}
|
| 293 |
+
if {[set over [$w cget -overrelief]] ne ""} {
|
| 294 |
+
set Priv($w,relief) [$w cget -relief]
|
| 295 |
+
set Priv($w,prelief) $over
|
| 296 |
+
$w configure -relief $over
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
set Priv(window) $w
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
# ::tk::CheckRadioDown --
|
| 303 |
+
# The procedure below is invoked when the mouse button is pressed in
|
| 304 |
+
# a button widget. It records the fact that the mouse is in the button,
|
| 305 |
+
# saves the button's relief so it can be restored later, and changes
|
| 306 |
+
# the relief to sunken.
|
| 307 |
+
#
|
| 308 |
+
# Arguments:
|
| 309 |
+
# w - The name of the widget.
|
| 310 |
+
|
| 311 |
+
proc ::tk::CheckRadioDown w {
|
| 312 |
+
variable ::tk::Priv
|
| 313 |
+
if {![info exists Priv($w,relief)]} {
|
| 314 |
+
set Priv($w,relief) [$w cget -relief]
|
| 315 |
+
}
|
| 316 |
+
if {[$w cget -state] ne "disabled"} {
|
| 317 |
+
set Priv(buttonWindow) $w
|
| 318 |
+
set Priv(repeated) 0
|
| 319 |
+
$w configure -state active
|
| 320 |
+
}
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
if {"x11" eq [tk windowingsystem]} {
|
| 326 |
+
|
| 327 |
+
#####################
|
| 328 |
+
# Unix implementation
|
| 329 |
+
#####################
|
| 330 |
+
|
| 331 |
+
# ::tk::ButtonEnter --
|
| 332 |
+
# The procedure below is invoked when the mouse pointer enters a
|
| 333 |
+
# button widget. It records the button we're in and changes the
|
| 334 |
+
# state of the button to active unless the button is disabled.
|
| 335 |
+
#
|
| 336 |
+
# Arguments:
|
| 337 |
+
# w - The name of the widget.
|
| 338 |
+
|
| 339 |
+
proc ::tk::ButtonEnter {w} {
|
| 340 |
+
variable ::tk::Priv
|
| 341 |
+
if {[$w cget -state] ne "disabled"} {
|
| 342 |
+
# On unix the state is active just with mouse-over
|
| 343 |
+
$w configure -state active
|
| 344 |
+
|
| 345 |
+
# If the mouse button is down, set the relief to sunken on entry.
|
| 346 |
+
# Overwise, if there's an -overrelief value, set the relief to that.
|
| 347 |
+
|
| 348 |
+
set Priv($w,relief) [$w cget -relief]
|
| 349 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 350 |
+
$w configure -relief sunken
|
| 351 |
+
set Priv($w,prelief) sunken
|
| 352 |
+
} elseif {[set over [$w cget -overrelief]] ne ""} {
|
| 353 |
+
$w configure -relief $over
|
| 354 |
+
set Priv($w,prelief) $over
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
set Priv(window) $w
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
# ::tk::ButtonLeave --
|
| 361 |
+
# The procedure below is invoked when the mouse pointer leaves a
|
| 362 |
+
# button widget. It changes the state of the button back to inactive.
|
| 363 |
+
# Restore any modified relief too.
|
| 364 |
+
#
|
| 365 |
+
# Arguments:
|
| 366 |
+
# w - The name of the widget.
|
| 367 |
+
|
| 368 |
+
proc ::tk::ButtonLeave w {
|
| 369 |
+
variable ::tk::Priv
|
| 370 |
+
if {[$w cget -state] ne "disabled"} {
|
| 371 |
+
$w configure -state normal
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
# Restore the original button relief if it was changed by Tk.
|
| 375 |
+
# That is signaled by the existence of Priv($w,prelief).
|
| 376 |
+
|
| 377 |
+
if {[info exists Priv($w,relief)]} {
|
| 378 |
+
if {[info exists Priv($w,prelief)] && \
|
| 379 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 380 |
+
$w configure -relief $Priv($w,relief)
|
| 381 |
+
}
|
| 382 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
set Priv(window) ""
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
# ::tk::ButtonDown --
|
| 389 |
+
# The procedure below is invoked when the mouse button is pressed in
|
| 390 |
+
# a button widget. It records the fact that the mouse is in the button,
|
| 391 |
+
# saves the button's relief so it can be restored later, and changes
|
| 392 |
+
# the relief to sunken.
|
| 393 |
+
#
|
| 394 |
+
# Arguments:
|
| 395 |
+
# w - The name of the widget.
|
| 396 |
+
|
| 397 |
+
proc ::tk::ButtonDown w {
|
| 398 |
+
variable ::tk::Priv
|
| 399 |
+
|
| 400 |
+
# Only save the button's relief if it does not yet exist. If there
|
| 401 |
+
# is an overrelief setting, Priv($w,relief) will already have been set,
|
| 402 |
+
# and the current value of the -relief option will be incorrect.
|
| 403 |
+
|
| 404 |
+
if {![info exists Priv($w,relief)]} {
|
| 405 |
+
set Priv($w,relief) [$w cget -relief]
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
if {[$w cget -state] ne "disabled"} {
|
| 409 |
+
set Priv(buttonWindow) $w
|
| 410 |
+
$w configure -relief sunken
|
| 411 |
+
set Priv($w,prelief) sunken
|
| 412 |
+
|
| 413 |
+
# If this button has a repeatdelay set up, get it going with an after
|
| 414 |
+
after cancel $Priv(afterId)
|
| 415 |
+
set delay [$w cget -repeatdelay]
|
| 416 |
+
set Priv(repeated) 0
|
| 417 |
+
if {$delay > 0} {
|
| 418 |
+
set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
# ::tk::ButtonUp --
|
| 424 |
+
# The procedure below is invoked when the mouse button is released
|
| 425 |
+
# in a button widget. It restores the button's relief and invokes
|
| 426 |
+
# the command as long as the mouse hasn't left the button.
|
| 427 |
+
#
|
| 428 |
+
# Arguments:
|
| 429 |
+
# w - The name of the widget.
|
| 430 |
+
|
| 431 |
+
proc ::tk::ButtonUp w {
|
| 432 |
+
variable ::tk::Priv
|
| 433 |
+
if {$w eq $Priv(buttonWindow)} {
|
| 434 |
+
set Priv(buttonWindow) ""
|
| 435 |
+
|
| 436 |
+
# Restore the button's relief if it was cached.
|
| 437 |
+
|
| 438 |
+
if {[info exists Priv($w,relief)]} {
|
| 439 |
+
if {[info exists Priv($w,prelief)] && \
|
| 440 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 441 |
+
$w configure -relief $Priv($w,relief)
|
| 442 |
+
}
|
| 443 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
# Clean up the after event from the auto-repeater
|
| 447 |
+
after cancel $Priv(afterId)
|
| 448 |
+
|
| 449 |
+
if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
|
| 450 |
+
# Only invoke the command if it wasn't already invoked by the
|
| 451 |
+
# auto-repeater functionality
|
| 452 |
+
if { $Priv(repeated) == 0 } {
|
| 453 |
+
uplevel #0 [list $w invoke]
|
| 454 |
+
}
|
| 455 |
+
}
|
| 456 |
+
}
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 462 |
+
|
| 463 |
+
####################
|
| 464 |
+
# Mac implementation
|
| 465 |
+
####################
|
| 466 |
+
|
| 467 |
+
# ::tk::ButtonEnter --
|
| 468 |
+
# The procedure below is invoked when the mouse pointer enters a
|
| 469 |
+
# button widget. It records the button we're in and changes the
|
| 470 |
+
# state of the button to active unless the button is disabled.
|
| 471 |
+
#
|
| 472 |
+
# Arguments:
|
| 473 |
+
# w - The name of the widget.
|
| 474 |
+
|
| 475 |
+
proc ::tk::ButtonEnter {w} {
|
| 476 |
+
variable ::tk::Priv
|
| 477 |
+
if {[$w cget -state] ne "disabled"} {
|
| 478 |
+
|
| 479 |
+
# If there's an -overrelief value, set the relief to that.
|
| 480 |
+
|
| 481 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 482 |
+
$w configure -state active
|
| 483 |
+
} elseif {[set over [$w cget -overrelief]] ne ""} {
|
| 484 |
+
set Priv($w,relief) [$w cget -relief]
|
| 485 |
+
set Priv($w,prelief) $over
|
| 486 |
+
$w configure -relief $over
|
| 487 |
+
}
|
| 488 |
+
}
|
| 489 |
+
set Priv(window) $w
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
# ::tk::ButtonLeave --
|
| 493 |
+
# The procedure below is invoked when the mouse pointer leaves a
|
| 494 |
+
# button widget. It changes the state of the button back to
|
| 495 |
+
# inactive. If we're leaving the button window with a mouse button
|
| 496 |
+
# pressed (Priv(buttonWindow) == $w), restore the relief of the
|
| 497 |
+
# button too.
|
| 498 |
+
#
|
| 499 |
+
# Arguments:
|
| 500 |
+
# w - The name of the widget.
|
| 501 |
+
|
| 502 |
+
proc ::tk::ButtonLeave w {
|
| 503 |
+
variable ::tk::Priv
|
| 504 |
+
if {$w eq $Priv(buttonWindow)} {
|
| 505 |
+
$w configure -state normal
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
# Restore the original button relief if it was changed by Tk.
|
| 509 |
+
# That is signaled by the existence of Priv($w,prelief).
|
| 510 |
+
|
| 511 |
+
if {[info exists Priv($w,relief)]} {
|
| 512 |
+
if {[info exists Priv($w,prelief)] && \
|
| 513 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 514 |
+
$w configure -relief $Priv($w,relief)
|
| 515 |
+
}
|
| 516 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
set Priv(window) ""
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
# ::tk::ButtonDown --
|
| 523 |
+
# The procedure below is invoked when the mouse button is pressed in
|
| 524 |
+
# a button widget. It records the fact that the mouse is in the button,
|
| 525 |
+
# saves the button's relief so it can be restored later, and changes
|
| 526 |
+
# the relief to sunken.
|
| 527 |
+
#
|
| 528 |
+
# Arguments:
|
| 529 |
+
# w - The name of the widget.
|
| 530 |
+
|
| 531 |
+
proc ::tk::ButtonDown w {
|
| 532 |
+
variable ::tk::Priv
|
| 533 |
+
|
| 534 |
+
if {[$w cget -state] ne "disabled"} {
|
| 535 |
+
set Priv(buttonWindow) $w
|
| 536 |
+
$w configure -state active
|
| 537 |
+
|
| 538 |
+
# If this button has a repeatdelay set up, get it going with an after
|
| 539 |
+
after cancel $Priv(afterId)
|
| 540 |
+
set Priv(repeated) 0
|
| 541 |
+
if { ![catch {$w cget -repeatdelay} delay] } {
|
| 542 |
+
if {$delay > 0} {
|
| 543 |
+
set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
|
| 544 |
+
}
|
| 545 |
+
}
|
| 546 |
+
}
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
# ::tk::ButtonUp --
|
| 550 |
+
# The procedure below is invoked when the mouse button is released
|
| 551 |
+
# in a button widget. It restores the button's relief and invokes
|
| 552 |
+
# the command as long as the mouse hasn't left the button.
|
| 553 |
+
#
|
| 554 |
+
# Arguments:
|
| 555 |
+
# w - The name of the widget.
|
| 556 |
+
|
| 557 |
+
proc ::tk::ButtonUp w {
|
| 558 |
+
variable ::tk::Priv
|
| 559 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 560 |
+
set Priv(buttonWindow) ""
|
| 561 |
+
$w configure -state normal
|
| 562 |
+
|
| 563 |
+
# Restore the button's relief if it was cached.
|
| 564 |
+
|
| 565 |
+
if {[info exists Priv($w,relief)]} {
|
| 566 |
+
if {[info exists Priv($w,prelief)] && \
|
| 567 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 568 |
+
$w configure -relief $Priv($w,relief)
|
| 569 |
+
}
|
| 570 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
# Clean up the after event from the auto-repeater
|
| 574 |
+
after cancel $Priv(afterId)
|
| 575 |
+
|
| 576 |
+
if {$Priv(window) eq $w && [$w cget -state] ne "disabled"} {
|
| 577 |
+
# Only invoke the command if it wasn't already invoked by the
|
| 578 |
+
# auto-repeater functionality
|
| 579 |
+
if { $Priv(repeated) == 0 } {
|
| 580 |
+
uplevel #0 [list $w invoke]
|
| 581 |
+
}
|
| 582 |
+
}
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
##################
|
| 589 |
+
# Shared routines
|
| 590 |
+
##################
|
| 591 |
+
|
| 592 |
+
# ::tk::ButtonInvoke --
|
| 593 |
+
# The procedure below is called when a button is invoked through
|
| 594 |
+
# the keyboard. It simulate a press of the button via the mouse.
|
| 595 |
+
#
|
| 596 |
+
# Arguments:
|
| 597 |
+
# w - The name of the widget.
|
| 598 |
+
|
| 599 |
+
proc ::tk::ButtonInvoke w {
|
| 600 |
+
if {[winfo exists $w] && [$w cget -state] ne "disabled"} {
|
| 601 |
+
set oldRelief [$w cget -relief]
|
| 602 |
+
set oldState [$w cget -state]
|
| 603 |
+
$w configure -state active -relief sunken
|
| 604 |
+
after 100 [list ::tk::ButtonInvokeEnd $w $oldState $oldRelief]
|
| 605 |
+
}
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
# ::tk::ButtonInvokeEnd --
|
| 609 |
+
# The procedure below is called after a button is invoked through
|
| 610 |
+
# the keyboard. It simulate a release of the button via the mouse.
|
| 611 |
+
#
|
| 612 |
+
# Arguments:
|
| 613 |
+
# w - The name of the widget.
|
| 614 |
+
# oldState - Old state to be set back.
|
| 615 |
+
# oldRelief - Old relief to be set back.
|
| 616 |
+
|
| 617 |
+
proc ::tk::ButtonInvokeEnd {w oldState oldRelief} {
|
| 618 |
+
if {[winfo exists $w]} {
|
| 619 |
+
$w configure -state $oldState -relief $oldRelief
|
| 620 |
+
uplevel #0 [list $w invoke]
|
| 621 |
+
}
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
# ::tk::ButtonAutoInvoke --
|
| 625 |
+
#
|
| 626 |
+
# Invoke an auto-repeating button, and set it up to continue to repeat.
|
| 627 |
+
#
|
| 628 |
+
# Arguments:
|
| 629 |
+
# w button to invoke.
|
| 630 |
+
#
|
| 631 |
+
# Results:
|
| 632 |
+
# None.
|
| 633 |
+
#
|
| 634 |
+
# Side effects:
|
| 635 |
+
# May create an after event to call ::tk::ButtonAutoInvoke.
|
| 636 |
+
|
| 637 |
+
proc ::tk::ButtonAutoInvoke {w} {
|
| 638 |
+
variable ::tk::Priv
|
| 639 |
+
after cancel $Priv(afterId)
|
| 640 |
+
set delay [$w cget -repeatinterval]
|
| 641 |
+
if {$Priv(window) eq $w} {
|
| 642 |
+
incr Priv(repeated)
|
| 643 |
+
uplevel #0 [list $w invoke]
|
| 644 |
+
}
|
| 645 |
+
if {$delay > 0} {
|
| 646 |
+
set Priv(afterId) [after $delay [list tk::ButtonAutoInvoke $w]]
|
| 647 |
+
}
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
# ::tk::CheckRadioInvoke --
|
| 651 |
+
# The procedure below is invoked when the mouse button is pressed in
|
| 652 |
+
# a checkbutton or radiobutton widget, or when the widget is invoked
|
| 653 |
+
# through the keyboard. It invokes the widget if it
|
| 654 |
+
# isn't disabled.
|
| 655 |
+
#
|
| 656 |
+
# Arguments:
|
| 657 |
+
# w - The name of the widget.
|
| 658 |
+
# cmd - The subcommand to invoke (one of invoke, select, or deselect).
|
| 659 |
+
|
| 660 |
+
proc ::tk::CheckRadioInvoke {w {cmd invoke}} {
|
| 661 |
+
if {[$w cget -state] ne "disabled"} {
|
| 662 |
+
uplevel #0 [list $w $cmd]
|
| 663 |
+
}
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
# Special versions of the handlers for checkbuttons on Unix that do the magic
|
| 667 |
+
# to make things work right when the checkbutton indicator is hidden;
|
| 668 |
+
# radiobuttons don't need this complexity.
|
| 669 |
+
|
| 670 |
+
# ::tk::CheckInvoke --
|
| 671 |
+
# The procedure below invokes the checkbutton, like ButtonInvoke, but handles
|
| 672 |
+
# what to do when the checkbutton indicator is missing. Only used on Unix.
|
| 673 |
+
#
|
| 674 |
+
# Arguments:
|
| 675 |
+
# w - The name of the widget.
|
| 676 |
+
|
| 677 |
+
proc ::tk::CheckInvoke {w} {
|
| 678 |
+
variable ::tk::Priv
|
| 679 |
+
if {[$w cget -state] ne "disabled"} {
|
| 680 |
+
# Additional logic to switch the "selected" colors around if necessary
|
| 681 |
+
# (when we're indicator-less).
|
| 682 |
+
|
| 683 |
+
if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} {
|
| 684 |
+
if {[$w cget -selectcolor] eq $Priv($w,aselectcolor)} {
|
| 685 |
+
$w configure -selectcolor $Priv($w,selectcolor)
|
| 686 |
+
} else {
|
| 687 |
+
$w configure -selectcolor $Priv($w,aselectcolor)
|
| 688 |
+
}
|
| 689 |
+
}
|
| 690 |
+
uplevel #0 [list $w invoke]
|
| 691 |
+
}
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
# ::tk::CheckEnter --
|
| 695 |
+
# The procedure below enters the checkbutton, like ButtonEnter, but handles
|
| 696 |
+
# what to do when the checkbutton indicator is missing. Only used on Unix.
|
| 697 |
+
#
|
| 698 |
+
# Arguments:
|
| 699 |
+
# w - The name of the widget.
|
| 700 |
+
|
| 701 |
+
proc ::tk::CheckEnter {w} {
|
| 702 |
+
variable ::tk::Priv
|
| 703 |
+
if {[$w cget -state] ne "disabled"} {
|
| 704 |
+
# On unix the state is active just with mouse-over
|
| 705 |
+
$w configure -state active
|
| 706 |
+
|
| 707 |
+
# If the mouse button is down, set the relief to sunken on entry.
|
| 708 |
+
# Overwise, if there's an -overrelief value, set the relief to that.
|
| 709 |
+
|
| 710 |
+
set Priv($w,relief) [$w cget -relief]
|
| 711 |
+
if {$Priv(buttonWindow) eq $w} {
|
| 712 |
+
$w configure -relief sunken
|
| 713 |
+
set Priv($w,prelief) sunken
|
| 714 |
+
} elseif {[set over [$w cget -overrelief]] ne ""} {
|
| 715 |
+
$w configure -relief $over
|
| 716 |
+
set Priv($w,prelief) $over
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
# Compute what the "selected and active" color should be.
|
| 720 |
+
|
| 721 |
+
if {![$w cget -indicatoron] && [$w cget -selectcolor] ne ""} {
|
| 722 |
+
set Priv($w,selectcolor) [$w cget -selectcolor]
|
| 723 |
+
lassign [winfo rgb $w [$w cget -selectcolor]] r1 g1 b1
|
| 724 |
+
lassign [winfo rgb $w [$w cget -activebackground]] r2 g2 b2
|
| 725 |
+
set Priv($w,aselectcolor) \
|
| 726 |
+
[format "#%04x%04x%04x" [expr {($r1+$r2)/2}] \
|
| 727 |
+
[expr {($g1+$g2)/2}] [expr {($b1+$b2)/2}]]
|
| 728 |
+
# use uplevel to work with other var resolvers
|
| 729 |
+
if {[uplevel #0 [list set [$w cget -variable]]]
|
| 730 |
+
eq [$w cget -onvalue]} {
|
| 731 |
+
$w configure -selectcolor $Priv($w,aselectcolor)
|
| 732 |
+
}
|
| 733 |
+
}
|
| 734 |
+
}
|
| 735 |
+
set Priv(window) $w
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
# ::tk::CheckLeave --
|
| 739 |
+
# The procedure below leaves the checkbutton, like ButtonLeave, but handles
|
| 740 |
+
# what to do when the checkbutton indicator is missing. Only used on Unix.
|
| 741 |
+
#
|
| 742 |
+
# Arguments:
|
| 743 |
+
# w - The name of the widget.
|
| 744 |
+
|
| 745 |
+
proc ::tk::CheckLeave {w} {
|
| 746 |
+
variable ::tk::Priv
|
| 747 |
+
if {[$w cget -state] ne "disabled"} {
|
| 748 |
+
$w configure -state normal
|
| 749 |
+
}
|
| 750 |
+
|
| 751 |
+
# Restore the original button "selected" color; but only if the user
|
| 752 |
+
# has not changed it in the meantime.
|
| 753 |
+
|
| 754 |
+
if {![$w cget -indicatoron] && [info exist Priv($w,selectcolor)]} {
|
| 755 |
+
if {[$w cget -selectcolor] eq $Priv($w,selectcolor)
|
| 756 |
+
|| ([info exist Priv($w,aselectcolor)] &&
|
| 757 |
+
[$w cget -selectcolor] eq $Priv($w,aselectcolor))} {
|
| 758 |
+
$w configure -selectcolor $Priv($w,selectcolor)
|
| 759 |
+
}
|
| 760 |
+
}
|
| 761 |
+
unset -nocomplain Priv($w,selectcolor) Priv($w,aselectcolor)
|
| 762 |
+
|
| 763 |
+
# Restore the original button relief if it was changed by Tk. That is
|
| 764 |
+
# signaled by the existence of Priv($w,prelief).
|
| 765 |
+
|
| 766 |
+
if {[info exists Priv($w,relief)]} {
|
| 767 |
+
if {[info exists Priv($w,prelief)] && \
|
| 768 |
+
$Priv($w,prelief) eq [$w cget -relief]} {
|
| 769 |
+
$w configure -relief $Priv($w,relief)
|
| 770 |
+
}
|
| 771 |
+
unset -nocomplain Priv($w,relief) Priv($w,prelief)
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
set Priv(window) ""
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
return
|
| 778 |
+
|
| 779 |
+
# Local Variables:
|
| 780 |
+
# mode: tcl
|
| 781 |
+
# fill-column: 78
|
| 782 |
+
# End:
|
mplug_owl2/lib/tk8.6/choosedir.tcl
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/clrpick.tcl
ADDED
|
@@ -0,0 +1,694 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
| 1 |
+
# clrpick.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Color selection dialog for platforms that do not support a
|
| 4 |
+
# standard color selection dialog.
|
| 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 |
+
# ToDo:
|
| 12 |
+
#
|
| 13 |
+
# (1): Find out how many free colors are left in the colormap and
|
| 14 |
+
# don't allocate too many colors.
|
| 15 |
+
# (2): Implement HSV color selection.
|
| 16 |
+
#
|
| 17 |
+
|
| 18 |
+
# Make sure namespaces exist
|
| 19 |
+
namespace eval ::tk {}
|
| 20 |
+
namespace eval ::tk::dialog {}
|
| 21 |
+
namespace eval ::tk::dialog::color {
|
| 22 |
+
namespace import ::tk::msgcat::*
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# ::tk::dialog::color:: --
|
| 26 |
+
#
|
| 27 |
+
# Create a color dialog and let the user choose a color. This function
|
| 28 |
+
# should not be called directly. It is called by the tk_chooseColor
|
| 29 |
+
# function when a native color selector widget does not exist
|
| 30 |
+
#
|
| 31 |
+
proc ::tk::dialog::color:: {args} {
|
| 32 |
+
variable ::tk::Priv
|
| 33 |
+
set dataName __tk__color
|
| 34 |
+
upvar ::tk::dialog::color::$dataName data
|
| 35 |
+
set w .$dataName
|
| 36 |
+
|
| 37 |
+
# The lines variables track the start and end indices of the line
|
| 38 |
+
# elements in the colorbar canvases.
|
| 39 |
+
set data(lines,red,start) 0
|
| 40 |
+
set data(lines,red,last) -1
|
| 41 |
+
set data(lines,green,start) 0
|
| 42 |
+
set data(lines,green,last) -1
|
| 43 |
+
set data(lines,blue,start) 0
|
| 44 |
+
set data(lines,blue,last) -1
|
| 45 |
+
|
| 46 |
+
# This is the actual number of lines that are drawn in each color strip.
|
| 47 |
+
# Note that the bars may be of any width.
|
| 48 |
+
# However, NUM_COLORBARS must be a number that evenly divides 256.
|
| 49 |
+
# Such as 256, 128, 64, etc.
|
| 50 |
+
set data(NUM_COLORBARS) 16
|
| 51 |
+
|
| 52 |
+
# BARS_WIDTH is the number of pixels wide the color bar portion of the
|
| 53 |
+
# canvas is. This number must be a multiple of NUM_COLORBARS
|
| 54 |
+
set data(BARS_WIDTH) 160
|
| 55 |
+
|
| 56 |
+
# PLGN_WIDTH is the number of pixels wide of the triangular selection
|
| 57 |
+
# polygon. This also results in the definition of the padding on the
|
| 58 |
+
# left and right sides which is half of PLGN_WIDTH. Make this number even.
|
| 59 |
+
set data(PLGN_HEIGHT) 10
|
| 60 |
+
|
| 61 |
+
# PLGN_HEIGHT is the height of the selection polygon and the height of the
|
| 62 |
+
# selection rectangle at the bottom of the color bar. No restrictions.
|
| 63 |
+
set data(PLGN_WIDTH) 10
|
| 64 |
+
|
| 65 |
+
Config $dataName $args
|
| 66 |
+
InitValues $dataName
|
| 67 |
+
|
| 68 |
+
set sc [winfo screen $data(-parent)]
|
| 69 |
+
set winExists [winfo exists $w]
|
| 70 |
+
if {!$winExists || $sc ne [winfo screen $w]} {
|
| 71 |
+
if {$winExists} {
|
| 72 |
+
destroy $w
|
| 73 |
+
}
|
| 74 |
+
toplevel $w -class TkColorDialog -screen $sc
|
| 75 |
+
if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}
|
| 76 |
+
BuildDialog $w
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
# Dialog boxes should be transient with respect to their parent,
|
| 80 |
+
# so that they will always stay on top of their parent window. However,
|
| 81 |
+
# some window managers will create the window as withdrawn if the parent
|
| 82 |
+
# window is withdrawn or iconified. Combined with the grab we put on the
|
| 83 |
+
# window, this can hang the entire application. Therefore we only make
|
| 84 |
+
# the dialog transient if the parent is viewable.
|
| 85 |
+
|
| 86 |
+
if {[winfo viewable [winfo toplevel $data(-parent)]] } {
|
| 87 |
+
wm transient $w $data(-parent)
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
# 5. 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 |
+
# 6. Set a grab and claim the focus too.
|
| 98 |
+
|
| 99 |
+
::tk::SetFocusGrab $w $data(okBtn)
|
| 100 |
+
|
| 101 |
+
# 7. Wait for the user to respond, then restore the focus and
|
| 102 |
+
# return the index of the selected button. Restore the focus
|
| 103 |
+
# before deleting the window, since otherwise the window manager
|
| 104 |
+
# may take the focus away so we can't redirect it. Finally,
|
| 105 |
+
# restore any grab that was in effect.
|
| 106 |
+
|
| 107 |
+
vwait ::tk::Priv(selectColor)
|
| 108 |
+
set result $Priv(selectColor)
|
| 109 |
+
::tk::RestoreFocusGrab $w $data(okBtn)
|
| 110 |
+
unset data
|
| 111 |
+
|
| 112 |
+
return $result
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# ::tk::dialog::color::InitValues --
|
| 116 |
+
#
|
| 117 |
+
# Get called during initialization or when user resets NUM_COLORBARS
|
| 118 |
+
#
|
| 119 |
+
proc ::tk::dialog::color::InitValues {dataName} {
|
| 120 |
+
upvar ::tk::dialog::color::$dataName data
|
| 121 |
+
|
| 122 |
+
# IntensityIncr is the difference in color intensity between a colorbar
|
| 123 |
+
# and its neighbors.
|
| 124 |
+
set data(intensityIncr) [expr {256 / $data(NUM_COLORBARS)}]
|
| 125 |
+
|
| 126 |
+
# ColorbarWidth is the width of each colorbar
|
| 127 |
+
set data(colorbarWidth) [expr {$data(BARS_WIDTH) / $data(NUM_COLORBARS)}]
|
| 128 |
+
|
| 129 |
+
# Indent is the width of the space at the left and right side of the
|
| 130 |
+
# colorbar. It is always half the selector polygon width, because the
|
| 131 |
+
# polygon extends into the space.
|
| 132 |
+
set data(indent) [expr {$data(PLGN_WIDTH) / 2}]
|
| 133 |
+
|
| 134 |
+
set data(colorPad) 2
|
| 135 |
+
set data(selPad) [expr {$data(PLGN_WIDTH) / 2}]
|
| 136 |
+
|
| 137 |
+
#
|
| 138 |
+
# minX is the x coordinate of the first colorbar
|
| 139 |
+
#
|
| 140 |
+
set data(minX) $data(indent)
|
| 141 |
+
|
| 142 |
+
#
|
| 143 |
+
# maxX is the x coordinate of the last colorbar
|
| 144 |
+
#
|
| 145 |
+
set data(maxX) [expr {$data(BARS_WIDTH) + $data(indent)-1}]
|
| 146 |
+
|
| 147 |
+
#
|
| 148 |
+
# canvasWidth is the width of the entire canvas, including the indents
|
| 149 |
+
#
|
| 150 |
+
set data(canvasWidth) [expr {$data(BARS_WIDTH) + $data(PLGN_WIDTH)}]
|
| 151 |
+
|
| 152 |
+
# Set the initial color, specified by -initialcolor, or the
|
| 153 |
+
# color chosen by the user the last time.
|
| 154 |
+
set data(selection) $data(-initialcolor)
|
| 155 |
+
set data(finalColor) $data(-initialcolor)
|
| 156 |
+
set rgb [winfo rgb . $data(selection)]
|
| 157 |
+
|
| 158 |
+
set data(red,intensity) [expr {[lindex $rgb 0]/0x100}]
|
| 159 |
+
set data(green,intensity) [expr {[lindex $rgb 1]/0x100}]
|
| 160 |
+
set data(blue,intensity) [expr {[lindex $rgb 2]/0x100}]
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
# ::tk::dialog::color::Config --
|
| 164 |
+
#
|
| 165 |
+
# Parses the command line arguments to tk_chooseColor
|
| 166 |
+
#
|
| 167 |
+
proc ::tk::dialog::color::Config {dataName argList} {
|
| 168 |
+
variable ::tk::Priv
|
| 169 |
+
upvar ::tk::dialog::color::$dataName data
|
| 170 |
+
|
| 171 |
+
# 1: the configuration specs
|
| 172 |
+
#
|
| 173 |
+
if {[info exists Priv(selectColor)] && $Priv(selectColor) ne ""} {
|
| 174 |
+
set defaultColor $Priv(selectColor)
|
| 175 |
+
} else {
|
| 176 |
+
set defaultColor [. cget -background]
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
set specs [list \
|
| 180 |
+
[list -initialcolor "" "" $defaultColor] \
|
| 181 |
+
[list -parent "" "" "."] \
|
| 182 |
+
[list -title "" "" [mc "Color"]] \
|
| 183 |
+
]
|
| 184 |
+
|
| 185 |
+
# 2: parse the arguments
|
| 186 |
+
#
|
| 187 |
+
tclParseConfigSpec ::tk::dialog::color::$dataName $specs "" $argList
|
| 188 |
+
|
| 189 |
+
if {$data(-title) eq ""} {
|
| 190 |
+
set data(-title) " "
|
| 191 |
+
}
|
| 192 |
+
if {[catch {winfo rgb . $data(-initialcolor)} err]} {
|
| 193 |
+
return -code error -errorcode [list TK LOOKUP COLOR $data(-initialcolor)] \
|
| 194 |
+
$err
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
if {![winfo exists $data(-parent)]} {
|
| 198 |
+
return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
|
| 199 |
+
"bad window path name \"$data(-parent)\""
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
# ::tk::dialog::color::BuildDialog --
|
| 204 |
+
#
|
| 205 |
+
# Build the dialog.
|
| 206 |
+
#
|
| 207 |
+
proc ::tk::dialog::color::BuildDialog {w} {
|
| 208 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 209 |
+
|
| 210 |
+
# TopFrame contains the color strips and the color selection
|
| 211 |
+
#
|
| 212 |
+
set topFrame [frame $w.top -relief raised -bd 1]
|
| 213 |
+
|
| 214 |
+
# StripsFrame contains the colorstrips and the individual RGB entries
|
| 215 |
+
set stripsFrame [frame $topFrame.colorStrip]
|
| 216 |
+
|
| 217 |
+
set maxWidth [::tk::mcmaxamp &Red &Green &Blue]
|
| 218 |
+
set maxWidth [expr {$maxWidth<6 ? 6 : $maxWidth}]
|
| 219 |
+
set colorList {
|
| 220 |
+
red "&Red"
|
| 221 |
+
green "&Green"
|
| 222 |
+
blue "&Blue"
|
| 223 |
+
}
|
| 224 |
+
foreach {color l} $colorList {
|
| 225 |
+
# each f frame contains an [R|G|B] entry and the equiv. color strip.
|
| 226 |
+
set f [frame $stripsFrame.$color]
|
| 227 |
+
|
| 228 |
+
# The box frame contains the label and entry widget for an [R|G|B]
|
| 229 |
+
set box [frame $f.box]
|
| 230 |
+
|
| 231 |
+
::tk::AmpWidget label $box.label -text "[mc $l]:" \
|
| 232 |
+
-width $maxWidth -anchor ne
|
| 233 |
+
bind $box.label <<AltUnderlined>> [list focus $box.entry]
|
| 234 |
+
|
| 235 |
+
entry $box.entry -textvariable \
|
| 236 |
+
::tk::dialog::color::[winfo name $w]($color,intensity) \
|
| 237 |
+
-width 4
|
| 238 |
+
pack $box.label -side left -fill y -padx 2 -pady 3
|
| 239 |
+
pack $box.entry -side left -anchor n -pady 0
|
| 240 |
+
pack $box -side left -fill both
|
| 241 |
+
|
| 242 |
+
set height [expr {
|
| 243 |
+
[winfo reqheight $box.entry] -
|
| 244 |
+
2*([$box.entry cget -highlightthickness] + [$box.entry cget -bd])
|
| 245 |
+
}]
|
| 246 |
+
|
| 247 |
+
canvas $f.color -height $height \
|
| 248 |
+
-width $data(BARS_WIDTH) -relief sunken -bd 2
|
| 249 |
+
canvas $f.sel -height $data(PLGN_HEIGHT) \
|
| 250 |
+
-width $data(canvasWidth) -highlightthickness 0
|
| 251 |
+
pack $f.color -expand yes -fill both
|
| 252 |
+
pack $f.sel -expand yes -fill both
|
| 253 |
+
|
| 254 |
+
pack $f -side top -fill x -padx 0 -pady 2
|
| 255 |
+
|
| 256 |
+
set data($color,entry) $box.entry
|
| 257 |
+
set data($color,col) $f.color
|
| 258 |
+
set data($color,sel) $f.sel
|
| 259 |
+
|
| 260 |
+
bind $data($color,col) <Configure> \
|
| 261 |
+
[list tk::dialog::color::DrawColorScale $w $color 1]
|
| 262 |
+
bind $data($color,col) <Enter> \
|
| 263 |
+
[list tk::dialog::color::EnterColorBar $w $color]
|
| 264 |
+
bind $data($color,col) <Leave> \
|
| 265 |
+
[list tk::dialog::color::LeaveColorBar $w $color]
|
| 266 |
+
|
| 267 |
+
bind $data($color,sel) <Enter> \
|
| 268 |
+
[list tk::dialog::color::EnterColorBar $w $color]
|
| 269 |
+
bind $data($color,sel) <Leave> \
|
| 270 |
+
[list tk::dialog::color::LeaveColorBar $w $color]
|
| 271 |
+
|
| 272 |
+
bind $box.entry <Return> [list tk::dialog::color::HandleRGBEntry $w]
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
pack $stripsFrame -side left -fill both -padx 4 -pady 10
|
| 276 |
+
|
| 277 |
+
# The selFrame contains a frame that demonstrates the currently
|
| 278 |
+
# selected color
|
| 279 |
+
#
|
| 280 |
+
set selFrame [frame $topFrame.sel]
|
| 281 |
+
set lab [::tk::AmpWidget label $selFrame.lab \
|
| 282 |
+
-text [mc "&Selection:"] -anchor sw]
|
| 283 |
+
set ent [entry $selFrame.ent \
|
| 284 |
+
-textvariable ::tk::dialog::color::[winfo name $w](selection) \
|
| 285 |
+
-width 16]
|
| 286 |
+
set f1 [frame $selFrame.f1 -relief sunken -bd 2]
|
| 287 |
+
set data(finalCanvas) [frame $f1.demo -bd 0 -width 100 -height 70]
|
| 288 |
+
|
| 289 |
+
pack $lab $ent -side top -fill x -padx 4 -pady 2
|
| 290 |
+
pack $f1 -expand yes -anchor nw -fill both -padx 6 -pady 10
|
| 291 |
+
pack $data(finalCanvas) -expand yes -fill both
|
| 292 |
+
|
| 293 |
+
bind $ent <Return> [list tk::dialog::color::HandleSelEntry $w]
|
| 294 |
+
|
| 295 |
+
pack $selFrame -side left -fill none -anchor nw
|
| 296 |
+
pack $topFrame -side top -expand yes -fill both -anchor nw
|
| 297 |
+
|
| 298 |
+
# the botFrame frame contains the buttons
|
| 299 |
+
#
|
| 300 |
+
set botFrame [frame $w.bot -relief raised -bd 1]
|
| 301 |
+
|
| 302 |
+
::tk::AmpWidget button $botFrame.ok -text [mc "&OK"] \
|
| 303 |
+
-command [list tk::dialog::color::OkCmd $w]
|
| 304 |
+
::tk::AmpWidget button $botFrame.cancel -text [mc "&Cancel"] \
|
| 305 |
+
-command [list tk::dialog::color::CancelCmd $w]
|
| 306 |
+
|
| 307 |
+
set data(okBtn) $botFrame.ok
|
| 308 |
+
set data(cancelBtn) $botFrame.cancel
|
| 309 |
+
|
| 310 |
+
grid x $botFrame.ok x $botFrame.cancel x -sticky ew
|
| 311 |
+
grid configure $botFrame.ok $botFrame.cancel -padx 10 -pady 10
|
| 312 |
+
grid columnconfigure $botFrame {0 4} -weight 1 -uniform space
|
| 313 |
+
grid columnconfigure $botFrame {1 3} -weight 1 -uniform button
|
| 314 |
+
grid columnconfigure $botFrame 2 -weight 2 -uniform space
|
| 315 |
+
pack $botFrame -side bottom -fill x
|
| 316 |
+
|
| 317 |
+
# Accelerator bindings
|
| 318 |
+
bind $lab <<AltUnderlined>> [list focus $ent]
|
| 319 |
+
bind $w <Escape> [list tk::ButtonInvoke $data(cancelBtn)]
|
| 320 |
+
bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
|
| 321 |
+
|
| 322 |
+
wm protocol $w WM_DELETE_WINDOW [list tk::dialog::color::CancelCmd $w]
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
# ::tk::dialog::color::SetRGBValue --
|
| 326 |
+
#
|
| 327 |
+
# Sets the current selection of the dialog box
|
| 328 |
+
#
|
| 329 |
+
proc ::tk::dialog::color::SetRGBValue {w color} {
|
| 330 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 331 |
+
|
| 332 |
+
set data(red,intensity) [lindex $color 0]
|
| 333 |
+
set data(green,intensity) [lindex $color 1]
|
| 334 |
+
set data(blue,intensity) [lindex $color 2]
|
| 335 |
+
|
| 336 |
+
RedrawColorBars $w all
|
| 337 |
+
|
| 338 |
+
# Now compute the new x value of each colorbars pointer polygon
|
| 339 |
+
foreach color {red green blue} {
|
| 340 |
+
set x [RgbToX $w $data($color,intensity)]
|
| 341 |
+
MoveSelector $w $data($color,sel) $color $x 0
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
# ::tk::dialog::color::XToRgb --
|
| 346 |
+
#
|
| 347 |
+
# Converts a screen coordinate to intensity
|
| 348 |
+
#
|
| 349 |
+
proc ::tk::dialog::color::XToRgb {w x} {
|
| 350 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 351 |
+
|
| 352 |
+
set x [expr {($x * $data(intensityIncr))/ $data(colorbarWidth)}]
|
| 353 |
+
if {$x > 255} {
|
| 354 |
+
set x 255
|
| 355 |
+
}
|
| 356 |
+
return $x
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
# ::tk::dialog::color::RgbToX
|
| 360 |
+
#
|
| 361 |
+
# Converts an intensity to screen coordinate.
|
| 362 |
+
#
|
| 363 |
+
proc ::tk::dialog::color::RgbToX {w color} {
|
| 364 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 365 |
+
|
| 366 |
+
return [expr {($color * $data(colorbarWidth)/ $data(intensityIncr))}]
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
# ::tk::dialog::color::DrawColorScale --
|
| 370 |
+
#
|
| 371 |
+
# Draw color scale is called whenever the size of one of the color
|
| 372 |
+
# scale canvases is changed.
|
| 373 |
+
#
|
| 374 |
+
proc ::tk::dialog::color::DrawColorScale {w c {create 0}} {
|
| 375 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 376 |
+
|
| 377 |
+
# col: color bar canvas
|
| 378 |
+
# sel: selector canvas
|
| 379 |
+
set col $data($c,col)
|
| 380 |
+
set sel $data($c,sel)
|
| 381 |
+
|
| 382 |
+
# First handle the case that we are creating everything for the first time.
|
| 383 |
+
if {$create} {
|
| 384 |
+
# First remove all the lines that already exist.
|
| 385 |
+
if { $data(lines,$c,last) > $data(lines,$c,start)} {
|
| 386 |
+
for {set i $data(lines,$c,start)} \
|
| 387 |
+
{$i <= $data(lines,$c,last)} {incr i} {
|
| 388 |
+
$sel delete $i
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
# Delete the selector if it exists
|
| 392 |
+
if {[info exists data($c,index)]} {
|
| 393 |
+
$sel delete $data($c,index)
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
# Draw the selection polygons
|
| 397 |
+
CreateSelector $w $sel $c
|
| 398 |
+
$sel bind $data($c,index) <Button-1> \
|
| 399 |
+
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad) 1]
|
| 400 |
+
$sel bind $data($c,index) <B1-Motion> \
|
| 401 |
+
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
|
| 402 |
+
$sel bind $data($c,index) <ButtonRelease-1> \
|
| 403 |
+
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
|
| 404 |
+
|
| 405 |
+
set height [winfo height $col]
|
| 406 |
+
# Create an invisible region under the colorstrip to catch mouse clicks
|
| 407 |
+
# that aren't on the selector.
|
| 408 |
+
set data($c,clickRegion) [$sel create rectangle 0 0 \
|
| 409 |
+
$data(canvasWidth) $height -fill {} -outline {}]
|
| 410 |
+
|
| 411 |
+
bind $col <Button-1> \
|
| 412 |
+
[list tk::dialog::color::StartMove $w $sel $c %x $data(colorPad)]
|
| 413 |
+
bind $col <B1-Motion> \
|
| 414 |
+
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(colorPad)]
|
| 415 |
+
bind $col <ButtonRelease-1> \
|
| 416 |
+
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(colorPad)]
|
| 417 |
+
|
| 418 |
+
$sel bind $data($c,clickRegion) <Button-1> \
|
| 419 |
+
[list tk::dialog::color::StartMove $w $sel $c %x $data(selPad)]
|
| 420 |
+
$sel bind $data($c,clickRegion) <B1-Motion> \
|
| 421 |
+
[list tk::dialog::color::MoveSelector $w $sel $c %x $data(selPad)]
|
| 422 |
+
$sel bind $data($c,clickRegion) <ButtonRelease-1> \
|
| 423 |
+
[list tk::dialog::color::ReleaseMouse $w $sel $c %x $data(selPad)]
|
| 424 |
+
} else {
|
| 425 |
+
# l is the canvas index of the first colorbar.
|
| 426 |
+
set l $data(lines,$c,start)
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
# Draw the color bars.
|
| 430 |
+
set highlightW [expr {[$col cget -highlightthickness] + [$col cget -bd]}]
|
| 431 |
+
for {set i 0} { $i < $data(NUM_COLORBARS)} { incr i} {
|
| 432 |
+
set intensity [expr {$i * $data(intensityIncr)}]
|
| 433 |
+
set startx [expr {$i * $data(colorbarWidth) + $highlightW}]
|
| 434 |
+
if {$c eq "red"} {
|
| 435 |
+
set color [format "#%02x%02x%02x" \
|
| 436 |
+
$intensity $data(green,intensity) $data(blue,intensity)]
|
| 437 |
+
} elseif {$c eq "green"} {
|
| 438 |
+
set color [format "#%02x%02x%02x" \
|
| 439 |
+
$data(red,intensity) $intensity $data(blue,intensity)]
|
| 440 |
+
} else {
|
| 441 |
+
set color [format "#%02x%02x%02x" \
|
| 442 |
+
$data(red,intensity) $data(green,intensity) $intensity]
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
if {$create} {
|
| 446 |
+
set index [$col create rect $startx $highlightW \
|
| 447 |
+
[expr {$startx +$data(colorbarWidth)}] \
|
| 448 |
+
[expr {[winfo height $col] + $highlightW}] \
|
| 449 |
+
-fill $color -outline $color]
|
| 450 |
+
} else {
|
| 451 |
+
$col itemconfigure $l -fill $color -outline $color
|
| 452 |
+
incr l
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
$sel raise $data($c,index)
|
| 456 |
+
|
| 457 |
+
if {$create} {
|
| 458 |
+
set data(lines,$c,last) $index
|
| 459 |
+
set data(lines,$c,start) [expr {$index - $data(NUM_COLORBARS) + 1}]
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
RedrawFinalColor $w
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
# ::tk::dialog::color::CreateSelector --
|
| 466 |
+
#
|
| 467 |
+
# Creates and draws the selector polygon at the position
|
| 468 |
+
# $data($c,intensity).
|
| 469 |
+
#
|
| 470 |
+
proc ::tk::dialog::color::CreateSelector {w sel c } {
|
| 471 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 472 |
+
set data($c,index) [$sel create polygon \
|
| 473 |
+
0 $data(PLGN_HEIGHT) \
|
| 474 |
+
$data(PLGN_WIDTH) $data(PLGN_HEIGHT) \
|
| 475 |
+
$data(indent) 0]
|
| 476 |
+
set data($c,x) [RgbToX $w $data($c,intensity)]
|
| 477 |
+
$sel move $data($c,index) $data($c,x) 0
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
# ::tk::dialog::color::RedrawFinalColor
|
| 481 |
+
#
|
| 482 |
+
# Combines the intensities of the three colors into the final color
|
| 483 |
+
#
|
| 484 |
+
proc ::tk::dialog::color::RedrawFinalColor {w} {
|
| 485 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 486 |
+
|
| 487 |
+
set color [format "#%02x%02x%02x" $data(red,intensity) \
|
| 488 |
+
$data(green,intensity) $data(blue,intensity)]
|
| 489 |
+
|
| 490 |
+
$data(finalCanvas) configure -bg $color
|
| 491 |
+
set data(finalColor) $color
|
| 492 |
+
set data(selection) $color
|
| 493 |
+
set data(finalRGB) [list \
|
| 494 |
+
$data(red,intensity) \
|
| 495 |
+
$data(green,intensity) \
|
| 496 |
+
$data(blue,intensity)]
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
# ::tk::dialog::color::RedrawColorBars --
|
| 500 |
+
#
|
| 501 |
+
# Only redraws the colors on the color strips that were not manipulated.
|
| 502 |
+
# Params: color of colorstrip that changed. If color is not [red|green|blue]
|
| 503 |
+
# Then all colorstrips will be updated
|
| 504 |
+
#
|
| 505 |
+
proc ::tk::dialog::color::RedrawColorBars {w colorChanged} {
|
| 506 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 507 |
+
|
| 508 |
+
switch $colorChanged {
|
| 509 |
+
red {
|
| 510 |
+
DrawColorScale $w green
|
| 511 |
+
DrawColorScale $w blue
|
| 512 |
+
}
|
| 513 |
+
green {
|
| 514 |
+
DrawColorScale $w red
|
| 515 |
+
DrawColorScale $w blue
|
| 516 |
+
}
|
| 517 |
+
blue {
|
| 518 |
+
DrawColorScale $w red
|
| 519 |
+
DrawColorScale $w green
|
| 520 |
+
}
|
| 521 |
+
default {
|
| 522 |
+
DrawColorScale $w red
|
| 523 |
+
DrawColorScale $w green
|
| 524 |
+
DrawColorScale $w blue
|
| 525 |
+
}
|
| 526 |
+
}
|
| 527 |
+
RedrawFinalColor $w
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
#----------------------------------------------------------------------
|
| 531 |
+
# Event handlers
|
| 532 |
+
#----------------------------------------------------------------------
|
| 533 |
+
|
| 534 |
+
# ::tk::dialog::color::StartMove --
|
| 535 |
+
#
|
| 536 |
+
# Handles a mousedown button event over the selector polygon.
|
| 537 |
+
# Adds the bindings for moving the mouse while the button is
|
| 538 |
+
# pressed. Sets the binding for the button-release event.
|
| 539 |
+
#
|
| 540 |
+
# Params: sel is the selector canvas window, color is the color of the strip.
|
| 541 |
+
#
|
| 542 |
+
proc ::tk::dialog::color::StartMove {w sel color x delta {dontMove 0}} {
|
| 543 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 544 |
+
|
| 545 |
+
if {!$dontMove} {
|
| 546 |
+
MoveSelector $w $sel $color $x $delta
|
| 547 |
+
}
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
# ::tk::dialog::color::MoveSelector --
|
| 551 |
+
#
|
| 552 |
+
# Moves the polygon selector so that its middle point has the same
|
| 553 |
+
# x value as the specified x. If x is outside the bounds [0,255],
|
| 554 |
+
# the selector is set to the closest endpoint.
|
| 555 |
+
#
|
| 556 |
+
# Params: sel is the selector canvas, c is [red|green|blue]
|
| 557 |
+
# x is a x-coordinate.
|
| 558 |
+
#
|
| 559 |
+
proc ::tk::dialog::color::MoveSelector {w sel color x delta} {
|
| 560 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 561 |
+
|
| 562 |
+
incr x -$delta
|
| 563 |
+
|
| 564 |
+
if { $x < 0 } {
|
| 565 |
+
set x 0
|
| 566 |
+
} elseif { $x > $data(BARS_WIDTH)} {
|
| 567 |
+
set x $data(BARS_WIDTH)
|
| 568 |
+
}
|
| 569 |
+
set diff [expr {$x - $data($color,x)}]
|
| 570 |
+
$sel move $data($color,index) $diff 0
|
| 571 |
+
set data($color,x) [expr {$data($color,x) + $diff}]
|
| 572 |
+
|
| 573 |
+
# Return the x value that it was actually set at
|
| 574 |
+
return $x
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
# ::tk::dialog::color::ReleaseMouse
|
| 578 |
+
#
|
| 579 |
+
# Removes mouse tracking bindings, updates the colorbars.
|
| 580 |
+
#
|
| 581 |
+
# Params: sel is the selector canvas, color is the color of the strip,
|
| 582 |
+
# x is the x-coord of the mouse.
|
| 583 |
+
#
|
| 584 |
+
proc ::tk::dialog::color::ReleaseMouse {w sel color x delta} {
|
| 585 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 586 |
+
|
| 587 |
+
set x [MoveSelector $w $sel $color $x $delta]
|
| 588 |
+
|
| 589 |
+
# Determine exactly what color we are looking at.
|
| 590 |
+
set data($color,intensity) [XToRgb $w $x]
|
| 591 |
+
|
| 592 |
+
RedrawColorBars $w $color
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
# ::tk::dialog::color::ResizeColorbars --
|
| 596 |
+
#
|
| 597 |
+
# Completely redraws the colorbars, including resizing the
|
| 598 |
+
# colorstrips
|
| 599 |
+
#
|
| 600 |
+
proc ::tk::dialog::color::ResizeColorBars {w} {
|
| 601 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 602 |
+
|
| 603 |
+
if {
|
| 604 |
+
($data(BARS_WIDTH) < $data(NUM_COLORBARS)) ||
|
| 605 |
+
(($data(BARS_WIDTH) % $data(NUM_COLORBARS)) != 0)
|
| 606 |
+
} then {
|
| 607 |
+
set data(BARS_WIDTH) $data(NUM_COLORBARS)
|
| 608 |
+
}
|
| 609 |
+
InitValues [winfo name $w]
|
| 610 |
+
foreach color {red green blue} {
|
| 611 |
+
$data($color,col) configure -width $data(canvasWidth)
|
| 612 |
+
DrawColorScale $w $color 1
|
| 613 |
+
}
|
| 614 |
+
}
|
| 615 |
+
|
| 616 |
+
# ::tk::dialog::color::HandleSelEntry --
|
| 617 |
+
#
|
| 618 |
+
# Handles the return keypress event in the "Selection:" entry
|
| 619 |
+
#
|
| 620 |
+
proc ::tk::dialog::color::HandleSelEntry {w} {
|
| 621 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 622 |
+
|
| 623 |
+
set text [string trim $data(selection)]
|
| 624 |
+
# Check to make sure that the color is valid
|
| 625 |
+
if {[catch {set color [winfo rgb . $text]} ]} {
|
| 626 |
+
set data(selection) $data(finalColor)
|
| 627 |
+
return
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
set R [expr {[lindex $color 0]/0x100}]
|
| 631 |
+
set G [expr {[lindex $color 1]/0x100}]
|
| 632 |
+
set B [expr {[lindex $color 2]/0x100}]
|
| 633 |
+
|
| 634 |
+
SetRGBValue $w "$R $G $B"
|
| 635 |
+
set data(selection) $text
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
# ::tk::dialog::color::HandleRGBEntry --
|
| 639 |
+
#
|
| 640 |
+
# Handles the return keypress event in the R, G or B entry
|
| 641 |
+
#
|
| 642 |
+
proc ::tk::dialog::color::HandleRGBEntry {w} {
|
| 643 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 644 |
+
|
| 645 |
+
foreach c {red green blue} {
|
| 646 |
+
if {[catch {
|
| 647 |
+
set data($c,intensity) [expr {int($data($c,intensity))}]
|
| 648 |
+
}]} {
|
| 649 |
+
set data($c,intensity) 0
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
if {$data($c,intensity) < 0} {
|
| 653 |
+
set data($c,intensity) 0
|
| 654 |
+
}
|
| 655 |
+
if {$data($c,intensity) > 255} {
|
| 656 |
+
set data($c,intensity) 255
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
SetRGBValue $w "$data(red,intensity) \
|
| 661 |
+
$data(green,intensity) $data(blue,intensity)"
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
# mouse cursor enters a color bar
|
| 665 |
+
#
|
| 666 |
+
proc ::tk::dialog::color::EnterColorBar {w color} {
|
| 667 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 668 |
+
|
| 669 |
+
$data($color,sel) itemconfigure $data($color,index) -fill red
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
# mouse leaves enters a color bar
|
| 673 |
+
#
|
| 674 |
+
proc ::tk::dialog::color::LeaveColorBar {w color} {
|
| 675 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 676 |
+
|
| 677 |
+
$data($color,sel) itemconfigure $data($color,index) -fill black
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
# user hits OK button
|
| 681 |
+
#
|
| 682 |
+
proc ::tk::dialog::color::OkCmd {w} {
|
| 683 |
+
variable ::tk::Priv
|
| 684 |
+
upvar ::tk::dialog::color::[winfo name $w] data
|
| 685 |
+
|
| 686 |
+
set Priv(selectColor) $data(finalColor)
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
# user hits Cancel button or destroys window
|
| 690 |
+
#
|
| 691 |
+
proc ::tk::dialog::color::CancelCmd {w} {
|
| 692 |
+
variable ::tk::Priv
|
| 693 |
+
set Priv(selectColor) ""
|
| 694 |
+
}
|
mplug_owl2/lib/tk8.6/comdlg.tcl
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/console.tcl
ADDED
|
@@ -0,0 +1,1154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# console.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This code constructs the console window for an application. It
|
| 4 |
+
# can be used by non-unix systems that do not have built-in support
|
| 5 |
+
# for shells.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
|
| 8 |
+
# Copyright (c) 1998-2000 Ajuba Solutions.
|
| 9 |
+
# Copyright (c) 2007-2008 Daniel A. Steffen <das@users.sourceforge.net>
|
| 10 |
+
#
|
| 11 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 12 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 13 |
+
#
|
| 14 |
+
|
| 15 |
+
# TODO: history - remember partially written command
|
| 16 |
+
|
| 17 |
+
namespace eval ::tk::console {
|
| 18 |
+
variable blinkTime 500 ; # msecs to blink braced range for
|
| 19 |
+
variable blinkRange 1 ; # enable blinking of the entire braced range
|
| 20 |
+
variable magicKeys 1 ; # enable brace matching and proc/var recognition
|
| 21 |
+
variable maxLines 600 ; # maximum # of lines buffered in console
|
| 22 |
+
variable showMatches 1 ; # show multiple expand matches
|
| 23 |
+
variable useFontchooser [llength [info command ::tk::fontchooser]]
|
| 24 |
+
variable inPlugin [info exists embed_args]
|
| 25 |
+
variable defaultPrompt ; # default prompt if tcl_prompt1 isn't used
|
| 26 |
+
|
| 27 |
+
if {$inPlugin} {
|
| 28 |
+
set defaultPrompt {subst {[history nextid] % }}
|
| 29 |
+
} else {
|
| 30 |
+
set defaultPrompt {subst {([file tail [pwd]]) [history nextid] % }}
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
# simple compat function for tkcon code added for this console
|
| 35 |
+
interp alias {} EvalAttached {} consoleinterp eval
|
| 36 |
+
|
| 37 |
+
# ::tk::ConsoleInit --
|
| 38 |
+
# This procedure constructs and configures the console windows.
|
| 39 |
+
#
|
| 40 |
+
# Arguments:
|
| 41 |
+
# None.
|
| 42 |
+
|
| 43 |
+
proc ::tk::ConsoleInit {} {
|
| 44 |
+
if {![consoleinterp eval {set tcl_interactive}]} {
|
| 45 |
+
wm withdraw .
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 49 |
+
set mod "Cmd"
|
| 50 |
+
} else {
|
| 51 |
+
set mod "Ctrl"
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
if {[catch {menu .menubar} err]} {
|
| 55 |
+
bgerror "INIT: $err"
|
| 56 |
+
}
|
| 57 |
+
AmpMenuArgs .menubar add cascade -label [mc &File] -menu .menubar.file
|
| 58 |
+
AmpMenuArgs .menubar add cascade -label [mc &Edit] -menu .menubar.edit
|
| 59 |
+
|
| 60 |
+
menu .menubar.file -tearoff 0
|
| 61 |
+
AmpMenuArgs .menubar.file add command -label [mc "&Source..."] \
|
| 62 |
+
-command {tk::ConsoleSource}
|
| 63 |
+
AmpMenuArgs .menubar.file add command -label [mc "&Hide Console"] \
|
| 64 |
+
-command {wm withdraw .}
|
| 65 |
+
AmpMenuArgs .menubar.file add command -label [mc "&Clear Console"] \
|
| 66 |
+
-command {.console delete 1.0 "promptEnd linestart"}
|
| 67 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 68 |
+
AmpMenuArgs .menubar.file add command -label [mc E&xit] -command {exit}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
menu .menubar.edit -tearoff 0
|
| 72 |
+
AmpMenuArgs .menubar.edit add command -label [mc Cu&t] -accel "$mod+X"\
|
| 73 |
+
-command {event generate .console <<Cut>>}
|
| 74 |
+
AmpMenuArgs .menubar.edit add command -label [mc &Copy] -accel "$mod+C"\
|
| 75 |
+
-command {event generate .console <<Copy>>}
|
| 76 |
+
AmpMenuArgs .menubar.edit add command -label [mc P&aste] -accel "$mod+V"\
|
| 77 |
+
-command {event generate .console <<Paste>>}
|
| 78 |
+
|
| 79 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 80 |
+
AmpMenuArgs .menubar.edit add command -label [mc Cl&ear] \
|
| 81 |
+
-command {event generate .console <<Clear>>}
|
| 82 |
+
} else {
|
| 83 |
+
AmpMenuArgs .menubar.edit add command -label [mc &Delete] \
|
| 84 |
+
-command {event generate .console <<Clear>>} -accel "Del"
|
| 85 |
+
|
| 86 |
+
AmpMenuArgs .menubar add cascade -label [mc &Help] -menu .menubar.help
|
| 87 |
+
menu .menubar.help -tearoff 0
|
| 88 |
+
AmpMenuArgs .menubar.help add command -label [mc &About...] \
|
| 89 |
+
-command tk::ConsoleAbout
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
AmpMenuArgs .menubar.edit add separator
|
| 93 |
+
if {$::tk::console::useFontchooser} {
|
| 94 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 95 |
+
.menubar.edit add command -label tk_choose_font_marker
|
| 96 |
+
set index [.menubar.edit index tk_choose_font_marker]
|
| 97 |
+
.menubar.edit entryconfigure $index \
|
| 98 |
+
-label [mc "Show Fonts"]\
|
| 99 |
+
-accelerator "$mod-T"\
|
| 100 |
+
-command [list ::tk::console::FontchooserToggle]
|
| 101 |
+
bind Console <<TkFontchooserVisibility>> \
|
| 102 |
+
[list ::tk::console::FontchooserVisibility $index]
|
| 103 |
+
::tk::console::FontchooserVisibility $index
|
| 104 |
+
} else {
|
| 105 |
+
AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \
|
| 106 |
+
-command [list ::tk::console::FontchooserToggle]
|
| 107 |
+
}
|
| 108 |
+
bind Console <FocusIn> [list ::tk::console::FontchooserFocus %W 1]
|
| 109 |
+
bind Console <FocusOut> [list ::tk::console::FontchooserFocus %W 0]
|
| 110 |
+
}
|
| 111 |
+
AmpMenuArgs .menubar.edit add command -label [mc "&Increase Font Size"] \
|
| 112 |
+
-accel "$mod++" -command {event generate .console <<Console_FontSizeIncr>>}
|
| 113 |
+
AmpMenuArgs .menubar.edit add command -label [mc "&Decrease Font Size"] \
|
| 114 |
+
-accel "$mod+-" -command {event generate .console <<Console_FontSizeDecr>>}
|
| 115 |
+
AmpMenuArgs .menubar.edit add command -label [mc "Fit To Screen Width"] \
|
| 116 |
+
-command {event generate .console <<Console_FitScreenWidth>>}
|
| 117 |
+
|
| 118 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 119 |
+
.menubar add cascade -label [mc Window] -menu [menu .menubar.window]
|
| 120 |
+
.menubar add cascade -label [mc Help] -menu [menu .menubar.help]
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
. configure -menu .menubar
|
| 124 |
+
|
| 125 |
+
# See if we can find a better font than the TkFixedFont
|
| 126 |
+
catch {font create TkConsoleFont {*}[font configure TkFixedFont]}
|
| 127 |
+
set families [font families]
|
| 128 |
+
switch -exact -- [tk windowingsystem] {
|
| 129 |
+
aqua { set preferred {Monaco 10} }
|
| 130 |
+
win32 { set preferred {ProFontWindows 8 Consolas 8} }
|
| 131 |
+
default { set preferred {} }
|
| 132 |
+
}
|
| 133 |
+
foreach {family size} $preferred {
|
| 134 |
+
if {$family in $families} {
|
| 135 |
+
font configure TkConsoleFont -family $family -size $size
|
| 136 |
+
break
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
# Provide the right border for the text widget (platform dependent).
|
| 141 |
+
::ttk::style layout ConsoleFrame {
|
| 142 |
+
Entry.field -sticky news -border 1 -children {
|
| 143 |
+
ConsoleFrame.padding -sticky news
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
::ttk::frame .consoleframe -style ConsoleFrame
|
| 147 |
+
|
| 148 |
+
set con [text .console -yscrollcommand [list .sb set] -setgrid true \
|
| 149 |
+
-borderwidth 0 -highlightthickness 0 -font TkConsoleFont]
|
| 150 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 151 |
+
scrollbar .sb -command [list $con yview]
|
| 152 |
+
} else {
|
| 153 |
+
::ttk::scrollbar .sb -command [list $con yview]
|
| 154 |
+
}
|
| 155 |
+
pack .sb -in .consoleframe -fill both -side right -padx 1 -pady 1
|
| 156 |
+
pack $con -in .consoleframe -fill both -expand 1 -side left -padx 1 -pady 1
|
| 157 |
+
pack .consoleframe -fill both -expand 1 -side left
|
| 158 |
+
|
| 159 |
+
ConsoleBind $con
|
| 160 |
+
|
| 161 |
+
$con tag configure stderr -foreground red
|
| 162 |
+
$con tag configure stdin -foreground blue
|
| 163 |
+
$con tag configure prompt -foreground \#8F4433
|
| 164 |
+
$con tag configure proc -foreground \#008800
|
| 165 |
+
$con tag configure var -background \#FFC0D0
|
| 166 |
+
$con tag raise sel
|
| 167 |
+
$con tag configure blink -background \#FFFF00
|
| 168 |
+
$con tag configure find -background \#FFFF00
|
| 169 |
+
|
| 170 |
+
focus $con
|
| 171 |
+
|
| 172 |
+
# Avoid listing this console in [winfo interps]
|
| 173 |
+
if {[info command ::send] eq "::send"} {rename ::send {}}
|
| 174 |
+
|
| 175 |
+
wm protocol . WM_DELETE_WINDOW { wm withdraw . }
|
| 176 |
+
wm title . [mc "Console"]
|
| 177 |
+
flush stdout
|
| 178 |
+
$con mark set output [$con index "end - 1 char"]
|
| 179 |
+
tk::TextSetCursor $con end
|
| 180 |
+
$con mark set promptEnd insert
|
| 181 |
+
$con mark gravity promptEnd left
|
| 182 |
+
|
| 183 |
+
# A variant of ConsolePrompt to avoid a 'puts' call
|
| 184 |
+
set w $con
|
| 185 |
+
set temp [$w index "end - 1 char"]
|
| 186 |
+
$w mark set output end
|
| 187 |
+
if {![consoleinterp eval "info exists tcl_prompt1"]} {
|
| 188 |
+
set string [EvalAttached $::tk::console::defaultPrompt]
|
| 189 |
+
$w insert output $string stdout
|
| 190 |
+
}
|
| 191 |
+
$w mark set output $temp
|
| 192 |
+
::tk::TextSetCursor $w end
|
| 193 |
+
$w mark set promptEnd insert
|
| 194 |
+
$w mark gravity promptEnd left
|
| 195 |
+
|
| 196 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 197 |
+
# Subtle work-around to erase the '% ' that tclMain.c prints out
|
| 198 |
+
after idle [subst -nocommand {
|
| 199 |
+
if {[$con get 1.0 output] eq "% "} { $con delete 1.0 output }
|
| 200 |
+
}]
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
# ::tk::ConsoleSource --
|
| 205 |
+
#
|
| 206 |
+
# Prompts the user for a file to source in the main interpreter.
|
| 207 |
+
#
|
| 208 |
+
# Arguments:
|
| 209 |
+
# None.
|
| 210 |
+
|
| 211 |
+
proc ::tk::ConsoleSource {} {
|
| 212 |
+
set filename [tk_getOpenFile -defaultextension .tcl -parent . \
|
| 213 |
+
-title [mc "Select a file to source"] \
|
| 214 |
+
-filetypes [list \
|
| 215 |
+
[list [mc "Tcl Scripts"] .tcl] \
|
| 216 |
+
[list [mc "All Files"] *]]]
|
| 217 |
+
if {$filename ne ""} {
|
| 218 |
+
set cmd [list source $filename]
|
| 219 |
+
if {[catch {consoleinterp eval $cmd} result]} {
|
| 220 |
+
ConsoleOutput stderr "$result\n"
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
# ::tk::ConsoleInvoke --
|
| 226 |
+
# Processes the command line input. If the command is complete it
|
| 227 |
+
# is evaled in the main interpreter. Otherwise, the continuation
|
| 228 |
+
# prompt is added and more input may be added.
|
| 229 |
+
#
|
| 230 |
+
# Arguments:
|
| 231 |
+
# None.
|
| 232 |
+
|
| 233 |
+
proc ::tk::ConsoleInvoke {args} {
|
| 234 |
+
set ranges [.console tag ranges input]
|
| 235 |
+
set cmd ""
|
| 236 |
+
if {[llength $ranges]} {
|
| 237 |
+
set pos 0
|
| 238 |
+
while {[lindex $ranges $pos] ne ""} {
|
| 239 |
+
set start [lindex $ranges $pos]
|
| 240 |
+
set end [lindex $ranges [incr pos]]
|
| 241 |
+
append cmd [.console get $start $end]
|
| 242 |
+
incr pos
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
if {$cmd eq ""} {
|
| 246 |
+
ConsolePrompt
|
| 247 |
+
} elseif {[info complete $cmd]} {
|
| 248 |
+
.console mark set output end
|
| 249 |
+
.console tag delete input
|
| 250 |
+
set result [consoleinterp record $cmd]
|
| 251 |
+
if {$result ne ""} {
|
| 252 |
+
puts $result
|
| 253 |
+
}
|
| 254 |
+
ConsoleHistory reset
|
| 255 |
+
ConsolePrompt
|
| 256 |
+
} else {
|
| 257 |
+
ConsolePrompt partial
|
| 258 |
+
}
|
| 259 |
+
.console yview -pickplace insert
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
# ::tk::ConsoleHistory --
|
| 263 |
+
# This procedure implements command line history for the
|
| 264 |
+
# console. In general is evals the history command in the
|
| 265 |
+
# main interpreter to obtain the history. The variable
|
| 266 |
+
# ::tk::HistNum is used to store the current location in the history.
|
| 267 |
+
#
|
| 268 |
+
# Arguments:
|
| 269 |
+
# cmd - Which action to take: prev, next, reset.
|
| 270 |
+
|
| 271 |
+
set ::tk::HistNum 1
|
| 272 |
+
proc ::tk::ConsoleHistory {cmd} {
|
| 273 |
+
variable HistNum
|
| 274 |
+
|
| 275 |
+
switch $cmd {
|
| 276 |
+
prev {
|
| 277 |
+
incr HistNum -1
|
| 278 |
+
if {$HistNum == 0} {
|
| 279 |
+
set cmd {history event [expr {[history nextid] -1}]}
|
| 280 |
+
} else {
|
| 281 |
+
set cmd "history event $HistNum"
|
| 282 |
+
}
|
| 283 |
+
if {[catch {consoleinterp eval $cmd} cmd]} {
|
| 284 |
+
incr HistNum
|
| 285 |
+
return
|
| 286 |
+
}
|
| 287 |
+
.console delete promptEnd end
|
| 288 |
+
.console insert promptEnd $cmd {input stdin}
|
| 289 |
+
.console see end
|
| 290 |
+
}
|
| 291 |
+
next {
|
| 292 |
+
incr HistNum
|
| 293 |
+
if {$HistNum == 0} {
|
| 294 |
+
set cmd {history event [expr {[history nextid] -1}]}
|
| 295 |
+
} elseif {$HistNum > 0} {
|
| 296 |
+
set cmd ""
|
| 297 |
+
set HistNum 1
|
| 298 |
+
} else {
|
| 299 |
+
set cmd "history event $HistNum"
|
| 300 |
+
}
|
| 301 |
+
if {$cmd ne ""} {
|
| 302 |
+
catch {consoleinterp eval $cmd} cmd
|
| 303 |
+
}
|
| 304 |
+
.console delete promptEnd end
|
| 305 |
+
.console insert promptEnd $cmd {input stdin}
|
| 306 |
+
.console see end
|
| 307 |
+
}
|
| 308 |
+
reset {
|
| 309 |
+
set HistNum 1
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
# ::tk::ConsolePrompt --
|
| 315 |
+
# This procedure draws the prompt. If tcl_prompt1 or tcl_prompt2
|
| 316 |
+
# exists in the main interpreter it will be called to generate the
|
| 317 |
+
# prompt. Otherwise, a hard coded default prompt is printed.
|
| 318 |
+
#
|
| 319 |
+
# Arguments:
|
| 320 |
+
# partial - Flag to specify which prompt to print.
|
| 321 |
+
|
| 322 |
+
proc ::tk::ConsolePrompt {{partial normal}} {
|
| 323 |
+
set w .console
|
| 324 |
+
if {$partial eq "normal"} {
|
| 325 |
+
set temp [$w index "end - 1 char"]
|
| 326 |
+
$w mark set output end
|
| 327 |
+
if {[consoleinterp eval "info exists tcl_prompt1"]} {
|
| 328 |
+
consoleinterp eval "eval \[set tcl_prompt1\]"
|
| 329 |
+
} else {
|
| 330 |
+
puts -nonewline [EvalAttached $::tk::console::defaultPrompt]
|
| 331 |
+
}
|
| 332 |
+
} else {
|
| 333 |
+
set temp [$w index output]
|
| 334 |
+
$w mark set output end
|
| 335 |
+
if {[consoleinterp eval "info exists tcl_prompt2"]} {
|
| 336 |
+
consoleinterp eval "eval \[set tcl_prompt2\]"
|
| 337 |
+
} else {
|
| 338 |
+
puts -nonewline "> "
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
flush stdout
|
| 342 |
+
$w mark set output $temp
|
| 343 |
+
::tk::TextSetCursor $w end
|
| 344 |
+
$w mark set promptEnd insert
|
| 345 |
+
$w mark gravity promptEnd left
|
| 346 |
+
::tk::console::ConstrainBuffer $w $::tk::console::maxLines
|
| 347 |
+
$w see end
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
# Copy selected text from the console
|
| 351 |
+
proc ::tk::console::Copy {w} {
|
| 352 |
+
if {![catch {set data [$w get sel.first sel.last]}]} {
|
| 353 |
+
clipboard clear -displayof $w
|
| 354 |
+
clipboard append -displayof $w $data
|
| 355 |
+
}
|
| 356 |
+
}
|
| 357 |
+
# Copies selected text. If the selection is within the current active edit
|
| 358 |
+
# region then it will be cut, if not it is only copied.
|
| 359 |
+
proc ::tk::console::Cut {w} {
|
| 360 |
+
if {![catch {set data [$w get sel.first sel.last]}]} {
|
| 361 |
+
clipboard clear -displayof $w
|
| 362 |
+
clipboard append -displayof $w $data
|
| 363 |
+
if {[$w compare sel.first >= output]} {
|
| 364 |
+
$w delete sel.first sel.last
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
# Paste text from the clipboard
|
| 369 |
+
proc ::tk::console::Paste {w} {
|
| 370 |
+
catch {
|
| 371 |
+
set clip [::tk::GetSelection $w CLIPBOARD]
|
| 372 |
+
set list [split $clip \n\r]
|
| 373 |
+
tk::ConsoleInsert $w [lindex $list 0]
|
| 374 |
+
foreach x [lrange $list 1 end] {
|
| 375 |
+
$w mark set insert {end - 1c}
|
| 376 |
+
tk::ConsoleInsert $w "\n"
|
| 377 |
+
tk::ConsoleInvoke
|
| 378 |
+
tk::ConsoleInsert $w $x
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
# Fit TkConsoleFont to window width
|
| 384 |
+
proc ::tk::console::FitScreenWidth {w} {
|
| 385 |
+
set width [winfo screenwidth $w]
|
| 386 |
+
set cwidth [$w cget -width]
|
| 387 |
+
set s -50
|
| 388 |
+
set fit 0
|
| 389 |
+
array set fi [font configure TkConsoleFont]
|
| 390 |
+
while {$s < 0} {
|
| 391 |
+
set fi(-size) $s
|
| 392 |
+
set f [font create {*}[array get fi]]
|
| 393 |
+
set c [font measure $f "eM"]
|
| 394 |
+
font delete $f
|
| 395 |
+
if {$c * $cwidth < 1.667 * $width} {
|
| 396 |
+
font configure TkConsoleFont -size $s
|
| 397 |
+
break
|
| 398 |
+
}
|
| 399 |
+
incr s 2
|
| 400 |
+
}
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
# ::tk::ConsoleBind --
|
| 404 |
+
# This procedure first ensures that the default bindings for the Text
|
| 405 |
+
# class have been defined. Then certain bindings are overridden for
|
| 406 |
+
# the class.
|
| 407 |
+
#
|
| 408 |
+
# Arguments:
|
| 409 |
+
# None.
|
| 410 |
+
|
| 411 |
+
proc ::tk::ConsoleBind {w} {
|
| 412 |
+
bindtags $w [list $w Console PostConsole [winfo toplevel $w] all]
|
| 413 |
+
|
| 414 |
+
## Get all Text bindings into Console
|
| 415 |
+
foreach ev [bind Text] {
|
| 416 |
+
bind Console $ev [bind Text $ev]
|
| 417 |
+
}
|
| 418 |
+
## We really didn't want the newline insertion...
|
| 419 |
+
bind Console <Control-o> {}
|
| 420 |
+
## ...or any Control-v binding (would block <<Paste>>)
|
| 421 |
+
bind Console <Control-v> {}
|
| 422 |
+
|
| 423 |
+
# For the moment, transpose isn't enabled until the console
|
| 424 |
+
# gets and overhaul of how it handles input -- hobbs
|
| 425 |
+
bind Console <Control-t> {}
|
| 426 |
+
|
| 427 |
+
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
|
| 428 |
+
# Otherwise, if a widget binding for one of these is defined, the
|
| 429 |
+
# <Keypress> class binding will also fire and insert the character
|
| 430 |
+
# which is wrong.
|
| 431 |
+
|
| 432 |
+
bind Console <Alt-Key> {# nothing }
|
| 433 |
+
bind Console <Meta-Key> {# nothing}
|
| 434 |
+
bind Console <Control-Key> {# nothing}
|
| 435 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 436 |
+
bind Console <Command-Key> {# nothing}
|
| 437 |
+
bind Console <Mod4-Key> {# nothing}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
foreach {ev key} {
|
| 441 |
+
<<Console_NextImmediate>> <Control-n>
|
| 442 |
+
<<Console_PrevImmediate>> <Control-p>
|
| 443 |
+
<<Console_PrevSearch>> <Control-r>
|
| 444 |
+
<<Console_NextSearch>> <Control-s>
|
| 445 |
+
|
| 446 |
+
<<Console_Expand>> <Tab>
|
| 447 |
+
<<Console_Expand>> <Escape>
|
| 448 |
+
<<Console_ExpandFile>> <Control-Shift-F>
|
| 449 |
+
<<Console_ExpandProc>> <Control-Shift-P>
|
| 450 |
+
<<Console_ExpandVar>> <Control-Shift-V>
|
| 451 |
+
<<Console_Tab>> <Control-i>
|
| 452 |
+
<<Console_Tab>> <Meta-i>
|
| 453 |
+
<<Console_Eval>> <Return>
|
| 454 |
+
<<Console_Eval>> <KP_Enter>
|
| 455 |
+
|
| 456 |
+
<<Console_Clear>> <Control-l>
|
| 457 |
+
<<Console_KillLine>> <Control-k>
|
| 458 |
+
<<Console_Transpose>> <Control-t>
|
| 459 |
+
<<Console_ClearLine>> <Control-u>
|
| 460 |
+
<<Console_SaveCommand>> <Control-z>
|
| 461 |
+
<<Console_FontSizeIncr>> <Control-plus>
|
| 462 |
+
<<Console_FontSizeDecr>> <Control-minus>
|
| 463 |
+
} {
|
| 464 |
+
event add $ev $key
|
| 465 |
+
bind Console $key {}
|
| 466 |
+
}
|
| 467 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 468 |
+
foreach {ev key} {
|
| 469 |
+
<<Console_FontSizeIncr>> <Command-plus>
|
| 470 |
+
<<Console_FontSizeDecr>> <Command-minus>
|
| 471 |
+
} {
|
| 472 |
+
event add $ev $key
|
| 473 |
+
bind Console $key {}
|
| 474 |
+
}
|
| 475 |
+
if {$::tk::console::useFontchooser} {
|
| 476 |
+
bind Console <Command-t> [list ::tk::console::FontchooserToggle]
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
bind Console <<Console_Expand>> {
|
| 480 |
+
if {[%W compare insert > promptEnd]} {
|
| 481 |
+
::tk::console::Expand %W
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
bind Console <<Console_ExpandFile>> {
|
| 485 |
+
if {[%W compare insert > promptEnd]} {
|
| 486 |
+
::tk::console::Expand %W path
|
| 487 |
+
}
|
| 488 |
+
}
|
| 489 |
+
bind Console <<Console_ExpandProc>> {
|
| 490 |
+
if {[%W compare insert > promptEnd]} {
|
| 491 |
+
::tk::console::Expand %W proc
|
| 492 |
+
}
|
| 493 |
+
}
|
| 494 |
+
bind Console <<Console_ExpandVar>> {
|
| 495 |
+
if {[%W compare insert > promptEnd]} {
|
| 496 |
+
::tk::console::Expand %W var
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
bind Console <<Console_Eval>> {
|
| 500 |
+
%W mark set insert {end - 1c}
|
| 501 |
+
tk::ConsoleInsert %W "\n"
|
| 502 |
+
tk::ConsoleInvoke
|
| 503 |
+
break
|
| 504 |
+
}
|
| 505 |
+
bind Console <Delete> {
|
| 506 |
+
if {{} ne [%W tag nextrange sel 1.0 end] \
|
| 507 |
+
&& [%W compare sel.first >= promptEnd]} {
|
| 508 |
+
%W delete sel.first sel.last
|
| 509 |
+
} elseif {[%W compare insert >= promptEnd]} {
|
| 510 |
+
%W delete insert
|
| 511 |
+
%W see insert
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
bind Console <BackSpace> {
|
| 515 |
+
if {{} ne [%W tag nextrange sel 1.0 end] \
|
| 516 |
+
&& [%W compare sel.first >= promptEnd]} {
|
| 517 |
+
%W delete sel.first sel.last
|
| 518 |
+
} elseif {[%W compare insert != 1.0] && \
|
| 519 |
+
[%W compare insert > promptEnd]} {
|
| 520 |
+
%W delete insert-1c
|
| 521 |
+
%W see insert
|
| 522 |
+
}
|
| 523 |
+
}
|
| 524 |
+
bind Console <Control-h> [bind Console <BackSpace>]
|
| 525 |
+
|
| 526 |
+
bind Console <<LineStart>> {
|
| 527 |
+
if {[%W compare insert < promptEnd]} {
|
| 528 |
+
tk::TextSetCursor %W {insert linestart}
|
| 529 |
+
} else {
|
| 530 |
+
tk::TextSetCursor %W promptEnd
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
bind Console <<LineEnd>> {
|
| 534 |
+
tk::TextSetCursor %W {insert lineend}
|
| 535 |
+
}
|
| 536 |
+
bind Console <Control-d> {
|
| 537 |
+
if {[%W compare insert < promptEnd]} {
|
| 538 |
+
break
|
| 539 |
+
}
|
| 540 |
+
%W delete insert
|
| 541 |
+
}
|
| 542 |
+
bind Console <<Console_KillLine>> {
|
| 543 |
+
if {[%W compare insert < promptEnd]} {
|
| 544 |
+
break
|
| 545 |
+
}
|
| 546 |
+
if {[%W compare insert == {insert lineend}]} {
|
| 547 |
+
%W delete insert
|
| 548 |
+
} else {
|
| 549 |
+
%W delete insert {insert lineend}
|
| 550 |
+
}
|
| 551 |
+
}
|
| 552 |
+
bind Console <<Console_Clear>> {
|
| 553 |
+
## Clear console display
|
| 554 |
+
%W delete 1.0 "promptEnd linestart"
|
| 555 |
+
}
|
| 556 |
+
bind Console <<Console_ClearLine>> {
|
| 557 |
+
## Clear command line (Unix shell staple)
|
| 558 |
+
%W delete promptEnd end
|
| 559 |
+
}
|
| 560 |
+
bind Console <Meta-d> {
|
| 561 |
+
if {[%W compare insert >= promptEnd]} {
|
| 562 |
+
%W delete insert {insert wordend}
|
| 563 |
+
}
|
| 564 |
+
}
|
| 565 |
+
bind Console <Meta-BackSpace> {
|
| 566 |
+
if {[%W compare {insert -1c wordstart} >= promptEnd]} {
|
| 567 |
+
%W delete {insert -1c wordstart} insert
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
bind Console <Meta-d> {
|
| 571 |
+
if {[%W compare insert >= promptEnd]} {
|
| 572 |
+
%W delete insert {insert wordend}
|
| 573 |
+
}
|
| 574 |
+
}
|
| 575 |
+
bind Console <Meta-BackSpace> {
|
| 576 |
+
if {[%W compare {insert -1c wordstart} >= promptEnd]} {
|
| 577 |
+
%W delete {insert -1c wordstart} insert
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
bind Console <Meta-Delete> {
|
| 581 |
+
if {[%W compare insert >= promptEnd]} {
|
| 582 |
+
%W delete insert {insert wordend}
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
bind Console <<PrevLine>> {
|
| 586 |
+
tk::ConsoleHistory prev
|
| 587 |
+
}
|
| 588 |
+
bind Console <<NextLine>> {
|
| 589 |
+
tk::ConsoleHistory next
|
| 590 |
+
}
|
| 591 |
+
bind Console <Insert> {
|
| 592 |
+
catch {tk::ConsoleInsert %W [::tk::GetSelection %W PRIMARY]}
|
| 593 |
+
}
|
| 594 |
+
bind Console <Key> {
|
| 595 |
+
tk::ConsoleInsert %W %A
|
| 596 |
+
}
|
| 597 |
+
bind Console <F9> {
|
| 598 |
+
destroy {*}[winfo children .]
|
| 599 |
+
source -encoding utf-8 [file join $tk_library console.tcl]
|
| 600 |
+
}
|
| 601 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 602 |
+
bind Console <Command-q> {
|
| 603 |
+
exit
|
| 604 |
+
}
|
| 605 |
+
}
|
| 606 |
+
bind Console <<Cut>> { ::tk::console::Cut %W }
|
| 607 |
+
bind Console <<Copy>> { ::tk::console::Copy %W }
|
| 608 |
+
bind Console <<Paste>> { ::tk::console::Paste %W }
|
| 609 |
+
|
| 610 |
+
bind Console <<Console_FontSizeIncr>> {
|
| 611 |
+
set size [font configure TkConsoleFont -size]
|
| 612 |
+
if {$size < 0} {set sign -1} else {set sign 1}
|
| 613 |
+
set size [expr {(abs($size) + 1) * $sign}]
|
| 614 |
+
font configure TkConsoleFont -size $size
|
| 615 |
+
if {$::tk::console::useFontchooser} {
|
| 616 |
+
tk fontchooser configure -font TkConsoleFont
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
bind Console <<Console_FontSizeDecr>> {
|
| 620 |
+
set size [font configure TkConsoleFont -size]
|
| 621 |
+
if {abs($size) < 2} { return }
|
| 622 |
+
if {$size < 0} {set sign -1} else {set sign 1}
|
| 623 |
+
set size [expr {(abs($size) - 1) * $sign}]
|
| 624 |
+
font configure TkConsoleFont -size $size
|
| 625 |
+
if {$::tk::console::useFontchooser} {
|
| 626 |
+
tk fontchooser configure -font TkConsoleFont
|
| 627 |
+
}
|
| 628 |
+
}
|
| 629 |
+
bind Console <<Console_FitScreenWidth>> {
|
| 630 |
+
::tk::console::FitScreenWidth %W
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
##
|
| 634 |
+
## Bindings for doing special things based on certain keys
|
| 635 |
+
##
|
| 636 |
+
bind PostConsole <parenright> {
|
| 637 |
+
if {"\\" ne [%W get insert-2c]} {
|
| 638 |
+
::tk::console::MatchPair %W \( \) promptEnd
|
| 639 |
+
}
|
| 640 |
+
}
|
| 641 |
+
bind PostConsole <bracketright> {
|
| 642 |
+
if {"\\" ne [%W get insert-2c]} {
|
| 643 |
+
::tk::console::MatchPair %W \[ \] promptEnd
|
| 644 |
+
}
|
| 645 |
+
}
|
| 646 |
+
bind PostConsole <braceright> {
|
| 647 |
+
if {"\\" ne [%W get insert-2c]} {
|
| 648 |
+
::tk::console::MatchPair %W \{ \} promptEnd
|
| 649 |
+
}
|
| 650 |
+
}
|
| 651 |
+
bind PostConsole <quotedbl> {
|
| 652 |
+
if {"\\" ne [%W get insert-2c]} {
|
| 653 |
+
::tk::console::MatchQuote %W promptEnd
|
| 654 |
+
}
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
bind PostConsole <Key> {
|
| 658 |
+
if {"%A" ne ""} {
|
| 659 |
+
::tk::console::TagProc %W
|
| 660 |
+
}
|
| 661 |
+
}
|
| 662 |
+
}
|
| 663 |
+
|
| 664 |
+
# ::tk::ConsoleInsert --
|
| 665 |
+
# Insert a string into a text at the point of the insertion cursor.
|
| 666 |
+
# If there is a selection in the text, and it covers the point of the
|
| 667 |
+
# insertion cursor, then delete the selection before inserting. Insertion
|
| 668 |
+
# is restricted to the prompt area.
|
| 669 |
+
#
|
| 670 |
+
# Arguments:
|
| 671 |
+
# w - The text window in which to insert the string
|
| 672 |
+
# s - The string to insert (usually just a single character)
|
| 673 |
+
|
| 674 |
+
proc ::tk::ConsoleInsert {w s} {
|
| 675 |
+
if {$s eq ""} {
|
| 676 |
+
return
|
| 677 |
+
}
|
| 678 |
+
catch {
|
| 679 |
+
if {[$w compare sel.first <= insert] \
|
| 680 |
+
&& [$w compare sel.last >= insert]} {
|
| 681 |
+
$w tag remove sel sel.first promptEnd
|
| 682 |
+
$w delete sel.first sel.last
|
| 683 |
+
}
|
| 684 |
+
}
|
| 685 |
+
if {[$w compare insert < promptEnd]} {
|
| 686 |
+
$w mark set insert end
|
| 687 |
+
}
|
| 688 |
+
$w insert insert $s {input stdin}
|
| 689 |
+
$w see insert
|
| 690 |
+
}
|
| 691 |
+
|
| 692 |
+
# ::tk::ConsoleOutput --
|
| 693 |
+
#
|
| 694 |
+
# This routine is called directly by ConsolePutsCmd to cause a string
|
| 695 |
+
# to be displayed in the console.
|
| 696 |
+
#
|
| 697 |
+
# Arguments:
|
| 698 |
+
# dest - The output tag to be used: either "stderr" or "stdout".
|
| 699 |
+
# string - The string to be displayed.
|
| 700 |
+
|
| 701 |
+
proc ::tk::ConsoleOutput {dest string} {
|
| 702 |
+
set w .console
|
| 703 |
+
$w insert output $string $dest
|
| 704 |
+
::tk::console::ConstrainBuffer $w $::tk::console::maxLines
|
| 705 |
+
$w see insert
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
# ::tk::ConsoleExit --
|
| 709 |
+
#
|
| 710 |
+
# This routine is called by ConsoleEventProc when the main window of
|
| 711 |
+
# the application is destroyed. Don't call exit - that probably already
|
| 712 |
+
# happened. Just delete our window.
|
| 713 |
+
#
|
| 714 |
+
# Arguments:
|
| 715 |
+
# None.
|
| 716 |
+
|
| 717 |
+
proc ::tk::ConsoleExit {} {
|
| 718 |
+
destroy .
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
# ::tk::ConsoleAbout --
|
| 722 |
+
#
|
| 723 |
+
# This routine displays an About box to show Tcl/Tk version info.
|
| 724 |
+
#
|
| 725 |
+
# Arguments:
|
| 726 |
+
# None.
|
| 727 |
+
|
| 728 |
+
proc ::tk::ConsoleAbout {} {
|
| 729 |
+
tk_messageBox -type ok -message "[mc {Tcl for Windows}]
|
| 730 |
+
|
| 731 |
+
Tcl $::tcl_patchLevel
|
| 732 |
+
Tk $::tk_patchLevel"
|
| 733 |
+
}
|
| 734 |
+
|
| 735 |
+
# ::tk::console::Fontchooser* --
|
| 736 |
+
# Let the user select the console font (TIP 324).
|
| 737 |
+
|
| 738 |
+
proc ::tk::console::FontchooserToggle {} {
|
| 739 |
+
if {[tk fontchooser configure -visible]} {
|
| 740 |
+
tk fontchooser hide
|
| 741 |
+
} else {
|
| 742 |
+
tk fontchooser show
|
| 743 |
+
}
|
| 744 |
+
}
|
| 745 |
+
proc ::tk::console::FontchooserVisibility {index} {
|
| 746 |
+
if {[tk fontchooser configure -visible]} {
|
| 747 |
+
.menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Hide Fonts"]
|
| 748 |
+
} else {
|
| 749 |
+
.menubar.edit entryconfigure $index -label [::tk::msgcat::mc "Show Fonts"]
|
| 750 |
+
}
|
| 751 |
+
}
|
| 752 |
+
proc ::tk::console::FontchooserFocus {w isFocusIn} {
|
| 753 |
+
if {$isFocusIn} {
|
| 754 |
+
tk fontchooser configure -parent $w -font TkConsoleFont \
|
| 755 |
+
-command [namespace code [list FontchooserApply]]
|
| 756 |
+
} else {
|
| 757 |
+
tk fontchooser configure -parent $w -font {} -command {}
|
| 758 |
+
}
|
| 759 |
+
}
|
| 760 |
+
proc ::tk::console::FontchooserApply {font args} {
|
| 761 |
+
catch {font configure TkConsoleFont {*}[font actual $font]}
|
| 762 |
+
}
|
| 763 |
+
|
| 764 |
+
# ::tk::console::TagProc --
|
| 765 |
+
#
|
| 766 |
+
# Tags a procedure in the console if it's recognized
|
| 767 |
+
# This procedure is not perfect. However, making it perfect wastes
|
| 768 |
+
# too much CPU time...
|
| 769 |
+
#
|
| 770 |
+
# Arguments:
|
| 771 |
+
# w - console text widget
|
| 772 |
+
|
| 773 |
+
proc ::tk::console::TagProc w {
|
| 774 |
+
if {!$::tk::console::magicKeys} {
|
| 775 |
+
return
|
| 776 |
+
}
|
| 777 |
+
set exp "\[^\\\\\]\[\[ \t\n\r\;{}\"\$\]"
|
| 778 |
+
set i [$w search -backwards -regexp $exp insert-1c promptEnd-1c]
|
| 779 |
+
if {$i eq ""} {
|
| 780 |
+
set i promptEnd
|
| 781 |
+
} else {
|
| 782 |
+
append i +2c
|
| 783 |
+
}
|
| 784 |
+
regsub -all "\[\[\\\\\\?\\*\]" [$w get $i "insert-1c wordend"] {\\\0} c
|
| 785 |
+
if {[llength [EvalAttached [list info commands $c]]]} {
|
| 786 |
+
$w tag add proc $i "insert-1c wordend"
|
| 787 |
+
} else {
|
| 788 |
+
$w tag remove proc $i "insert-1c wordend"
|
| 789 |
+
}
|
| 790 |
+
if {[llength [EvalAttached [list info vars $c]]]} {
|
| 791 |
+
$w tag add var $i "insert-1c wordend"
|
| 792 |
+
} else {
|
| 793 |
+
$w tag remove var $i "insert-1c wordend"
|
| 794 |
+
}
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
# ::tk::console::MatchPair --
|
| 798 |
+
#
|
| 799 |
+
# Blinks a matching pair of characters
|
| 800 |
+
# c2 is assumed to be at the text index 'insert'.
|
| 801 |
+
# This proc is really loopy and took me an hour to figure out given
|
| 802 |
+
# all possible combinations with escaping except for escaped \'s.
|
| 803 |
+
# It doesn't take into account possible commenting... Oh well. If
|
| 804 |
+
# anyone has something better, I'd like to see/use it. This is really
|
| 805 |
+
# only efficient for small contexts.
|
| 806 |
+
#
|
| 807 |
+
# Arguments:
|
| 808 |
+
# w - console text widget
|
| 809 |
+
# c1 - first char of pair
|
| 810 |
+
# c2 - second char of pair
|
| 811 |
+
#
|
| 812 |
+
# Calls: ::tk::console::Blink
|
| 813 |
+
|
| 814 |
+
proc ::tk::console::MatchPair {w c1 c2 {lim 1.0}} {
|
| 815 |
+
if {!$::tk::console::magicKeys} {
|
| 816 |
+
return
|
| 817 |
+
}
|
| 818 |
+
if {{} ne [set ix [$w search -back $c1 insert $lim]]} {
|
| 819 |
+
while {
|
| 820 |
+
[string match {\\} [$w get $ix-1c]] &&
|
| 821 |
+
[set ix [$w search -back $c1 $ix-1c $lim]] ne {}
|
| 822 |
+
} {}
|
| 823 |
+
set i1 insert-1c
|
| 824 |
+
while {$ix ne {}} {
|
| 825 |
+
set i0 $ix
|
| 826 |
+
set j 0
|
| 827 |
+
while {[set i0 [$w search $c2 $i0 $i1]] ne {}} {
|
| 828 |
+
append i0 +1c
|
| 829 |
+
if {[string match {\\} [$w get $i0-2c]]} {
|
| 830 |
+
continue
|
| 831 |
+
}
|
| 832 |
+
incr j
|
| 833 |
+
}
|
| 834 |
+
if {!$j} {
|
| 835 |
+
break
|
| 836 |
+
}
|
| 837 |
+
set i1 $ix
|
| 838 |
+
while {$j && [set ix [$w search -back $c1 $ix $lim]] ne {}} {
|
| 839 |
+
if {[string match {\\} [$w get $ix-1c]]} {
|
| 840 |
+
continue
|
| 841 |
+
}
|
| 842 |
+
incr j -1
|
| 843 |
+
}
|
| 844 |
+
}
|
| 845 |
+
if {[string match {} $ix]} {
|
| 846 |
+
set ix [$w index $lim]
|
| 847 |
+
}
|
| 848 |
+
} else {
|
| 849 |
+
set ix [$w index $lim]
|
| 850 |
+
}
|
| 851 |
+
if {$::tk::console::blinkRange} {
|
| 852 |
+
Blink $w $ix [$w index insert]
|
| 853 |
+
} else {
|
| 854 |
+
Blink $w $ix $ix+1c [$w index insert-1c] [$w index insert]
|
| 855 |
+
}
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
# ::tk::console::MatchQuote --
|
| 859 |
+
#
|
| 860 |
+
# Blinks between matching quotes.
|
| 861 |
+
# Blinks just the quote if it's unmatched, otherwise blinks quoted string
|
| 862 |
+
# The quote to match is assumed to be at the text index 'insert'.
|
| 863 |
+
#
|
| 864 |
+
# Arguments:
|
| 865 |
+
# w - console text widget
|
| 866 |
+
#
|
| 867 |
+
# Calls: ::tk::console::Blink
|
| 868 |
+
|
| 869 |
+
proc ::tk::console::MatchQuote {w {lim 1.0}} {
|
| 870 |
+
if {!$::tk::console::magicKeys} {
|
| 871 |
+
return
|
| 872 |
+
}
|
| 873 |
+
set i insert-1c
|
| 874 |
+
set j 0
|
| 875 |
+
while {[set i [$w search -back \" $i $lim]] ne {}} {
|
| 876 |
+
if {[string match {\\} [$w get $i-1c]]} {
|
| 877 |
+
continue
|
| 878 |
+
}
|
| 879 |
+
if {!$j} {
|
| 880 |
+
set i0 $i
|
| 881 |
+
}
|
| 882 |
+
incr j
|
| 883 |
+
}
|
| 884 |
+
if {$j&1} {
|
| 885 |
+
if {$::tk::console::blinkRange} {
|
| 886 |
+
Blink $w $i0 [$w index insert]
|
| 887 |
+
} else {
|
| 888 |
+
Blink $w $i0 $i0+1c [$w index insert-1c] [$w index insert]
|
| 889 |
+
}
|
| 890 |
+
} else {
|
| 891 |
+
Blink $w [$w index insert-1c] [$w index insert]
|
| 892 |
+
}
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
# ::tk::console::Blink --
|
| 896 |
+
#
|
| 897 |
+
# Blinks between n index pairs for a specified duration.
|
| 898 |
+
#
|
| 899 |
+
# Arguments:
|
| 900 |
+
# w - console text widget
|
| 901 |
+
# i1 - start index to blink region
|
| 902 |
+
# i2 - end index of blink region
|
| 903 |
+
# dur - duration in usecs to blink for
|
| 904 |
+
#
|
| 905 |
+
# Outputs:
|
| 906 |
+
# blinks selected characters in $w
|
| 907 |
+
|
| 908 |
+
proc ::tk::console::Blink {w args} {
|
| 909 |
+
eval [list $w tag add blink] $args
|
| 910 |
+
after $::tk::console::blinkTime [list $w] tag remove blink $args
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
# ::tk::console::ConstrainBuffer --
|
| 914 |
+
#
|
| 915 |
+
# This limits the amount of data in the text widget
|
| 916 |
+
# Called by Prompt and ConsoleOutput
|
| 917 |
+
#
|
| 918 |
+
# Arguments:
|
| 919 |
+
# w - console text widget
|
| 920 |
+
# size - # of lines to constrain to
|
| 921 |
+
#
|
| 922 |
+
# Outputs:
|
| 923 |
+
# may delete data in console widget
|
| 924 |
+
|
| 925 |
+
proc ::tk::console::ConstrainBuffer {w size} {
|
| 926 |
+
if {[$w index end] > $size} {
|
| 927 |
+
$w delete 1.0 [expr {int([$w index end])-$size}].0
|
| 928 |
+
}
|
| 929 |
+
}
|
| 930 |
+
|
| 931 |
+
# ::tk::console::Expand --
|
| 932 |
+
#
|
| 933 |
+
# Arguments:
|
| 934 |
+
# ARGS: w - text widget in which to expand str
|
| 935 |
+
# type - type of expansion (path / proc / variable)
|
| 936 |
+
#
|
| 937 |
+
# Calls: ::tk::console::Expand(Pathname|Procname|Variable)
|
| 938 |
+
#
|
| 939 |
+
# Outputs: The string to match is expanded to the longest possible match.
|
| 940 |
+
# If ::tk::console::showMatches is non-zero and the longest match
|
| 941 |
+
# equaled the string to expand, then all possible matches are
|
| 942 |
+
# output to stdout. Triggers bell if no matches are found.
|
| 943 |
+
#
|
| 944 |
+
# Returns: number of matches found
|
| 945 |
+
|
| 946 |
+
proc ::tk::console::Expand {w {type ""}} {
|
| 947 |
+
set exp "\[^\\\\\]\[\[ \t\n\r\\\{\"\\\\\$\]"
|
| 948 |
+
set tmp [$w search -backwards -regexp $exp insert-1c promptEnd-1c]
|
| 949 |
+
if {$tmp eq ""} {
|
| 950 |
+
set tmp promptEnd
|
| 951 |
+
} else {
|
| 952 |
+
append tmp +2c
|
| 953 |
+
}
|
| 954 |
+
if {[$w compare $tmp >= insert]} {
|
| 955 |
+
return
|
| 956 |
+
}
|
| 957 |
+
set str [$w get $tmp insert]
|
| 958 |
+
switch -glob $type {
|
| 959 |
+
path* {
|
| 960 |
+
set res [ExpandPathname $str]
|
| 961 |
+
}
|
| 962 |
+
proc* {
|
| 963 |
+
set res [ExpandProcname $str]
|
| 964 |
+
}
|
| 965 |
+
var* {
|
| 966 |
+
set res [ExpandVariable $str]
|
| 967 |
+
}
|
| 968 |
+
default {
|
| 969 |
+
set res {}
|
| 970 |
+
foreach t {Pathname Procname Variable} {
|
| 971 |
+
if {![catch {Expand$t $str} res] && ($res ne "")} {
|
| 972 |
+
break
|
| 973 |
+
}
|
| 974 |
+
}
|
| 975 |
+
}
|
| 976 |
+
}
|
| 977 |
+
set len [llength $res]
|
| 978 |
+
if {$len} {
|
| 979 |
+
set repl [lindex $res 0]
|
| 980 |
+
$w delete $tmp insert
|
| 981 |
+
$w insert $tmp $repl {input stdin}
|
| 982 |
+
if {($len > 1) && ($::tk::console::showMatches) && ($repl eq $str)} {
|
| 983 |
+
puts stdout [lsort [lreplace $res 0 0]]
|
| 984 |
+
}
|
| 985 |
+
} else {
|
| 986 |
+
bell
|
| 987 |
+
}
|
| 988 |
+
return [incr len -1]
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
# ::tk::console::ExpandPathname --
|
| 992 |
+
#
|
| 993 |
+
# Expand a file pathname based on $str
|
| 994 |
+
# This is based on UNIX file name conventions
|
| 995 |
+
#
|
| 996 |
+
# Arguments:
|
| 997 |
+
# str - partial file pathname to expand
|
| 998 |
+
#
|
| 999 |
+
# Calls: ::tk::console::ExpandBestMatch
|
| 1000 |
+
#
|
| 1001 |
+
# Returns: list containing longest unique match followed by all the
|
| 1002 |
+
# possible further matches
|
| 1003 |
+
|
| 1004 |
+
proc ::tk::console::ExpandPathname str {
|
| 1005 |
+
set pwd [EvalAttached pwd]
|
| 1006 |
+
if {[catch {EvalAttached [list cd [file dirname $str]]} err opt]} {
|
| 1007 |
+
return -options $opt $err
|
| 1008 |
+
}
|
| 1009 |
+
set dir [file tail $str]
|
| 1010 |
+
## Check to see if it was known to be a directory and keep the trailing
|
| 1011 |
+
## slash if so (file tail cuts it off)
|
| 1012 |
+
if {[string match */ $str]} {
|
| 1013 |
+
append dir /
|
| 1014 |
+
}
|
| 1015 |
+
if {[catch {lsort [EvalAttached [list glob $dir*]]} m]} {
|
| 1016 |
+
set match {}
|
| 1017 |
+
} else {
|
| 1018 |
+
if {[llength $m] > 1} {
|
| 1019 |
+
if { $::tcl_platform(platform) eq "windows" } {
|
| 1020 |
+
## Windows is screwy because it's case insensitive
|
| 1021 |
+
set tmp [ExpandBestMatch [string tolower $m] \
|
| 1022 |
+
[string tolower $dir]]
|
| 1023 |
+
## Don't change case if we haven't changed the word
|
| 1024 |
+
if {[string length $dir]==[string length $tmp]} {
|
| 1025 |
+
set tmp $dir
|
| 1026 |
+
}
|
| 1027 |
+
} else {
|
| 1028 |
+
set tmp [ExpandBestMatch $m $dir]
|
| 1029 |
+
}
|
| 1030 |
+
if {[string match ?*/* $str]} {
|
| 1031 |
+
set tmp [file dirname $str]/$tmp
|
| 1032 |
+
} elseif {[string match /* $str]} {
|
| 1033 |
+
set tmp /$tmp
|
| 1034 |
+
}
|
| 1035 |
+
regsub -all { } $tmp {\\ } tmp
|
| 1036 |
+
set match [linsert $m 0 $tmp]
|
| 1037 |
+
} else {
|
| 1038 |
+
## This may look goofy, but it handles spaces in path names
|
| 1039 |
+
eval append match $m
|
| 1040 |
+
if {[file isdir $match]} {
|
| 1041 |
+
append match /
|
| 1042 |
+
}
|
| 1043 |
+
if {[string match ?*/* $str]} {
|
| 1044 |
+
set match [file dirname $str]/$match
|
| 1045 |
+
} elseif {[string match /* $str]} {
|
| 1046 |
+
set match /$match
|
| 1047 |
+
}
|
| 1048 |
+
regsub -all { } $match {\\ } match
|
| 1049 |
+
## Why is this one needed and the ones below aren't!!
|
| 1050 |
+
set match [list $match]
|
| 1051 |
+
}
|
| 1052 |
+
}
|
| 1053 |
+
EvalAttached [list cd $pwd]
|
| 1054 |
+
return $match
|
| 1055 |
+
}
|
| 1056 |
+
|
| 1057 |
+
# ::tk::console::ExpandProcname --
|
| 1058 |
+
#
|
| 1059 |
+
# Expand a tcl proc name based on $str
|
| 1060 |
+
#
|
| 1061 |
+
# Arguments:
|
| 1062 |
+
# str - partial proc name to expand
|
| 1063 |
+
#
|
| 1064 |
+
# Calls: ::tk::console::ExpandBestMatch
|
| 1065 |
+
#
|
| 1066 |
+
# Returns: list containing longest unique match followed by all the
|
| 1067 |
+
# possible further matches
|
| 1068 |
+
|
| 1069 |
+
proc ::tk::console::ExpandProcname str {
|
| 1070 |
+
set match [EvalAttached [list info commands $str*]]
|
| 1071 |
+
if {[llength $match] == 0} {
|
| 1072 |
+
set ns [EvalAttached \
|
| 1073 |
+
"namespace children \[namespace current\] [list $str*]"]
|
| 1074 |
+
if {[llength $ns]==1} {
|
| 1075 |
+
set match [EvalAttached [list info commands ${ns}::*]]
|
| 1076 |
+
} else {
|
| 1077 |
+
set match $ns
|
| 1078 |
+
}
|
| 1079 |
+
}
|
| 1080 |
+
if {[llength $match] > 1} {
|
| 1081 |
+
regsub -all { } [ExpandBestMatch $match $str] {\\ } str
|
| 1082 |
+
set match [linsert $match 0 $str]
|
| 1083 |
+
} else {
|
| 1084 |
+
regsub -all { } $match {\\ } match
|
| 1085 |
+
}
|
| 1086 |
+
return $match
|
| 1087 |
+
}
|
| 1088 |
+
|
| 1089 |
+
# ::tk::console::ExpandVariable --
|
| 1090 |
+
#
|
| 1091 |
+
# Expand a tcl variable name based on $str
|
| 1092 |
+
#
|
| 1093 |
+
# Arguments:
|
| 1094 |
+
# str - partial tcl var name to expand
|
| 1095 |
+
#
|
| 1096 |
+
# Calls: ::tk::console::ExpandBestMatch
|
| 1097 |
+
#
|
| 1098 |
+
# Returns: list containing longest unique match followed by all the
|
| 1099 |
+
# possible further matches
|
| 1100 |
+
|
| 1101 |
+
proc ::tk::console::ExpandVariable str {
|
| 1102 |
+
if {[regexp {([^\(]*)\((.*)} $str -> ary str]} {
|
| 1103 |
+
## Looks like they're trying to expand an array.
|
| 1104 |
+
set match [EvalAttached [list array names $ary $str*]]
|
| 1105 |
+
if {[llength $match] > 1} {
|
| 1106 |
+
set vars $ary\([ExpandBestMatch $match $str]
|
| 1107 |
+
foreach var $match {
|
| 1108 |
+
lappend vars $ary\($var\)
|
| 1109 |
+
}
|
| 1110 |
+
return $vars
|
| 1111 |
+
} elseif {[llength $match] == 1} {
|
| 1112 |
+
set match $ary\($match\)
|
| 1113 |
+
}
|
| 1114 |
+
## Space transformation avoided for array names.
|
| 1115 |
+
} else {
|
| 1116 |
+
set match [EvalAttached [list info vars $str*]]
|
| 1117 |
+
if {[llength $match] > 1} {
|
| 1118 |
+
regsub -all { } [ExpandBestMatch $match $str] {\\ } str
|
| 1119 |
+
set match [linsert $match 0 $str]
|
| 1120 |
+
} else {
|
| 1121 |
+
regsub -all { } $match {\\ } match
|
| 1122 |
+
}
|
| 1123 |
+
}
|
| 1124 |
+
return $match
|
| 1125 |
+
}
|
| 1126 |
+
|
| 1127 |
+
# ::tk::console::ExpandBestMatch --
|
| 1128 |
+
#
|
| 1129 |
+
# Finds the best unique match in a list of names.
|
| 1130 |
+
# The extra $e in this argument allows us to limit the innermost loop a little
|
| 1131 |
+
# further. This improves speed as $l becomes large or $e becomes long.
|
| 1132 |
+
#
|
| 1133 |
+
# Arguments:
|
| 1134 |
+
# l - list to find best unique match in
|
| 1135 |
+
# e - currently best known unique match
|
| 1136 |
+
#
|
| 1137 |
+
# Returns: longest unique match in the list
|
| 1138 |
+
|
| 1139 |
+
proc ::tk::console::ExpandBestMatch {l {e {}}} {
|
| 1140 |
+
set ec [lindex $l 0]
|
| 1141 |
+
if {[llength $l]>1} {
|
| 1142 |
+
set e [expr {[string length $e] - 1}]
|
| 1143 |
+
set ei [expr {[string length $ec] - 1}]
|
| 1144 |
+
foreach l $l {
|
| 1145 |
+
while {$ei>=$e && [string first $ec $l]} {
|
| 1146 |
+
set ec [string range $ec 0 [incr ei -1]]
|
| 1147 |
+
}
|
| 1148 |
+
}
|
| 1149 |
+
}
|
| 1150 |
+
return $ec
|
| 1151 |
+
}
|
| 1152 |
+
|
| 1153 |
+
# now initialize the console
|
| 1154 |
+
::tk::ConsoleInit
|
mplug_owl2/lib/tk8.6/dialog.tcl
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# dialog.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the procedure tk_dialog, which creates a dialog
|
| 4 |
+
# box containing a bitmap, a message, and one or more buttons.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1992-1993 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 |
+
# ::tk_dialog:
|
| 15 |
+
#
|
| 16 |
+
# This procedure displays a dialog box, waits for a button in the dialog
|
| 17 |
+
# to be invoked, then returns the index of the selected button. If the
|
| 18 |
+
# dialog somehow gets destroyed, -1 is returned.
|
| 19 |
+
#
|
| 20 |
+
# Arguments:
|
| 21 |
+
# w - Window to use for dialog top-level.
|
| 22 |
+
# title - Title to display in dialog's decorative frame.
|
| 23 |
+
# text - Message to display in dialog.
|
| 24 |
+
# bitmap - Bitmap to display in dialog (empty string means none).
|
| 25 |
+
# default - Index of button that is to display the default ring
|
| 26 |
+
# (-1 means none).
|
| 27 |
+
# args - One or more strings to display in buttons across the
|
| 28 |
+
# bottom of the dialog box.
|
| 29 |
+
|
| 30 |
+
proc ::tk_dialog {w title text bitmap default args} {
|
| 31 |
+
variable ::tk::Priv
|
| 32 |
+
|
| 33 |
+
# Check that $default was properly given
|
| 34 |
+
if {[string is integer -strict $default]} {
|
| 35 |
+
if {$default >= [llength $args]} {
|
| 36 |
+
return -code error -errorcode {TK DIALOG BAD_DEFAULT} \
|
| 37 |
+
"default button index greater than number of buttons\
|
| 38 |
+
specified for tk_dialog"
|
| 39 |
+
}
|
| 40 |
+
} elseif {"" eq $default} {
|
| 41 |
+
set default -1
|
| 42 |
+
} else {
|
| 43 |
+
set default [lsearch -exact $args $default]
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
set windowingsystem [tk windowingsystem]
|
| 47 |
+
|
| 48 |
+
# 1. Create the top-level window and divide it into top
|
| 49 |
+
# and bottom parts.
|
| 50 |
+
|
| 51 |
+
destroy $w
|
| 52 |
+
toplevel $w -class Dialog
|
| 53 |
+
wm title $w $title
|
| 54 |
+
wm iconname $w Dialog
|
| 55 |
+
wm protocol $w WM_DELETE_WINDOW { }
|
| 56 |
+
|
| 57 |
+
# Dialog boxes should be transient with respect to their parent,
|
| 58 |
+
# so that they will always stay on top of their parent window. However,
|
| 59 |
+
# some window managers will create the window as withdrawn if the parent
|
| 60 |
+
# window is withdrawn or iconified. Combined with the grab we put on the
|
| 61 |
+
# window, this can hang the entire application. Therefore we only make
|
| 62 |
+
# the dialog transient if the parent is viewable.
|
| 63 |
+
#
|
| 64 |
+
if {[winfo viewable [winfo toplevel [winfo parent $w]]] } {
|
| 65 |
+
wm transient $w [winfo toplevel [winfo parent $w]]
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
if {$windowingsystem eq "aqua"} {
|
| 69 |
+
::tk::unsupported::MacWindowStyle style $w moveableModal {}
|
| 70 |
+
} elseif {$windowingsystem eq "x11"} {
|
| 71 |
+
wm attributes $w -type dialog
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
frame $w.bot
|
| 75 |
+
frame $w.top
|
| 76 |
+
if {$windowingsystem eq "x11"} {
|
| 77 |
+
$w.bot configure -relief raised -bd 1
|
| 78 |
+
$w.top configure -relief raised -bd 1
|
| 79 |
+
}
|
| 80 |
+
pack $w.bot -side bottom -fill both
|
| 81 |
+
pack $w.top -side top -fill both -expand 1
|
| 82 |
+
grid anchor $w.bot center
|
| 83 |
+
|
| 84 |
+
# 2. Fill the top part with bitmap and message (use the option
|
| 85 |
+
# database for -wraplength and -font so that they can be
|
| 86 |
+
# overridden by the caller).
|
| 87 |
+
|
| 88 |
+
option add *Dialog.msg.wrapLength 3i widgetDefault
|
| 89 |
+
option add *Dialog.msg.font TkCaptionFont widgetDefault
|
| 90 |
+
|
| 91 |
+
label $w.msg -justify left -text $text
|
| 92 |
+
pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m
|
| 93 |
+
if {$bitmap ne ""} {
|
| 94 |
+
if {$windowingsystem eq "aqua" && $bitmap eq "error"} {
|
| 95 |
+
set bitmap "stop"
|
| 96 |
+
}
|
| 97 |
+
label $w.bitmap -bitmap $bitmap
|
| 98 |
+
pack $w.bitmap -in $w.top -side left -padx 3m -pady 3m
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
# 3. Create a row of buttons at the bottom of the dialog.
|
| 102 |
+
|
| 103 |
+
set i 0
|
| 104 |
+
foreach but $args {
|
| 105 |
+
button $w.button$i -text $but -command [list set ::tk::Priv(button) $i]
|
| 106 |
+
if {$i == $default} {
|
| 107 |
+
$w.button$i configure -default active
|
| 108 |
+
} else {
|
| 109 |
+
$w.button$i configure -default normal
|
| 110 |
+
}
|
| 111 |
+
grid $w.button$i -in $w.bot -column $i -row 0 -sticky ew \
|
| 112 |
+
-padx 10 -pady 4
|
| 113 |
+
grid columnconfigure $w.bot $i
|
| 114 |
+
# We boost the size of some Mac buttons for l&f
|
| 115 |
+
if {$windowingsystem eq "aqua"} {
|
| 116 |
+
set tmp [string tolower $but]
|
| 117 |
+
if {$tmp eq "ok" || $tmp eq "cancel"} {
|
| 118 |
+
grid columnconfigure $w.bot $i -minsize 90
|
| 119 |
+
}
|
| 120 |
+
grid configure $w.button$i -pady 7
|
| 121 |
+
}
|
| 122 |
+
incr i
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
# 4. Create a binding for <Return> on the dialog if there is a
|
| 126 |
+
# default button.
|
| 127 |
+
# Convention also dictates that if the keyboard focus moves among the
|
| 128 |
+
# the buttons that the <Return> binding affects the button with the focus.
|
| 129 |
+
|
| 130 |
+
if {$default >= 0} {
|
| 131 |
+
bind $w <Return> [list $w.button$default invoke]
|
| 132 |
+
}
|
| 133 |
+
bind $w <<PrevWindow>> [list bind $w <Return> {[tk_focusPrev %W] invoke}]
|
| 134 |
+
bind $w <<NextWindow>> [list bind $w <Return> {[tk_focusNext %W] invoke}]
|
| 135 |
+
|
| 136 |
+
# 5. Create a <Destroy> binding for the window that sets the
|
| 137 |
+
# button variable to -1; this is needed in case something happens
|
| 138 |
+
# that destroys the window, such as its parent window being destroyed.
|
| 139 |
+
|
| 140 |
+
bind $w <Destroy> {set ::tk::Priv(button) -1}
|
| 141 |
+
|
| 142 |
+
# 6. Withdraw the window, then update all the geometry information
|
| 143 |
+
# so we know how big it wants to be, then center the window in the
|
| 144 |
+
# display (Motif style) and de-iconify it.
|
| 145 |
+
|
| 146 |
+
::tk::PlaceWindow $w
|
| 147 |
+
tkwait visibility $w
|
| 148 |
+
|
| 149 |
+
# 7. Set a grab and claim the focus too.
|
| 150 |
+
|
| 151 |
+
if {$default >= 0} {
|
| 152 |
+
set focus $w.button$default
|
| 153 |
+
} else {
|
| 154 |
+
set focus $w
|
| 155 |
+
}
|
| 156 |
+
tk::SetFocusGrab $w $focus
|
| 157 |
+
|
| 158 |
+
# 8. Wait for the user to respond, then restore the focus and
|
| 159 |
+
# return the index of the selected button. Restore the focus
|
| 160 |
+
# before deleting the window, since otherwise the window manager
|
| 161 |
+
# may take the focus away so we can't redirect it. Finally,
|
| 162 |
+
# restore any grab that was in effect.
|
| 163 |
+
|
| 164 |
+
vwait ::tk::Priv(button)
|
| 165 |
+
|
| 166 |
+
catch {
|
| 167 |
+
# It's possible that the window has already been destroyed,
|
| 168 |
+
# hence this "catch". Delete the Destroy handler so that
|
| 169 |
+
# Priv(button) doesn't get reset by it.
|
| 170 |
+
|
| 171 |
+
bind $w <Destroy> {}
|
| 172 |
+
}
|
| 173 |
+
tk::RestoreFocusGrab $w $focus
|
| 174 |
+
return $Priv(button)
|
| 175 |
+
}
|
mplug_owl2/lib/tk8.6/entry.tcl
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 [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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# focus.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines several procedures for managing the input
|
| 4 |
+
# focus.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1994-1995 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_focusNext --
|
| 13 |
+
# This procedure returns the name of the next window after "w" in
|
| 14 |
+
# "focus order" (the window that should receive the focus next if
|
| 15 |
+
# Tab is typed in w). "Next" is defined by a pre-order search
|
| 16 |
+
# of a top-level and its non-top-level descendants, with the stacking
|
| 17 |
+
# order determining the order of siblings. The "-takefocus" options
|
| 18 |
+
# on windows determine whether or not they should be skipped.
|
| 19 |
+
#
|
| 20 |
+
# Arguments:
|
| 21 |
+
# w - Name of a window.
|
| 22 |
+
|
| 23 |
+
proc ::tk_focusNext w {
|
| 24 |
+
set cur $w
|
| 25 |
+
while {1} {
|
| 26 |
+
|
| 27 |
+
# Descend to just before the first child of the current widget.
|
| 28 |
+
|
| 29 |
+
set parent $cur
|
| 30 |
+
set children [winfo children $cur]
|
| 31 |
+
set i -1
|
| 32 |
+
|
| 33 |
+
# Look for the next sibling that isn't a top-level.
|
| 34 |
+
|
| 35 |
+
while {1} {
|
| 36 |
+
incr i
|
| 37 |
+
if {$i < [llength $children]} {
|
| 38 |
+
set cur [lindex $children $i]
|
| 39 |
+
if {[winfo toplevel $cur] eq $cur} {
|
| 40 |
+
continue
|
| 41 |
+
} else {
|
| 42 |
+
break
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# No more siblings, so go to the current widget's parent.
|
| 47 |
+
# If it's a top-level, break out of the loop, otherwise
|
| 48 |
+
# look for its next sibling.
|
| 49 |
+
|
| 50 |
+
set cur $parent
|
| 51 |
+
if {[winfo toplevel $cur] eq $cur} {
|
| 52 |
+
break
|
| 53 |
+
}
|
| 54 |
+
set parent [winfo parent $parent]
|
| 55 |
+
set children [winfo children $parent]
|
| 56 |
+
set i [lsearch -exact $children $cur]
|
| 57 |
+
}
|
| 58 |
+
if {$w eq $cur || [tk::FocusOK $cur]} {
|
| 59 |
+
return $cur
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
# ::tk_focusPrev --
|
| 65 |
+
# This procedure returns the name of the previous window before "w" in
|
| 66 |
+
# "focus order" (the window that should receive the focus next if
|
| 67 |
+
# Shift-Tab is typed in w). "Next" is defined by a pre-order search
|
| 68 |
+
# of a top-level and its non-top-level descendants, with the stacking
|
| 69 |
+
# order determining the order of siblings. The "-takefocus" options
|
| 70 |
+
# on windows determine whether or not they should be skipped.
|
| 71 |
+
#
|
| 72 |
+
# Arguments:
|
| 73 |
+
# w - Name of a window.
|
| 74 |
+
|
| 75 |
+
proc ::tk_focusPrev w {
|
| 76 |
+
set cur $w
|
| 77 |
+
while {1} {
|
| 78 |
+
|
| 79 |
+
# Collect information about the current window's position
|
| 80 |
+
# among its siblings. Also, if the window is a top-level,
|
| 81 |
+
# then reposition to just after the last child of the window.
|
| 82 |
+
|
| 83 |
+
if {[winfo toplevel $cur] eq $cur} {
|
| 84 |
+
set parent $cur
|
| 85 |
+
set children [winfo children $cur]
|
| 86 |
+
set i [llength $children]
|
| 87 |
+
} else {
|
| 88 |
+
set parent [winfo parent $cur]
|
| 89 |
+
set children [winfo children $parent]
|
| 90 |
+
set i [lsearch -exact $children $cur]
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
# Go to the previous sibling, then descend to its last descendant
|
| 94 |
+
# (highest in stacking order. While doing this, ignore top-levels
|
| 95 |
+
# and their descendants. When we run out of descendants, go up
|
| 96 |
+
# one level to the parent.
|
| 97 |
+
|
| 98 |
+
while {$i > 0} {
|
| 99 |
+
incr i -1
|
| 100 |
+
set cur [lindex $children $i]
|
| 101 |
+
if {[winfo toplevel $cur] eq $cur} {
|
| 102 |
+
continue
|
| 103 |
+
}
|
| 104 |
+
set parent $cur
|
| 105 |
+
set children [winfo children $parent]
|
| 106 |
+
set i [llength $children]
|
| 107 |
+
}
|
| 108 |
+
set cur $parent
|
| 109 |
+
if {$w eq $cur || [tk::FocusOK $cur]} {
|
| 110 |
+
return $cur
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# ::tk::FocusOK --
|
| 116 |
+
#
|
| 117 |
+
# This procedure is invoked to decide whether or not to focus on
|
| 118 |
+
# a given window. It returns 1 if it's OK to focus on the window,
|
| 119 |
+
# 0 if it's not OK. The code first checks whether the window is
|
| 120 |
+
# viewable. If not, then it never focuses on the window. Then it
|
| 121 |
+
# checks the -takefocus option for the window and uses it if it's
|
| 122 |
+
# set. If there's no -takefocus option, the procedure checks to
|
| 123 |
+
# see if (a) the widget isn't disabled, and (b) it has some key
|
| 124 |
+
# bindings. If all of these are true, then 1 is returned.
|
| 125 |
+
#
|
| 126 |
+
# Arguments:
|
| 127 |
+
# w - Name of a window.
|
| 128 |
+
|
| 129 |
+
proc ::tk::FocusOK w {
|
| 130 |
+
set code [catch {$w cget -takefocus} value]
|
| 131 |
+
if {($code == 0) && ($value ne "")} {
|
| 132 |
+
if {$value == 0} {
|
| 133 |
+
return 0
|
| 134 |
+
} elseif {$value == 1} {
|
| 135 |
+
return [winfo viewable $w]
|
| 136 |
+
} else {
|
| 137 |
+
set value [uplevel #0 $value [list $w]]
|
| 138 |
+
if {$value ne ""} {
|
| 139 |
+
return $value
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
if {![winfo viewable $w]} {
|
| 144 |
+
return 0
|
| 145 |
+
}
|
| 146 |
+
set code [catch {$w cget -state} value]
|
| 147 |
+
if {($code == 0) && $value eq "disabled"} {
|
| 148 |
+
return 0
|
| 149 |
+
}
|
| 150 |
+
regexp Key|Focus "[bind $w] [bind [winfo class $w]]"
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
# ::tk_focusFollowsMouse --
|
| 154 |
+
#
|
| 155 |
+
# If this procedure is invoked, Tk will enter "focus-follows-mouse"
|
| 156 |
+
# mode, where the focus is always on whatever window contains the
|
| 157 |
+
# mouse. If this procedure isn't invoked, then the user typically
|
| 158 |
+
# has to click on a window to give it the focus.
|
| 159 |
+
#
|
| 160 |
+
# Arguments:
|
| 161 |
+
# None.
|
| 162 |
+
|
| 163 |
+
proc ::tk_focusFollowsMouse {} {
|
| 164 |
+
set old [bind all <Enter>]
|
| 165 |
+
set script {
|
| 166 |
+
if {"%d" eq "NotifyAncestor" || "%d" eq "NotifyNonlinear" \
|
| 167 |
+
|| "%d" eq "NotifyInferior"} {
|
| 168 |
+
if {[tk::FocusOK %W]} {
|
| 169 |
+
focus %W
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
if {$old ne ""} {
|
| 174 |
+
bind all <Enter> "$old; $script"
|
| 175 |
+
} else {
|
| 176 |
+
bind all <Enter> $script
|
| 177 |
+
}
|
| 178 |
+
}
|
mplug_owl2/lib/tk8.6/fontchooser.tcl
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/iconlist.tcl
AD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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# iconlist.tcl
|
| 2 |
+
#
|
| 3 |
+
# Implements the icon-list megawidget used in the "Tk" standard file
|
| 4 |
+
# selection dialog boxes.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
|
| 7 |
+
# Copyright (c) 2009 Donal K. Fellows
|
| 8 |
+
#
|
| 9 |
+
# See the file "license.terms" for information on usage and redistribution of
|
| 10 |
+
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 11 |
+
#
|
| 12 |
+
# API Summary:
|
| 13 |
+
# tk::IconList <path> ?<option> <value>? ...
|
| 14 |
+
# <path> add <imageName> <itemList>
|
| 15 |
+
# <path> cget <option>
|
| 16 |
+
# <path> configure ?<option>? ?<value>? ...
|
| 17 |
+
# <path> deleteall
|
| 18 |
+
# <path> destroy
|
| 19 |
+
# <path> get <itemIndex>
|
| 20 |
+
# <path> index <index>
|
| 21 |
+
# <path> invoke
|
| 22 |
+
# <path> see <index>
|
| 23 |
+
# <path> selection anchor ?<int>?
|
| 24 |
+
# <path> selection clear <first> ?<last>?
|
| 25 |
+
# <path> selection get
|
| 26 |
+
# <path> selection includes <item>
|
| 27 |
+
# <path> selection set <first> ?<last>?
|
| 28 |
+
|
| 29 |
+
package require Tk
|
| 30 |
+
|
| 31 |
+
::tk::Megawidget create ::tk::IconList ::tk::FocusableWidget {
|
| 32 |
+
variable w canvas sbar accel accelCB fill font index \
|
| 33 |
+
itemList itemsPerColumn list maxIH maxIW maxTH maxTW noScroll \
|
| 34 |
+
numItems oldX oldY options rect selected selection textList
|
| 35 |
+
constructor args {
|
| 36 |
+
next {*}$args
|
| 37 |
+
set accelCB {}
|
| 38 |
+
}
|
| 39 |
+
destructor {
|
| 40 |
+
my Reset
|
| 41 |
+
next
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
method GetSpecs {} {
|
| 45 |
+
concat [next] {
|
| 46 |
+
{-command "" "" ""}
|
| 47 |
+
{-font "" "" "TkIconFont"}
|
| 48 |
+
{-multiple "" "" "0"}
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
# ----------------------------------------------------------------------
|
| 53 |
+
|
| 54 |
+
method index i {
|
| 55 |
+
if {![info exist list]} {
|
| 56 |
+
set list {}
|
| 57 |
+
}
|
| 58 |
+
switch -regexp -- $i {
|
| 59 |
+
"^-?[0-9]+$" {
|
| 60 |
+
if {$i < 0} {
|
| 61 |
+
set i 0
|
| 62 |
+
}
|
| 63 |
+
if {$i >= [llength $list]} {
|
| 64 |
+
set i [expr {[llength $list] - 1}]
|
| 65 |
+
}
|
| 66 |
+
return $i
|
| 67 |
+
}
|
| 68 |
+
"^anchor$" {
|
| 69 |
+
return $index(anchor)
|
| 70 |
+
}
|
| 71 |
+
"^end$" {
|
| 72 |
+
return [llength $list]
|
| 73 |
+
}
|
| 74 |
+
"@-?[0-9]+,-?[0-9]+" {
|
| 75 |
+
scan $i "@%d,%d" x y
|
| 76 |
+
set item [$canvas find closest \
|
| 77 |
+
[$canvas canvasx $x] [$canvas canvasy $y]]
|
| 78 |
+
return [lindex [$canvas itemcget $item -tags] 1]
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
method selection {op args} {
|
| 84 |
+
switch -exact -- $op {
|
| 85 |
+
anchor {
|
| 86 |
+
if {[llength $args] == 1} {
|
| 87 |
+
set index(anchor) [$w index [lindex $args 0]]
|
| 88 |
+
} else {
|
| 89 |
+
return $index(anchor)
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
clear {
|
| 93 |
+
switch [llength $args] {
|
| 94 |
+
2 {
|
| 95 |
+
lassign $args first last
|
| 96 |
+
}
|
| 97 |
+
1 {
|
| 98 |
+
set first [set last [lindex $args 0]]
|
| 99 |
+
}
|
| 100 |
+
default {
|
| 101 |
+
return -code error -errorcode {TCL WRONGARGS} \
|
| 102 |
+
"wrong # args: should be\
|
| 103 |
+
\"[lrange [info level 0] 0 1] first ?last?\""
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
set first [$w index $first]
|
| 108 |
+
set last [$w index $last]
|
| 109 |
+
if {$first > $last} {
|
| 110 |
+
set tmp $first
|
| 111 |
+
set first $last
|
| 112 |
+
set last $tmp
|
| 113 |
+
}
|
| 114 |
+
set ind 0
|
| 115 |
+
foreach item $selection {
|
| 116 |
+
if {$item >= $first} {
|
| 117 |
+
set first $ind
|
| 118 |
+
break
|
| 119 |
+
}
|
| 120 |
+
incr ind
|
| 121 |
+
}
|
| 122 |
+
set ind [expr {[llength $selection] - 1}]
|
| 123 |
+
for {} {$ind >= 0} {incr ind -1} {
|
| 124 |
+
set item [lindex $selection $ind]
|
| 125 |
+
if {$item <= $last} {
|
| 126 |
+
set last $ind
|
| 127 |
+
break
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
if {$first > $last} {
|
| 132 |
+
return
|
| 133 |
+
}
|
| 134 |
+
set selection [lreplace $selection $first $last]
|
| 135 |
+
event generate $w <<ListboxSelect>>
|
| 136 |
+
my DrawSelection
|
| 137 |
+
}
|
| 138 |
+
get {
|
| 139 |
+
return $selection
|
| 140 |
+
}
|
| 141 |
+
includes {
|
| 142 |
+
return [expr {[lindex $args 0] in $selection}]
|
| 143 |
+
}
|
| 144 |
+
set {
|
| 145 |
+
switch [llength $args] {
|
| 146 |
+
2 {
|
| 147 |
+
lassign $args first last
|
| 148 |
+
}
|
| 149 |
+
1 {
|
| 150 |
+
set first [set last [lindex $args 0]]
|
| 151 |
+
}
|
| 152 |
+
default {
|
| 153 |
+
return -code error -errorcode {TCL WRONGARGS} \
|
| 154 |
+
"wrong # args: should be\
|
| 155 |
+
\"[lrange [info level 0] 0 1] first ?last?\""
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
set first [$w index $first]
|
| 160 |
+
set last [$w index $last]
|
| 161 |
+
if {$first > $last} {
|
| 162 |
+
set tmp $first
|
| 163 |
+
set first $last
|
| 164 |
+
set last $tmp
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
for {set i $first} {$i <= $last} {incr i} {
|
| 168 |
+
lappend selection $i
|
| 169 |
+
}
|
| 170 |
+
set selection [lsort -integer -unique $selection]
|
| 171 |
+
event generate $w <<ListboxSelect>>
|
| 172 |
+
my DrawSelection
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
method get item {
|
| 178 |
+
set rTag [lindex $list $item 2]
|
| 179 |
+
lassign $itemList($rTag) iTag tTag text serial
|
| 180 |
+
return $text
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
# Deletes all the items inside the canvas subwidget and reset the
|
| 184 |
+
# iconList's state.
|
| 185 |
+
#
|
| 186 |
+
method deleteall {} {
|
| 187 |
+
$canvas delete all
|
| 188 |
+
unset -nocomplain selected rect list itemList
|
| 189 |
+
set maxIW 1
|
| 190 |
+
set maxIH 1
|
| 191 |
+
set maxTW 1
|
| 192 |
+
set maxTH 1
|
| 193 |
+
set numItems 0
|
| 194 |
+
set noScroll 1
|
| 195 |
+
set selection {}
|
| 196 |
+
set index(anchor) ""
|
| 197 |
+
$sbar set 0.0 1.0
|
| 198 |
+
$canvas xview moveto 0
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
# Adds an icon into the IconList with the designated image and text
|
| 202 |
+
#
|
| 203 |
+
method add {image items} {
|
| 204 |
+
foreach text $items {
|
| 205 |
+
set iID item$numItems
|
| 206 |
+
set iTag [$canvas create image 0 0 -image $image -anchor nw \
|
| 207 |
+
-tags [list icon $numItems $iID]]
|
| 208 |
+
set tTag [$canvas create text 0 0 -text $text -anchor nw \
|
| 209 |
+
-font $options(-font) -fill $fill \
|
| 210 |
+
-tags [list text $numItems $iID]]
|
| 211 |
+
set rTag [$canvas create rect 0 0 0 0 -fill "" -outline "" \
|
| 212 |
+
-tags [list rect $numItems $iID]]
|
| 213 |
+
|
| 214 |
+
lassign [$canvas bbox $iTag] x1 y1 x2 y2
|
| 215 |
+
set iW [expr {$x2 - $x1}]
|
| 216 |
+
set iH [expr {$y2 - $y1}]
|
| 217 |
+
if {$maxIW < $iW} {
|
| 218 |
+
set maxIW $iW
|
| 219 |
+
}
|
| 220 |
+
if {$maxIH < $iH} {
|
| 221 |
+
set maxIH $iH
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
lassign [$canvas bbox $tTag] x1 y1 x2 y2
|
| 225 |
+
set tW [expr {$x2 - $x1}]
|
| 226 |
+
set tH [expr {$y2 - $y1}]
|
| 227 |
+
if {$maxTW < $tW} {
|
| 228 |
+
set maxTW $tW
|
| 229 |
+
}
|
| 230 |
+
if {$maxTH < $tH} {
|
| 231 |
+
set maxTH $tH
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
lappend list [list $iTag $tTag $rTag $iW $iH $tW $tH $numItems]
|
| 235 |
+
set itemList($rTag) [list $iTag $tTag $text $numItems]
|
| 236 |
+
set textList($numItems) [string tolower $text]
|
| 237 |
+
incr numItems
|
| 238 |
+
}
|
| 239 |
+
my WhenIdle Arrange
|
| 240 |
+
return
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
# Gets called when the user invokes the IconList (usually by
|
| 244 |
+
# double-clicking or pressing the Return key).
|
| 245 |
+
#
|
| 246 |
+
method invoke {} {
|
| 247 |
+
if {$options(-command) ne "" && [llength $selection]} {
|
| 248 |
+
uplevel #0 $options(-command)
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
# If the item is not (completely) visible, scroll the canvas so that it
|
| 253 |
+
# becomes visible.
|
| 254 |
+
#
|
| 255 |
+
method see rTag {
|
| 256 |
+
if {$noScroll} {
|
| 257 |
+
return
|
| 258 |
+
}
|
| 259 |
+
set sRegion [$canvas cget -scrollregion]
|
| 260 |
+
if {$sRegion eq ""} {
|
| 261 |
+
return
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
if {$rTag < 0 || $rTag >= [llength $list]} {
|
| 265 |
+
return
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
set bbox [$canvas bbox item$rTag]
|
| 269 |
+
set pad [expr {[$canvas cget -highlightthickness]+[$canvas cget -bd]}]
|
| 270 |
+
|
| 271 |
+
set x1 [lindex $bbox 0]
|
| 272 |
+
set x2 [lindex $bbox 2]
|
| 273 |
+
incr x1 [expr {$pad * -2}]
|
| 274 |
+
incr x2 [expr {$pad * -1}]
|
| 275 |
+
|
| 276 |
+
set cW [expr {[winfo width $canvas] - $pad*2}]
|
| 277 |
+
|
| 278 |
+
set scrollW [expr {[lindex $sRegion 2]-[lindex $sRegion 0]+1}]
|
| 279 |
+
set dispX [expr {int([lindex [$canvas xview] 0]*$scrollW)}]
|
| 280 |
+
set oldDispX $dispX
|
| 281 |
+
|
| 282 |
+
# check if out of the right edge
|
| 283 |
+
#
|
| 284 |
+
if {($x2 - $dispX) >= $cW} {
|
| 285 |
+
set dispX [expr {$x2 - $cW}]
|
| 286 |
+
}
|
| 287 |
+
# check if out of the left edge
|
| 288 |
+
#
|
| 289 |
+
if {($x1 - $dispX) < 0} {
|
| 290 |
+
set dispX $x1
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
if {$oldDispX ne $dispX} {
|
| 294 |
+
set fraction [expr {double($dispX) / double($scrollW)}]
|
| 295 |
+
$canvas xview moveto $fraction
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
# ----------------------------------------------------------------------
|
| 300 |
+
|
| 301 |
+
# Places the icons in a column-major arrangement.
|
| 302 |
+
#
|
| 303 |
+
method Arrange {} {
|
| 304 |
+
if {![info exists list]} {
|
| 305 |
+
if {[info exists canvas] && [winfo exists $canvas]} {
|
| 306 |
+
set noScroll 1
|
| 307 |
+
$sbar configure -command ""
|
| 308 |
+
}
|
| 309 |
+
return
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
set W [winfo width $canvas]
|
| 313 |
+
set H [winfo height $canvas]
|
| 314 |
+
set pad [expr {[$canvas cget -highlightthickness]+[$canvas cget -bd]}]
|
| 315 |
+
if {$pad < 2} {
|
| 316 |
+
set pad 2
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
incr W [expr {$pad*-2}]
|
| 320 |
+
incr H [expr {$pad*-2}]
|
| 321 |
+
|
| 322 |
+
set dx [expr {$maxIW + $maxTW + 8}]
|
| 323 |
+
if {$maxTH > $maxIH} {
|
| 324 |
+
set dy $maxTH
|
| 325 |
+
} else {
|
| 326 |
+
set dy $maxIH
|
| 327 |
+
}
|
| 328 |
+
incr dy 2
|
| 329 |
+
set shift [expr {$maxIW + 4}]
|
| 330 |
+
|
| 331 |
+
set x [expr {$pad * 2}]
|
| 332 |
+
set y [expr {$pad * 1}] ; # Why * 1 ?
|
| 333 |
+
set usedColumn 0
|
| 334 |
+
foreach sublist $list {
|
| 335 |
+
set usedColumn 1
|
| 336 |
+
lassign $sublist iTag tTag rTag iW iH tW tH
|
| 337 |
+
|
| 338 |
+
set i_dy [expr {($dy - $iH)/2}]
|
| 339 |
+
set t_dy [expr {($dy - $tH)/2}]
|
| 340 |
+
|
| 341 |
+
$canvas coords $iTag $x [expr {$y + $i_dy}]
|
| 342 |
+
$canvas coords $tTag [expr {$x + $shift}] [expr {$y + $t_dy}]
|
| 343 |
+
$canvas coords $rTag $x $y [expr {$x+$dx}] [expr {$y+$dy}]
|
| 344 |
+
|
| 345 |
+
incr y $dy
|
| 346 |
+
if {($y + $dy) > $H} {
|
| 347 |
+
set y [expr {$pad * 1}] ; # *1 ?
|
| 348 |
+
incr x $dx
|
| 349 |
+
set usedColumn 0
|
| 350 |
+
}
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
if {$usedColumn} {
|
| 354 |
+
set sW [expr {$x + $dx}]
|
| 355 |
+
} else {
|
| 356 |
+
set sW $x
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
if {$sW < $W} {
|
| 360 |
+
$canvas configure -scrollregion [list $pad $pad $sW $H]
|
| 361 |
+
$sbar configure -command ""
|
| 362 |
+
$canvas xview moveto 0
|
| 363 |
+
set noScroll 1
|
| 364 |
+
} else {
|
| 365 |
+
$canvas configure -scrollregion [list $pad $pad $sW $H]
|
| 366 |
+
$sbar configure -command [list $canvas xview]
|
| 367 |
+
set noScroll 0
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
set itemsPerColumn [expr {($H-$pad) / $dy}]
|
| 371 |
+
if {$itemsPerColumn < 1} {
|
| 372 |
+
set itemsPerColumn 1
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
my DrawSelection
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
method DrawSelection {} {
|
| 379 |
+
$canvas delete selection
|
| 380 |
+
$canvas itemconfigure selectionText -fill $fill
|
| 381 |
+
$canvas dtag selectionText
|
| 382 |
+
set cbg [ttk::style lookup TEntry -selectbackground focus]
|
| 383 |
+
set cfg [ttk::style lookup TEntry -selectforeground focus]
|
| 384 |
+
foreach item $selection {
|
| 385 |
+
set rTag [lindex $list $item 2]
|
| 386 |
+
foreach {iTag tTag text serial} $itemList($rTag) {
|
| 387 |
+
break
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
set bbox [$canvas bbox $tTag]
|
| 391 |
+
$canvas create rect $bbox -fill $cbg -outline $cbg \
|
| 392 |
+
-tags selection
|
| 393 |
+
$canvas itemconfigure $tTag -fill $cfg -tags selectionText
|
| 394 |
+
}
|
| 395 |
+
$canvas lower selection
|
| 396 |
+
return
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
# Creates an IconList widget by assembling a canvas widget and a
|
| 400 |
+
# scrollbar widget. Sets all the bindings necessary for the IconList's
|
| 401 |
+
# operations.
|
| 402 |
+
#
|
| 403 |
+
method Create {} {
|
| 404 |
+
variable hull
|
| 405 |
+
set sbar [ttk::scrollbar $hull.sbar -orient horizontal -takefocus 0]
|
| 406 |
+
catch {$sbar configure -highlightthickness 0}
|
| 407 |
+
set canvas [canvas $hull.canvas -highlightthick 0 -takefocus 1 \
|
| 408 |
+
-width 400 -height 120 -background white]
|
| 409 |
+
pack $sbar -side bottom -fill x -padx 2 -pady {0 2}
|
| 410 |
+
pack $canvas -expand yes -fill both -padx 2 -pady {2 0}
|
| 411 |
+
|
| 412 |
+
$sbar configure -command [list $canvas xview]
|
| 413 |
+
$canvas configure -xscrollcommand [list $sbar set]
|
| 414 |
+
|
| 415 |
+
# Initializes the max icon/text width and height and other variables
|
| 416 |
+
#
|
| 417 |
+
set maxIW 1
|
| 418 |
+
set maxIH 1
|
| 419 |
+
set maxTW 1
|
| 420 |
+
set maxTH 1
|
| 421 |
+
set numItems 0
|
| 422 |
+
set noScroll 1
|
| 423 |
+
set selection {}
|
| 424 |
+
set index(anchor) ""
|
| 425 |
+
set fill black
|
| 426 |
+
|
| 427 |
+
# Creates the event bindings.
|
| 428 |
+
#
|
| 429 |
+
bind $canvas <Configure> [namespace code {my WhenIdle Arrange}]
|
| 430 |
+
|
| 431 |
+
bind $canvas <Button-1> [namespace code {my Btn1 %x %y}]
|
| 432 |
+
bind $canvas <B1-Motion> [namespace code {my Motion1 %x %y}]
|
| 433 |
+
bind $canvas <B1-Leave> [namespace code {my Leave1 %x %y}]
|
| 434 |
+
bind $canvas <Control-Button-1> [namespace code {my CtrlBtn1 %x %y}]
|
| 435 |
+
bind $canvas <Shift-Button-1> [namespace code {my ShiftBtn1 %x %y}]
|
| 436 |
+
bind $canvas <B1-Enter> [list tk::CancelRepeat]
|
| 437 |
+
bind $canvas <ButtonRelease-1> [list tk::CancelRepeat]
|
| 438 |
+
bind $canvas <Double-ButtonRelease-1> \
|
| 439 |
+
[namespace code {my Double1 %x %y}]
|
| 440 |
+
|
| 441 |
+
bind $canvas <Control-B1-Motion> {;}
|
| 442 |
+
bind $canvas <Shift-B1-Motion> [namespace code {my ShiftMotion1 %x %y}]
|
| 443 |
+
|
| 444 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 445 |
+
bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel [expr {40 * (%D)}]}]
|
| 446 |
+
bind $canvas <Option-Shift-MouseWheel> [namespace code {my MouseWheel [expr {400 * (%D)}]}]
|
| 447 |
+
bind $canvas <Command-Key> {# nothing}
|
| 448 |
+
bind $canvas <Mod4-Key> {# nothing}
|
| 449 |
+
} else {
|
| 450 |
+
bind $canvas <Shift-MouseWheel> [namespace code {my MouseWheel %D}]
|
| 451 |
+
}
|
| 452 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 453 |
+
bind $canvas <Shift-Button-4> [namespace code {my MouseWheel 120}]
|
| 454 |
+
bind $canvas <Shift-Button-5> [namespace code {my MouseWheel -120}]
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
bind $canvas <<PrevLine>> [namespace code {my UpDown -1}]
|
| 458 |
+
bind $canvas <<NextLine>> [namespace code {my UpDown 1}]
|
| 459 |
+
bind $canvas <<PrevChar>> [namespace code {my LeftRight -1}]
|
| 460 |
+
bind $canvas <<NextChar>> [namespace code {my LeftRight 1}]
|
| 461 |
+
bind $canvas <Return> [namespace code {my ReturnKey}]
|
| 462 |
+
bind $canvas <Key> [namespace code {my KeyPress %A}]
|
| 463 |
+
bind $canvas <Alt-Key> {# nothing}
|
| 464 |
+
bind $canvas <Meta-Key> {# nothing}
|
| 465 |
+
bind $canvas <Control-Key> {# nothing}
|
| 466 |
+
|
| 467 |
+
bind $canvas <FocusIn> [namespace code {my FocusIn}]
|
| 468 |
+
bind $canvas <FocusOut> [namespace code {my FocusOut}]
|
| 469 |
+
|
| 470 |
+
return $w
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
# This procedure is invoked when the mouse leaves an entry window with
|
| 474 |
+
# button 1 down. It scrolls the window up, down, left, or right,
|
| 475 |
+
# depending on where the mouse left the window, and reschedules itself
|
| 476 |
+
# as an "after" command so that the window continues to scroll until the
|
| 477 |
+
# mouse moves back into the window or the mouse button is released.
|
| 478 |
+
#
|
| 479 |
+
method AutoScan {} {
|
| 480 |
+
if {![winfo exists $w]} return
|
| 481 |
+
set x $oldX
|
| 482 |
+
set y $oldY
|
| 483 |
+
if {$noScroll} {
|
| 484 |
+
return
|
| 485 |
+
}
|
| 486 |
+
if {$x >= [winfo width $canvas]} {
|
| 487 |
+
$canvas xview scroll 1 units
|
| 488 |
+
} elseif {$x < 0} {
|
| 489 |
+
$canvas xview scroll -1 units
|
| 490 |
+
} elseif {$y >= [winfo height $canvas]} {
|
| 491 |
+
# do nothing
|
| 492 |
+
} elseif {$y < 0} {
|
| 493 |
+
# do nothing
|
| 494 |
+
} else {
|
| 495 |
+
return
|
| 496 |
+
}
|
| 497 |
+
my Motion1 $x $y
|
| 498 |
+
set ::tk::Priv(afterId) [after 50 [namespace code {my AutoScan}]]
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
# ----------------------------------------------------------------------
|
| 502 |
+
|
| 503 |
+
# Event handlers
|
| 504 |
+
method MouseWheel {amount} {
|
| 505 |
+
if {$noScroll || $::tk_strictMotif} {
|
| 506 |
+
return
|
| 507 |
+
}
|
| 508 |
+
if {$amount > 0} {
|
| 509 |
+
$canvas xview scroll [expr {(-119-$amount) / 120}] units
|
| 510 |
+
} else {
|
| 511 |
+
$canvas xview scroll [expr {-($amount / 120)}] units
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
method Btn1 {x y} {
|
| 515 |
+
focus $canvas
|
| 516 |
+
set i [$w index @$x,$y]
|
| 517 |
+
if {$i eq ""} {
|
| 518 |
+
return
|
| 519 |
+
}
|
| 520 |
+
$w selection clear 0 end
|
| 521 |
+
$w selection set $i
|
| 522 |
+
$w selection anchor $i
|
| 523 |
+
}
|
| 524 |
+
method CtrlBtn1 {x y} {
|
| 525 |
+
if {$options(-multiple)} {
|
| 526 |
+
focus $canvas
|
| 527 |
+
set i [$w index @$x,$y]
|
| 528 |
+
if {$i eq ""} {
|
| 529 |
+
return
|
| 530 |
+
}
|
| 531 |
+
if {[$w selection includes $i]} {
|
| 532 |
+
$w selection clear $i
|
| 533 |
+
} else {
|
| 534 |
+
$w selection set $i
|
| 535 |
+
$w selection anchor $i
|
| 536 |
+
}
|
| 537 |
+
}
|
| 538 |
+
}
|
| 539 |
+
method ShiftBtn1 {x y} {
|
| 540 |
+
if {$options(-multiple)} {
|
| 541 |
+
focus $canvas
|
| 542 |
+
set i [$w index @$x,$y]
|
| 543 |
+
if {$i eq ""} {
|
| 544 |
+
return
|
| 545 |
+
}
|
| 546 |
+
if {[$w index anchor] eq ""} {
|
| 547 |
+
$w selection anchor $i
|
| 548 |
+
}
|
| 549 |
+
$w selection clear 0 end
|
| 550 |
+
$w selection set anchor $i
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
# Gets called on button-1 motions
|
| 555 |
+
#
|
| 556 |
+
method Motion1 {x y} {
|
| 557 |
+
set oldX $x
|
| 558 |
+
set oldY $y
|
| 559 |
+
set i [$w index @$x,$y]
|
| 560 |
+
if {$i eq ""} {
|
| 561 |
+
return
|
| 562 |
+
}
|
| 563 |
+
$w selection clear 0 end
|
| 564 |
+
$w selection set $i
|
| 565 |
+
}
|
| 566 |
+
method ShiftMotion1 {x y} {
|
| 567 |
+
set oldX $x
|
| 568 |
+
set oldY $y
|
| 569 |
+
set i [$w index @$x,$y]
|
| 570 |
+
if {$i eq ""} {
|
| 571 |
+
return
|
| 572 |
+
}
|
| 573 |
+
$w selection clear 0 end
|
| 574 |
+
$w selection set anchor $i
|
| 575 |
+
}
|
| 576 |
+
method Double1 {x y} {
|
| 577 |
+
if {[llength $selection]} {
|
| 578 |
+
$w invoke
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
method ReturnKey {} {
|
| 582 |
+
$w invoke
|
| 583 |
+
}
|
| 584 |
+
method Leave1 {x y} {
|
| 585 |
+
set oldX $x
|
| 586 |
+
set oldY $y
|
| 587 |
+
my AutoScan
|
| 588 |
+
}
|
| 589 |
+
method FocusIn {} {
|
| 590 |
+
$w state focus
|
| 591 |
+
if {![info exists list]} {
|
| 592 |
+
return
|
| 593 |
+
}
|
| 594 |
+
if {[llength $selection]} {
|
| 595 |
+
my DrawSelection
|
| 596 |
+
}
|
| 597 |
+
}
|
| 598 |
+
method FocusOut {} {
|
| 599 |
+
$w state !focus
|
| 600 |
+
$w selection clear 0 end
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
# Moves the active element up or down by one element
|
| 604 |
+
#
|
| 605 |
+
# Arguments:
|
| 606 |
+
# amount - +1 to move down one item, -1 to move back one item.
|
| 607 |
+
#
|
| 608 |
+
method UpDown amount {
|
| 609 |
+
if {![info exists list]} {
|
| 610 |
+
return
|
| 611 |
+
}
|
| 612 |
+
set curr [$w selection get]
|
| 613 |
+
if {[llength $curr] == 0} {
|
| 614 |
+
set i 0
|
| 615 |
+
} else {
|
| 616 |
+
set i [$w index anchor]
|
| 617 |
+
if {$i eq ""} {
|
| 618 |
+
return
|
| 619 |
+
}
|
| 620 |
+
incr i $amount
|
| 621 |
+
}
|
| 622 |
+
$w selection clear 0 end
|
| 623 |
+
$w selection set $i
|
| 624 |
+
$w selection anchor $i
|
| 625 |
+
$w see $i
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
# Moves the active element left or right by one column
|
| 629 |
+
#
|
| 630 |
+
# Arguments:
|
| 631 |
+
# amount - +1 to move right one column, -1 to move left one
|
| 632 |
+
# column
|
| 633 |
+
#
|
| 634 |
+
method LeftRight amount {
|
| 635 |
+
if {![info exists list]} {
|
| 636 |
+
return
|
| 637 |
+
}
|
| 638 |
+
set curr [$w selection get]
|
| 639 |
+
if {[llength $curr] == 0} {
|
| 640 |
+
set i 0
|
| 641 |
+
} else {
|
| 642 |
+
set i [$w index anchor]
|
| 643 |
+
if {$i eq ""} {
|
| 644 |
+
return
|
| 645 |
+
}
|
| 646 |
+
incr i [expr {$amount * $itemsPerColumn}]
|
| 647 |
+
}
|
| 648 |
+
$w selection clear 0 end
|
| 649 |
+
$w selection set $i
|
| 650 |
+
$w selection anchor $i
|
| 651 |
+
$w see $i
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
# Gets called when user enters an arbitrary key in the listbox.
|
| 655 |
+
#
|
| 656 |
+
method KeyPress key {
|
| 657 |
+
append accel $key
|
| 658 |
+
my Goto $accel
|
| 659 |
+
after cancel $accelCB
|
| 660 |
+
set accelCB [after 500 [namespace code {my Reset}]]
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
method Goto text {
|
| 664 |
+
if {![info exists list]} {
|
| 665 |
+
return
|
| 666 |
+
}
|
| 667 |
+
if {$text eq "" || $numItems == 0} {
|
| 668 |
+
return
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
if {[llength [$w selection get]]} {
|
| 672 |
+
set start [$w index anchor]
|
| 673 |
+
} else {
|
| 674 |
+
set start 0
|
| 675 |
+
}
|
| 676 |
+
set theIndex -1
|
| 677 |
+
set less 0
|
| 678 |
+
set len [string length $text]
|
| 679 |
+
set len0 [expr {$len - 1}]
|
| 680 |
+
set i $start
|
| 681 |
+
|
| 682 |
+
# Search forward until we find a filename whose prefix is a
|
| 683 |
+
# case-insensitive match with $text
|
| 684 |
+
while {1} {
|
| 685 |
+
if {[string equal -nocase -length $len0 $textList($i) $text]} {
|
| 686 |
+
set theIndex $i
|
| 687 |
+
break
|
| 688 |
+
}
|
| 689 |
+
incr i
|
| 690 |
+
if {$i == $numItems} {
|
| 691 |
+
set i 0
|
| 692 |
+
}
|
| 693 |
+
if {$i == $start} {
|
| 694 |
+
break
|
| 695 |
+
}
|
| 696 |
+
}
|
| 697 |
+
|
| 698 |
+
if {$theIndex >= 0} {
|
| 699 |
+
$w selection clear 0 end
|
| 700 |
+
$w selection set $theIndex
|
| 701 |
+
$w selection anchor $theIndex
|
| 702 |
+
$w see $theIndex
|
| 703 |
+
}
|
| 704 |
+
}
|
| 705 |
+
method Reset {} {
|
| 706 |
+
unset -nocomplain accel
|
| 707 |
+
}
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
return
|
| 711 |
+
|
| 712 |
+
# Local Variables:
|
| 713 |
+
# mode: tcl
|
| 714 |
+
# fill-column: 78
|
| 715 |
+
# End:
|
mplug_owl2/lib/tk8.6/icons.tcl
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# icons.tcl --
|
| 2 |
+
#
|
| 3 |
+
# A set of stock icons for use in Tk dialogs. The icons used here
|
| 4 |
+
# were provided by the Tango Desktop project which provides a
|
| 5 |
+
# unified set of high quality icons licensed under the
|
| 6 |
+
# Creative Commons Attribution Share-Alike license
|
| 7 |
+
# (https://creativecommons.org/licenses/by-sa/3.0/)
|
| 8 |
+
#
|
| 9 |
+
# See http://tango.freedesktop.org/Tango_Desktop_Project
|
| 10 |
+
#
|
| 11 |
+
# Copyright (c) 2009 Pat Thoyts <patthoyts@users.sourceforge.net>
|
| 12 |
+
|
| 13 |
+
namespace eval ::tk::icons {}
|
| 14 |
+
|
| 15 |
+
image create photo ::tk::icons::warning -data {
|
| 16 |
+
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABSZJREFU
|
| 17 |
+
WIXll1toVEcYgL+Zc87u2Yu7MYmrWRuTJuvdiMuqiJd4yYKXgMQKVkSjFR80kFIVJfWCWlvpg4h9
|
| 18 |
+
8sXGWGof8iKNICYSo6JgkCBEJRG8ImYThNrNxmaTeM7pQ5IlJkabi0/9YZhhZv7///4z/8zPgf+7
|
| 19 |
+
KCNRLgdlJijXwRyuDTlcxV9hbzv8nQmxMjg+XDtiOEplkG9PSfkztGmTgmFQd+FCVzwa3fYN/PHZ
|
| 20 |
+
AcpBaReicW5xcbb64IEQqko8Lc26d/58cxS+/BY6hmJvyEfQBoUpwWCmW1FErKaGWHU13uRk4Qk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+FKAUxtm83pKMUEiLVVejLVqEtmTJB50LIdi2bRuFPbnRd7232efM
|
| 34 |
+
wbVuHR2PHjHR77dJXS8sg5mDAihweFJenmrevYvR1oazpGTQ6IQQaJqG7ClI/dd655IOHsSyLMSL
|
| 35 |
+
F6QFAib9nugEQClk2Xy+orTsbK3t1i3sa9ei5eQMGr0QgvLyci5evDiocyEEtsxMPNu30/nsGRO8
|
| 36 |
+
XlVzu8NlkNvrV+0T/fHMZcusrtu3MeNx9PXrobUVq8cYQrw3TrRub1h9+v573Bs3Ej1zBvP5c/zp
|
| 37 |
+
6dbLhoaTwPy+ANKCfF92thq7dg2A6JYt/fNlxGK8eUNSerryHEJHQT8K8V4A5ztojty8OeaLzZul
|
| 38 |
+
1DSwLCzDANPEMozusWFgmWZ33288YK3/nGlixuM0v3xpWfDX0Z4i1VupXEWwIgRnJfhGPfQ+YsLr
|
| 39 |
+
+7DzNFwCuvqWyiRg7DSYoIBu9smPkYqEd4AwIN4ITUAL0A4Da7UC6ICdEfy2fUBMoAvo7GnWKNoe
|
| 40 |
+
mfwLcAuinuFNL7QAAAAASUVORK5CYII=
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
image create photo ::tk::icons::error -data {
|
| 44 |
+
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABiRJREFU
|
| 45 |
+
WIXFl11sHFcVgL97Z/bX693sbtd2ipOqCU7sQKukFYUigQgv/a+hoZGoqipvfQKpAsEDD0hIvCHE
|
| 46 |
+
j/pQ3sIDUdOiIqUyqXioEFSUhqit7cRJFJpEruxs1mt77Z3d2Z259/KwM5vZXTtOERJXOrozZ+6e
|
| 47 |
+
852fuXcW/s9D3O3Cs1Bow1Nx234BKQ9qpYpK6yFLSseScsVoveApdUrAzNOw9j8DOAMTtmX9RsM3
|
| 48 |
+
SqOjevcXDqUzu8dI5AvEc8O0axu4q6s4yzdZvnCxUSmXLWHMXzxjXpmGq/81wGmIZ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OlV18O3D
|
| 101 |
+
1xzXGXpx8LnZO94Tbt/x+MFYouexh7dsQU/PWjRGI+BcAyMgm1vAO28fxvj4xOX5jL7u0KEX7Dvq
|
| 102 |
+
AAC0Nucf2rLZhq8Y3njjT8gulOBKDw0NAQjNQT435eQWL3iHDk3YS81ZF0B6psI/GbuAXbu+gQf7
|
| 103 |
+
H4ArPeQWC5jLZKCUhQvjWb2QD3bVk5PVM9nz5LML8waOH38fekBHIhFDqqMFXd0pnDhxGmMTU3Bd
|
| 104 |
+
9/X/GQDntO/eezswMPBjaFwAABxH4sKFq+jt7cX6ni6EQuJbdeWsZ3J3d/PTmqaEYUyhXDZBTEOh
|
| 105 |
+
WIIQwOi5jzA1eRnZXPFSPO7/bmbGlLfqhus5BVotRH9/x7rGxtBeIQJPACrMOYNSPpRiUIpnlTIO
|
| 106 |
+
nzmT+eX8fLH8WZMKF4Csje7ncUAHEKhFcHq6ZE5OZoc7O3tlc3N33+7dP9c2bXoE09NlO52uHDhy
|
| 107 |
+
ZOTVatUWte+otsTXg2pQSwagG6r/jwsAQul0erqjo+OesbGx1tHRUT+fz48dP378j57neQD8mtB1
|
| 108 |
+
B1TtnV9zo64loJqoXhtFDUQHEGhvb2/2fZ9nMpliTcAFYNdC1sIBYN1sCeq5Ca9bqtWcu9Fe3FDl
|
| 109 |
+
9Uqvu3HLjfhvTUo85WzjhogAAAAASUVORK5CYII=
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
image create photo ::tk::icons::question -data {
|
| 113 |
+
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAACG5JREFU
|
| 114 |
+
WIXFl3twVdUVxn97n3Nubm7euZcghEdeBBICEQUFIgVECqIo1uJMp3WodqyjMzpjZ7TTh20cK31N
|
| 115 |
+
/2jL2FYdKXaqRcbnDKGpoBFaAY1BHgHMgyRKQkJy87yv3Nyzd/84594k1RlppzPumTXn3Dl3r/Wd
|
| 116 |
+
b31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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/megawidget.tcl
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# megawidget.tcl
|
| 2 |
+
#
|
| 3 |
+
# Basic megawidget support classes. Experimental for any use other than
|
| 4 |
+
# the ::tk::IconList megawdget, which is itself only designed for use in
|
| 5 |
+
# the Unix file dialogs.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 2009-2010 Donal K. Fellows
|
| 8 |
+
#
|
| 9 |
+
# See the file "license.terms" for information on usage and redistribution of
|
| 10 |
+
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 11 |
+
#
|
| 12 |
+
|
| 13 |
+
package require Tk
|
| 14 |
+
|
| 15 |
+
::oo::class create ::tk::Megawidget {
|
| 16 |
+
superclass ::oo::class
|
| 17 |
+
method unknown {w args} {
|
| 18 |
+
if {[string match .* $w]} {
|
| 19 |
+
[self] create $w {*}$args
|
| 20 |
+
return $w
|
| 21 |
+
}
|
| 22 |
+
next $w {*}$args
|
| 23 |
+
}
|
| 24 |
+
unexport new unknown
|
| 25 |
+
self method create {name superclasses body} {
|
| 26 |
+
next $name [list \
|
| 27 |
+
superclass ::tk::MegawidgetClass {*}$superclasses]\;$body
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
::oo::class create ::tk::MegawidgetClass {
|
| 32 |
+
variable w hull options IdleCallbacks
|
| 33 |
+
constructor args {
|
| 34 |
+
# Extract the "widget name" from the object name
|
| 35 |
+
set w [namespace tail [self]]
|
| 36 |
+
|
| 37 |
+
# Configure things
|
| 38 |
+
tclParseConfigSpec [my varname options] [my GetSpecs] "" $args
|
| 39 |
+
|
| 40 |
+
# Move the object out of the way of the hull widget
|
| 41 |
+
rename [self] _tmp
|
| 42 |
+
|
| 43 |
+
# Make the hull widget(s)
|
| 44 |
+
my CreateHull
|
| 45 |
+
bind $hull <Destroy> [list [namespace which my] destroy]
|
| 46 |
+
|
| 47 |
+
# Rename things into their final places
|
| 48 |
+
rename ::$w theWidget
|
| 49 |
+
rename [self] ::$w
|
| 50 |
+
|
| 51 |
+
# Make the contents
|
| 52 |
+
my Create
|
| 53 |
+
}
|
| 54 |
+
destructor {
|
| 55 |
+
foreach {name cb} [array get IdleCallbacks] {
|
| 56 |
+
after cancel $cb
|
| 57 |
+
unset IdleCallbacks($name)
|
| 58 |
+
}
|
| 59 |
+
if {[winfo exists $w]} {
|
| 60 |
+
bind $hull <Destroy> {}
|
| 61 |
+
destroy $w
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
####################################################################
|
| 66 |
+
#
|
| 67 |
+
# MegawidgetClass::configure --
|
| 68 |
+
#
|
| 69 |
+
# Implementation of 'configure' for megawidgets. Emulates the operation
|
| 70 |
+
# of the standard Tk configure method fairly closely, which makes things
|
| 71 |
+
# substantially more complex than they otherwise would be.
|
| 72 |
+
#
|
| 73 |
+
# This method assumes that the 'GetSpecs' method returns a description
|
| 74 |
+
# of all the specifications of the options (i.e., as Tk returns except
|
| 75 |
+
# with the actual values removed). It also assumes that the 'options'
|
| 76 |
+
# array in the class holds all options; it is up to subclasses to set
|
| 77 |
+
# traces on that array if they want to respond to configuration changes.
|
| 78 |
+
#
|
| 79 |
+
# TODO: allow unambiguous abbreviations.
|
| 80 |
+
#
|
| 81 |
+
method configure args {
|
| 82 |
+
# Configure behaves differently depending on the number of arguments
|
| 83 |
+
set argc [llength $args]
|
| 84 |
+
if {$argc == 0} {
|
| 85 |
+
return [lmap spec [my GetSpecs] {
|
| 86 |
+
lappend spec $options([lindex $spec 0])
|
| 87 |
+
}]
|
| 88 |
+
} elseif {$argc == 1} {
|
| 89 |
+
set opt [lindex $args 0]
|
| 90 |
+
if {[info exists options($opt)]} {
|
| 91 |
+
set spec [lsearch -inline -index 0 -exact [my GetSpecs] $opt]
|
| 92 |
+
return [linsert $spec end $options($opt)]
|
| 93 |
+
}
|
| 94 |
+
} elseif {$argc == 2} {
|
| 95 |
+
# Special case for where we're setting a single option. This
|
| 96 |
+
# avoids some of the costly operations. We still do the [array
|
| 97 |
+
# get] as this gives a sufficiently-consistent trace.
|
| 98 |
+
set opt [lindex $args 0]
|
| 99 |
+
if {[dict exists [array get options] $opt]} {
|
| 100 |
+
# Actually set the new value of the option. Use a catch to
|
| 101 |
+
# allow a megawidget user to throw an error from a write trace
|
| 102 |
+
# on the options array to reject invalid values.
|
| 103 |
+
try {
|
| 104 |
+
array set options $args
|
| 105 |
+
} on error {ret info} {
|
| 106 |
+
# Rethrow the error to get a clean stack trace
|
| 107 |
+
return -code error -errorcode [dict get $info -errorcode] $ret
|
| 108 |
+
}
|
| 109 |
+
return
|
| 110 |
+
}
|
| 111 |
+
} elseif {$argc % 2 == 0} {
|
| 112 |
+
# Check that all specified options exist. Any unknown option will
|
| 113 |
+
# cause the merged dictionary to be bigger than the options array
|
| 114 |
+
set merge [dict merge [array get options] $args]
|
| 115 |
+
if {[dict size $merge] == [array size options]} {
|
| 116 |
+
# Actually set the new values of the options. Use a catch to
|
| 117 |
+
# allow a megawidget user to throw an error from a write trace
|
| 118 |
+
# on the options array to reject invalid values
|
| 119 |
+
try {
|
| 120 |
+
array set options $args
|
| 121 |
+
} on error {ret info} {
|
| 122 |
+
# Rethrow the error to get a clean stack trace
|
| 123 |
+
return -code error -errorcode [dict get $info -errorcode] $ret
|
| 124 |
+
}
|
| 125 |
+
return
|
| 126 |
+
}
|
| 127 |
+
# Due to the order of the merge, the unknown options will be at
|
| 128 |
+
# the end of the dict. This makes the first unknown option easy to
|
| 129 |
+
# find.
|
| 130 |
+
set opt [lindex [dict keys $merge] [array size options]]
|
| 131 |
+
} else {
|
| 132 |
+
set opt [lindex $args end]
|
| 133 |
+
return -code error -errorcode [list TK VALUE_MISSING] \
|
| 134 |
+
"value for \"$opt\" missing"
|
| 135 |
+
}
|
| 136 |
+
return -code error -errorcode [list TK LOOKUP OPTION $opt] \
|
| 137 |
+
"bad option \"$opt\": must be [tclListValidFlags options]"
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
####################################################################
|
| 141 |
+
#
|
| 142 |
+
# MegawidgetClass::cget --
|
| 143 |
+
#
|
| 144 |
+
# Implementation of 'cget' for megawidgets. Emulates the operation of
|
| 145 |
+
# the standard Tk cget method fairly closely.
|
| 146 |
+
#
|
| 147 |
+
# This method assumes that the 'options' array in the class holds all
|
| 148 |
+
# options; it is up to subclasses to set traces on that array if they
|
| 149 |
+
# want to respond to configuration reads.
|
| 150 |
+
#
|
| 151 |
+
# TODO: allow unambiguous abbreviations.
|
| 152 |
+
#
|
| 153 |
+
method cget option {
|
| 154 |
+
return $options($option)
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
####################################################################
|
| 158 |
+
#
|
| 159 |
+
# MegawidgetClass::TraceOption --
|
| 160 |
+
#
|
| 161 |
+
# Sets up the tracing of an element of the options variable.
|
| 162 |
+
#
|
| 163 |
+
method TraceOption {option method args} {
|
| 164 |
+
set callback [list my $method {*}$args]
|
| 165 |
+
trace add variable options($option) write [namespace code $callback]
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
####################################################################
|
| 169 |
+
#
|
| 170 |
+
# MegawidgetClass::GetSpecs --
|
| 171 |
+
#
|
| 172 |
+
# Return a list of descriptions of options supported by this
|
| 173 |
+
# megawidget. Each option is described by the 4-tuple list, consisting
|
| 174 |
+
# of the name of the option, the "option database" name, the "option
|
| 175 |
+
# database" class-name, and the default value of the option. These are
|
| 176 |
+
# the same values returned by calling the configure method of a widget,
|
| 177 |
+
# except without the current values of the options.
|
| 178 |
+
#
|
| 179 |
+
method GetSpecs {} {
|
| 180 |
+
return {
|
| 181 |
+
{-takefocus takeFocus TakeFocus {}}
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
####################################################################
|
| 186 |
+
#
|
| 187 |
+
# MegawidgetClass::CreateHull --
|
| 188 |
+
#
|
| 189 |
+
# Creates the real main widget of the megawidget. This is often a frame
|
| 190 |
+
# or toplevel widget, but isn't always (lightweight megawidgets might
|
| 191 |
+
# use a content widget directly).
|
| 192 |
+
#
|
| 193 |
+
# The name of the hull widget is given by the 'w' instance variable. The
|
| 194 |
+
# name should be written into the 'hull' instance variable. The command
|
| 195 |
+
# created by this method will be renamed.
|
| 196 |
+
#
|
| 197 |
+
method CreateHull {} {
|
| 198 |
+
return -code error -errorcode {TCL OO ABSTRACT_METHOD} \
|
| 199 |
+
"method must be overridden"
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
####################################################################
|
| 203 |
+
#
|
| 204 |
+
# MegawidgetClass::Create --
|
| 205 |
+
#
|
| 206 |
+
# Creates the content of the megawidget. The name of the widget to
|
| 207 |
+
# create the content in will be in the 'hull' instance variable.
|
| 208 |
+
#
|
| 209 |
+
method Create {} {
|
| 210 |
+
return -code error -errorcode {TCL OO ABSTRACT_METHOD} \
|
| 211 |
+
"method must be overridden"
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
####################################################################
|
| 215 |
+
#
|
| 216 |
+
# MegawidgetClass::WhenIdle --
|
| 217 |
+
#
|
| 218 |
+
# Arrange for a method to be called on the current instance when Tk is
|
| 219 |
+
# idle. Only one such method call per method will be queued; subsequent
|
| 220 |
+
# queuing actions before the callback fires will be silently ignored.
|
| 221 |
+
# The additional args will be passed to the callback, and the callbacks
|
| 222 |
+
# will be properly cancelled if the widget is destroyed.
|
| 223 |
+
#
|
| 224 |
+
method WhenIdle {method args} {
|
| 225 |
+
if {![info exists IdleCallbacks($method)]} {
|
| 226 |
+
set IdleCallbacks($method) [after idle [list \
|
| 227 |
+
[namespace which my] DoWhenIdle $method $args]]
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
method DoWhenIdle {method arguments} {
|
| 231 |
+
unset IdleCallbacks($method)
|
| 232 |
+
tailcall my $method {*}$arguments
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
####################################################################
|
| 237 |
+
#
|
| 238 |
+
# tk::SimpleWidget --
|
| 239 |
+
#
|
| 240 |
+
# Simple megawidget class that makes it easy create widgets that behave
|
| 241 |
+
# like a ttk widget. It creates the hull as a ttk::frame and maps the
|
| 242 |
+
# state manipulation methods of the overall megawidget to the equivalent
|
| 243 |
+
# operations on the ttk::frame.
|
| 244 |
+
#
|
| 245 |
+
::tk::Megawidget create ::tk::SimpleWidget {} {
|
| 246 |
+
variable w hull options
|
| 247 |
+
method GetSpecs {} {
|
| 248 |
+
return {
|
| 249 |
+
{-cursor cursor Cursor {}}
|
| 250 |
+
{-takefocus takeFocus TakeFocus {}}
|
| 251 |
+
}
|
| 252 |
+
}
|
| 253 |
+
method CreateHull {} {
|
| 254 |
+
set hull [::ttk::frame $w -cursor $options(-cursor)]
|
| 255 |
+
my TraceOption -cursor UpdateCursorOption
|
| 256 |
+
}
|
| 257 |
+
method UpdateCursorOption args {
|
| 258 |
+
$hull configure -cursor $options(-cursor)
|
| 259 |
+
}
|
| 260 |
+
# Not fixed names, so can't forward
|
| 261 |
+
method state args {
|
| 262 |
+
tailcall $hull state {*}$args
|
| 263 |
+
}
|
| 264 |
+
method instate args {
|
| 265 |
+
tailcall $hull instate {*}$args
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
####################################################################
|
| 270 |
+
#
|
| 271 |
+
# tk::FocusableWidget --
|
| 272 |
+
#
|
| 273 |
+
# Simple megawidget class that makes a ttk-like widget that has a focus
|
| 274 |
+
# ring.
|
| 275 |
+
#
|
| 276 |
+
::tk::Megawidget create ::tk::FocusableWidget ::tk::SimpleWidget {
|
| 277 |
+
variable w hull options
|
| 278 |
+
method GetSpecs {} {
|
| 279 |
+
return {
|
| 280 |
+
{-cursor cursor Cursor {}}
|
| 281 |
+
{-takefocus takeFocus TakeFocus ::ttk::takefocus}
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
method CreateHull {} {
|
| 285 |
+
ttk::frame $w
|
| 286 |
+
set hull [ttk::entry $w.cHull -takefocus 0 -cursor $options(-cursor)]
|
| 287 |
+
pack $hull -expand yes -fill both -ipadx 2 -ipady 2
|
| 288 |
+
my TraceOption -cursor UpdateCursorOption
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
return
|
| 293 |
+
|
| 294 |
+
# Local Variables:
|
| 295 |
+
# mode: tcl
|
| 296 |
+
# fill-column: 78
|
| 297 |
+
# End:
|
mplug_owl2/lib/tk8.6/menu.tcl
ADDED
|
@@ -0,0 +1,1387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# menu.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the default bindings for Tk menus and menubuttons.
|
| 4 |
+
# It also implements keyboard traversal of menus and implements a few
|
| 5 |
+
# other utility procedures related to menus.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 1992-1994 The Regents of the University of California.
|
| 8 |
+
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
| 9 |
+
# Copyright (c) 1998-1999 Scriptics Corporation.
|
| 10 |
+
# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
|
| 11 |
+
#
|
| 12 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 13 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
#-------------------------------------------------------------------------
|
| 17 |
+
# Elements of tk::Priv that are used in this file:
|
| 18 |
+
#
|
| 19 |
+
# cursor - Saves the -cursor option for the posted menubutton.
|
| 20 |
+
# focus - Saves the focus during a menu selection operation.
|
| 21 |
+
# Focus gets restored here when the menu is unposted.
|
| 22 |
+
# grabGlobal - Used in conjunction with tk::Priv(oldGrab): if
|
| 23 |
+
# tk::Priv(oldGrab) is non-empty, then tk::Priv(grabGlobal)
|
| 24 |
+
# contains either an empty string or "-global" to
|
| 25 |
+
# indicate whether the old grab was a local one or
|
| 26 |
+
# a global one.
|
| 27 |
+
# inMenubutton - The name of the menubutton widget containing
|
| 28 |
+
# the mouse, or an empty string if the mouse is
|
| 29 |
+
# not over any menubutton.
|
| 30 |
+
# menuBar - The name of the menubar that is the root
|
| 31 |
+
# of the cascade hierarchy which is currently
|
| 32 |
+
# posted. This is null when there is no menu currently
|
| 33 |
+
# being pulled down from a menu bar.
|
| 34 |
+
# oldGrab - Window that had the grab before a menu was posted.
|
| 35 |
+
# Used to restore the grab state after the menu
|
| 36 |
+
# is unposted. Empty string means there was no
|
| 37 |
+
# grab previously set.
|
| 38 |
+
# popup - If a menu has been popped up via tk_popup, this
|
| 39 |
+
# gives the name of the menu. Otherwise this
|
| 40 |
+
# value is empty.
|
| 41 |
+
# postedMb - Name of the menubutton whose menu is currently
|
| 42 |
+
# posted, or an empty string if nothing is posted
|
| 43 |
+
# A grab is set on this widget.
|
| 44 |
+
# relief - Used to save the original relief of the current
|
| 45 |
+
# menubutton.
|
| 46 |
+
# window - When the mouse is over a menu, this holds the
|
| 47 |
+
# name of the menu; it's cleared when the mouse
|
| 48 |
+
# leaves the menu.
|
| 49 |
+
# tearoff - Whether the last menu posted was a tearoff or not.
|
| 50 |
+
# This is true always for unix, for tearoffs for Mac
|
| 51 |
+
# and Windows.
|
| 52 |
+
# activeMenu - This is the last active menu for use
|
| 53 |
+
# with the <<MenuSelect>> virtual event.
|
| 54 |
+
# activeItem - This is the last active menu item for
|
| 55 |
+
# use with the <<MenuSelect>> virtual event.
|
| 56 |
+
#-------------------------------------------------------------------------
|
| 57 |
+
|
| 58 |
+
#-------------------------------------------------------------------------
|
| 59 |
+
# Overall note:
|
| 60 |
+
# This file is tricky because there are five different ways that menus
|
| 61 |
+
# can be used:
|
| 62 |
+
#
|
| 63 |
+
# 1. As a pulldown from a menubutton. In this style, the variable
|
| 64 |
+
# tk::Priv(postedMb) identifies the posted menubutton.
|
| 65 |
+
# 2. As a torn-off menu copied from some other menu. In this style
|
| 66 |
+
# tk::Priv(postedMb) is empty, and menu's type is "tearoff".
|
| 67 |
+
# 3. As an option menu, triggered from an option menubutton. In this
|
| 68 |
+
# style tk::Priv(postedMb) identifies the posted menubutton.
|
| 69 |
+
# 4. As a popup menu. In this style tk::Priv(postedMb) is empty and
|
| 70 |
+
# the top-level menu's type is "normal".
|
| 71 |
+
# 5. As a pulldown from a menubar. The variable tk::Priv(menubar) has
|
| 72 |
+
# the owning menubar, and the menu itself is of type "normal".
|
| 73 |
+
#
|
| 74 |
+
# The various binding procedures use the state described above to
|
| 75 |
+
# distinguish the various cases and take different actions in each
|
| 76 |
+
# case.
|
| 77 |
+
#-------------------------------------------------------------------------
|
| 78 |
+
|
| 79 |
+
#-------------------------------------------------------------------------
|
| 80 |
+
# The code below creates the default class bindings for menus
|
| 81 |
+
# and menubuttons.
|
| 82 |
+
#-------------------------------------------------------------------------
|
| 83 |
+
|
| 84 |
+
bind Menubutton <FocusIn> {}
|
| 85 |
+
bind Menubutton <Enter> {
|
| 86 |
+
tk::MbEnter %W
|
| 87 |
+
}
|
| 88 |
+
bind Menubutton <Leave> {
|
| 89 |
+
tk::MbLeave %W
|
| 90 |
+
}
|
| 91 |
+
bind Menubutton <Button-1> {
|
| 92 |
+
if {$tk::Priv(inMenubutton) ne ""} {
|
| 93 |
+
tk::MbPost $tk::Priv(inMenubutton) %X %Y
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
bind Menubutton <Motion> {
|
| 97 |
+
tk::MbMotion %W up %X %Y
|
| 98 |
+
}
|
| 99 |
+
bind Menubutton <B1-Motion> {
|
| 100 |
+
tk::MbMotion %W down %X %Y
|
| 101 |
+
}
|
| 102 |
+
bind Menubutton <ButtonRelease-1> {
|
| 103 |
+
tk::MbButtonUp %W
|
| 104 |
+
}
|
| 105 |
+
bind Menubutton <space> {
|
| 106 |
+
tk::MbPost %W
|
| 107 |
+
tk::MenuFirstEntry [%W cget -menu]
|
| 108 |
+
}
|
| 109 |
+
bind Menubutton <<Invoke>> {
|
| 110 |
+
tk::MbPost %W
|
| 111 |
+
tk::MenuFirstEntry [%W cget -menu]
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
# Must set focus when mouse enters a menu, in order to allow
|
| 115 |
+
# mixed-mode processing using both the mouse and the keyboard.
|
| 116 |
+
# Don't set the focus if the event comes from a grab release,
|
| 117 |
+
# though: such an event can happen after as part of unposting
|
| 118 |
+
# a cascaded chain of menus, after the focus has already been
|
| 119 |
+
# restored to wherever it was before menu selection started.
|
| 120 |
+
|
| 121 |
+
bind Menu <FocusIn> {}
|
| 122 |
+
|
| 123 |
+
bind Menu <Enter> {
|
| 124 |
+
set tk::Priv(window) %W
|
| 125 |
+
if {[%W cget -type] eq "tearoff"} {
|
| 126 |
+
if {"%m" ne "NotifyUngrab"} {
|
| 127 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 128 |
+
tk_menuSetFocus %W
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
tk::MenuMotion %W %x %y %s
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
bind Menu <Leave> {
|
| 136 |
+
tk::MenuLeave %W %X %Y %s
|
| 137 |
+
}
|
| 138 |
+
bind Menu <Motion> {
|
| 139 |
+
tk::MenuMotion %W %x %y %s
|
| 140 |
+
}
|
| 141 |
+
bind Menu <Button> {
|
| 142 |
+
tk::MenuButtonDown %W
|
| 143 |
+
}
|
| 144 |
+
bind Menu <ButtonRelease> {
|
| 145 |
+
tk::MenuInvoke %W 1
|
| 146 |
+
}
|
| 147 |
+
bind Menu <space> {
|
| 148 |
+
tk::MenuInvoke %W 0
|
| 149 |
+
}
|
| 150 |
+
bind Menu <<Invoke>> {
|
| 151 |
+
tk::MenuInvoke %W 0
|
| 152 |
+
}
|
| 153 |
+
bind Menu <Return> {
|
| 154 |
+
tk::MenuInvoke %W 0
|
| 155 |
+
}
|
| 156 |
+
bind Menu <Escape> {
|
| 157 |
+
tk::MenuEscape %W
|
| 158 |
+
}
|
| 159 |
+
bind Menu <<PrevChar>> {
|
| 160 |
+
tk::MenuLeftArrow %W
|
| 161 |
+
}
|
| 162 |
+
bind Menu <<NextChar>> {
|
| 163 |
+
tk::MenuRightArrow %W
|
| 164 |
+
}
|
| 165 |
+
bind Menu <<PrevLine>> {
|
| 166 |
+
tk::MenuUpArrow %W
|
| 167 |
+
}
|
| 168 |
+
bind Menu <<NextLine>> {
|
| 169 |
+
tk::MenuDownArrow %W
|
| 170 |
+
}
|
| 171 |
+
bind Menu <Key> {
|
| 172 |
+
tk::TraverseWithinMenu %W %A
|
| 173 |
+
break
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
# The following bindings apply to all windows, and are used to
|
| 177 |
+
# implement keyboard menu traversal.
|
| 178 |
+
|
| 179 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 180 |
+
bind all <Alt-Key> {
|
| 181 |
+
tk::TraverseToMenu %W %A
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
bind all <F10> {
|
| 185 |
+
tk::FirstMenu %W
|
| 186 |
+
}
|
| 187 |
+
} else {
|
| 188 |
+
bind Menubutton <Alt-Key> {
|
| 189 |
+
tk::TraverseToMenu %W %A
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
bind Menubutton <F10> {
|
| 193 |
+
tk::FirstMenu %W
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
# ::tk::MbEnter --
|
| 198 |
+
# This procedure is invoked when the mouse enters a menubutton
|
| 199 |
+
# widget. It activates the widget unless it is disabled. Note:
|
| 200 |
+
# this procedure is only invoked when mouse button 1 is *not* down.
|
| 201 |
+
# The procedure ::tk::MbB1Enter is invoked if the button is down.
|
| 202 |
+
#
|
| 203 |
+
# Arguments:
|
| 204 |
+
# w - The name of the widget.
|
| 205 |
+
|
| 206 |
+
proc ::tk::MbEnter w {
|
| 207 |
+
variable ::tk::Priv
|
| 208 |
+
|
| 209 |
+
if {$Priv(inMenubutton) ne ""} {
|
| 210 |
+
MbLeave $Priv(inMenubutton)
|
| 211 |
+
}
|
| 212 |
+
set Priv(inMenubutton) $w
|
| 213 |
+
if {[$w cget -state] ne "disabled" && [tk windowingsystem] ne "aqua"} {
|
| 214 |
+
$w configure -state active
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
# ::tk::MbLeave --
|
| 219 |
+
# This procedure is invoked when the mouse leaves a menubutton widget.
|
| 220 |
+
# It de-activates the widget, if the widget still exists.
|
| 221 |
+
#
|
| 222 |
+
# Arguments:
|
| 223 |
+
# w - The name of the widget.
|
| 224 |
+
|
| 225 |
+
proc ::tk::MbLeave w {
|
| 226 |
+
variable ::tk::Priv
|
| 227 |
+
|
| 228 |
+
set Priv(inMenubutton) {}
|
| 229 |
+
if {![winfo exists $w]} {
|
| 230 |
+
return
|
| 231 |
+
}
|
| 232 |
+
if {[$w cget -state] eq "active" && [tk windowingsystem] ne "aqua"} {
|
| 233 |
+
$w configure -state normal
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
# ::tk::MbPost --
|
| 239 |
+
# Given a menubutton, this procedure does all the work of posting
|
| 240 |
+
# its associated menu and unposting any other menu that is currently
|
| 241 |
+
# posted.
|
| 242 |
+
#
|
| 243 |
+
# Arguments:
|
| 244 |
+
# w - The name of the menubutton widget whose menu
|
| 245 |
+
# is to be posted.
|
| 246 |
+
# x, y - Root coordinates of cursor, used for positioning
|
| 247 |
+
# option menus. If not specified, then the center
|
| 248 |
+
# of the menubutton is used for an option menu.
|
| 249 |
+
|
| 250 |
+
proc ::tk::MbPost {w {x {}} {y {}}} {
|
| 251 |
+
global errorInfo
|
| 252 |
+
variable ::tk::Priv
|
| 253 |
+
|
| 254 |
+
if {[$w cget -state] eq "disabled" || $w eq $Priv(postedMb)} {
|
| 255 |
+
return
|
| 256 |
+
}
|
| 257 |
+
set menu [$w cget -menu]
|
| 258 |
+
if {$menu eq ""} {
|
| 259 |
+
return
|
| 260 |
+
}
|
| 261 |
+
set tearoff [expr {[tk windowingsystem] eq "x11" \
|
| 262 |
+
|| [$menu cget -type] eq "tearoff"}]
|
| 263 |
+
if {[string first $w $menu] != 0} {
|
| 264 |
+
return -code error -errorcode {TK MENUBUTTON POST_NONCHILD} \
|
| 265 |
+
"can't post $menu: it isn't a descendant of $w"
|
| 266 |
+
}
|
| 267 |
+
set cur $Priv(postedMb)
|
| 268 |
+
if {$cur ne ""} {
|
| 269 |
+
MenuUnpost {}
|
| 270 |
+
}
|
| 271 |
+
if {$::tk_strictMotif} {
|
| 272 |
+
set Priv(cursor) [$w cget -cursor]
|
| 273 |
+
$w configure -cursor arrow
|
| 274 |
+
}
|
| 275 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 276 |
+
set Priv(relief) [$w cget -relief]
|
| 277 |
+
$w configure -relief raised
|
| 278 |
+
} else {
|
| 279 |
+
$w configure -state active
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
set Priv(postedMb) $w
|
| 283 |
+
set Priv(focus) [focus]
|
| 284 |
+
$menu activate none
|
| 285 |
+
GenerateMenuSelect $menu
|
| 286 |
+
update idletasks
|
| 287 |
+
|
| 288 |
+
if {[catch {PostMenubuttonMenu $w $menu $x $y} msg opt]} {
|
| 289 |
+
# Error posting menu (e.g. bogus -postcommand). Unpost it and
|
| 290 |
+
# reflect the error.
|
| 291 |
+
MenuUnpost {}
|
| 292 |
+
return -options $opt $msg
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
set Priv(tearoff) $tearoff
|
| 296 |
+
if {$tearoff != 0 && [tk windowingsystem] ne "aqua"} {
|
| 297 |
+
focus $menu
|
| 298 |
+
if {[winfo viewable $w]} {
|
| 299 |
+
SaveGrabInfo $w
|
| 300 |
+
grab -global $w
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
# ::tk::MenuUnpost --
|
| 306 |
+
# This procedure unposts a given menu, plus all of its ancestors up
|
| 307 |
+
# to (and including) a menubutton, if any. It also restores various
|
| 308 |
+
# values to what they were before the menu was posted, and releases
|
| 309 |
+
# a grab if there's a menubutton involved. Special notes:
|
| 310 |
+
# 1. It's important to unpost all menus before releasing the grab, so
|
| 311 |
+
# that any Enter-Leave events (e.g. from menu back to main
|
| 312 |
+
# application) have mode NotifyGrab.
|
| 313 |
+
# 2. Be sure to enclose various groups of commands in "catch" so that
|
| 314 |
+
# the procedure will complete even if the menubutton or the menu
|
| 315 |
+
# or the grab window has been deleted.
|
| 316 |
+
#
|
| 317 |
+
# Arguments:
|
| 318 |
+
# menu - Name of a menu to unpost. Ignored if there
|
| 319 |
+
# is a posted menubutton.
|
| 320 |
+
|
| 321 |
+
proc ::tk::MenuUnpost menu {
|
| 322 |
+
variable ::tk::Priv
|
| 323 |
+
set mb $Priv(postedMb)
|
| 324 |
+
|
| 325 |
+
# Restore focus right away (otherwise X will take focus away when
|
| 326 |
+
# the menu is unmapped and under some window managers (e.g. olvwm)
|
| 327 |
+
# we'll lose the focus completely).
|
| 328 |
+
|
| 329 |
+
catch {focus $Priv(focus)}
|
| 330 |
+
set Priv(focus) ""
|
| 331 |
+
|
| 332 |
+
# Unpost menu(s) and restore some stuff that's dependent on
|
| 333 |
+
# what was posted.
|
| 334 |
+
|
| 335 |
+
after cancel [array get Priv menuActivatedTimer]
|
| 336 |
+
unset -nocomplain Priv(menuActivated)
|
| 337 |
+
after cancel [array get Priv menuDeactivatedTimer]
|
| 338 |
+
unset -nocomplain Priv(menuDeactivated)
|
| 339 |
+
|
| 340 |
+
catch {
|
| 341 |
+
if {$mb ne ""} {
|
| 342 |
+
set menu [$mb cget -menu]
|
| 343 |
+
$menu unpost
|
| 344 |
+
set Priv(postedMb) {}
|
| 345 |
+
if {$::tk_strictMotif} {
|
| 346 |
+
$mb configure -cursor $Priv(cursor)
|
| 347 |
+
}
|
| 348 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 349 |
+
$mb configure -relief $Priv(relief)
|
| 350 |
+
} else {
|
| 351 |
+
$mb configure -state normal
|
| 352 |
+
}
|
| 353 |
+
} elseif {$Priv(popup) ne ""} {
|
| 354 |
+
$Priv(popup) unpost
|
| 355 |
+
set Priv(popup) {}
|
| 356 |
+
} elseif {[$menu cget -type] ne "menubar" && [$menu cget -type] ne "tearoff"} {
|
| 357 |
+
# We're in a cascaded sub-menu from a torn-off menu or popup.
|
| 358 |
+
# Unpost all the menus up to the toplevel one (but not
|
| 359 |
+
# including the top-level torn-off one) and deactivate the
|
| 360 |
+
# top-level torn off menu if there is one.
|
| 361 |
+
|
| 362 |
+
while {1} {
|
| 363 |
+
set parent [winfo parent $menu]
|
| 364 |
+
if {[winfo class $parent] ne "Menu" || ![winfo ismapped $parent]} {
|
| 365 |
+
break
|
| 366 |
+
}
|
| 367 |
+
$parent activate none
|
| 368 |
+
$parent postcascade none
|
| 369 |
+
GenerateMenuSelect $parent
|
| 370 |
+
set type [$parent cget -type]
|
| 371 |
+
if {$type eq "menubar" || $type eq "tearoff"} {
|
| 372 |
+
break
|
| 373 |
+
}
|
| 374 |
+
set menu $parent
|
| 375 |
+
}
|
| 376 |
+
if {[$menu cget -type] ne "menubar"} {
|
| 377 |
+
$menu unpost
|
| 378 |
+
}
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
if {($Priv(tearoff) != 0) || $Priv(menuBar) ne ""} {
|
| 383 |
+
# Release grab, if any, and restore the previous grab, if there
|
| 384 |
+
# was one.
|
| 385 |
+
if {$menu ne ""} {
|
| 386 |
+
set grab [grab current $menu]
|
| 387 |
+
if {$grab ne ""} {
|
| 388 |
+
grab release $grab
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
RestoreOldGrab
|
| 392 |
+
if {$Priv(menuBar) ne ""} {
|
| 393 |
+
if {$::tk_strictMotif} {
|
| 394 |
+
$Priv(menuBar) configure -cursor $Priv(cursor)
|
| 395 |
+
}
|
| 396 |
+
set Priv(menuBar) {}
|
| 397 |
+
}
|
| 398 |
+
if {[tk windowingsystem] ne "x11"} {
|
| 399 |
+
set Priv(tearoff) 0
|
| 400 |
+
}
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
# ::tk::MbMotion --
|
| 405 |
+
# This procedure handles mouse motion events inside menubuttons, and
|
| 406 |
+
# also outside menubuttons when a menubutton has a grab (e.g. when a
|
| 407 |
+
# menu selection operation is in progress).
|
| 408 |
+
#
|
| 409 |
+
# Arguments:
|
| 410 |
+
# w - The name of the menubutton widget.
|
| 411 |
+
# upDown - "down" means button 1 is pressed, "up" means
|
| 412 |
+
# it isn't.
|
| 413 |
+
# rootx, rooty - Coordinates of mouse, in (virtual?) root window.
|
| 414 |
+
|
| 415 |
+
proc ::tk::MbMotion {w upDown rootx rooty} {
|
| 416 |
+
variable ::tk::Priv
|
| 417 |
+
|
| 418 |
+
if {$Priv(inMenubutton) eq $w} {
|
| 419 |
+
return
|
| 420 |
+
}
|
| 421 |
+
set new [winfo containing $rootx $rooty]
|
| 422 |
+
if {$new ne $Priv(inMenubutton) \
|
| 423 |
+
&& ($new eq "" || [winfo toplevel $new] eq [winfo toplevel $w])} {
|
| 424 |
+
if {$Priv(inMenubutton) ne ""} {
|
| 425 |
+
MbLeave $Priv(inMenubutton)
|
| 426 |
+
}
|
| 427 |
+
if {$new ne "" \
|
| 428 |
+
&& [winfo class $new] eq "Menubutton" \
|
| 429 |
+
&& ([$new cget -indicatoron] == 0) \
|
| 430 |
+
&& ([$w cget -indicatoron] == 0)} {
|
| 431 |
+
if {$upDown eq "down"} {
|
| 432 |
+
MbPost $new $rootx $rooty
|
| 433 |
+
} else {
|
| 434 |
+
MbEnter $new
|
| 435 |
+
}
|
| 436 |
+
}
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
# ::tk::MbButtonUp --
|
| 441 |
+
# This procedure is invoked to handle button 1 releases for menubuttons.
|
| 442 |
+
# If the release happens inside the menubutton then leave its menu
|
| 443 |
+
# posted with element 0 activated. Otherwise, unpost the menu.
|
| 444 |
+
#
|
| 445 |
+
# Arguments:
|
| 446 |
+
# w - The name of the menubutton widget.
|
| 447 |
+
|
| 448 |
+
proc ::tk::MbButtonUp w {
|
| 449 |
+
variable ::tk::Priv
|
| 450 |
+
|
| 451 |
+
set menu [$w cget -menu]
|
| 452 |
+
set tearoff [expr {[tk windowingsystem] eq "x11" || \
|
| 453 |
+
($menu ne "" && [$menu cget -type] eq "tearoff")}]
|
| 454 |
+
if {($tearoff != 0) && $Priv(postedMb) eq $w \
|
| 455 |
+
&& $Priv(inMenubutton) eq $w} {
|
| 456 |
+
MenuFirstEntry [$Priv(postedMb) cget -menu]
|
| 457 |
+
} else {
|
| 458 |
+
MenuUnpost {}
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
# ::tk::MenuMotion --
|
| 463 |
+
# This procedure is called to handle mouse motion events for menus.
|
| 464 |
+
# It does two things. First, it resets the active element in the
|
| 465 |
+
# menu, if the mouse is over the menu. Second, if a mouse button
|
| 466 |
+
# is down, it posts and unposts cascade entries to match the mouse
|
| 467 |
+
# position.
|
| 468 |
+
#
|
| 469 |
+
# Arguments:
|
| 470 |
+
# menu - The menu window.
|
| 471 |
+
# x - The x position of the mouse.
|
| 472 |
+
# y - The y position of the mouse.
|
| 473 |
+
# state - Modifier state (tells whether buttons are down).
|
| 474 |
+
|
| 475 |
+
proc ::tk::MenuMotion {menu x y state} {
|
| 476 |
+
variable ::tk::Priv
|
| 477 |
+
if {$menu eq $Priv(window)} {
|
| 478 |
+
set activeindex [$menu index active]
|
| 479 |
+
if {[$menu cget -type] eq "menubar"} {
|
| 480 |
+
if {[info exists Priv(focus)] && $menu ne $Priv(focus)} {
|
| 481 |
+
$menu activate @$x,$y
|
| 482 |
+
GenerateMenuSelect $menu
|
| 483 |
+
}
|
| 484 |
+
} else {
|
| 485 |
+
$menu activate @$x,$y
|
| 486 |
+
GenerateMenuSelect $menu
|
| 487 |
+
}
|
| 488 |
+
set index [$menu index @$x,$y]
|
| 489 |
+
if {[info exists Priv(menuActivated)] \
|
| 490 |
+
&& $index ne "none" \
|
| 491 |
+
&& $index >= 0 \
|
| 492 |
+
&& $index ne $activeindex} {
|
| 493 |
+
set mode [option get $menu clickToFocus ClickToFocus]
|
| 494 |
+
if {[string is false $mode]} {
|
| 495 |
+
set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}]
|
| 496 |
+
if {[$menu type $index] eq "cascade"} {
|
| 497 |
+
# Catch these postcascade commands since the menu could be
|
| 498 |
+
# destroyed before they run.
|
| 499 |
+
set Priv(menuActivatedTimer) \
|
| 500 |
+
[after $delay [list catch [list \
|
| 501 |
+
$menu postcascade active]]]
|
| 502 |
+
} else {
|
| 503 |
+
set Priv(menuDeactivatedTimer) \
|
| 504 |
+
[after $delay [list catch [list
|
| 505 |
+
$menu postcascade none]]]
|
| 506 |
+
}
|
| 507 |
+
}
|
| 508 |
+
}
|
| 509 |
+
}
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
# ::tk::MenuButtonDown --
|
| 513 |
+
# Handles button presses in menus. There are a couple of tricky things
|
| 514 |
+
# here:
|
| 515 |
+
# 1. Change the posted cascade entry (if any) to match the mouse position.
|
| 516 |
+
# 2. If there is a posted menubutton, must grab to the menubutton; this
|
| 517 |
+
# overrrides the implicit grab on button press, so that the menu
|
| 518 |
+
# button can track mouse motions over other menubuttons and change
|
| 519 |
+
# the posted menu.
|
| 520 |
+
# 3. If there's no posted menubutton (e.g. because we're a torn-off menu
|
| 521 |
+
# or one of its descendants) must grab to the top-level menu so that
|
| 522 |
+
# we can track mouse motions across the entire menu hierarchy.
|
| 523 |
+
#
|
| 524 |
+
# Arguments:
|
| 525 |
+
# menu - The menu window.
|
| 526 |
+
|
| 527 |
+
proc ::tk::MenuButtonDown menu {
|
| 528 |
+
variable ::tk::Priv
|
| 529 |
+
|
| 530 |
+
if {![winfo viewable $menu]} {
|
| 531 |
+
return
|
| 532 |
+
}
|
| 533 |
+
set activeindex [$menu index active]
|
| 534 |
+
if {($activeindex eq "none") || ($activeindex < 0)} {
|
| 535 |
+
if {[$menu cget -type] ne "menubar" } {
|
| 536 |
+
set Priv(window) {}
|
| 537 |
+
}
|
| 538 |
+
return
|
| 539 |
+
}
|
| 540 |
+
$menu postcascade active
|
| 541 |
+
if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} {
|
| 542 |
+
grab -global $Priv(postedMb)
|
| 543 |
+
} else {
|
| 544 |
+
while {[$menu cget -type] eq "normal" \
|
| 545 |
+
&& [winfo class [winfo parent $menu]] eq "Menu" \
|
| 546 |
+
&& [winfo ismapped [winfo parent $menu]]} {
|
| 547 |
+
set menu [winfo parent $menu]
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
if {$Priv(menuBar) eq {}} {
|
| 551 |
+
set Priv(menuBar) $menu
|
| 552 |
+
if {$::tk_strictMotif} {
|
| 553 |
+
set Priv(cursor) [$menu cget -cursor]
|
| 554 |
+
$menu configure -cursor arrow
|
| 555 |
+
}
|
| 556 |
+
if {[$menu type active] eq "cascade"} {
|
| 557 |
+
set Priv(menuActivated) 1
|
| 558 |
+
}
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
# Don't update grab information if the grab window isn't changing.
|
| 562 |
+
# Otherwise, we'll get an error when we unpost the menus and
|
| 563 |
+
# restore the grab, since the old grab window will not be viewable
|
| 564 |
+
# anymore.
|
| 565 |
+
|
| 566 |
+
if {$menu ne [grab current $menu]} {
|
| 567 |
+
SaveGrabInfo $menu
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
# Must re-grab even if the grab window hasn't changed, in order
|
| 571 |
+
# to release the implicit grab from the button press.
|
| 572 |
+
|
| 573 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 574 |
+
grab -global $menu
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
# ::tk::MenuLeave --
|
| 580 |
+
# This procedure is invoked to handle Leave events for a menu. It
|
| 581 |
+
# deactivates everything unless the active element is a cascade element
|
| 582 |
+
# and the mouse is now over the submenu.
|
| 583 |
+
#
|
| 584 |
+
# Arguments:
|
| 585 |
+
# menu - The menu window.
|
| 586 |
+
# rootx, rooty - Root coordinates of mouse.
|
| 587 |
+
# state - Modifier state.
|
| 588 |
+
|
| 589 |
+
proc ::tk::MenuLeave {menu rootx rooty state} {
|
| 590 |
+
variable ::tk::Priv
|
| 591 |
+
set Priv(window) {}
|
| 592 |
+
set activeindex [$menu index active]
|
| 593 |
+
if {($activeindex eq "none") || ($activeindex < 0)} {
|
| 594 |
+
return
|
| 595 |
+
}
|
| 596 |
+
if {[$menu type active] eq "cascade" \
|
| 597 |
+
&& [winfo containing $rootx $rooty] eq \
|
| 598 |
+
[$menu entrycget active -menu]} {
|
| 599 |
+
return
|
| 600 |
+
}
|
| 601 |
+
$menu activate none
|
| 602 |
+
GenerateMenuSelect $menu
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
+
# ::tk::MenuInvoke --
|
| 606 |
+
# This procedure is invoked when button 1 is released over a menu.
|
| 607 |
+
# It invokes the appropriate menu action and unposts the menu if
|
| 608 |
+
# it came from a menubutton.
|
| 609 |
+
#
|
| 610 |
+
# Arguments:
|
| 611 |
+
# w - Name of the menu widget.
|
| 612 |
+
# buttonRelease - 1 means this procedure is called because of
|
| 613 |
+
# a button release; 0 means because of keystroke.
|
| 614 |
+
|
| 615 |
+
proc ::tk::MenuInvoke {w buttonRelease} {
|
| 616 |
+
variable ::tk::Priv
|
| 617 |
+
|
| 618 |
+
if {$buttonRelease && $Priv(window) eq ""} {
|
| 619 |
+
# Mouse was pressed over a menu without a menu button, then
|
| 620 |
+
# dragged off the menu (possibly with a cascade posted) and
|
| 621 |
+
# released. Unpost everything and quit.
|
| 622 |
+
|
| 623 |
+
$w postcascade none
|
| 624 |
+
$w activate none
|
| 625 |
+
event generate $w <<MenuSelect>>
|
| 626 |
+
MenuUnpost $w
|
| 627 |
+
return
|
| 628 |
+
}
|
| 629 |
+
if {[$w type active] eq "cascade"} {
|
| 630 |
+
$w postcascade active
|
| 631 |
+
set menu [$w entrycget active -menu]
|
| 632 |
+
MenuFirstEntry $menu
|
| 633 |
+
} elseif {[$w type active] eq "tearoff"} {
|
| 634 |
+
::tk::TearOffMenu $w
|
| 635 |
+
MenuUnpost $w
|
| 636 |
+
} elseif {[$w cget -type] eq "menubar"} {
|
| 637 |
+
$w postcascade none
|
| 638 |
+
set activeindex [$w index active]
|
| 639 |
+
set isCascade [string equal [$w type $activeindex] "cascade"]
|
| 640 |
+
|
| 641 |
+
# Only de-activate the active item if it's a cascade; this prevents
|
| 642 |
+
# the annoying "activation flicker" you otherwise get with
|
| 643 |
+
# checkbuttons/commands/etc. on menubars
|
| 644 |
+
|
| 645 |
+
if { $isCascade } {
|
| 646 |
+
$w activate none
|
| 647 |
+
event generate $w <<MenuSelect>>
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
MenuUnpost $w
|
| 651 |
+
|
| 652 |
+
# If the active item is not a cascade, invoke it. This enables
|
| 653 |
+
# the use of checkbuttons/commands/etc. on menubars (which is legal,
|
| 654 |
+
# but not recommended)
|
| 655 |
+
|
| 656 |
+
if { !$isCascade } {
|
| 657 |
+
uplevel #0 [list $w invoke $activeindex]
|
| 658 |
+
}
|
| 659 |
+
} else {
|
| 660 |
+
set activeindex [$w index active]
|
| 661 |
+
if {($Priv(popup) eq "") || (($activeindex ne "none") && ($activeindex >= 0))} {
|
| 662 |
+
MenuUnpost $w
|
| 663 |
+
}
|
| 664 |
+
uplevel #0 [list $w invoke active]
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
# ::tk::MenuEscape --
|
| 669 |
+
# This procedure is invoked for the Cancel (or Escape) key. It unposts
|
| 670 |
+
# the given menu and, if it is the top-level menu for a menu button,
|
| 671 |
+
# unposts the menu button as well.
|
| 672 |
+
#
|
| 673 |
+
# Arguments:
|
| 674 |
+
# menu - Name of the menu window.
|
| 675 |
+
|
| 676 |
+
proc ::tk::MenuEscape menu {
|
| 677 |
+
set parent [winfo parent $menu]
|
| 678 |
+
if {[winfo class $parent] ne "Menu"} {
|
| 679 |
+
MenuUnpost $menu
|
| 680 |
+
} elseif {[$parent cget -type] eq "menubar"} {
|
| 681 |
+
MenuUnpost $menu
|
| 682 |
+
RestoreOldGrab
|
| 683 |
+
} else {
|
| 684 |
+
MenuNextMenu $menu left
|
| 685 |
+
}
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
# The following routines handle arrow keys. Arrow keys behave
|
| 689 |
+
# differently depending on whether the menu is a menu bar or not.
|
| 690 |
+
|
| 691 |
+
proc ::tk::MenuUpArrow {menu} {
|
| 692 |
+
if {[$menu cget -type] eq "menubar"} {
|
| 693 |
+
MenuNextMenu $menu left
|
| 694 |
+
} else {
|
| 695 |
+
MenuNextEntry $menu -1
|
| 696 |
+
}
|
| 697 |
+
}
|
| 698 |
+
|
| 699 |
+
proc ::tk::MenuDownArrow {menu} {
|
| 700 |
+
if {[$menu cget -type] eq "menubar"} {
|
| 701 |
+
MenuNextMenu $menu right
|
| 702 |
+
} else {
|
| 703 |
+
MenuNextEntry $menu 1
|
| 704 |
+
}
|
| 705 |
+
}
|
| 706 |
+
|
| 707 |
+
proc ::tk::MenuLeftArrow {menu} {
|
| 708 |
+
if {[$menu cget -type] eq "menubar"} {
|
| 709 |
+
MenuNextEntry $menu -1
|
| 710 |
+
} else {
|
| 711 |
+
MenuNextMenu $menu left
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
proc ::tk::MenuRightArrow {menu} {
|
| 716 |
+
if {[$menu cget -type] eq "menubar"} {
|
| 717 |
+
MenuNextEntry $menu 1
|
| 718 |
+
} else {
|
| 719 |
+
MenuNextMenu $menu right
|
| 720 |
+
}
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
# ::tk::MenuNextMenu --
|
| 724 |
+
# This procedure is invoked to handle "left" and "right" traversal
|
| 725 |
+
# motions in menus. It traverses to the next menu in a menu bar,
|
| 726 |
+
# or into or out of a cascaded menu.
|
| 727 |
+
#
|
| 728 |
+
# Arguments:
|
| 729 |
+
# menu - The menu that received the keyboard
|
| 730 |
+
# event.
|
| 731 |
+
# direction - Direction in which to move: "left" or "right"
|
| 732 |
+
|
| 733 |
+
proc ::tk::MenuNextMenu {menu direction} {
|
| 734 |
+
variable ::tk::Priv
|
| 735 |
+
|
| 736 |
+
# First handle traversals into and out of cascaded menus.
|
| 737 |
+
|
| 738 |
+
if {$direction eq "right"} {
|
| 739 |
+
set count 1
|
| 740 |
+
set parent [winfo parent $menu]
|
| 741 |
+
set class [winfo class $parent]
|
| 742 |
+
if {[$menu type active] eq "cascade"} {
|
| 743 |
+
$menu postcascade active
|
| 744 |
+
set m2 [$menu entrycget active -menu]
|
| 745 |
+
if {$m2 ne ""} {
|
| 746 |
+
MenuFirstEntry $m2
|
| 747 |
+
}
|
| 748 |
+
return
|
| 749 |
+
} else {
|
| 750 |
+
set parent [winfo parent $menu]
|
| 751 |
+
while {$parent ne "."} {
|
| 752 |
+
if {[winfo class $parent] eq "Menu" \
|
| 753 |
+
&& [$parent cget -type] eq "menubar"} {
|
| 754 |
+
tk_menuSetFocus $parent
|
| 755 |
+
MenuNextEntry $parent 1
|
| 756 |
+
return
|
| 757 |
+
}
|
| 758 |
+
set parent [winfo parent $parent]
|
| 759 |
+
}
|
| 760 |
+
}
|
| 761 |
+
} else {
|
| 762 |
+
set count -1
|
| 763 |
+
set m2 [winfo parent $menu]
|
| 764 |
+
if {[winfo class $m2] eq "Menu"} {
|
| 765 |
+
$menu activate none
|
| 766 |
+
GenerateMenuSelect $menu
|
| 767 |
+
tk_menuSetFocus $m2
|
| 768 |
+
|
| 769 |
+
$m2 postcascade none
|
| 770 |
+
|
| 771 |
+
if {[$m2 cget -type] ne "menubar"} {
|
| 772 |
+
return
|
| 773 |
+
}
|
| 774 |
+
}
|
| 775 |
+
}
|
| 776 |
+
|
| 777 |
+
# Can't traverse into or out of a cascaded menu. Go to the next
|
| 778 |
+
# or previous menubutton, if that makes sense.
|
| 779 |
+
|
| 780 |
+
set m2 [winfo parent $menu]
|
| 781 |
+
if {[winfo class $m2] eq "Menu" && [$m2 cget -type] eq "menubar"} {
|
| 782 |
+
tk_menuSetFocus $m2
|
| 783 |
+
MenuNextEntry $m2 -1
|
| 784 |
+
return
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
set w $Priv(postedMb)
|
| 788 |
+
if {$w eq ""} {
|
| 789 |
+
return
|
| 790 |
+
}
|
| 791 |
+
set buttons [winfo children [winfo parent $w]]
|
| 792 |
+
set length [llength $buttons]
|
| 793 |
+
set i [expr {[lsearch -exact $buttons $w] + $count}]
|
| 794 |
+
while {1} {
|
| 795 |
+
while {$i < 0} {
|
| 796 |
+
incr i $length
|
| 797 |
+
}
|
| 798 |
+
while {$i >= $length} {
|
| 799 |
+
incr i -$length
|
| 800 |
+
}
|
| 801 |
+
set mb [lindex $buttons $i]
|
| 802 |
+
if {[winfo class $mb] eq "Menubutton" \
|
| 803 |
+
&& [$mb cget -state] ne "disabled" \
|
| 804 |
+
&& [$mb cget -menu] ne "" \
|
| 805 |
+
&& [[$mb cget -menu] index last] ne "none" \
|
| 806 |
+
&& [[$mb cget -menu] index last] >= 0} {
|
| 807 |
+
break
|
| 808 |
+
}
|
| 809 |
+
if {$mb eq $w} {
|
| 810 |
+
return
|
| 811 |
+
}
|
| 812 |
+
incr i $count
|
| 813 |
+
}
|
| 814 |
+
MbPost $mb
|
| 815 |
+
MenuFirstEntry [$mb cget -menu]
|
| 816 |
+
}
|
| 817 |
+
|
| 818 |
+
# ::tk::MenuNextEntry --
|
| 819 |
+
# Activate the next higher or lower entry in the posted menu,
|
| 820 |
+
# wrapping around at the ends. Disabled entries are skipped.
|
| 821 |
+
#
|
| 822 |
+
# Arguments:
|
| 823 |
+
# menu - Menu window that received the keystroke.
|
| 824 |
+
# count - 1 means go to the next lower entry,
|
| 825 |
+
# -1 means go to the next higher entry.
|
| 826 |
+
|
| 827 |
+
proc ::tk::MenuNextEntry {menu count} {
|
| 828 |
+
set last [$menu index last]
|
| 829 |
+
if {($last eq "none") || ($last < 0)} {
|
| 830 |
+
return
|
| 831 |
+
}
|
| 832 |
+
set length [expr {$last+1}]
|
| 833 |
+
set quitAfter $length
|
| 834 |
+
set activeindex [$menu index active]
|
| 835 |
+
if {($activeindex eq "none") || ($activeindex < 0)} {
|
| 836 |
+
set i 0
|
| 837 |
+
} else {
|
| 838 |
+
set i [expr {$activeindex + $count}]
|
| 839 |
+
}
|
| 840 |
+
while {1} {
|
| 841 |
+
if {$quitAfter <= 0} {
|
| 842 |
+
# We've tried every entry in the menu. Either there are
|
| 843 |
+
# none, or they're all disabled. Just give up.
|
| 844 |
+
|
| 845 |
+
return
|
| 846 |
+
}
|
| 847 |
+
while {$i < 0} {
|
| 848 |
+
incr i $length
|
| 849 |
+
}
|
| 850 |
+
while {$i >= $length} {
|
| 851 |
+
incr i -$length
|
| 852 |
+
}
|
| 853 |
+
if {[catch {$menu entrycget $i -state} state] == 0} {
|
| 854 |
+
if {$state ne "disabled" && \
|
| 855 |
+
($i!=0 || [$menu cget -type] ne "tearoff" \
|
| 856 |
+
|| [$menu type 0] ne "tearoff")} {
|
| 857 |
+
break
|
| 858 |
+
}
|
| 859 |
+
}
|
| 860 |
+
if {$i == $activeindex} {
|
| 861 |
+
return
|
| 862 |
+
}
|
| 863 |
+
incr i $count
|
| 864 |
+
incr quitAfter -1
|
| 865 |
+
}
|
| 866 |
+
$menu activate $i
|
| 867 |
+
GenerateMenuSelect $menu
|
| 868 |
+
|
| 869 |
+
if {[$menu type $i] eq "cascade" && [$menu cget -type] eq "menubar"} {
|
| 870 |
+
set cascade [$menu entrycget $i -menu]
|
| 871 |
+
if {$cascade ne ""} {
|
| 872 |
+
# Here we auto-post a cascade. This is necessary when
|
| 873 |
+
# we traverse left/right in the menubar, but undesirable when
|
| 874 |
+
# we traverse up/down in a menu.
|
| 875 |
+
$menu postcascade $i
|
| 876 |
+
MenuFirstEntry $cascade
|
| 877 |
+
}
|
| 878 |
+
}
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
# ::tk::MenuFind --
|
| 882 |
+
# This procedure searches the entire window hierarchy under w for
|
| 883 |
+
# a menubutton that isn't disabled and whose underlined character
|
| 884 |
+
# is "char" or an entry in a menubar that isn't disabled and whose
|
| 885 |
+
# underlined character is "char".
|
| 886 |
+
# It returns the name of that window, if found, or an
|
| 887 |
+
# empty string if no matching window was found. If "char" is an
|
| 888 |
+
# empty string then the procedure returns the name of the first
|
| 889 |
+
# menubutton found that isn't disabled.
|
| 890 |
+
#
|
| 891 |
+
# Arguments:
|
| 892 |
+
# w - Name of window where key was typed.
|
| 893 |
+
# char - Underlined character to search for;
|
| 894 |
+
# may be either upper or lower case, and
|
| 895 |
+
# will match either upper or lower case.
|
| 896 |
+
|
| 897 |
+
proc ::tk::MenuFind {w char} {
|
| 898 |
+
set char [string tolower $char]
|
| 899 |
+
set windowlist [winfo child $w]
|
| 900 |
+
|
| 901 |
+
foreach child $windowlist {
|
| 902 |
+
# Don't descend into other toplevels.
|
| 903 |
+
if {[winfo toplevel $w] ne [winfo toplevel $child]} {
|
| 904 |
+
continue
|
| 905 |
+
}
|
| 906 |
+
if {[winfo class $child] eq "Menu" && \
|
| 907 |
+
[$child cget -type] eq "menubar"} {
|
| 908 |
+
if {$char eq ""} {
|
| 909 |
+
return $child
|
| 910 |
+
}
|
| 911 |
+
set last [$child index last]
|
| 912 |
+
for {set i [$child cget -tearoff]} {$i <= $last} {incr i} {
|
| 913 |
+
if {([$child type $i] eq "separator") || ([$child entrycget $i -state] eq "disabled")} {
|
| 914 |
+
continue
|
| 915 |
+
}
|
| 916 |
+
set underline [$child entrycget $i -underline]
|
| 917 |
+
if {$underline >= 0} {
|
| 918 |
+
if {$char eq [string tolower [string index [$child entrycget $i -label] $underline]]} {
|
| 919 |
+
return $child
|
| 920 |
+
}
|
| 921 |
+
}
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
foreach child $windowlist {
|
| 927 |
+
# Don't descend into other toplevels.
|
| 928 |
+
if {[winfo toplevel $w] ne [winfo toplevel $child]} {
|
| 929 |
+
continue
|
| 930 |
+
}
|
| 931 |
+
switch -- [winfo class $child] {
|
| 932 |
+
Menubutton {
|
| 933 |
+
set char2 [string index [$child cget -text] \
|
| 934 |
+
[$child cget -underline]]
|
| 935 |
+
if {$char eq [string tolower $char2] || $char eq ""} {
|
| 936 |
+
if {[$child cget -state] ne "disabled"} {
|
| 937 |
+
return $child
|
| 938 |
+
}
|
| 939 |
+
}
|
| 940 |
+
}
|
| 941 |
+
|
| 942 |
+
default {
|
| 943 |
+
set match [MenuFind $child $char]
|
| 944 |
+
if {$match ne ""} {
|
| 945 |
+
return $match
|
| 946 |
+
}
|
| 947 |
+
}
|
| 948 |
+
}
|
| 949 |
+
}
|
| 950 |
+
return {}
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
# ::tk::TraverseToMenu --
|
| 954 |
+
# This procedure implements keyboard traversal of menus. Given an
|
| 955 |
+
# ASCII character "char", it looks for a menubutton with that character
|
| 956 |
+
# underlined. If one is found, it posts the menubutton's menu
|
| 957 |
+
#
|
| 958 |
+
# Arguments:
|
| 959 |
+
# w - Window in which the key was typed (selects
|
| 960 |
+
# a toplevel window).
|
| 961 |
+
# char - Character that selects a menu. The case
|
| 962 |
+
# is ignored. If an empty string, nothing
|
| 963 |
+
# happens.
|
| 964 |
+
|
| 965 |
+
proc ::tk::TraverseToMenu {w char} {
|
| 966 |
+
variable ::tk::Priv
|
| 967 |
+
if {![winfo exists $w] || $char eq ""} {
|
| 968 |
+
return
|
| 969 |
+
}
|
| 970 |
+
while {[winfo class $w] eq "Menu"} {
|
| 971 |
+
if {[$w cget -type] eq "menubar"} {
|
| 972 |
+
break
|
| 973 |
+
} elseif {$Priv(postedMb) eq ""} {
|
| 974 |
+
return
|
| 975 |
+
}
|
| 976 |
+
set w [winfo parent $w]
|
| 977 |
+
}
|
| 978 |
+
set w [MenuFind [winfo toplevel $w] $char]
|
| 979 |
+
if {$w ne ""} {
|
| 980 |
+
if {[winfo class $w] eq "Menu"} {
|
| 981 |
+
tk_menuSetFocus $w
|
| 982 |
+
set Priv(window) $w
|
| 983 |
+
SaveGrabInfo $w
|
| 984 |
+
grab -global $w
|
| 985 |
+
TraverseWithinMenu $w $char
|
| 986 |
+
} else {
|
| 987 |
+
MbPost $w
|
| 988 |
+
MenuFirstEntry [$w cget -menu]
|
| 989 |
+
}
|
| 990 |
+
}
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
# ::tk::FirstMenu --
|
| 994 |
+
# This procedure traverses to the first menubutton in the toplevel
|
| 995 |
+
# for a given window, and posts that menubutton's menu.
|
| 996 |
+
#
|
| 997 |
+
# Arguments:
|
| 998 |
+
# w - Name of a window. Selects which toplevel
|
| 999 |
+
# to search for menubuttons.
|
| 1000 |
+
|
| 1001 |
+
proc ::tk::FirstMenu w {
|
| 1002 |
+
variable ::tk::Priv
|
| 1003 |
+
set w [MenuFind [winfo toplevel $w] ""]
|
| 1004 |
+
if {$w ne ""} {
|
| 1005 |
+
if {[winfo class $w] eq "Menu"} {
|
| 1006 |
+
tk_menuSetFocus $w
|
| 1007 |
+
set Priv(window) $w
|
| 1008 |
+
SaveGrabInfo $w
|
| 1009 |
+
grab -global $w
|
| 1010 |
+
MenuFirstEntry $w
|
| 1011 |
+
} else {
|
| 1012 |
+
MbPost $w
|
| 1013 |
+
MenuFirstEntry [$w cget -menu]
|
| 1014 |
+
}
|
| 1015 |
+
}
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
# ::tk::TraverseWithinMenu
|
| 1019 |
+
# This procedure implements keyboard traversal within a menu. It
|
| 1020 |
+
# searches for an entry in the menu that has "char" underlined. If
|
| 1021 |
+
# such an entry is found, it is invoked and the menu is unposted.
|
| 1022 |
+
#
|
| 1023 |
+
# Arguments:
|
| 1024 |
+
# w - The name of the menu widget.
|
| 1025 |
+
# char - The character to look for; case is
|
| 1026 |
+
# ignored. If the string is empty then
|
| 1027 |
+
# nothing happens.
|
| 1028 |
+
|
| 1029 |
+
proc ::tk::TraverseWithinMenu {w char} {
|
| 1030 |
+
if {$char eq ""} {
|
| 1031 |
+
return
|
| 1032 |
+
}
|
| 1033 |
+
set char [string tolower $char]
|
| 1034 |
+
set last [$w index last]
|
| 1035 |
+
if {$last eq "none"} {
|
| 1036 |
+
return
|
| 1037 |
+
}
|
| 1038 |
+
for {set i 0} {$i <= $last} {incr i} {
|
| 1039 |
+
if {[catch {set char2 [string index \
|
| 1040 |
+
[$w entrycget $i -label] [$w entrycget $i -underline]]}]} {
|
| 1041 |
+
continue
|
| 1042 |
+
}
|
| 1043 |
+
if {$char eq [string tolower $char2]} {
|
| 1044 |
+
if {[$w type $i] eq "cascade"} {
|
| 1045 |
+
$w activate $i
|
| 1046 |
+
$w postcascade active
|
| 1047 |
+
event generate $w <<MenuSelect>>
|
| 1048 |
+
set m2 [$w entrycget $i -menu]
|
| 1049 |
+
if {$m2 ne ""} {
|
| 1050 |
+
MenuFirstEntry $m2
|
| 1051 |
+
}
|
| 1052 |
+
} else {
|
| 1053 |
+
MenuUnpost $w
|
| 1054 |
+
uplevel #0 [list $w invoke $i]
|
| 1055 |
+
}
|
| 1056 |
+
return
|
| 1057 |
+
}
|
| 1058 |
+
}
|
| 1059 |
+
}
|
| 1060 |
+
|
| 1061 |
+
# ::tk::MenuFirstEntry --
|
| 1062 |
+
# Given a menu, this procedure finds the first entry that isn't
|
| 1063 |
+
# disabled or a tear-off or separator, and activates that entry.
|
| 1064 |
+
# However, if there is already an active entry in the menu (e.g.,
|
| 1065 |
+
# because of a previous call to tk::PostOverPoint) then the active
|
| 1066 |
+
# entry isn't changed. This procedure also sets the input focus
|
| 1067 |
+
# to the menu.
|
| 1068 |
+
#
|
| 1069 |
+
# Arguments:
|
| 1070 |
+
# menu - Name of the menu window (possibly empty).
|
| 1071 |
+
|
| 1072 |
+
proc ::tk::MenuFirstEntry menu {
|
| 1073 |
+
if {$menu eq ""} {
|
| 1074 |
+
return
|
| 1075 |
+
}
|
| 1076 |
+
tk_menuSetFocus $menu
|
| 1077 |
+
set activeindex [$menu index active]
|
| 1078 |
+
if {($activeindex ne "none") && ($activeindex >= 0)} {
|
| 1079 |
+
return
|
| 1080 |
+
}
|
| 1081 |
+
set last [$menu index last]
|
| 1082 |
+
if {$last eq "none"} {
|
| 1083 |
+
return
|
| 1084 |
+
}
|
| 1085 |
+
for {set i 0} {$i <= $last} {incr i} {
|
| 1086 |
+
if {([catch {set state [$menu entrycget $i -state]}] == 0) \
|
| 1087 |
+
&& $state ne "disabled" && [$menu type $i] ne "tearoff"} {
|
| 1088 |
+
$menu activate $i
|
| 1089 |
+
GenerateMenuSelect $menu
|
| 1090 |
+
# Only post the cascade if the current menu is a menubar;
|
| 1091 |
+
# otherwise, if the first entry of the cascade is a cascade,
|
| 1092 |
+
# we can get an annoying cascading effect resulting in a bunch of
|
| 1093 |
+
# menus getting posted (bug 676)
|
| 1094 |
+
if {[$menu type $i] eq "cascade" && [$menu cget -type] eq "menubar"} {
|
| 1095 |
+
set cascade [$menu entrycget $i -menu]
|
| 1096 |
+
if {$cascade ne ""} {
|
| 1097 |
+
$menu postcascade $i
|
| 1098 |
+
MenuFirstEntry $cascade
|
| 1099 |
+
}
|
| 1100 |
+
}
|
| 1101 |
+
return
|
| 1102 |
+
}
|
| 1103 |
+
}
|
| 1104 |
+
}
|
| 1105 |
+
|
| 1106 |
+
# ::tk::MenuFindName --
|
| 1107 |
+
# Given a menu and a text string, return the index of the menu entry
|
| 1108 |
+
# that displays the string as its label. If there is no such entry,
|
| 1109 |
+
# return an empty string. This procedure is tricky because some names
|
| 1110 |
+
# like "active" have a special meaning in menu commands, so we can't
|
| 1111 |
+
# always use the "index" widget command.
|
| 1112 |
+
#
|
| 1113 |
+
# Arguments:
|
| 1114 |
+
# menu - Name of the menu widget.
|
| 1115 |
+
# s - String to look for.
|
| 1116 |
+
|
| 1117 |
+
proc ::tk::MenuFindName {menu s} {
|
| 1118 |
+
set i ""
|
| 1119 |
+
if {![regexp {^active$|^last$|^none$|^[0-9]|^@} $s]} {
|
| 1120 |
+
catch {set i [$menu index $s]}
|
| 1121 |
+
return $i
|
| 1122 |
+
}
|
| 1123 |
+
set last [$menu index last]
|
| 1124 |
+
if {$last eq "none"} {
|
| 1125 |
+
return ""
|
| 1126 |
+
}
|
| 1127 |
+
for {set i 0} {$i <= $last} {incr i} {
|
| 1128 |
+
if {![catch {$menu entrycget $i -label} label]} {
|
| 1129 |
+
if {$label eq $s} {
|
| 1130 |
+
return $i
|
| 1131 |
+
}
|
| 1132 |
+
}
|
| 1133 |
+
}
|
| 1134 |
+
return ""
|
| 1135 |
+
}
|
| 1136 |
+
|
| 1137 |
+
# ::tk::PostMenubuttonMenu --
|
| 1138 |
+
#
|
| 1139 |
+
# Given a menubutton and a menu, this procedure posts the menu at the
|
| 1140 |
+
# appropriate location. If the menubutton looks like an option
|
| 1141 |
+
# menubutton, meaning that the indicator is on and the direction is
|
| 1142 |
+
# neither above nor below, then the menu is posted so that the current
|
| 1143 |
+
# entry is vertically aligned with the menubutton. On the Mac this
|
| 1144 |
+
# will expose a small amount of the blue indicator on the right hand
|
| 1145 |
+
# side. On other platforms the entry is centered over the button.
|
| 1146 |
+
|
| 1147 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 1148 |
+
proc ::tk::PostMenubuttonMenu {button menu cx cy} {
|
| 1149 |
+
set entry ""
|
| 1150 |
+
if {[$button cget -indicatoron]} {
|
| 1151 |
+
set entry [MenuFindName $menu [$button cget -text]]
|
| 1152 |
+
if {$entry eq ""} {
|
| 1153 |
+
set entry 0
|
| 1154 |
+
}
|
| 1155 |
+
}
|
| 1156 |
+
set x [winfo rootx $button]
|
| 1157 |
+
set y [expr {2 + [winfo rooty $button]}]
|
| 1158 |
+
switch [$button cget -direction] {
|
| 1159 |
+
above {
|
| 1160 |
+
set entry ""
|
| 1161 |
+
incr y [expr {4 - [winfo reqheight $menu]}]
|
| 1162 |
+
}
|
| 1163 |
+
below {
|
| 1164 |
+
set entry ""
|
| 1165 |
+
incr y [expr {2 + [winfo height $button]}]
|
| 1166 |
+
}
|
| 1167 |
+
left {
|
| 1168 |
+
incr x [expr {-[winfo reqwidth $menu]}]
|
| 1169 |
+
}
|
| 1170 |
+
right {
|
| 1171 |
+
incr x [winfo width $button]
|
| 1172 |
+
}
|
| 1173 |
+
default { # flush
|
| 1174 |
+
incr x [expr {[winfo width $button] - [winfo reqwidth $menu] - 5}]
|
| 1175 |
+
}
|
| 1176 |
+
}
|
| 1177 |
+
PostOverPoint $menu $x $y $entry
|
| 1178 |
+
}
|
| 1179 |
+
} else {
|
| 1180 |
+
proc ::tk::PostMenubuttonMenu {button menu cx cy} {
|
| 1181 |
+
set entry ""
|
| 1182 |
+
if {[$button cget -indicatoron]} {
|
| 1183 |
+
set entry [MenuFindName $menu [$button cget -text]]
|
| 1184 |
+
if {$entry eq ""} {
|
| 1185 |
+
set entry 0
|
| 1186 |
+
}
|
| 1187 |
+
}
|
| 1188 |
+
set x [winfo rootx $button]
|
| 1189 |
+
set y [winfo rooty $button]
|
| 1190 |
+
switch [$button cget -direction] {
|
| 1191 |
+
above {
|
| 1192 |
+
incr y [expr {-[winfo reqheight $menu]}]
|
| 1193 |
+
# if we go offscreen to the top, show as 'below'
|
| 1194 |
+
if {$y < [winfo vrooty $button]} {
|
| 1195 |
+
set y [expr {[winfo vrooty $button] + [winfo rooty $button]\
|
| 1196 |
+
+ [winfo reqheight $button]}]
|
| 1197 |
+
}
|
| 1198 |
+
set entry {}
|
| 1199 |
+
}
|
| 1200 |
+
below {
|
| 1201 |
+
incr y [winfo height $button]
|
| 1202 |
+
# if we go offscreen to the bottom, show as 'above'
|
| 1203 |
+
set mh [winfo reqheight $menu]
|
| 1204 |
+
if {($y + $mh) > ([winfo vrooty $button] + [winfo vrootheight $button])} {
|
| 1205 |
+
set y [expr {[winfo vrooty $button] + [winfo vrootheight $button] \
|
| 1206 |
+
+ [winfo rooty $button] - $mh}]
|
| 1207 |
+
}
|
| 1208 |
+
set entry {}
|
| 1209 |
+
}
|
| 1210 |
+
left {
|
| 1211 |
+
incr x [expr {- [winfo reqwidth $menu]}]
|
| 1212 |
+
}
|
| 1213 |
+
right {
|
| 1214 |
+
incr x [expr {[winfo width $button]}]
|
| 1215 |
+
}
|
| 1216 |
+
default { # flush
|
| 1217 |
+
if {[$button cget -indicatoron]} {
|
| 1218 |
+
if {$cx ne ""} {
|
| 1219 |
+
set x [expr {$cx - [winfo reqwidth $menu] / 2}]
|
| 1220 |
+
set l [font metrics [$menu cget -font] -linespace]
|
| 1221 |
+
set y [expr {$cy - $l/2 - 2}]
|
| 1222 |
+
} else {
|
| 1223 |
+
incr x [expr {([winfo width $button] - \
|
| 1224 |
+
[winfo reqwidth $menu])/ 2}]
|
| 1225 |
+
}
|
| 1226 |
+
} else {
|
| 1227 |
+
incr y [winfo height $button]
|
| 1228 |
+
}
|
| 1229 |
+
}
|
| 1230 |
+
}
|
| 1231 |
+
PostOverPoint $menu $x $y $entry
|
| 1232 |
+
}
|
| 1233 |
+
}
|
| 1234 |
+
|
| 1235 |
+
# ::tk::PostOverPoint --
|
| 1236 |
+
#
|
| 1237 |
+
# This procedure posts a menu on the screen so that a given entry in
|
| 1238 |
+
# the menu is positioned with its upper left corner at a given point
|
| 1239 |
+
# in the root window. The procedure also activates that entry. If no
|
| 1240 |
+
# entry is specified the upper left corner of the entire menu is
|
| 1241 |
+
# placed at the point.
|
| 1242 |
+
#
|
| 1243 |
+
# Arguments:
|
| 1244 |
+
# menu - Menu to post.
|
| 1245 |
+
# x, y - Root coordinates of point.
|
| 1246 |
+
# entry - Index of entry within menu to center over (x,y).
|
| 1247 |
+
# If omitted or specified as {}, then the menu's
|
| 1248 |
+
# upper-left corner goes at (x,y).
|
| 1249 |
+
|
| 1250 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 1251 |
+
proc ::tk::PostOverPoint {menu x y {entry {}}} {
|
| 1252 |
+
if {$entry ne ""} {
|
| 1253 |
+
$menu post $x $y $entry
|
| 1254 |
+
if {[$menu type $entry] ni {separator tearoff} &&
|
| 1255 |
+
[$menu entrycget $entry -state] ne "disabled"} {
|
| 1256 |
+
$menu activate $entry
|
| 1257 |
+
GenerateMenuSelect $menu
|
| 1258 |
+
}
|
| 1259 |
+
} else {
|
| 1260 |
+
$menu post $x $y
|
| 1261 |
+
}
|
| 1262 |
+
return
|
| 1263 |
+
}
|
| 1264 |
+
} else {
|
| 1265 |
+
proc ::tk::PostOverPoint {menu x y {entry {}}} {
|
| 1266 |
+
if {$entry ne ""} {
|
| 1267 |
+
incr y [expr {-[$menu yposition $entry]}]
|
| 1268 |
+
}
|
| 1269 |
+
# osVersion is not available in safe interps
|
| 1270 |
+
set ver 5
|
| 1271 |
+
if {[info exists ::tcl_platform(osVersion)]} {
|
| 1272 |
+
scan $::tcl_platform(osVersion) %d ver
|
| 1273 |
+
}
|
| 1274 |
+
|
| 1275 |
+
# We need to fix some problems with menu posting on Windows,
|
| 1276 |
+
# where, if the menu would overlap top or bottom of screen,
|
| 1277 |
+
# Windows puts it in the wrong place for us. We must also
|
| 1278 |
+
# subtract an extra amount for half the height of the current
|
| 1279 |
+
# entry. To be safe we subtract an extra 10.
|
| 1280 |
+
# NOTE: this issue appears to have been resolved in the Window
|
| 1281 |
+
# manager provided with Vista and Windows 7.
|
| 1282 |
+
if {$ver < 6} {
|
| 1283 |
+
set yoffset [expr {[winfo screenheight $menu] \
|
| 1284 |
+
- $y - [winfo reqheight $menu] - 10}]
|
| 1285 |
+
if {$yoffset < [winfo vrooty $menu]} {
|
| 1286 |
+
# The bottom of the menu is offscreen, so adjust upwards
|
| 1287 |
+
incr y [expr {$yoffset - [winfo vrooty $menu]}]
|
| 1288 |
+
}
|
| 1289 |
+
# If we're off the top of the screen (either because we were
|
| 1290 |
+
# originally or because we just adjusted too far upwards),
|
| 1291 |
+
# then make the menu popup on the top edge.
|
| 1292 |
+
if {$y < [winfo vrooty $menu]} {
|
| 1293 |
+
set y [winfo vrooty $menu]
|
| 1294 |
+
}
|
| 1295 |
+
}
|
| 1296 |
+
$menu post $x $y
|
| 1297 |
+
if {$entry ne "" && [$menu entrycget $entry -state] ne "disabled"} {
|
| 1298 |
+
$menu activate $entry
|
| 1299 |
+
GenerateMenuSelect $menu
|
| 1300 |
+
}
|
| 1301 |
+
}
|
| 1302 |
+
}
|
| 1303 |
+
|
| 1304 |
+
# ::tk::SaveGrabInfo --
|
| 1305 |
+
# Sets the variables tk::Priv(oldGrab) and tk::Priv(grabStatus) to record
|
| 1306 |
+
# the state of any existing grab on the w's display.
|
| 1307 |
+
#
|
| 1308 |
+
# Arguments:
|
| 1309 |
+
# w - Name of a window; used to select the display
|
| 1310 |
+
# whose grab information is to be recorded.
|
| 1311 |
+
|
| 1312 |
+
proc tk::SaveGrabInfo w {
|
| 1313 |
+
variable ::tk::Priv
|
| 1314 |
+
set Priv(oldGrab) [grab current $w]
|
| 1315 |
+
if {$Priv(oldGrab) ne ""} {
|
| 1316 |
+
set Priv(grabStatus) [grab status $Priv(oldGrab)]
|
| 1317 |
+
}
|
| 1318 |
+
}
|
| 1319 |
+
|
| 1320 |
+
# ::tk::RestoreOldGrab --
|
| 1321 |
+
# Restores the grab to what it was before TkSaveGrabInfo was called.
|
| 1322 |
+
#
|
| 1323 |
+
|
| 1324 |
+
proc ::tk::RestoreOldGrab {} {
|
| 1325 |
+
variable ::tk::Priv
|
| 1326 |
+
|
| 1327 |
+
if {$Priv(oldGrab) ne ""} {
|
| 1328 |
+
# Be careful restoring the old grab, since it's window may not
|
| 1329 |
+
# be visible anymore.
|
| 1330 |
+
|
| 1331 |
+
catch {
|
| 1332 |
+
if {$Priv(grabStatus) eq "global"} {
|
| 1333 |
+
grab set -global $Priv(oldGrab)
|
| 1334 |
+
} else {
|
| 1335 |
+
grab set $Priv(oldGrab)
|
| 1336 |
+
}
|
| 1337 |
+
}
|
| 1338 |
+
set Priv(oldGrab) ""
|
| 1339 |
+
}
|
| 1340 |
+
}
|
| 1341 |
+
|
| 1342 |
+
proc ::tk_menuSetFocus {menu} {
|
| 1343 |
+
variable ::tk::Priv
|
| 1344 |
+
if {![info exists Priv(focus)] || $Priv(focus) eq ""} {
|
| 1345 |
+
set Priv(focus) [focus]
|
| 1346 |
+
}
|
| 1347 |
+
focus $menu
|
| 1348 |
+
}
|
| 1349 |
+
|
| 1350 |
+
proc ::tk::GenerateMenuSelect {menu} {
|
| 1351 |
+
variable ::tk::Priv
|
| 1352 |
+
|
| 1353 |
+
if {$Priv(activeMenu) ne $menu \
|
| 1354 |
+
|| $Priv(activeItem) ne [$menu index active]} {
|
| 1355 |
+
set Priv(activeMenu) $menu
|
| 1356 |
+
set Priv(activeItem) [$menu index active]
|
| 1357 |
+
event generate $menu <<MenuSelect>>
|
| 1358 |
+
}
|
| 1359 |
+
}
|
| 1360 |
+
|
| 1361 |
+
# ::tk_popup --
|
| 1362 |
+
# This procedure pops up a menu and sets things up for traversing
|
| 1363 |
+
# the menu and its submenus.
|
| 1364 |
+
#
|
| 1365 |
+
# Arguments:
|
| 1366 |
+
# menu - Name of the menu to be popped up.
|
| 1367 |
+
# x, y - Root coordinates at which to pop up the
|
| 1368 |
+
# menu.
|
| 1369 |
+
# entry - Index of a menu entry to center over (x,y).
|
| 1370 |
+
# If omitted or specified as {}, then menu's
|
| 1371 |
+
# upper-left corner goes at (x,y).
|
| 1372 |
+
|
| 1373 |
+
proc ::tk_popup {menu x y {entry {}}} {
|
| 1374 |
+
variable ::tk::Priv
|
| 1375 |
+
if {$Priv(popup) ne "" || $Priv(postedMb) ne ""} {
|
| 1376 |
+
tk::MenuUnpost {}
|
| 1377 |
+
}
|
| 1378 |
+
tk::PostOverPoint $menu $x $y $entry
|
| 1379 |
+
if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} {
|
| 1380 |
+
tk::SaveGrabInfo $menu
|
| 1381 |
+
grab -global $menu
|
| 1382 |
+
set Priv(popup) $menu
|
| 1383 |
+
set Priv(window) $menu
|
| 1384 |
+
set Priv(menuActivated) 1
|
| 1385 |
+
tk_menuSetFocus $menu
|
| 1386 |
+
}
|
| 1387 |
+
}
|
mplug_owl2/lib/tk8.6/mkpsenc.tcl
ADDED
|
@@ -0,0 +1,1488 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/obsolete.tcl
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# obsolete.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file contains obsolete procedures that people really shouldn't
|
| 4 |
+
# be using anymore, but which are kept around for backward compatibility.
|
| 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 |
+
# The procedures below are here strictly for backward compatibility with
|
| 14 |
+
# Tk version 3.6 and earlier. The procedures are no longer needed, so
|
| 15 |
+
# they are no-ops. You should not use these procedures anymore, since
|
| 16 |
+
# they may be removed in some future release.
|
| 17 |
+
|
| 18 |
+
proc tk_menuBar args {}
|
| 19 |
+
proc tk_bindForTraversal args {}
|
| 20 |
+
|
| 21 |
+
# ::tk::classic::restore --
|
| 22 |
+
#
|
| 23 |
+
# Restore the pre-8.5 (Tk classic) look as the widget defaults for classic
|
| 24 |
+
# Tk widgets.
|
| 25 |
+
#
|
| 26 |
+
# The value following an 'option add' call is the new 8.5 value.
|
| 27 |
+
#
|
| 28 |
+
namespace eval ::tk::classic {
|
| 29 |
+
# This may need to be adjusted for some window managers that are
|
| 30 |
+
# more aggressive with their own Xdefaults (like KDE and CDE)
|
| 31 |
+
variable prio "widgetDefault"
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
proc ::tk::classic::restore {args} {
|
| 35 |
+
# Restore classic (8.4) look to classic Tk widgets
|
| 36 |
+
variable prio
|
| 37 |
+
|
| 38 |
+
if {[llength $args]} {
|
| 39 |
+
foreach what $args {
|
| 40 |
+
::tk::classic::restore_$what
|
| 41 |
+
}
|
| 42 |
+
} else {
|
| 43 |
+
foreach cmd [info procs restore_*] {
|
| 44 |
+
$cmd
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
proc ::tk::classic::restore_font {args} {
|
| 50 |
+
# Many widgets were adjusted from hard-coded defaults to using the
|
| 51 |
+
# TIP#145 fonts defined in fonts.tcl (eg TkDefaultFont, TkFixedFont, ...)
|
| 52 |
+
# For restoring compatibility, we only correct size and weighting changes,
|
| 53 |
+
# as the fonts themselves remained mostly the same.
|
| 54 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 55 |
+
font configure TkDefaultFont -weight bold ; # normal
|
| 56 |
+
font configure TkFixedFont -size -12 ; # -10
|
| 57 |
+
}
|
| 58 |
+
# Add these with prio 21 to override value in dialog/msgbox.tcl
|
| 59 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 60 |
+
option add *Dialog.msg.font system 21; # TkCaptionFont
|
| 61 |
+
option add *Dialog.dtl.font system 21; # TkCaptionFont
|
| 62 |
+
option add *ErrorDialog*Label.font system 21; # TkCaptionFont
|
| 63 |
+
} else {
|
| 64 |
+
option add *Dialog.msg.font {Times 12} 21; # TkCaptionFont
|
| 65 |
+
option add *Dialog.dtl.font {Times 10} 21; # TkCaptionFont
|
| 66 |
+
option add *ErrorDialog*Label.font {Times -18} 21; # TkCaptionFont
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
proc ::tk::classic::restore_button {args} {
|
| 71 |
+
variable prio
|
| 72 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 73 |
+
foreach cls {Button Radiobutton Checkbutton} {
|
| 74 |
+
option add *$cls.borderWidth 2 $prio; # 1
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
proc ::tk::classic::restore_entry {args} {
|
| 80 |
+
variable prio
|
| 81 |
+
# Entry and Spinbox share core defaults
|
| 82 |
+
foreach cls {Entry Spinbox} {
|
| 83 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 84 |
+
option add *$cls.borderWidth 2 $prio; # 1
|
| 85 |
+
}
|
| 86 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 87 |
+
option add *$cls.background "#d9d9d9" $prio; # "white"
|
| 88 |
+
option add *$cls.selectBorderWidth 1 $prio; # 0
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
proc ::tk::classic::restore_listbox {args} {
|
| 94 |
+
variable prio
|
| 95 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 96 |
+
option add *Listbox.background "#d9d9d9" $prio; # "white"
|
| 97 |
+
option add *Listbox.activeStyle "underline" $prio; # "dotbox"
|
| 98 |
+
}
|
| 99 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 100 |
+
option add *Listbox.borderWidth 2 $prio; # 1
|
| 101 |
+
}
|
| 102 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 103 |
+
option add *Listbox.selectBorderWidth 1 $prio; # 0
|
| 104 |
+
}
|
| 105 |
+
# Remove focus into Listbox added for 8.5
|
| 106 |
+
bind Listbox <1> {
|
| 107 |
+
if {[winfo exists %W]} {
|
| 108 |
+
tk::ListboxBeginSelect %W [%W index @%x,%y]
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
proc ::tk::classic::restore_menu {args} {
|
| 114 |
+
variable prio
|
| 115 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 116 |
+
option add *Menu.activeBorderWidth 2 $prio; # 1
|
| 117 |
+
option add *Menu.borderWidth 2 $prio; # 1
|
| 118 |
+
option add *Menu.clickToFocus true $prio
|
| 119 |
+
option add *Menu.useMotifHelp true $prio
|
| 120 |
+
}
|
| 121 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 122 |
+
option add *Menu.font "TkDefaultFont" $prio; # "TkMenuFont"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
proc ::tk::classic::restore_menubutton {args} {
|
| 127 |
+
variable prio
|
| 128 |
+
option add *Menubutton.borderWidth 2 $prio; # 1
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
proc ::tk::classic::restore_message {args} {
|
| 132 |
+
variable prio
|
| 133 |
+
option add *Message.borderWidth 2 $prio; # 1
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
proc ::tk::classic::restore_panedwindow {args} {
|
| 137 |
+
variable prio
|
| 138 |
+
option add *Panedwindow.borderWidth 2 $prio; # 1
|
| 139 |
+
option add *Panedwindow.sashWidth 2 $prio; # 3
|
| 140 |
+
option add *Panedwindow.sashPad 2 $prio; # 0
|
| 141 |
+
option add *Panedwindow.sashRelief raised $prio; # flat
|
| 142 |
+
option add *Panedwindow.opaqueResize 0 $prio; # 1
|
| 143 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 144 |
+
option add *Panedwindow.showHandle 1 $prio; # 0
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
proc ::tk::classic::restore_scale {args} {
|
| 149 |
+
variable prio
|
| 150 |
+
option add *Scale.borderWidth 2 $prio; # 1
|
| 151 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 152 |
+
option add *Scale.troughColor "#c3c3c3" $prio; # "#b3b3b3"
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
proc ::tk::classic::restore_scrollbar {args} {
|
| 157 |
+
variable prio
|
| 158 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 159 |
+
option add *Scrollbar.borderWidth 2 $prio; # 1
|
| 160 |
+
option add *Scrollbar.highlightThickness 1 $prio; # 0
|
| 161 |
+
option add *Scrollbar.width 15 $prio; # 11
|
| 162 |
+
option add *Scrollbar.troughColor "#c3c3c3" $prio; # "#b3b3b3"
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
proc ::tk::classic::restore_text {args} {
|
| 167 |
+
variable prio
|
| 168 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 169 |
+
option add *Text.borderWidth 2 $prio; # 1
|
| 170 |
+
}
|
| 171 |
+
if {[tk windowingsystem] eq "win32"} {
|
| 172 |
+
option add *Text.font "TkDefaultFont" $prio; # "TkFixedFont"
|
| 173 |
+
}
|
| 174 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 175 |
+
option add *Text.background "#d9d9d9" $prio; # white
|
| 176 |
+
option add *Text.selectBorderWidth 1 $prio; # 0
|
| 177 |
+
}
|
| 178 |
+
}
|
mplug_owl2/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 |
+
}
|
mplug_owl2/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 #c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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# panedwindow.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the default bindings for Tk panedwindow widgets and
|
| 4 |
+
# provides procedures that help in implementing those bindings.
|
| 5 |
+
|
| 6 |
+
bind Panedwindow <Button-1> { ::tk::panedwindow::MarkSash %W %x %y 1 }
|
| 7 |
+
bind Panedwindow <Button-2> { ::tk::panedwindow::MarkSash %W %x %y 0 }
|
| 8 |
+
|
| 9 |
+
bind Panedwindow <B1-Motion> { ::tk::panedwindow::DragSash %W %x %y 1 }
|
| 10 |
+
bind Panedwindow <B2-Motion> { ::tk::panedwindow::DragSash %W %x %y 0 }
|
| 11 |
+
|
| 12 |
+
bind Panedwindow <ButtonRelease-1> {::tk::panedwindow::ReleaseSash %W 1}
|
| 13 |
+
bind Panedwindow <ButtonRelease-2> {::tk::panedwindow::ReleaseSash %W 0}
|
| 14 |
+
|
| 15 |
+
bind Panedwindow <Motion> { ::tk::panedwindow::Motion %W %x %y }
|
| 16 |
+
|
| 17 |
+
bind Panedwindow <Leave> { ::tk::panedwindow::Leave %W }
|
| 18 |
+
|
| 19 |
+
# Initialize namespace
|
| 20 |
+
namespace eval ::tk::panedwindow {}
|
| 21 |
+
|
| 22 |
+
# ::tk::panedwindow::MarkSash --
|
| 23 |
+
#
|
| 24 |
+
# Handle marking the correct sash for possible dragging
|
| 25 |
+
#
|
| 26 |
+
# Arguments:
|
| 27 |
+
# w the widget
|
| 28 |
+
# x widget local x coord
|
| 29 |
+
# y widget local y coord
|
| 30 |
+
# proxy whether this should be a proxy sash
|
| 31 |
+
# Results:
|
| 32 |
+
# None
|
| 33 |
+
#
|
| 34 |
+
proc ::tk::panedwindow::MarkSash {w x y proxy} {
|
| 35 |
+
variable ::tk::Priv
|
| 36 |
+
if {[$w cget -opaqueresize]} {
|
| 37 |
+
set proxy 0
|
| 38 |
+
}
|
| 39 |
+
set what [$w identify $x $y]
|
| 40 |
+
if { [llength $what] == 2 } {
|
| 41 |
+
lassign $what index which
|
| 42 |
+
if {!$::tk_strictMotif || $which eq "handle"} {
|
| 43 |
+
if {!$proxy} {
|
| 44 |
+
$w sash mark $index $x $y
|
| 45 |
+
}
|
| 46 |
+
set Priv(sash) $index
|
| 47 |
+
lassign [$w sash coord $index] sx sy
|
| 48 |
+
set Priv(dx) [expr {$sx-$x}]
|
| 49 |
+
set Priv(dy) [expr {$sy-$y}]
|
| 50 |
+
# Do this to init the proxy location
|
| 51 |
+
DragSash $w $x $y $proxy
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
# ::tk::panedwindow::DragSash --
|
| 57 |
+
#
|
| 58 |
+
# Handle dragging of the correct sash
|
| 59 |
+
#
|
| 60 |
+
# Arguments:
|
| 61 |
+
# w the widget
|
| 62 |
+
# x widget local x coord
|
| 63 |
+
# y widget local y coord
|
| 64 |
+
# proxy whether this should be a proxy sash
|
| 65 |
+
# Results:
|
| 66 |
+
# Moves sash
|
| 67 |
+
#
|
| 68 |
+
proc ::tk::panedwindow::DragSash {w x y proxy} {
|
| 69 |
+
variable ::tk::Priv
|
| 70 |
+
if {[$w cget -opaqueresize]} {
|
| 71 |
+
set proxy 0
|
| 72 |
+
}
|
| 73 |
+
if {[info exists Priv(sash)]} {
|
| 74 |
+
if {$proxy} {
|
| 75 |
+
$w proxy place [expr {$x+$Priv(dx)}] [expr {$y+$Priv(dy)}]
|
| 76 |
+
} else {
|
| 77 |
+
$w sash place $Priv(sash) \
|
| 78 |
+
[expr {$x+$Priv(dx)}] [expr {$y+$Priv(dy)}]
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
# ::tk::panedwindow::ReleaseSash --
|
| 84 |
+
#
|
| 85 |
+
# Handle releasing of the sash
|
| 86 |
+
#
|
| 87 |
+
# Arguments:
|
| 88 |
+
# w the widget
|
| 89 |
+
# proxy whether this should be a proxy sash
|
| 90 |
+
# Results:
|
| 91 |
+
# Returns ...
|
| 92 |
+
#
|
| 93 |
+
proc ::tk::panedwindow::ReleaseSash {w proxy} {
|
| 94 |
+
variable ::tk::Priv
|
| 95 |
+
if {[$w cget -opaqueresize]} {
|
| 96 |
+
set proxy 0
|
| 97 |
+
}
|
| 98 |
+
if {[info exists Priv(sash)]} {
|
| 99 |
+
if {$proxy} {
|
| 100 |
+
lassign [$w proxy coord] x y
|
| 101 |
+
$w sash place $Priv(sash) $x $y
|
| 102 |
+
$w proxy forget
|
| 103 |
+
}
|
| 104 |
+
unset Priv(sash) Priv(dx) Priv(dy)
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
# ::tk::panedwindow::Motion --
|
| 109 |
+
#
|
| 110 |
+
# Handle motion on the widget. This is used to change the cursor
|
| 111 |
+
# when the user moves over the sash area.
|
| 112 |
+
#
|
| 113 |
+
# Arguments:
|
| 114 |
+
# w the widget
|
| 115 |
+
# x widget local x coord
|
| 116 |
+
# y widget local y coord
|
| 117 |
+
# Results:
|
| 118 |
+
# May change the cursor. Sets up a timer to verify that we are still
|
| 119 |
+
# over the widget.
|
| 120 |
+
#
|
| 121 |
+
proc ::tk::panedwindow::Motion {w x y} {
|
| 122 |
+
variable ::tk::Priv
|
| 123 |
+
set id [$w identify $x $y]
|
| 124 |
+
if {([llength $id] == 2) && \
|
| 125 |
+
(!$::tk_strictMotif || [lindex $id 1] eq "handle")} {
|
| 126 |
+
if {![info exists Priv($w,panecursor)]} {
|
| 127 |
+
set Priv($w,panecursor) [$w cget -cursor]
|
| 128 |
+
if {[$w cget -sashcursor] ne ""} {
|
| 129 |
+
$w configure -cursor [$w cget -sashcursor]
|
| 130 |
+
} elseif {[$w cget -orient] eq "horizontal"} {
|
| 131 |
+
$w configure -cursor sb_h_double_arrow
|
| 132 |
+
} else {
|
| 133 |
+
$w configure -cursor sb_v_double_arrow
|
| 134 |
+
}
|
| 135 |
+
if {[info exists Priv($w,pwAfterId)]} {
|
| 136 |
+
after cancel $Priv($w,pwAfterId)
|
| 137 |
+
}
|
| 138 |
+
set Priv($w,pwAfterId) [after 150 \
|
| 139 |
+
[list ::tk::panedwindow::Cursor $w]]
|
| 140 |
+
}
|
| 141 |
+
return
|
| 142 |
+
}
|
| 143 |
+
if {[info exists Priv($w,panecursor)]} {
|
| 144 |
+
$w configure -cursor $Priv($w,panecursor)
|
| 145 |
+
unset Priv($w,panecursor)
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
# ::tk::panedwindow::Cursor --
|
| 150 |
+
#
|
| 151 |
+
# Handles returning the normal cursor when we are no longer over the
|
| 152 |
+
# sash area. This needs to be done this way, because the panedwindow
|
| 153 |
+
# won't see Leave events when the mouse moves from the sash to a
|
| 154 |
+
# paned child, although the child does receive an Enter event.
|
| 155 |
+
#
|
| 156 |
+
# Arguments:
|
| 157 |
+
# w the widget
|
| 158 |
+
# Results:
|
| 159 |
+
# May restore the default cursor, or schedule a timer to do it.
|
| 160 |
+
#
|
| 161 |
+
proc ::tk::panedwindow::Cursor {w} {
|
| 162 |
+
variable ::tk::Priv
|
| 163 |
+
# Make sure to check window existence in case it is destroyed.
|
| 164 |
+
if {[info exists Priv($w,panecursor)] && [winfo exists $w]} {
|
| 165 |
+
if {[winfo containing [winfo pointerx $w] [winfo pointery $w]] eq $w} {
|
| 166 |
+
set Priv($w,pwAfterId) [after 150 \
|
| 167 |
+
[list ::tk::panedwindow::Cursor $w]]
|
| 168 |
+
} else {
|
| 169 |
+
$w configure -cursor $Priv($w,panecursor)
|
| 170 |
+
unset Priv($w,panecursor)
|
| 171 |
+
if {[info exists Priv($w,pwAfterId)]} {
|
| 172 |
+
after cancel $Priv($w,pwAfterId)
|
| 173 |
+
unset Priv($w,pwAfterId)
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
# ::tk::panedwindow::Leave --
|
| 180 |
+
#
|
| 181 |
+
# Return to default cursor when leaving the pw widget.
|
| 182 |
+
#
|
| 183 |
+
# Arguments:
|
| 184 |
+
# w the widget
|
| 185 |
+
# Results:
|
| 186 |
+
# Restores the default cursor
|
| 187 |
+
#
|
| 188 |
+
proc ::tk::panedwindow::Leave {w} {
|
| 189 |
+
variable ::tk::Priv
|
| 190 |
+
if {[info exists Priv($w,panecursor)]} {
|
| 191 |
+
$w configure -cursor $Priv($w,panecursor)
|
| 192 |
+
unset Priv($w,panecursor)
|
| 193 |
+
}
|
| 194 |
+
}
|
mplug_owl2/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]]]
|
mplug_owl2/lib/tk8.6/safetk.tcl
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
mplug_owl2/lib/tk8.6/scale.tcl
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# scale.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the default bindings for Tk scale widgets and provides
|
| 4 |
+
# procedures that help in implementing the bindings.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1994 The Regents of the University of California.
|
| 7 |
+
# Copyright (c) 1994-1995 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 entries.
|
| 15 |
+
#-------------------------------------------------------------------------
|
| 16 |
+
|
| 17 |
+
# Standard Motif bindings:
|
| 18 |
+
|
| 19 |
+
bind Scale <Enter> {
|
| 20 |
+
if {$tk_strictMotif} {
|
| 21 |
+
set tk::Priv(activeBg) [%W cget -activebackground]
|
| 22 |
+
%W configure -activebackground [%W cget -background]
|
| 23 |
+
}
|
| 24 |
+
tk::ScaleActivate %W %x %y
|
| 25 |
+
}
|
| 26 |
+
bind Scale <Motion> {
|
| 27 |
+
tk::ScaleActivate %W %x %y
|
| 28 |
+
}
|
| 29 |
+
bind Scale <Leave> {
|
| 30 |
+
if {$tk_strictMotif} {
|
| 31 |
+
%W configure -activebackground $tk::Priv(activeBg)
|
| 32 |
+
}
|
| 33 |
+
if {[%W cget -state] eq "active"} {
|
| 34 |
+
%W configure -state normal
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
bind Scale <1> {
|
| 38 |
+
tk::ScaleButtonDown %W %x %y
|
| 39 |
+
}
|
| 40 |
+
bind Scale <B1-Motion> {
|
| 41 |
+
tk::ScaleDrag %W %x %y
|
| 42 |
+
}
|
| 43 |
+
bind Scale <B1-Leave> { }
|
| 44 |
+
bind Scale <B1-Enter> { }
|
| 45 |
+
bind Scale <ButtonRelease-1> {
|
| 46 |
+
tk::CancelRepeat
|
| 47 |
+
tk::ScaleEndDrag %W
|
| 48 |
+
tk::ScaleActivate %W %x %y
|
| 49 |
+
}
|
| 50 |
+
bind Scale <2> {
|
| 51 |
+
tk::ScaleButton2Down %W %x %y
|
| 52 |
+
}
|
| 53 |
+
bind Scale <B2-Motion> {
|
| 54 |
+
tk::ScaleDrag %W %x %y
|
| 55 |
+
}
|
| 56 |
+
bind Scale <B2-Leave> { }
|
| 57 |
+
bind Scale <B2-Enter> { }
|
| 58 |
+
bind Scale <ButtonRelease-2> {
|
| 59 |
+
tk::CancelRepeat
|
| 60 |
+
tk::ScaleEndDrag %W
|
| 61 |
+
tk::ScaleActivate %W %x %y
|
| 62 |
+
}
|
| 63 |
+
if {[tk windowingsystem] eq "win32"} {
|
| 64 |
+
# On Windows do the same with button 3, as that is the right mouse button
|
| 65 |
+
bind Scale <3> [bind Scale <2>]
|
| 66 |
+
bind Scale <B3-Motion> [bind Scale <B2-Motion>]
|
| 67 |
+
bind Scale <B3-Leave> [bind Scale <B2-Leave>]
|
| 68 |
+
bind Scale <B3-Enter> [bind Scale <B2-Enter>]
|
| 69 |
+
bind Scale <ButtonRelease-3> [bind Scale <ButtonRelease-2>]
|
| 70 |
+
}
|
| 71 |
+
bind Scale <Control-1> {
|
| 72 |
+
tk::ScaleControlPress %W %x %y
|
| 73 |
+
}
|
| 74 |
+
bind Scale <<PrevLine>> {
|
| 75 |
+
tk::ScaleIncrement %W up little noRepeat
|
| 76 |
+
}
|
| 77 |
+
bind Scale <<NextLine>> {
|
| 78 |
+
tk::ScaleIncrement %W down little noRepeat
|
| 79 |
+
}
|
| 80 |
+
bind Scale <<PrevChar>> {
|
| 81 |
+
tk::ScaleIncrement %W up little noRepeat
|
| 82 |
+
}
|
| 83 |
+
bind Scale <<NextChar>> {
|
| 84 |
+
tk::ScaleIncrement %W down little noRepeat
|
| 85 |
+
}
|
| 86 |
+
bind Scale <<PrevPara>> {
|
| 87 |
+
tk::ScaleIncrement %W up big noRepeat
|
| 88 |
+
}
|
| 89 |
+
bind Scale <<NextPara>> {
|
| 90 |
+
tk::ScaleIncrement %W down big noRepeat
|
| 91 |
+
}
|
| 92 |
+
bind Scale <<PrevWord>> {
|
| 93 |
+
tk::ScaleIncrement %W up big noRepeat
|
| 94 |
+
}
|
| 95 |
+
bind Scale <<NextWord>> {
|
| 96 |
+
tk::ScaleIncrement %W down big noRepeat
|
| 97 |
+
}
|
| 98 |
+
bind Scale <<LineStart>> {
|
| 99 |
+
%W set [%W cget -from]
|
| 100 |
+
}
|
| 101 |
+
bind Scale <<LineEnd>> {
|
| 102 |
+
%W set [%W cget -to]
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
# ::tk::ScaleActivate --
|
| 106 |
+
# This procedure is invoked to check a given x-y position in the
|
| 107 |
+
# scale and activate the slider if the x-y position falls within
|
| 108 |
+
# the slider.
|
| 109 |
+
#
|
| 110 |
+
# Arguments:
|
| 111 |
+
# w - The scale widget.
|
| 112 |
+
# x, y - Mouse coordinates.
|
| 113 |
+
|
| 114 |
+
proc ::tk::ScaleActivate {w x y} {
|
| 115 |
+
if {[$w cget -state] eq "disabled"} {
|
| 116 |
+
return
|
| 117 |
+
}
|
| 118 |
+
if {[$w identify $x $y] eq "slider"} {
|
| 119 |
+
set state active
|
| 120 |
+
} else {
|
| 121 |
+
set state normal
|
| 122 |
+
}
|
| 123 |
+
if {[$w cget -state] ne $state} {
|
| 124 |
+
$w configure -state $state
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
# ::tk::ScaleButtonDown --
|
| 129 |
+
# This procedure is invoked when a button is pressed in a scale. It
|
| 130 |
+
# takes different actions depending on where the button was pressed.
|
| 131 |
+
#
|
| 132 |
+
# Arguments:
|
| 133 |
+
# w - The scale widget.
|
| 134 |
+
# x, y - Mouse coordinates of button press.
|
| 135 |
+
|
| 136 |
+
proc ::tk::ScaleButtonDown {w x y} {
|
| 137 |
+
variable ::tk::Priv
|
| 138 |
+
set Priv(dragging) 0
|
| 139 |
+
set el [$w identify $x $y]
|
| 140 |
+
|
| 141 |
+
# save the relief
|
| 142 |
+
set Priv($w,relief) [$w cget -sliderrelief]
|
| 143 |
+
|
| 144 |
+
if {$el eq "trough1"} {
|
| 145 |
+
ScaleIncrement $w up little initial
|
| 146 |
+
} elseif {$el eq "trough2"} {
|
| 147 |
+
ScaleIncrement $w down little initial
|
| 148 |
+
} elseif {$el eq "slider"} {
|
| 149 |
+
set Priv(dragging) 1
|
| 150 |
+
set Priv(initValue) [$w get]
|
| 151 |
+
set coords [$w coords]
|
| 152 |
+
set Priv(deltaX) [expr {$x - [lindex $coords 0]}]
|
| 153 |
+
set Priv(deltaY) [expr {$y - [lindex $coords 1]}]
|
| 154 |
+
switch -exact -- $Priv($w,relief) {
|
| 155 |
+
"raised" { $w configure -sliderrelief sunken }
|
| 156 |
+
"ridge" { $w configure -sliderrelief groove }
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
# ::tk::ScaleDrag --
|
| 162 |
+
# This procedure is called when the mouse is dragged with
|
| 163 |
+
# mouse button 1 down. If the drag started inside the slider
|
| 164 |
+
# (i.e. the scale is active) then the scale's value is adjusted
|
| 165 |
+
# to reflect the mouse's position.
|
| 166 |
+
#
|
| 167 |
+
# Arguments:
|
| 168 |
+
# w - The scale widget.
|
| 169 |
+
# x, y - Mouse coordinates.
|
| 170 |
+
|
| 171 |
+
proc ::tk::ScaleDrag {w x y} {
|
| 172 |
+
variable ::tk::Priv
|
| 173 |
+
if {!$Priv(dragging)} {
|
| 174 |
+
return
|
| 175 |
+
}
|
| 176 |
+
$w set [$w get [expr {$x-$Priv(deltaX)}] [expr {$y-$Priv(deltaY)}]]
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
# ::tk::ScaleEndDrag --
|
| 180 |
+
# This procedure is called to end an interactive drag of the
|
| 181 |
+
# slider. It just marks the drag as over.
|
| 182 |
+
#
|
| 183 |
+
# Arguments:
|
| 184 |
+
# w - The scale widget.
|
| 185 |
+
|
| 186 |
+
proc ::tk::ScaleEndDrag {w} {
|
| 187 |
+
variable ::tk::Priv
|
| 188 |
+
set Priv(dragging) 0
|
| 189 |
+
if {[info exists Priv($w,relief)]} {
|
| 190 |
+
$w configure -sliderrelief $Priv($w,relief)
|
| 191 |
+
unset Priv($w,relief)
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
# ::tk::ScaleIncrement --
|
| 196 |
+
# This procedure is invoked to increment the value of a scale and
|
| 197 |
+
# to set up auto-repeating of the action if that is desired. The
|
| 198 |
+
# way the value is incremented depends on the "dir" and "big"
|
| 199 |
+
# arguments.
|
| 200 |
+
#
|
| 201 |
+
# Arguments:
|
| 202 |
+
# w - The scale widget.
|
| 203 |
+
# dir - "up" means move value towards -from, "down" means
|
| 204 |
+
# move towards -to.
|
| 205 |
+
# big - Size of increments: "big" or "little".
|
| 206 |
+
# repeat - Whether and how to auto-repeat the action: "noRepeat"
|
| 207 |
+
# means don't auto-repeat, "initial" means this is the
|
| 208 |
+
# first action in an auto-repeat sequence, and "again"
|
| 209 |
+
# means this is the second repetition or later.
|
| 210 |
+
|
| 211 |
+
proc ::tk::ScaleIncrement {w dir big repeat} {
|
| 212 |
+
variable ::tk::Priv
|
| 213 |
+
|
| 214 |
+
if {![winfo exists $w]} return
|
| 215 |
+
|
| 216 |
+
# give the cancel callback a chance to be serviced if the execution time of
|
| 217 |
+
# the -command script lasts longer than -repeatdelay
|
| 218 |
+
set clockms [clock milliseconds]
|
| 219 |
+
if {$repeat eq "again" &&
|
| 220 |
+
[expr {$clockms - $Priv(clockms)}] > [expr {[$w cget -repeatinterval] * 1.1}]} {
|
| 221 |
+
set Priv(clockms) $clockms
|
| 222 |
+
set Priv(afterId) [after [$w cget -repeatinterval] \
|
| 223 |
+
[list tk::ScaleIncrement $w $dir $big again]]
|
| 224 |
+
return
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
if {$big eq "big"} {
|
| 228 |
+
set inc [$w cget -bigincrement]
|
| 229 |
+
if {$inc == 0} {
|
| 230 |
+
set inc [expr {abs([$w cget -to] - [$w cget -from])/10.0}]
|
| 231 |
+
}
|
| 232 |
+
if {$inc < [$w cget -resolution]} {
|
| 233 |
+
set inc [$w cget -resolution]
|
| 234 |
+
}
|
| 235 |
+
} else {
|
| 236 |
+
set inc [$w cget -resolution]
|
| 237 |
+
}
|
| 238 |
+
if {([$w cget -from] > [$w cget -to]) ^ ($dir eq "up")} {
|
| 239 |
+
if {$inc > 0} {
|
| 240 |
+
set inc [expr {-$inc}]
|
| 241 |
+
}
|
| 242 |
+
} else {
|
| 243 |
+
if {$inc < 0} {
|
| 244 |
+
set inc [expr {-$inc}]
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
# this will run the -command script (if any) during the redrawing
|
| 248 |
+
# of the scale at idle time
|
| 249 |
+
$w set [expr {[$w get] + $inc}]
|
| 250 |
+
|
| 251 |
+
if {$repeat eq "again"} {
|
| 252 |
+
set Priv(clockms) $clockms
|
| 253 |
+
set Priv(afterId) [after [$w cget -repeatinterval] \
|
| 254 |
+
[list tk::ScaleIncrement $w $dir $big again]]
|
| 255 |
+
} elseif {$repeat eq "initial"} {
|
| 256 |
+
set delay [$w cget -repeatdelay]
|
| 257 |
+
if {$delay > 0} {
|
| 258 |
+
set Priv(clockms) $clockms
|
| 259 |
+
set Priv(afterId) [after $delay \
|
| 260 |
+
[list tk::ScaleIncrement $w $dir $big again]]
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
# ::tk::ScaleControlPress --
|
| 266 |
+
# This procedure handles button presses that are made with the Control
|
| 267 |
+
# key down. Depending on the mouse position, it adjusts the scale
|
| 268 |
+
# value to one end of the range or the other.
|
| 269 |
+
#
|
| 270 |
+
# Arguments:
|
| 271 |
+
# w - The scale widget.
|
| 272 |
+
# x, y - Mouse coordinates where the button was pressed.
|
| 273 |
+
|
| 274 |
+
proc ::tk::ScaleControlPress {w x y} {
|
| 275 |
+
set el [$w identify $x $y]
|
| 276 |
+
if {$el eq "trough1"} {
|
| 277 |
+
$w set [$w cget -from]
|
| 278 |
+
} elseif {$el eq "trough2"} {
|
| 279 |
+
$w set [$w cget -to]
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
# ::tk::ScaleButton2Down
|
| 284 |
+
# This procedure is invoked when button 2 is pressed over a scale.
|
| 285 |
+
# It sets the value to correspond to the mouse position and starts
|
| 286 |
+
# a slider drag.
|
| 287 |
+
#
|
| 288 |
+
# Arguments:
|
| 289 |
+
# w - The scrollbar widget.
|
| 290 |
+
# x, y - Mouse coordinates within the widget.
|
| 291 |
+
|
| 292 |
+
proc ::tk::ScaleButton2Down {w x y} {
|
| 293 |
+
variable ::tk::Priv
|
| 294 |
+
|
| 295 |
+
if {[$w cget -state] eq "disabled"} {
|
| 296 |
+
return
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
$w configure -state active
|
| 300 |
+
$w set [$w get $x $y]
|
| 301 |
+
set Priv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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
$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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# spinbox.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file defines the default bindings for Tk spinbox widgets and provides
|
| 4 |
+
# procedures that help in implementing those bindings. The spinbox builds
|
| 5 |
+
# off the entry widget, so it can reuse Entry bindings and procedures.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 1992-1994 The Regents of the University of California.
|
| 8 |
+
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
| 9 |
+
# Copyright (c) 1999-2000 Jeffrey Hobbs
|
| 10 |
+
# Copyright (c) 2000 Ajuba Solutions
|
| 11 |
+
#
|
| 12 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 13 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
#-------------------------------------------------------------------------
|
| 17 |
+
# Elements of tk::Priv that are used in this file:
|
| 18 |
+
#
|
| 19 |
+
# afterId - If non-null, it means that auto-scanning is underway
|
| 20 |
+
# and it gives the "after" id for the next auto-scan
|
| 21 |
+
# command to be executed.
|
| 22 |
+
# mouseMoved - Non-zero means the mouse has moved a significant
|
| 23 |
+
# amount since the button went down (so, for example,
|
| 24 |
+
# start dragging out a selection).
|
| 25 |
+
# pressX - X-coordinate at which the mouse button was pressed.
|
| 26 |
+
# selectMode - The style of selection currently underway:
|
| 27 |
+
# char, word, or line.
|
| 28 |
+
# x, y - Last known mouse coordinates for scanning
|
| 29 |
+
# and auto-scanning.
|
| 30 |
+
# data - Used for Cut and Copy
|
| 31 |
+
#-------------------------------------------------------------------------
|
| 32 |
+
|
| 33 |
+
# Initialize namespace
|
| 34 |
+
namespace eval ::tk::spinbox {}
|
| 35 |
+
|
| 36 |
+
#-------------------------------------------------------------------------
|
| 37 |
+
# The code below creates the default class bindings for entries.
|
| 38 |
+
#-------------------------------------------------------------------------
|
| 39 |
+
bind Spinbox <<Cut>> {
|
| 40 |
+
if {![catch {::tk::spinbox::GetSelection %W} tk::Priv(data)]} {
|
| 41 |
+
clipboard clear -displayof %W
|
| 42 |
+
clipboard append -displayof %W $tk::Priv(data)
|
| 43 |
+
%W delete sel.first sel.last
|
| 44 |
+
unset tk::Priv(data)
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
bind Spinbox <<Copy>> {
|
| 48 |
+
if {![catch {::tk::spinbox::GetSelection %W} tk::Priv(data)]} {
|
| 49 |
+
clipboard clear -displayof %W
|
| 50 |
+
clipboard append -displayof %W $tk::Priv(data)
|
| 51 |
+
unset tk::Priv(data)
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
bind Spinbox <<Paste>> {
|
| 55 |
+
catch {
|
| 56 |
+
if {[tk windowingsystem] ne "x11"} {
|
| 57 |
+
catch {
|
| 58 |
+
%W delete sel.first sel.last
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
%W insert insert [::tk::GetSelection %W CLIPBOARD]
|
| 62 |
+
::tk::EntrySeeInsert %W
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
bind Spinbox <<Clear>> {
|
| 66 |
+
%W delete sel.first sel.last
|
| 67 |
+
}
|
| 68 |
+
bind Spinbox <<PasteSelection>> {
|
| 69 |
+
if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
|
| 70 |
+
|| !$tk::Priv(mouseMoved)} {
|
| 71 |
+
::tk::spinbox::Paste %W %x
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
bind Spinbox <<TraverseIn>> {
|
| 76 |
+
%W selection range 0 end
|
| 77 |
+
%W icursor end
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
# Standard Motif bindings:
|
| 81 |
+
|
| 82 |
+
bind Spinbox <1> {
|
| 83 |
+
::tk::spinbox::ButtonDown %W %x %y
|
| 84 |
+
}
|
| 85 |
+
bind Spinbox <B1-Motion> {
|
| 86 |
+
::tk::spinbox::Motion %W %x %y
|
| 87 |
+
}
|
| 88 |
+
bind Spinbox <Double-1> {
|
| 89 |
+
::tk::spinbox::ArrowPress %W %x %y
|
| 90 |
+
set tk::Priv(selectMode) word
|
| 91 |
+
::tk::spinbox::MouseSelect %W %x sel.first
|
| 92 |
+
}
|
| 93 |
+
bind Spinbox <Triple-1> {
|
| 94 |
+
::tk::spinbox::ArrowPress %W %x %y
|
| 95 |
+
set tk::Priv(selectMode) line
|
| 96 |
+
::tk::spinbox::MouseSelect %W %x 0
|
| 97 |
+
}
|
| 98 |
+
bind Spinbox <Shift-1> {
|
| 99 |
+
set tk::Priv(selectMode) char
|
| 100 |
+
%W selection adjust @%x
|
| 101 |
+
}
|
| 102 |
+
bind Spinbox <Double-Shift-1> {
|
| 103 |
+
set tk::Priv(selectMode) word
|
| 104 |
+
::tk::spinbox::MouseSelect %W %x
|
| 105 |
+
}
|
| 106 |
+
bind Spinbox <Triple-Shift-1> {
|
| 107 |
+
set tk::Priv(selectMode) line
|
| 108 |
+
::tk::spinbox::MouseSelect %W %x
|
| 109 |
+
}
|
| 110 |
+
bind Spinbox <B1-Leave> {
|
| 111 |
+
set tk::Priv(x) %x
|
| 112 |
+
::tk::spinbox::AutoScan %W
|
| 113 |
+
}
|
| 114 |
+
bind Spinbox <B1-Enter> {
|
| 115 |
+
tk::CancelRepeat
|
| 116 |
+
}
|
| 117 |
+
bind Spinbox <ButtonRelease-1> {
|
| 118 |
+
::tk::spinbox::ButtonUp %W %x %y
|
| 119 |
+
}
|
| 120 |
+
bind Spinbox <Control-1> {
|
| 121 |
+
%W icursor @%x
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
bind Spinbox <<PrevLine>> {
|
| 125 |
+
%W invoke buttonup
|
| 126 |
+
}
|
| 127 |
+
bind Spinbox <<NextLine>> {
|
| 128 |
+
%W invoke buttondown
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
bind Spinbox <<PrevChar>> {
|
| 132 |
+
::tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
|
| 133 |
+
}
|
| 134 |
+
bind Spinbox <<NextChar>> {
|
| 135 |
+
::tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
|
| 136 |
+
}
|
| 137 |
+
bind Spinbox <<SelectPrevChar>> {
|
| 138 |
+
::tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
|
| 139 |
+
::tk::EntrySeeInsert %W
|
| 140 |
+
}
|
| 141 |
+
bind Spinbox <<SelectNextChar>> {
|
| 142 |
+
::tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
|
| 143 |
+
::tk::EntrySeeInsert %W
|
| 144 |
+
}
|
| 145 |
+
bind Spinbox <<PrevWord>> {
|
| 146 |
+
::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert]
|
| 147 |
+
}
|
| 148 |
+
bind Spinbox <<NextWord>> {
|
| 149 |
+
::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert]
|
| 150 |
+
}
|
| 151 |
+
bind Spinbox <<SelectPrevWord>> {
|
| 152 |
+
::tk::EntryKeySelect %W [::tk::EntryPreviousWord %W insert]
|
| 153 |
+
::tk::EntrySeeInsert %W
|
| 154 |
+
}
|
| 155 |
+
bind Spinbox <<SelectNextWord>> {
|
| 156 |
+
::tk::EntryKeySelect %W [::tk::EntryNextWord %W insert]
|
| 157 |
+
::tk::EntrySeeInsert %W
|
| 158 |
+
}
|
| 159 |
+
bind Spinbox <<LineStart>> {
|
| 160 |
+
::tk::EntrySetCursor %W 0
|
| 161 |
+
}
|
| 162 |
+
bind Spinbox <<SelectLineStart>> {
|
| 163 |
+
::tk::EntryKeySelect %W 0
|
| 164 |
+
::tk::EntrySeeInsert %W
|
| 165 |
+
}
|
| 166 |
+
bind Spinbox <<LineEnd>> {
|
| 167 |
+
::tk::EntrySetCursor %W end
|
| 168 |
+
}
|
| 169 |
+
bind Spinbox <<SelectLineEnd>> {
|
| 170 |
+
::tk::EntryKeySelect %W end
|
| 171 |
+
::tk::EntrySeeInsert %W
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
bind Spinbox <Delete> {
|
| 175 |
+
if {[%W selection present]} {
|
| 176 |
+
%W delete sel.first sel.last
|
| 177 |
+
} else {
|
| 178 |
+
%W delete insert
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
bind Spinbox <BackSpace> {
|
| 182 |
+
::tk::EntryBackspace %W
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
bind Spinbox <Control-space> {
|
| 186 |
+
%W selection from insert
|
| 187 |
+
}
|
| 188 |
+
bind Spinbox <Select> {
|
| 189 |
+
%W selection from insert
|
| 190 |
+
}
|
| 191 |
+
bind Spinbox <Control-Shift-space> {
|
| 192 |
+
%W selection adjust insert
|
| 193 |
+
}
|
| 194 |
+
bind Spinbox <Shift-Select> {
|
| 195 |
+
%W selection adjust insert
|
| 196 |
+
}
|
| 197 |
+
bind Spinbox <<SelectAll>> {
|
| 198 |
+
%W selection range 0 end
|
| 199 |
+
}
|
| 200 |
+
bind Spinbox <<SelectNone>> {
|
| 201 |
+
%W selection clear
|
| 202 |
+
}
|
| 203 |
+
bind Spinbox <Key> {
|
| 204 |
+
::tk::EntryInsert %W %A
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
# Ignore all Alt, Meta, Control, and Mod4 keypresses unless explicitly bound.
|
| 208 |
+
# Otherwise, if a widget binding for one of these is defined, the
|
| 209 |
+
# <Key> class binding will also fire and insert the character,
|
| 210 |
+
# which is wrong. Ditto for Escape, Return, and Tab.
|
| 211 |
+
|
| 212 |
+
bind Spinbox <Alt-Key> {# nothing}
|
| 213 |
+
bind Spinbox <Meta-Key> {# nothing}
|
| 214 |
+
bind Spinbox <Control-Key> {# nothing}
|
| 215 |
+
bind Spinbox <Escape> {# nothing}
|
| 216 |
+
bind Spinbox <Return> {# nothing}
|
| 217 |
+
bind Spinbox <KP_Enter> {# nothing}
|
| 218 |
+
bind Spinbox <Tab> {# nothing}
|
| 219 |
+
bind Spinbox <Prior> {# nothing}
|
| 220 |
+
bind Spinbox <Next> {# nothing}
|
| 221 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 222 |
+
bind Spinbox <Command-Key> {# nothing}
|
| 223 |
+
bind Spinbox <Mod4-Key> {# nothing}
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
# On Windows, paste is done using Shift-Insert. Shift-Insert already
|
| 227 |
+
# generates the <<Paste>> event, so we don't need to do anything here.
|
| 228 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 229 |
+
bind Spinbox <Insert> {
|
| 230 |
+
catch {::tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]}
|
| 231 |
+
}
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
# Additional emacs-like bindings:
|
| 235 |
+
|
| 236 |
+
bind Spinbox <Control-d> {
|
| 237 |
+
if {!$tk_strictMotif} {
|
| 238 |
+
%W delete insert
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
bind Spinbox <Control-h> {
|
| 242 |
+
if {!$tk_strictMotif} {
|
| 243 |
+
::tk::EntryBackspace %W
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
bind Spinbox <Control-k> {
|
| 247 |
+
if {!$tk_strictMotif} {
|
| 248 |
+
%W delete insert end
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
bind Spinbox <Control-t> {
|
| 252 |
+
if {!$tk_strictMotif} {
|
| 253 |
+
::tk::EntryTranspose %W
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
bind Spinbox <Meta-b> {
|
| 257 |
+
if {!$tk_strictMotif} {
|
| 258 |
+
::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert]
|
| 259 |
+
}
|
| 260 |
+
}
|
| 261 |
+
bind Spinbox <Meta-d> {
|
| 262 |
+
if {!$tk_strictMotif} {
|
| 263 |
+
%W delete insert [::tk::EntryNextWord %W insert]
|
| 264 |
+
}
|
| 265 |
+
}
|
| 266 |
+
bind Spinbox <Meta-f> {
|
| 267 |
+
if {!$tk_strictMotif} {
|
| 268 |
+
::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert]
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
bind Spinbox <Meta-BackSpace> {
|
| 272 |
+
if {!$tk_strictMotif} {
|
| 273 |
+
%W delete [::tk::EntryPreviousWord %W insert] insert
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
bind Spinbox <Meta-Delete> {
|
| 277 |
+
if {!$tk_strictMotif} {
|
| 278 |
+
%W delete [::tk::EntryPreviousWord %W insert] insert
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
# A few additional bindings of my own.
|
| 283 |
+
|
| 284 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 285 |
+
bind Spinbox <2> {
|
| 286 |
+
if {!$tk_strictMotif} {
|
| 287 |
+
::tk::EntryScanMark %W %x
|
| 288 |
+
}
|
| 289 |
+
}
|
| 290 |
+
bind Spinbox <B2-Motion> {
|
| 291 |
+
if {!$tk_strictMotif} {
|
| 292 |
+
::tk::EntryScanDrag %W %x
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
} else {
|
| 296 |
+
bind Spinbox <3> {
|
| 297 |
+
if {!$tk_strictMotif} {
|
| 298 |
+
::tk::EntryScanMark %W %x
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
bind Spinbox <B3-Motion> {
|
| 302 |
+
if {!$tk_strictMotif} {
|
| 303 |
+
::tk::EntryScanDrag %W %x
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
# ::tk::spinbox::Invoke --
|
| 309 |
+
# Invoke an element of the spinbox
|
| 310 |
+
#
|
| 311 |
+
# Arguments:
|
| 312 |
+
# w - The spinbox window.
|
| 313 |
+
# elem - Element to invoke
|
| 314 |
+
|
| 315 |
+
proc ::tk::spinbox::Invoke {w elem} {
|
| 316 |
+
variable ::tk::Priv
|
| 317 |
+
|
| 318 |
+
if {![winfo exists $w]} {
|
| 319 |
+
return
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
if {![info exists Priv(outsideElement)]} {
|
| 323 |
+
$w invoke $elem
|
| 324 |
+
incr Priv(repeated)
|
| 325 |
+
}
|
| 326 |
+
set delay [$w cget -repeatinterval]
|
| 327 |
+
if {$delay > 0} {
|
| 328 |
+
set Priv(afterId) [after $delay \
|
| 329 |
+
[list ::tk::spinbox::Invoke $w $elem]]
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
# ::tk::spinbox::ClosestGap --
|
| 334 |
+
# Given x and y coordinates, this procedure finds the closest boundary
|
| 335 |
+
# between characters to the given coordinates and returns the index
|
| 336 |
+
# of the character just after the boundary.
|
| 337 |
+
#
|
| 338 |
+
# Arguments:
|
| 339 |
+
# w - The spinbox window.
|
| 340 |
+
# x - X-coordinate within the window.
|
| 341 |
+
|
| 342 |
+
proc ::tk::spinbox::ClosestGap {w x} {
|
| 343 |
+
set pos [$w index @$x]
|
| 344 |
+
set bbox [$w bbox $pos]
|
| 345 |
+
if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} {
|
| 346 |
+
return $pos
|
| 347 |
+
}
|
| 348 |
+
incr pos
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
# ::tk::spinbox::ArrowPress --
|
| 352 |
+
# This procedure is invoked to handle button-1 presses in buttonup
|
| 353 |
+
# or buttondown elements of spinbox widgets.
|
| 354 |
+
#
|
| 355 |
+
# Arguments:
|
| 356 |
+
# w - The spinbox window in which the button was pressed.
|
| 357 |
+
# x - The x-coordinate of the button press.
|
| 358 |
+
# y - The y-coordinate of the button press.
|
| 359 |
+
|
| 360 |
+
proc ::tk::spinbox::ArrowPress {w x y} {
|
| 361 |
+
variable ::tk::Priv
|
| 362 |
+
|
| 363 |
+
if {[$w cget -state] ne "disabled" && \
|
| 364 |
+
[string match "button*" $Priv(element)]} {
|
| 365 |
+
$w selection element $Priv(element)
|
| 366 |
+
set Priv(repeated) 0
|
| 367 |
+
set Priv(relief) [$w cget -$Priv(element)relief]
|
| 368 |
+
catch {after cancel $Priv(afterId)}
|
| 369 |
+
set delay [$w cget -repeatdelay]
|
| 370 |
+
if {$delay > 0} {
|
| 371 |
+
set Priv(afterId) [after $delay \
|
| 372 |
+
[list ::tk::spinbox::Invoke $w $Priv(element)]]
|
| 373 |
+
}
|
| 374 |
+
if {[info exists Priv(outsideElement)]} {
|
| 375 |
+
unset Priv(outsideElement)
|
| 376 |
+
}
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
# ::tk::spinbox::ButtonDown --
|
| 381 |
+
# This procedure is invoked to handle button-1 presses in spinbox
|
| 382 |
+
# widgets. It moves the insertion cursor, sets the selection anchor,
|
| 383 |
+
# and claims the input focus.
|
| 384 |
+
#
|
| 385 |
+
# Arguments:
|
| 386 |
+
# w - The spinbox window in which the button was pressed.
|
| 387 |
+
# x - The x-coordinate of the button press.
|
| 388 |
+
# y - The y-coordinate of the button press.
|
| 389 |
+
|
| 390 |
+
proc ::tk::spinbox::ButtonDown {w x y} {
|
| 391 |
+
variable ::tk::Priv
|
| 392 |
+
|
| 393 |
+
# Get the element that was clicked in. If we are not directly over
|
| 394 |
+
# the spinbox, default to entry. This is necessary for spinbox grabs.
|
| 395 |
+
#
|
| 396 |
+
set Priv(element) [$w identify $x $y]
|
| 397 |
+
if {$Priv(element) eq ""} {
|
| 398 |
+
set Priv(element) "entry"
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
switch -exact $Priv(element) {
|
| 402 |
+
"buttonup" - "buttondown" {
|
| 403 |
+
::tk::spinbox::ArrowPress $w $x $y
|
| 404 |
+
}
|
| 405 |
+
"entry" {
|
| 406 |
+
set Priv(selectMode) char
|
| 407 |
+
set Priv(mouseMoved) 0
|
| 408 |
+
set Priv(pressX) $x
|
| 409 |
+
$w icursor [::tk::spinbox::ClosestGap $w $x]
|
| 410 |
+
$w selection from insert
|
| 411 |
+
if {"disabled" ne [$w cget -state]} {focus $w}
|
| 412 |
+
$w selection clear
|
| 413 |
+
}
|
| 414 |
+
default {
|
| 415 |
+
return -code error -errorcode {TK SPINBOX UNKNOWN_ELEMENT} \
|
| 416 |
+
"unknown spinbox element \"$Priv(element)\""
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
# ::tk::spinbox::ButtonUp --
|
| 422 |
+
# This procedure is invoked to handle button-1 releases in spinbox
|
| 423 |
+
# widgets.
|
| 424 |
+
#
|
| 425 |
+
# Arguments:
|
| 426 |
+
# w - The spinbox window in which the button was pressed.
|
| 427 |
+
# x - The x-coordinate of the button press.
|
| 428 |
+
# y - The y-coordinate of the button press.
|
| 429 |
+
|
| 430 |
+
proc ::tk::spinbox::ButtonUp {w x y} {
|
| 431 |
+
variable ::tk::Priv
|
| 432 |
+
|
| 433 |
+
::tk::CancelRepeat
|
| 434 |
+
|
| 435 |
+
# Priv(relief) may not exist if the ButtonUp is not paired with
|
| 436 |
+
# a preceding ButtonDown
|
| 437 |
+
if {[info exists Priv(element)] && [info exists Priv(relief)] && \
|
| 438 |
+
[string match "button*" $Priv(element)]} {
|
| 439 |
+
if {[info exists Priv(repeated)] && !$Priv(repeated)} {
|
| 440 |
+
$w invoke $Priv(element)
|
| 441 |
+
}
|
| 442 |
+
$w configure -$Priv(element)relief $Priv(relief)
|
| 443 |
+
$w selection element none
|
| 444 |
+
}
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
# ::tk::spinbox::MouseSelect --
|
| 448 |
+
# This procedure is invoked when dragging out a selection with
|
| 449 |
+
# the mouse. Depending on the selection mode (character, word,
|
| 450 |
+
# line) it selects in different-sized units. This procedure
|
| 451 |
+
# ignores mouse motions initially until the mouse has moved from
|
| 452 |
+
# one character to another or until there have been multiple clicks.
|
| 453 |
+
#
|
| 454 |
+
# Arguments:
|
| 455 |
+
# w - The spinbox window in which the button was pressed.
|
| 456 |
+
# x - The x-coordinate of the mouse.
|
| 457 |
+
# cursor - optional place to set cursor.
|
| 458 |
+
|
| 459 |
+
proc ::tk::spinbox::MouseSelect {w x {cursor {}}} {
|
| 460 |
+
variable ::tk::Priv
|
| 461 |
+
|
| 462 |
+
if {$Priv(element) ne "entry"} {
|
| 463 |
+
# The ButtonUp command triggered by ButtonRelease-1 handles
|
| 464 |
+
# invoking one of the spinbuttons.
|
| 465 |
+
return
|
| 466 |
+
}
|
| 467 |
+
set cur [::tk::spinbox::ClosestGap $w $x]
|
| 468 |
+
set anchor [$w index anchor]
|
| 469 |
+
if {($cur ne $anchor) || (abs($Priv(pressX) - $x) >= 3)} {
|
| 470 |
+
set Priv(mouseMoved) 1
|
| 471 |
+
}
|
| 472 |
+
switch $Priv(selectMode) {
|
| 473 |
+
char {
|
| 474 |
+
if {$Priv(mouseMoved)} {
|
| 475 |
+
if {$cur < $anchor} {
|
| 476 |
+
$w selection range $cur $anchor
|
| 477 |
+
} elseif {$cur > $anchor} {
|
| 478 |
+
$w selection range $anchor $cur
|
| 479 |
+
} else {
|
| 480 |
+
$w selection clear
|
| 481 |
+
}
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
word {
|
| 485 |
+
if {$cur < [$w index anchor]} {
|
| 486 |
+
set before [tcl_wordBreakBefore [$w get] $cur]
|
| 487 |
+
set after [tcl_wordBreakAfter [$w get] $anchor-1]
|
| 488 |
+
} else {
|
| 489 |
+
set before [tcl_wordBreakBefore [$w get] $anchor]
|
| 490 |
+
set after [tcl_wordBreakAfter [$w get] $cur-1]
|
| 491 |
+
}
|
| 492 |
+
if {$before < 0} {
|
| 493 |
+
set before 0
|
| 494 |
+
}
|
| 495 |
+
if {$after < 0} {
|
| 496 |
+
set after end
|
| 497 |
+
}
|
| 498 |
+
$w selection range $before $after
|
| 499 |
+
}
|
| 500 |
+
line {
|
| 501 |
+
$w selection range 0 end
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
if {$cursor ne {} && $cursor ne "ignore"} {
|
| 505 |
+
catch {$w icursor $cursor}
|
| 506 |
+
}
|
| 507 |
+
update idletasks
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
# ::tk::spinbox::Paste --
|
| 511 |
+
# This procedure sets the insertion cursor to the current mouse position,
|
| 512 |
+
# pastes the selection there, and sets the focus to the window.
|
| 513 |
+
#
|
| 514 |
+
# Arguments:
|
| 515 |
+
# w - The spinbox window.
|
| 516 |
+
# x - X position of the mouse.
|
| 517 |
+
|
| 518 |
+
proc ::tk::spinbox::Paste {w x} {
|
| 519 |
+
$w icursor [::tk::spinbox::ClosestGap $w $x]
|
| 520 |
+
catch {$w insert insert [::tk::GetSelection $w PRIMARY]}
|
| 521 |
+
if {"disabled" eq [$w cget -state]} {
|
| 522 |
+
focus $w
|
| 523 |
+
}
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
# ::tk::spinbox::Motion --
|
| 527 |
+
# This procedure is invoked when the mouse moves in a spinbox window
|
| 528 |
+
# with button 1 down.
|
| 529 |
+
#
|
| 530 |
+
# Arguments:
|
| 531 |
+
# w - The spinbox window.
|
| 532 |
+
# x - The x-coordinate of the mouse.
|
| 533 |
+
# y - The y-coordinate of the mouse.
|
| 534 |
+
|
| 535 |
+
proc ::tk::spinbox::Motion {w x y} {
|
| 536 |
+
variable ::tk::Priv
|
| 537 |
+
|
| 538 |
+
if {![info exists Priv(element)]} {
|
| 539 |
+
set Priv(element) [$w identify $x $y]
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
set Priv(x) $x
|
| 543 |
+
if {"entry" eq $Priv(element)} {
|
| 544 |
+
::tk::spinbox::MouseSelect $w $x ignore
|
| 545 |
+
} elseif {[$w identify $x $y] ne $Priv(element)} {
|
| 546 |
+
if {![info exists Priv(outsideElement)]} {
|
| 547 |
+
# We've wandered out of the spin button
|
| 548 |
+
# setting outside element will cause ::tk::spinbox::Invoke to
|
| 549 |
+
# loop without doing anything
|
| 550 |
+
set Priv(outsideElement) ""
|
| 551 |
+
$w selection element none
|
| 552 |
+
}
|
| 553 |
+
} elseif {[info exists Priv(outsideElement)]} {
|
| 554 |
+
unset Priv(outsideElement)
|
| 555 |
+
$w selection element $Priv(element)
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
# ::tk::spinbox::AutoScan --
|
| 560 |
+
# This procedure is invoked when the mouse leaves an spinbox window
|
| 561 |
+
# with button 1 down. It scrolls the window left or right,
|
| 562 |
+
# depending on where the mouse is, and reschedules itself as an
|
| 563 |
+
# "after" command so that the window continues to scroll until the
|
| 564 |
+
# mouse moves back into the window or the mouse button is released.
|
| 565 |
+
#
|
| 566 |
+
# Arguments:
|
| 567 |
+
# w - The spinbox window.
|
| 568 |
+
|
| 569 |
+
proc ::tk::spinbox::AutoScan {w} {
|
| 570 |
+
variable ::tk::Priv
|
| 571 |
+
|
| 572 |
+
set x $Priv(x)
|
| 573 |
+
if {$x >= [winfo width $w]} {
|
| 574 |
+
$w xview scroll 2 units
|
| 575 |
+
::tk::spinbox::MouseSelect $w $x ignore
|
| 576 |
+
} elseif {$x < 0} {
|
| 577 |
+
$w xview scroll -2 units
|
| 578 |
+
::tk::spinbox::MouseSelect $w $x ignore
|
| 579 |
+
}
|
| 580 |
+
set Priv(afterId) [after 50 [list ::tk::spinbox::AutoScan $w]]
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
# ::tk::spinbox::GetSelection --
|
| 584 |
+
#
|
| 585 |
+
# Returns the selected text of the spinbox. Differs from entry in that
|
| 586 |
+
# a spinbox has no -show option to obscure contents.
|
| 587 |
+
#
|
| 588 |
+
# Arguments:
|
| 589 |
+
# w - The spinbox window from which the text to get
|
| 590 |
+
|
| 591 |
+
proc ::tk::spinbox::GetSelection {w} {
|
| 592 |
+
return [string range [$w get] [$w index sel.first] \
|
| 593 |
+
[expr {[$w index sel.last] - 1}]]
|
| 594 |
+
}
|
mplug_owl2/lib/tk8.6/tclIndex
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 font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.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file contains procedures that implement tear-off menus.
|
| 4 |
+
#
|
| 5 |
+
# Copyright (c) 1994 The Regents of the University of California.
|
| 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 |
+
# ::tk::TearoffMenu --
|
| 13 |
+
# Given the name of a menu, this procedure creates a torn-off menu
|
| 14 |
+
# that is identical to the given menu (including nested submenus).
|
| 15 |
+
# The new torn-off menu exists as a toplevel window managed by the
|
| 16 |
+
# window manager. The return value is the name of the new menu.
|
| 17 |
+
# The window is created at the point specified by x and y
|
| 18 |
+
#
|
| 19 |
+
# Arguments:
|
| 20 |
+
# w - The menu to be torn-off (duplicated).
|
| 21 |
+
# x - x coordinate where window is created
|
| 22 |
+
# y - y coordinate where window is created
|
| 23 |
+
|
| 24 |
+
proc ::tk::TearOffMenu {w {x 0} {y 0}} {
|
| 25 |
+
# Find a unique name to use for the torn-off menu. Find the first
|
| 26 |
+
# ancestor of w that is a toplevel but not a menu, and use this as
|
| 27 |
+
# the parent of the new menu. This guarantees that the torn off
|
| 28 |
+
# menu will be on the same screen as the original menu. By making
|
| 29 |
+
# it a child of the ancestor, rather than a child of the menu, it
|
| 30 |
+
# can continue to live even if the menu is deleted; it will go
|
| 31 |
+
# away when the toplevel goes away.
|
| 32 |
+
|
| 33 |
+
if {$x == 0} {
|
| 34 |
+
set x [winfo rootx $w]
|
| 35 |
+
}
|
| 36 |
+
if {$y == 0} {
|
| 37 |
+
set y [winfo rooty $w]
|
| 38 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 39 |
+
# Shift by height of tearoff entry minus height of window titlebar
|
| 40 |
+
catch {incr y [expr {[$w yposition 1] - 16}]}
|
| 41 |
+
# Avoid the native menu bar which sits on top of everything.
|
| 42 |
+
if {$y < 22} {set y 22}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
set parent [winfo parent $w]
|
| 47 |
+
while {[winfo toplevel $parent] ne $parent \
|
| 48 |
+
|| [winfo class $parent] eq "Menu"} {
|
| 49 |
+
set parent [winfo parent $parent]
|
| 50 |
+
}
|
| 51 |
+
if {$parent eq "."} {
|
| 52 |
+
set parent ""
|
| 53 |
+
}
|
| 54 |
+
for {set i 1} 1 {incr i} {
|
| 55 |
+
set menu $parent.tearoff$i
|
| 56 |
+
if {![winfo exists $menu]} {
|
| 57 |
+
break
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
$w clone $menu tearoff
|
| 62 |
+
|
| 63 |
+
# Pick a title for the new menu by looking at the parent of the
|
| 64 |
+
# original: if the parent is a menu, then use the text of the active
|
| 65 |
+
# entry. If it's a menubutton then use its text.
|
| 66 |
+
|
| 67 |
+
set parent [winfo parent $w]
|
| 68 |
+
if {[$menu cget -title] ne ""} {
|
| 69 |
+
wm title $menu [$menu cget -title]
|
| 70 |
+
} else {
|
| 71 |
+
switch -- [winfo class $parent] {
|
| 72 |
+
Menubutton {
|
| 73 |
+
wm title $menu [$parent cget -text]
|
| 74 |
+
}
|
| 75 |
+
Menu {
|
| 76 |
+
wm title $menu [$parent entrycget active -label]
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if {[tk windowingsystem] eq "win32"} {
|
| 82 |
+
# [Bug 3181181]: Find the toplevel window for the menu
|
| 83 |
+
set parent [winfo toplevel $parent]
|
| 84 |
+
while {[winfo class $parent] eq "Menu"} {
|
| 85 |
+
set parent [winfo toplevel [winfo parent $parent]]
|
| 86 |
+
}
|
| 87 |
+
wm transient $menu [winfo toplevel $parent]
|
| 88 |
+
wm attributes $menu -toolwindow 1
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
$menu post $x $y
|
| 92 |
+
|
| 93 |
+
if {[winfo exists $menu] == 0} {
|
| 94 |
+
return ""
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
# Set tk::Priv(focus) on entry: otherwise the focus will get lost
|
| 98 |
+
# after keyboard invocation of a sub-menu (it will stay on the
|
| 99 |
+
# submenu).
|
| 100 |
+
|
| 101 |
+
bind $menu <Enter> {
|
| 102 |
+
set tk::Priv(focus) %W
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
# If there is a -tearoffcommand option for the menu, invoke it
|
| 106 |
+
# now.
|
| 107 |
+
|
| 108 |
+
set cmd [$w cget -tearoffcommand]
|
| 109 |
+
if {$cmd ne ""} {
|
| 110 |
+
uplevel #0 $cmd [list $w $menu]
|
| 111 |
+
}
|
| 112 |
+
return $menu
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# ::tk::MenuDup --
|
| 116 |
+
# Given a menu (hierarchy), create a duplicate menu (hierarchy)
|
| 117 |
+
# in a given window.
|
| 118 |
+
#
|
| 119 |
+
# Arguments:
|
| 120 |
+
# src - Source window. Must be a menu. It and its
|
| 121 |
+
# menu descendants will be duplicated at dst.
|
| 122 |
+
# dst - Name to use for topmost menu in duplicate
|
| 123 |
+
# hierarchy.
|
| 124 |
+
|
| 125 |
+
proc ::tk::MenuDup {src dst type} {
|
| 126 |
+
set cmd [list menu $dst -type $type]
|
| 127 |
+
foreach option [$src configure] {
|
| 128 |
+
if {[llength $option] == 2} {
|
| 129 |
+
continue
|
| 130 |
+
}
|
| 131 |
+
if {[lindex $option 0] eq "-type"} {
|
| 132 |
+
continue
|
| 133 |
+
}
|
| 134 |
+
lappend cmd [lindex $option 0] [lindex $option 4]
|
| 135 |
+
}
|
| 136 |
+
eval $cmd
|
| 137 |
+
|
| 138 |
+
# Copy the meny entries, if any
|
| 139 |
+
|
| 140 |
+
set last [$src index last]
|
| 141 |
+
if {$last ne "none"} {
|
| 142 |
+
for {set i [$src cget -tearoff]} {$i <= $last} {incr i} {
|
| 143 |
+
set cmd [list $dst add [$src type $i]]
|
| 144 |
+
foreach option [$src entryconfigure $i] {
|
| 145 |
+
lappend cmd [lindex $option 0] [lindex $option 4]
|
| 146 |
+
}
|
| 147 |
+
eval $cmd
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
# Duplicate the binding tags from the source menu, replacing src with dst
|
| 152 |
+
|
| 153 |
+
set tags [bindtags $src]
|
| 154 |
+
set x [lsearch -exact $tags $src]
|
| 155 |
+
if {$x >= 0} {lset tags $x $dst}
|
| 156 |
+
bindtags $dst $tags
|
| 157 |
+
}
|
mplug_owl2/lib/tk8.6/text.tcl
ADDED
|
@@ -0,0 +1,1242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tk.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Initialization script normally executed in the interpreter for each Tk-based
|
| 4 |
+
# application. Arranges class bindings for widgets.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1992-1994 The Regents of the University of California.
|
| 7 |
+
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
| 8 |
+
# Copyright (c) 1998-2000 Ajuba Solutions.
|
| 9 |
+
#
|
| 10 |
+
# See the file "license.terms" for information on usage and redistribution of
|
| 11 |
+
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 12 |
+
|
| 13 |
+
# Verify that we have Tk binary and script components from the same release
|
| 14 |
+
package require -exact Tk 8.6.14
|
| 15 |
+
|
| 16 |
+
# Create a ::tk namespace
|
| 17 |
+
namespace eval ::tk {
|
| 18 |
+
# Set up the msgcat commands
|
| 19 |
+
namespace eval msgcat {
|
| 20 |
+
namespace export mc mcmax
|
| 21 |
+
if {[interp issafe] || [catch {package require msgcat}]} {
|
| 22 |
+
# The msgcat package is not available. Supply our own
|
| 23 |
+
# minimal replacement.
|
| 24 |
+
proc mc {src args} {
|
| 25 |
+
return [format $src {*}$args]
|
| 26 |
+
}
|
| 27 |
+
proc mcmax {args} {
|
| 28 |
+
set max 0
|
| 29 |
+
foreach string $args {
|
| 30 |
+
set len [string length $string]
|
| 31 |
+
if {$len>$max} {
|
| 32 |
+
set max $len
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
return $max
|
| 36 |
+
}
|
| 37 |
+
} else {
|
| 38 |
+
# Get the commands from the msgcat package that Tk uses.
|
| 39 |
+
namespace import ::msgcat::mc
|
| 40 |
+
namespace import ::msgcat::mcmax
|
| 41 |
+
::msgcat::mcload [file join $::tk_library msgs]
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
namespace import ::tk::msgcat::*
|
| 45 |
+
}
|
| 46 |
+
# and a ::ttk namespace
|
| 47 |
+
namespace eval ::ttk {
|
| 48 |
+
if {$::tk_library ne ""} {
|
| 49 |
+
# avoid file join to work in safe interps, but this is also x-plat ok
|
| 50 |
+
variable library $::tk_library/ttk
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
# Add Ttk & Tk's directory to the end of the auto-load search path, if it
|
| 55 |
+
# isn't already on the path:
|
| 56 |
+
|
| 57 |
+
if {[info exists ::auto_path] && ($::tk_library ne "")
|
| 58 |
+
&& ($::tk_library ni $::auto_path)
|
| 59 |
+
} then {
|
| 60 |
+
lappend ::auto_path $::tk_library $::ttk::library
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
# Turn off strict Motif look and feel as a default.
|
| 64 |
+
|
| 65 |
+
set ::tk_strictMotif 0
|
| 66 |
+
|
| 67 |
+
# Turn on useinputmethods (X Input Methods) by default.
|
| 68 |
+
# We catch this because safe interpreters may not allow the call.
|
| 69 |
+
|
| 70 |
+
catch {tk useinputmethods 1}
|
| 71 |
+
|
| 72 |
+
# ::tk::PlaceWindow --
|
| 73 |
+
# place a toplevel at a particular position
|
| 74 |
+
# Arguments:
|
| 75 |
+
# toplevel name of toplevel window
|
| 76 |
+
# ?placement? pointer ?center? ; places $w centered on the pointer
|
| 77 |
+
# widget widgetPath ; centers $w over widget_name
|
| 78 |
+
# defaults to placing toplevel in the middle of the screen
|
| 79 |
+
# ?anchor? center or widgetPath
|
| 80 |
+
# Results:
|
| 81 |
+
# Returns nothing
|
| 82 |
+
#
|
| 83 |
+
proc ::tk::PlaceWindow {w {place ""} {anchor ""}} {
|
| 84 |
+
wm withdraw $w
|
| 85 |
+
update idletasks
|
| 86 |
+
set checkBounds 1
|
| 87 |
+
if {$place eq ""} {
|
| 88 |
+
set x [expr {([winfo screenwidth $w]-[winfo reqwidth $w])/2}]
|
| 89 |
+
set y [expr {([winfo screenheight $w]-[winfo reqheight $w])/2}]
|
| 90 |
+
set checkBounds 0
|
| 91 |
+
} elseif {[string equal -length [string length $place] $place "pointer"]} {
|
| 92 |
+
## place at POINTER (centered if $anchor == center)
|
| 93 |
+
if {[string equal -length [string length $anchor] $anchor "center"]} {
|
| 94 |
+
set x [expr {[winfo pointerx $w]-[winfo reqwidth $w]/2}]
|
| 95 |
+
set y [expr {[winfo pointery $w]-[winfo reqheight $w]/2}]
|
| 96 |
+
} else {
|
| 97 |
+
set x [winfo pointerx $w]
|
| 98 |
+
set y [winfo pointery $w]
|
| 99 |
+
}
|
| 100 |
+
} elseif {[string equal -length [string length $place] $place "widget"] && \
|
| 101 |
+
[winfo exists $anchor] && [winfo ismapped $anchor]} {
|
| 102 |
+
## center about WIDGET $anchor, widget must be mapped
|
| 103 |
+
set x [expr {[winfo rootx $anchor] + \
|
| 104 |
+
([winfo width $anchor]-[winfo reqwidth $w])/2}]
|
| 105 |
+
set y [expr {[winfo rooty $anchor] + \
|
| 106 |
+
([winfo height $anchor]-[winfo reqheight $w])/2}]
|
| 107 |
+
} else {
|
| 108 |
+
set x [expr {([winfo screenwidth $w]-[winfo reqwidth $w])/2}]
|
| 109 |
+
set y [expr {([winfo screenheight $w]-[winfo reqheight $w])/2}]
|
| 110 |
+
set checkBounds 0
|
| 111 |
+
}
|
| 112 |
+
if {$checkBounds} {
|
| 113 |
+
if {$x < [winfo vrootx $w]} {
|
| 114 |
+
set x [winfo vrootx $w]
|
| 115 |
+
} elseif {$x > ([winfo vrootx $w]+[winfo vrootwidth $w]-[winfo reqwidth $w])} {
|
| 116 |
+
set x [expr {[winfo vrootx $w]+[winfo vrootwidth $w]-[winfo reqwidth $w]}]
|
| 117 |
+
}
|
| 118 |
+
if {$y < [winfo vrooty $w]} {
|
| 119 |
+
set y [winfo vrooty $w]
|
| 120 |
+
} elseif {$y > ([winfo vrooty $w]+[winfo vrootheight $w]-[winfo reqheight $w])} {
|
| 121 |
+
set y [expr {[winfo vrooty $w]+[winfo vrootheight $w]-[winfo reqheight $w]}]
|
| 122 |
+
}
|
| 123 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 124 |
+
# Avoid the native menu bar which sits on top of everything.
|
| 125 |
+
if {$y < 22} {
|
| 126 |
+
set y 22
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
wm maxsize $w [winfo vrootwidth $w] [winfo vrootheight $w]
|
| 131 |
+
wm geometry $w +$x+$y
|
| 132 |
+
wm deiconify $w
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
# ::tk::SetFocusGrab --
|
| 136 |
+
# swap out current focus and grab temporarily (for dialogs)
|
| 137 |
+
# Arguments:
|
| 138 |
+
# grab new window to grab
|
| 139 |
+
# focus window to give focus to
|
| 140 |
+
# Results:
|
| 141 |
+
# Returns nothing
|
| 142 |
+
#
|
| 143 |
+
proc ::tk::SetFocusGrab {grab {focus {}}} {
|
| 144 |
+
set index "$grab,$focus"
|
| 145 |
+
upvar ::tk::FocusGrab($index) data
|
| 146 |
+
|
| 147 |
+
lappend data [focus]
|
| 148 |
+
set oldGrab [grab current $grab]
|
| 149 |
+
lappend data $oldGrab
|
| 150 |
+
if {[winfo exists $oldGrab]} {
|
| 151 |
+
lappend data [grab status $oldGrab]
|
| 152 |
+
}
|
| 153 |
+
# The "grab" command will fail if another application
|
| 154 |
+
# already holds the grab. So catch it.
|
| 155 |
+
catch {grab $grab}
|
| 156 |
+
if {[winfo exists $focus]} {
|
| 157 |
+
focus $focus
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
# ::tk::RestoreFocusGrab --
|
| 162 |
+
# restore old focus and grab (for dialogs)
|
| 163 |
+
# Arguments:
|
| 164 |
+
# grab window that had taken grab
|
| 165 |
+
# focus window that had taken focus
|
| 166 |
+
# destroy destroy|withdraw - how to handle the old grabbed window
|
| 167 |
+
# Results:
|
| 168 |
+
# Returns nothing
|
| 169 |
+
#
|
| 170 |
+
proc ::tk::RestoreFocusGrab {grab focus {destroy destroy}} {
|
| 171 |
+
set index "$grab,$focus"
|
| 172 |
+
if {[info exists ::tk::FocusGrab($index)]} {
|
| 173 |
+
foreach {oldFocus oldGrab oldStatus} $::tk::FocusGrab($index) { break }
|
| 174 |
+
unset ::tk::FocusGrab($index)
|
| 175 |
+
} else {
|
| 176 |
+
set oldGrab ""
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
catch {focus $oldFocus}
|
| 180 |
+
grab release $grab
|
| 181 |
+
if {[winfo exists $grab]} {
|
| 182 |
+
if {$destroy eq "withdraw"} {
|
| 183 |
+
wm withdraw $grab
|
| 184 |
+
} else {
|
| 185 |
+
destroy $grab
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
if {[winfo exists $oldGrab] && [winfo ismapped $oldGrab]} {
|
| 189 |
+
# The "grab" command will fail if another application
|
| 190 |
+
# already holds the grab on a window with the same name.
|
| 191 |
+
# So catch it. See [7447ed20ec] for an example.
|
| 192 |
+
if {$oldStatus eq "global"} {
|
| 193 |
+
catch {grab -global $oldGrab}
|
| 194 |
+
} else {
|
| 195 |
+
catch {grab $oldGrab}
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
# ::tk::GetSelection --
|
| 201 |
+
# This tries to obtain the default selection. On Unix, we first try
|
| 202 |
+
# and get a UTF8_STRING, a type supported by modern Unix apps for
|
| 203 |
+
# passing Unicode data safely. We fall back on the default STRING
|
| 204 |
+
# type otherwise. On Windows, only the STRING type is necessary.
|
| 205 |
+
# Arguments:
|
| 206 |
+
# w The widget for which the selection will be retrieved.
|
| 207 |
+
# Important for the -displayof property.
|
| 208 |
+
# sel The source of the selection (PRIMARY or CLIPBOARD)
|
| 209 |
+
# Results:
|
| 210 |
+
# Returns the selection, or an error if none could be found
|
| 211 |
+
#
|
| 212 |
+
if {[tk windowingsystem] ne "win32"} {
|
| 213 |
+
proc ::tk::GetSelection {w {sel PRIMARY}} {
|
| 214 |
+
if {[catch {
|
| 215 |
+
selection get -displayof $w -selection $sel -type UTF8_STRING
|
| 216 |
+
} txt] && [catch {
|
| 217 |
+
selection get -displayof $w -selection $sel
|
| 218 |
+
} txt]} then {
|
| 219 |
+
return -code error -errorcode {TK SELECTION NONE} \
|
| 220 |
+
"could not find default selection"
|
| 221 |
+
} else {
|
| 222 |
+
return $txt
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
} else {
|
| 226 |
+
proc ::tk::GetSelection {w {sel PRIMARY}} {
|
| 227 |
+
if {[catch {
|
| 228 |
+
selection get -displayof $w -selection $sel
|
| 229 |
+
} txt]} then {
|
| 230 |
+
return -code error -errorcode {TK SELECTION NONE} \
|
| 231 |
+
"could not find default selection"
|
| 232 |
+
} else {
|
| 233 |
+
return $txt
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
# ::tk::ScreenChanged --
|
| 239 |
+
# This procedure is invoked by the binding mechanism whenever the
|
| 240 |
+
# "current" screen is changing. The procedure does two things.
|
| 241 |
+
# First, it uses "upvar" to make variable "::tk::Priv" point at an
|
| 242 |
+
# array variable that holds state for the current display. Second,
|
| 243 |
+
# it initializes the array if it didn't already exist.
|
| 244 |
+
#
|
| 245 |
+
# Arguments:
|
| 246 |
+
# screen - The name of the new screen.
|
| 247 |
+
|
| 248 |
+
proc ::tk::ScreenChanged screen {
|
| 249 |
+
# Extract the display name.
|
| 250 |
+
set disp [string range $screen 0 [string last . $screen]-1]
|
| 251 |
+
|
| 252 |
+
# Ensure that namespace separators never occur in the display name (as
|
| 253 |
+
# they cause problems in variable names). Double-colons exist in some VNC
|
| 254 |
+
# display names. [Bug 2912473]
|
| 255 |
+
set disp [string map {:: _doublecolon_} $disp]
|
| 256 |
+
|
| 257 |
+
uplevel #0 [list upvar #0 ::tk::Priv.$disp ::tk::Priv]
|
| 258 |
+
variable ::tk::Priv
|
| 259 |
+
|
| 260 |
+
if {[info exists Priv]} {
|
| 261 |
+
set Priv(screen) $screen
|
| 262 |
+
return
|
| 263 |
+
}
|
| 264 |
+
array set Priv {
|
| 265 |
+
activeMenu {}
|
| 266 |
+
activeItem {}
|
| 267 |
+
afterId {}
|
| 268 |
+
buttons 0
|
| 269 |
+
buttonWindow {}
|
| 270 |
+
dragging 0
|
| 271 |
+
focus {}
|
| 272 |
+
grab {}
|
| 273 |
+
initPos {}
|
| 274 |
+
inMenubutton {}
|
| 275 |
+
listboxPrev {}
|
| 276 |
+
menuBar {}
|
| 277 |
+
mouseMoved 0
|
| 278 |
+
oldGrab {}
|
| 279 |
+
popup {}
|
| 280 |
+
postedMb {}
|
| 281 |
+
pressX 0
|
| 282 |
+
pressY 0
|
| 283 |
+
prevPos 0
|
| 284 |
+
selectMode char
|
| 285 |
+
}
|
| 286 |
+
set Priv(screen) $screen
|
| 287 |
+
set Priv(tearoff) [string equal [tk windowingsystem] "x11"]
|
| 288 |
+
set Priv(window) {}
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
# Do initial setup for Priv, so that it is always bound to something
|
| 292 |
+
# (otherwise, if someone references it, it may get set to a non-upvar-ed
|
| 293 |
+
# value, which will cause trouble later).
|
| 294 |
+
|
| 295 |
+
tk::ScreenChanged [winfo screen .]
|
| 296 |
+
|
| 297 |
+
# ::tk::EventMotifBindings --
|
| 298 |
+
# This procedure is invoked as a trace whenever ::tk_strictMotif is
|
| 299 |
+
# changed. It is used to turn on or turn off the motif virtual
|
| 300 |
+
# bindings.
|
| 301 |
+
#
|
| 302 |
+
# Arguments:
|
| 303 |
+
# n1 - the name of the variable being changed ("::tk_strictMotif").
|
| 304 |
+
|
| 305 |
+
proc ::tk::EventMotifBindings {n1 dummy dummy} {
|
| 306 |
+
upvar $n1 name
|
| 307 |
+
|
| 308 |
+
if {$name} {
|
| 309 |
+
set op delete
|
| 310 |
+
} else {
|
| 311 |
+
set op add
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
event $op <<Cut>> <Control-Key-w> <Control-Lock-Key-W> <Shift-Key-Delete>
|
| 315 |
+
event $op <<Copy>> <Meta-Key-w> <Meta-Lock-Key-W> <Control-Key-Insert>
|
| 316 |
+
event $op <<Paste>> <Control-Key-y> <Control-Lock-Key-Y> <Shift-Key-Insert>
|
| 317 |
+
event $op <<PrevChar>> <Control-Key-b> <Control-Lock-Key-B>
|
| 318 |
+
event $op <<NextChar>> <Control-Key-f> <Control-Lock-Key-F>
|
| 319 |
+
event $op <<PrevLine>> <Control-Key-p> <Control-Lock-Key-P>
|
| 320 |
+
event $op <<NextLine>> <Control-Key-n> <Control-Lock-Key-N>
|
| 321 |
+
event $op <<LineStart>> <Control-Key-a> <Control-Lock-Key-A>
|
| 322 |
+
event $op <<LineEnd>> <Control-Key-e> <Control-Lock-Key-E>
|
| 323 |
+
event $op <<SelectPrevChar>> <Control-Key-B> <Control-Lock-Key-b>
|
| 324 |
+
event $op <<SelectNextChar>> <Control-Key-F> <Control-Lock-Key-f>
|
| 325 |
+
event $op <<SelectPrevLine>> <Control-Key-P> <Control-Lock-Key-p>
|
| 326 |
+
event $op <<SelectNextLine>> <Control-Key-N> <Control-Lock-Key-n>
|
| 327 |
+
event $op <<SelectLineStart>> <Control-Key-A> <Control-Lock-Key-a>
|
| 328 |
+
event $op <<SelectLineEnd>> <Control-Key-E> <Control-Lock-Key-e>
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
#----------------------------------------------------------------------
|
| 332 |
+
# Define common dialogs on platforms where they are not implemented
|
| 333 |
+
# using compiled code.
|
| 334 |
+
#----------------------------------------------------------------------
|
| 335 |
+
|
| 336 |
+
if {![llength [info commands tk_chooseColor]]} {
|
| 337 |
+
proc ::tk_chooseColor {args} {
|
| 338 |
+
return [::tk::dialog::color:: {*}$args]
|
| 339 |
+
}
|
| 340 |
+
}
|
| 341 |
+
if {![llength [info commands tk_getOpenFile]]} {
|
| 342 |
+
proc ::tk_getOpenFile {args} {
|
| 343 |
+
if {$::tk_strictMotif} {
|
| 344 |
+
return [::tk::MotifFDialog open {*}$args]
|
| 345 |
+
} else {
|
| 346 |
+
return [::tk::dialog::file:: open {*}$args]
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
if {![llength [info commands tk_getSaveFile]]} {
|
| 351 |
+
proc ::tk_getSaveFile {args} {
|
| 352 |
+
if {$::tk_strictMotif} {
|
| 353 |
+
return [::tk::MotifFDialog save {*}$args]
|
| 354 |
+
} else {
|
| 355 |
+
return [::tk::dialog::file:: save {*}$args]
|
| 356 |
+
}
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
if {![llength [info commands tk_messageBox]]} {
|
| 360 |
+
proc ::tk_messageBox {args} {
|
| 361 |
+
return [::tk::MessageBox {*}$args]
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
if {![llength [info command tk_chooseDirectory]]} {
|
| 365 |
+
proc ::tk_chooseDirectory {args} {
|
| 366 |
+
return [::tk::dialog::file::chooseDir:: {*}$args]
|
| 367 |
+
}
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
#----------------------------------------------------------------------
|
| 371 |
+
# Define the set of common virtual events.
|
| 372 |
+
#----------------------------------------------------------------------
|
| 373 |
+
|
| 374 |
+
switch -exact -- [tk windowingsystem] {
|
| 375 |
+
"x11" {
|
| 376 |
+
event add <<Cut>> <Control-Key-x> <Key-F20> <Control-Lock-Key-X>
|
| 377 |
+
event add <<Copy>> <Control-Key-c> <Key-F16> <Control-Lock-Key-C>
|
| 378 |
+
event add <<Paste>> <Control-Key-v> <Key-F18> <Control-Lock-Key-V>
|
| 379 |
+
event add <<PasteSelection>> <ButtonRelease-2>
|
| 380 |
+
event add <<Undo>> <Control-Key-z> <Control-Lock-Key-Z>
|
| 381 |
+
event add <<Redo>> <Control-Key-Z> <Control-Lock-Key-z>
|
| 382 |
+
event add <<ContextMenu>> <Button-3>
|
| 383 |
+
# On Darwin/Aqua, buttons from left to right are 1,3,2. On Darwin/X11 with recent
|
| 384 |
+
# XQuartz as the X server, they are 1,2,3; other X servers may differ.
|
| 385 |
+
|
| 386 |
+
event add <<SelectAll>> <Control-Key-slash>
|
| 387 |
+
event add <<SelectNone>> <Control-Key-backslash>
|
| 388 |
+
event add <<NextChar>> <Right>
|
| 389 |
+
event add <<SelectNextChar>> <Shift-Right>
|
| 390 |
+
event add <<PrevChar>> <Left>
|
| 391 |
+
event add <<SelectPrevChar>> <Shift-Left>
|
| 392 |
+
event add <<NextWord>> <Control-Right>
|
| 393 |
+
event add <<SelectNextWord>> <Control-Shift-Right>
|
| 394 |
+
event add <<PrevWord>> <Control-Left>
|
| 395 |
+
event add <<SelectPrevWord>> <Control-Shift-Left>
|
| 396 |
+
event add <<LineStart>> <Home>
|
| 397 |
+
event add <<SelectLineStart>> <Shift-Home>
|
| 398 |
+
event add <<LineEnd>> <End>
|
| 399 |
+
event add <<SelectLineEnd>> <Shift-End>
|
| 400 |
+
event add <<PrevLine>> <Up>
|
| 401 |
+
event add <<NextLine>> <Down>
|
| 402 |
+
event add <<SelectPrevLine>> <Shift-Up>
|
| 403 |
+
event add <<SelectNextLine>> <Shift-Down>
|
| 404 |
+
event add <<PrevPara>> <Control-Up>
|
| 405 |
+
event add <<NextPara>> <Control-Down>
|
| 406 |
+
event add <<SelectPrevPara>> <Control-Shift-Up>
|
| 407 |
+
event add <<SelectNextPara>> <Control-Shift-Down>
|
| 408 |
+
event add <<ToggleSelection>> <Control-Button-1>
|
| 409 |
+
|
| 410 |
+
# Some OS's define a goofy (as in, not <Shift-Tab>) keysym that is
|
| 411 |
+
# returned when the user presses <Shift-Tab>. In order for tab
|
| 412 |
+
# traversal to work, we have to add these keysyms to the PrevWindow
|
| 413 |
+
# event. We use catch just in case the keysym isn't recognized.
|
| 414 |
+
|
| 415 |
+
# This is needed for XFree86 systems
|
| 416 |
+
catch { event add <<PrevWindow>> <ISO_Left_Tab> }
|
| 417 |
+
# This seems to be correct on *some* HP systems.
|
| 418 |
+
catch { event add <<PrevWindow>> <hpBackTab> }
|
| 419 |
+
|
| 420 |
+
trace add variable ::tk_strictMotif write ::tk::EventMotifBindings
|
| 421 |
+
set ::tk_strictMotif $::tk_strictMotif
|
| 422 |
+
# On unix, we want to always display entry/text selection,
|
| 423 |
+
# regardless of which window has focus
|
| 424 |
+
set ::tk::AlwaysShowSelection 1
|
| 425 |
+
}
|
| 426 |
+
"win32" {
|
| 427 |
+
event add <<Cut>> <Control-Key-x> <Shift-Key-Delete> <Control-Lock-Key-X>
|
| 428 |
+
event add <<Copy>> <Control-Key-c> <Control-Key-Insert> <Control-Lock-Key-C>
|
| 429 |
+
event add <<Paste>> <Control-Key-v> <Shift-Key-Insert> <Control-Lock-Key-V>
|
| 430 |
+
event add <<PasteSelection>> <ButtonRelease-2>
|
| 431 |
+
event add <<Undo>> <Control-Key-z> <Control-Lock-Key-Z>
|
| 432 |
+
event add <<Redo>> <Control-Key-y> <Control-Lock-Key-Y>
|
| 433 |
+
event add <<ContextMenu>> <Button-3>
|
| 434 |
+
|
| 435 |
+
event add <<SelectAll>> <Control-Key-slash> <Control-Key-a> <Control-Lock-Key-A>
|
| 436 |
+
event add <<SelectNone>> <Control-Key-backslash>
|
| 437 |
+
event add <<NextChar>> <Right>
|
| 438 |
+
event add <<SelectNextChar>> <Shift-Right>
|
| 439 |
+
event add <<PrevChar>> <Left>
|
| 440 |
+
event add <<SelectPrevChar>> <Shift-Left>
|
| 441 |
+
event add <<NextWord>> <Control-Right>
|
| 442 |
+
event add <<SelectNextWord>> <Control-Shift-Right>
|
| 443 |
+
event add <<PrevWord>> <Control-Left>
|
| 444 |
+
event add <<SelectPrevWord>> <Control-Shift-Left>
|
| 445 |
+
event add <<LineStart>> <Home>
|
| 446 |
+
event add <<SelectLineStart>> <Shift-Home>
|
| 447 |
+
event add <<LineEnd>> <End>
|
| 448 |
+
event add <<SelectLineEnd>> <Shift-End>
|
| 449 |
+
event add <<PrevLine>> <Up>
|
| 450 |
+
event add <<NextLine>> <Down>
|
| 451 |
+
event add <<SelectPrevLine>> <Shift-Up>
|
| 452 |
+
event add <<SelectNextLine>> <Shift-Down>
|
| 453 |
+
event add <<PrevPara>> <Control-Up>
|
| 454 |
+
event add <<NextPara>> <Control-Down>
|
| 455 |
+
event add <<SelectPrevPara>> <Control-Shift-Up>
|
| 456 |
+
event add <<SelectNextPara>> <Control-Shift-Down>
|
| 457 |
+
event add <<ToggleSelection>> <Control-Button-1>
|
| 458 |
+
}
|
| 459 |
+
"aqua" {
|
| 460 |
+
event add <<Cut>> <Command-Key-x> <Key-F2> <Command-Lock-Key-X>
|
| 461 |
+
event add <<Copy>> <Command-Key-c> <Key-F3> <Command-Lock-Key-C>
|
| 462 |
+
event add <<Paste>> <Command-Key-v> <Key-F4> <Command-Lock-Key-V>
|
| 463 |
+
event add <<PasteSelection>> <ButtonRelease-3>
|
| 464 |
+
event add <<Clear>> <Clear>
|
| 465 |
+
event add <<ContextMenu>> <Button-2>
|
| 466 |
+
|
| 467 |
+
# Official bindings
|
| 468 |
+
# See https://support.apple.com/en-us/HT201236
|
| 469 |
+
event add <<SelectAll>> <Command-Key-a>
|
| 470 |
+
event add <<Undo>> <Command-Key-z> <Command-Lock-Key-Z>
|
| 471 |
+
event add <<Redo>> <Shift-Command-Key-z> <Shift-Command-Lock-Key-z>
|
| 472 |
+
event add <<NextChar>> <Right> <Control-Key-f> <Control-Lock-Key-F>
|
| 473 |
+
event add <<SelectNextChar>> <Shift-Right> <Shift-Control-Key-F> <Shift-Control-Lock-Key-F>
|
| 474 |
+
event add <<PrevChar>> <Left> <Control-Key-b> <Control-Lock-Key-B>
|
| 475 |
+
event add <<SelectPrevChar>> <Shift-Left> <Shift-Control-Key-B> <Shift-Control-Lock-Key-B>
|
| 476 |
+
event add <<NextWord>> <Option-Right>
|
| 477 |
+
event add <<SelectNextWord>> <Shift-Option-Right>
|
| 478 |
+
event add <<PrevWord>> <Option-Left>
|
| 479 |
+
event add <<SelectPrevWord>> <Shift-Option-Left>
|
| 480 |
+
event add <<LineStart>> <Home> <Command-Left> <Control-Key-a> <Control-Lock-Key-A>
|
| 481 |
+
event add <<SelectLineStart>> <Shift-Home> <Shift-Command-Left> <Shift-Control-Key-A> <Shift-Control-Lock-Key-A>
|
| 482 |
+
event add <<LineEnd>> <End> <Command-Right> <Control-Key-e> <Control-Lock-Key-E>
|
| 483 |
+
event add <<SelectLineEnd>> <Shift-End> <Shift-Command-Right> <Shift-Control-Key-E> <Shift-Control-Lock-Key-E>
|
| 484 |
+
event add <<PrevLine>> <Up> <Control-Key-p> <Control-Lock-Key-P>
|
| 485 |
+
event add <<SelectPrevLine>> <Shift-Up> <Shift-Control-Key-P> <Shift-Control-Lock-Key-P>
|
| 486 |
+
event add <<NextLine>> <Down> <Control-Key-n> <Control-Lock-Key-N>
|
| 487 |
+
event add <<SelectNextLine>> <Shift-Down> <Shift-Control-Key-N> <Shift-Control-Lock-Key-N>
|
| 488 |
+
# Not official, but logical extensions of above. Also derived from
|
| 489 |
+
# bindings present in MS Word on OSX.
|
| 490 |
+
event add <<PrevPara>> <Option-Up>
|
| 491 |
+
event add <<NextPara>> <Option-Down>
|
| 492 |
+
event add <<SelectPrevPara>> <Shift-Option-Up>
|
| 493 |
+
event add <<SelectNextPara>> <Shift-Option-Down>
|
| 494 |
+
event add <<ToggleSelection>> <Command-Button-1>
|
| 495 |
+
}
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
# ----------------------------------------------------------------------
|
| 499 |
+
# Read in files that define all of the class bindings.
|
| 500 |
+
# ----------------------------------------------------------------------
|
| 501 |
+
|
| 502 |
+
if {$::tk_library ne ""} {
|
| 503 |
+
proc ::tk::SourceLibFile {file} {
|
| 504 |
+
namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]]
|
| 505 |
+
}
|
| 506 |
+
namespace eval ::tk {
|
| 507 |
+
SourceLibFile icons
|
| 508 |
+
SourceLibFile button
|
| 509 |
+
SourceLibFile entry
|
| 510 |
+
SourceLibFile listbox
|
| 511 |
+
SourceLibFile menu
|
| 512 |
+
SourceLibFile panedwindow
|
| 513 |
+
SourceLibFile scale
|
| 514 |
+
SourceLibFile scrlbar
|
| 515 |
+
SourceLibFile spinbox
|
| 516 |
+
SourceLibFile text
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
# ----------------------------------------------------------------------
|
| 521 |
+
# Default bindings for keyboard traversal.
|
| 522 |
+
# ----------------------------------------------------------------------
|
| 523 |
+
|
| 524 |
+
event add <<PrevWindow>> <Shift-Tab>
|
| 525 |
+
event add <<NextWindow>> <Tab>
|
| 526 |
+
bind all <<NextWindow>> {tk::TabToWindow [tk_focusNext %W]}
|
| 527 |
+
bind all <<PrevWindow>> {tk::TabToWindow [tk_focusPrev %W]}
|
| 528 |
+
|
| 529 |
+
# ::tk::CancelRepeat --
|
| 530 |
+
# This procedure is invoked to cancel an auto-repeat action described
|
| 531 |
+
# by ::tk::Priv(afterId). It's used by several widgets to auto-scroll
|
| 532 |
+
# the widget when the mouse is dragged out of the widget with a
|
| 533 |
+
# button pressed.
|
| 534 |
+
#
|
| 535 |
+
# Arguments:
|
| 536 |
+
# None.
|
| 537 |
+
|
| 538 |
+
proc ::tk::CancelRepeat {} {
|
| 539 |
+
variable ::tk::Priv
|
| 540 |
+
after cancel $Priv(afterId)
|
| 541 |
+
set Priv(afterId) {}
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
# ::tk::TabToWindow --
|
| 545 |
+
# This procedure moves the focus to the given widget.
|
| 546 |
+
# It sends a <<TraverseOut>> virtual event to the previous focus window,
|
| 547 |
+
# if any, before changing the focus, and a <<TraverseIn>> event
|
| 548 |
+
# to the new focus window afterwards.
|
| 549 |
+
#
|
| 550 |
+
# Arguments:
|
| 551 |
+
# w - Window to which focus should be set.
|
| 552 |
+
|
| 553 |
+
proc ::tk::TabToWindow {w} {
|
| 554 |
+
set focus [focus]
|
| 555 |
+
if {$focus ne ""} {
|
| 556 |
+
event generate $focus <<TraverseOut>>
|
| 557 |
+
}
|
| 558 |
+
focus $w
|
| 559 |
+
event generate $w <<TraverseIn>>
|
| 560 |
+
}
|
| 561 |
+
|
| 562 |
+
# ::tk::UnderlineAmpersand --
|
| 563 |
+
# This procedure takes some text with ampersand and returns text w/o
|
| 564 |
+
# ampersand and position of the ampersand. Double ampersands are
|
| 565 |
+
# converted to single ones. Position returned is -1 when there is no
|
| 566 |
+
# ampersand.
|
| 567 |
+
#
|
| 568 |
+
proc ::tk::UnderlineAmpersand {text} {
|
| 569 |
+
set s [string map {&& & & \ufeff} $text]
|
| 570 |
+
set idx [string first \ufeff $s]
|
| 571 |
+
return [list [string map {\ufeff {}} $s] $idx]
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
# ::tk::SetAmpText --
|
| 575 |
+
# Given widget path and text with "magic ampersands", sets -text and
|
| 576 |
+
# -underline options for the widget
|
| 577 |
+
#
|
| 578 |
+
proc ::tk::SetAmpText {widget text} {
|
| 579 |
+
lassign [UnderlineAmpersand $text] newtext under
|
| 580 |
+
$widget configure -text $newtext -underline $under
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
# ::tk::AmpWidget --
|
| 584 |
+
# Creates new widget, turning -text option into -text and -underline
|
| 585 |
+
# options, returned by ::tk::UnderlineAmpersand.
|
| 586 |
+
#
|
| 587 |
+
proc ::tk::AmpWidget {class path args} {
|
| 588 |
+
set options {}
|
| 589 |
+
foreach {opt val} $args {
|
| 590 |
+
if {$opt eq "-text"} {
|
| 591 |
+
lassign [UnderlineAmpersand $val] newtext under
|
| 592 |
+
lappend options -text $newtext -underline $under
|
| 593 |
+
} else {
|
| 594 |
+
lappend options $opt $val
|
| 595 |
+
}
|
| 596 |
+
}
|
| 597 |
+
set result [$class $path {*}$options]
|
| 598 |
+
if {[string match "*button" $class]} {
|
| 599 |
+
bind $path <<AltUnderlined>> [list $path invoke]
|
| 600 |
+
}
|
| 601 |
+
return $result
|
| 602 |
+
}
|
| 603 |
+
|
| 604 |
+
# ::tk::AmpMenuArgs --
|
| 605 |
+
# Processes arguments for a menu entry, turning -label option into
|
| 606 |
+
# -label and -underline options, returned by ::tk::UnderlineAmpersand.
|
| 607 |
+
# The cmd argument is supposed to be either "add" or "entryconfigure"
|
| 608 |
+
#
|
| 609 |
+
proc ::tk::AmpMenuArgs {widget cmd type args} {
|
| 610 |
+
set options {}
|
| 611 |
+
foreach {opt val} $args {
|
| 612 |
+
if {$opt eq "-label"} {
|
| 613 |
+
lassign [UnderlineAmpersand $val] newlabel under
|
| 614 |
+
lappend options -label $newlabel -underline $under
|
| 615 |
+
} else {
|
| 616 |
+
lappend options $opt $val
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
$widget $cmd $type {*}$options
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
# ::tk::FindAltKeyTarget --
|
| 623 |
+
# Search recursively through the hierarchy of visible widgets to find
|
| 624 |
+
# button or label which has $char as underlined character.
|
| 625 |
+
#
|
| 626 |
+
proc ::tk::FindAltKeyTarget {path char} {
|
| 627 |
+
set class [winfo class $path]
|
| 628 |
+
if {$class in {
|
| 629 |
+
Button Checkbutton Label Radiobutton
|
| 630 |
+
TButton TCheckbutton TLabel TRadiobutton
|
| 631 |
+
} && [string equal -nocase $char \
|
| 632 |
+
[string index [$path cget -text] [$path cget -underline]]]} {
|
| 633 |
+
return $path
|
| 634 |
+
}
|
| 635 |
+
set subwins [concat [grid slaves $path] [pack slaves $path] \
|
| 636 |
+
[place slaves $path]]
|
| 637 |
+
if {$class eq "Canvas"} {
|
| 638 |
+
foreach item [$path find all] {
|
| 639 |
+
if {[$path type $item] eq "window"} {
|
| 640 |
+
set w [$path itemcget $item -window]
|
| 641 |
+
if {$w ne ""} {lappend subwins $w}
|
| 642 |
+
}
|
| 643 |
+
}
|
| 644 |
+
} elseif {$class eq "Text"} {
|
| 645 |
+
lappend subwins {*}[$path window names]
|
| 646 |
+
}
|
| 647 |
+
foreach child $subwins {
|
| 648 |
+
set target [FindAltKeyTarget $child $char]
|
| 649 |
+
if {$target ne ""} {
|
| 650 |
+
return $target
|
| 651 |
+
}
|
| 652 |
+
}
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
# ::tk::AltKeyInDialog --
|
| 656 |
+
# <Alt-Key> event handler for standard dialogs. Sends <<AltUnderlined>>
|
| 657 |
+
# to button or label which has appropriate underlined character.
|
| 658 |
+
#
|
| 659 |
+
proc ::tk::AltKeyInDialog {path key} {
|
| 660 |
+
set target [FindAltKeyTarget $path $key]
|
| 661 |
+
if {$target ne ""} {
|
| 662 |
+
event generate $target <<AltUnderlined>>
|
| 663 |
+
}
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
# ::tk::mcmaxamp --
|
| 667 |
+
# Replacement for mcmax, used for texts with "magic ampersand" in it.
|
| 668 |
+
#
|
| 669 |
+
|
| 670 |
+
proc ::tk::mcmaxamp {args} {
|
| 671 |
+
set maxlen 0
|
| 672 |
+
foreach arg $args {
|
| 673 |
+
# Should we run [mc] in caller's namespace?
|
| 674 |
+
lassign [UnderlineAmpersand [mc $arg]] msg
|
| 675 |
+
set length [string length $msg]
|
| 676 |
+
if {$length > $maxlen} {
|
| 677 |
+
set maxlen $length
|
| 678 |
+
}
|
| 679 |
+
}
|
| 680 |
+
return $maxlen
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 684 |
+
#stub procedures to respond to "do script" Apple Events
|
| 685 |
+
proc ::tk::mac::DoScriptFile {file} {
|
| 686 |
+
uplevel #0 $file
|
| 687 |
+
source -encoding utf-8 $file
|
| 688 |
+
}
|
| 689 |
+
proc ::tk::mac::DoScriptText {script} {
|
| 690 |
+
uplevel #0 $script
|
| 691 |
+
eval $script
|
| 692 |
+
}
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
# Create a dictionary to store the starting index of the IME marked
|
| 696 |
+
# text in an Entry or Text widget.
|
| 697 |
+
|
| 698 |
+
set ::tk::Priv(IMETextMark) [dict create]
|
| 699 |
+
|
| 700 |
+
# Run the Ttk themed widget set initialization
|
| 701 |
+
if {$::ttk::library ne ""} {
|
| 702 |
+
uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl]
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
# Local Variables:
|
| 706 |
+
# mode: tcl
|
| 707 |
+
# fill-column: 78
|
| 708 |
+
# End:
|
mplug_owl2/lib/tk8.6/tkAppInit.c
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* tkAppInit.c --
|
| 3 |
+
*
|
| 4 |
+
* Provides a default version of the main program and Tcl_AppInit
|
| 5 |
+
* procedure for wish and other Tk-based applications.
|
| 6 |
+
*
|
| 7 |
+
* Copyright (c) 1993 The Regents of the University of California.
|
| 8 |
+
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
| 9 |
+
* Copyright (c) 1998-1999 Scriptics Corporation.
|
| 10 |
+
*
|
| 11 |
+
* See the file "license.terms" for information on usage and redistribution of
|
| 12 |
+
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
#undef BUILD_tk
|
| 16 |
+
#undef STATIC_BUILD
|
| 17 |
+
#include "tk.h"
|
| 18 |
+
#include "tkPort.h"
|
| 19 |
+
#if TCL_MAJOR_VERSION < 9 && TCL_MINOR_VERSION < 7
|
| 20 |
+
# define Tcl_LibraryInitProc Tcl_PackageInitProc
|
| 21 |
+
# define Tcl_StaticLibrary Tcl_StaticPackage
|
| 22 |
+
#endif
|
| 23 |
+
|
| 24 |
+
#ifdef TK_TEST
|
| 25 |
+
#ifdef __cplusplus
|
| 26 |
+
extern "C" {
|
| 27 |
+
#endif
|
| 28 |
+
extern Tcl_LibraryInitProc Tktest_Init;
|
| 29 |
+
#ifdef __cplusplus
|
| 30 |
+
}
|
| 31 |
+
#endif
|
| 32 |
+
#endif /* TK_TEST */
|
| 33 |
+
|
| 34 |
+
/*
|
| 35 |
+
* The following #if block allows you to change the AppInit function by using
|
| 36 |
+
* a #define of TCL_LOCAL_APPINIT instead of rewriting this entire file. The
|
| 37 |
+
* #if checks for that #define and uses Tcl_AppInit if it doesn't exist.
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
#ifndef TK_LOCAL_APPINIT
|
| 41 |
+
#define TK_LOCAL_APPINIT Tcl_AppInit
|
| 42 |
+
#endif
|
| 43 |
+
#ifndef MODULE_SCOPE
|
| 44 |
+
# ifdef __cplusplus
|
| 45 |
+
# define MODULE_SCOPE extern "C"
|
| 46 |
+
# else
|
| 47 |
+
# define MODULE_SCOPE extern
|
| 48 |
+
# endif
|
| 49 |
+
#endif
|
| 50 |
+
MODULE_SCOPE int TK_LOCAL_APPINIT(Tcl_Interp *);
|
| 51 |
+
MODULE_SCOPE int main(int, char **);
|
| 52 |
+
|
| 53 |
+
/*
|
| 54 |
+
* The following #if block allows you to change how Tcl finds the startup
|
| 55 |
+
* script, prime the library or encoding paths, fiddle with the argv, etc.,
|
| 56 |
+
* without needing to rewrite Tk_Main()
|
| 57 |
+
*/
|
| 58 |
+
|
| 59 |
+
#ifdef TK_LOCAL_MAIN_HOOK
|
| 60 |
+
MODULE_SCOPE int TK_LOCAL_MAIN_HOOK(int *argc, char ***argv);
|
| 61 |
+
#endif
|
| 62 |
+
|
| 63 |
+
/* Make sure the stubbed variants of those are never used. */
|
| 64 |
+
#undef Tcl_ObjSetVar2
|
| 65 |
+
#undef Tcl_NewStringObj
|
| 66 |
+
|
| 67 |
+
/*
|
| 68 |
+
*----------------------------------------------------------------------
|
| 69 |
+
*
|
| 70 |
+
* main --
|
| 71 |
+
*
|
| 72 |
+
* This is the main program for the application.
|
| 73 |
+
*
|
| 74 |
+
* Results:
|
| 75 |
+
* None: Tk_Main never returns here, so this procedure never returns
|
| 76 |
+
* either.
|
| 77 |
+
*
|
| 78 |
+
* Side effects:
|
| 79 |
+
* Just about anything, since from here we call arbitrary Tcl code.
|
| 80 |
+
*
|
| 81 |
+
*----------------------------------------------------------------------
|
| 82 |
+
*/
|
| 83 |
+
|
| 84 |
+
int
|
| 85 |
+
main(
|
| 86 |
+
int argc, /* Number of command-line arguments. */
|
| 87 |
+
char **argv) /* Values of command-line arguments. */
|
| 88 |
+
{
|
| 89 |
+
#ifdef TK_LOCAL_MAIN_HOOK
|
| 90 |
+
TK_LOCAL_MAIN_HOOK(&argc, &argv);
|
| 91 |
+
#endif
|
| 92 |
+
|
| 93 |
+
Tk_Main(argc, argv, TK_LOCAL_APPINIT);
|
| 94 |
+
return 0; /* Needed only to prevent compiler warning. */
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/*
|
| 98 |
+
*----------------------------------------------------------------------
|
| 99 |
+
*
|
| 100 |
+
* Tcl_AppInit --
|
| 101 |
+
*
|
| 102 |
+
* This procedure performs application-specific initialization. Most
|
| 103 |
+
* applications, especially those that incorporate additional packages,
|
| 104 |
+
* will have their own version of this procedure.
|
| 105 |
+
*
|
| 106 |
+
* Results:
|
| 107 |
+
* Returns a standard Tcl completion code, and leaves an error message in
|
| 108 |
+
* the interp's result if an error occurs.
|
| 109 |
+
*
|
| 110 |
+
* Side effects:
|
| 111 |
+
* Depends on the startup script.
|
| 112 |
+
*
|
| 113 |
+
*----------------------------------------------------------------------
|
| 114 |
+
*/
|
| 115 |
+
|
| 116 |
+
int
|
| 117 |
+
Tcl_AppInit(
|
| 118 |
+
Tcl_Interp *interp) /* Interpreter for application. */
|
| 119 |
+
{
|
| 120 |
+
if ((Tcl_Init)(interp) == TCL_ERROR) {
|
| 121 |
+
return TCL_ERROR;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
if (Tk_Init(interp) == TCL_ERROR) {
|
| 125 |
+
return TCL_ERROR;
|
| 126 |
+
}
|
| 127 |
+
Tcl_StaticLibrary(interp, "Tk", Tk_Init, Tk_SafeInit);
|
| 128 |
+
|
| 129 |
+
#if defined(USE_CUSTOM_EXIT_PROC)
|
| 130 |
+
if (TkpWantsExitProc()) {
|
| 131 |
+
Tcl_SetExitProc(TkpExitProc);
|
| 132 |
+
}
|
| 133 |
+
#endif
|
| 134 |
+
|
| 135 |
+
#ifdef TK_TEST
|
| 136 |
+
if (Tktest_Init(interp) == TCL_ERROR) {
|
| 137 |
+
return TCL_ERROR;
|
| 138 |
+
}
|
| 139 |
+
Tcl_StaticLibrary(interp, "Tktest", Tktest_Init, 0);
|
| 140 |
+
#endif /* TK_TEST */
|
| 141 |
+
|
| 142 |
+
/*
|
| 143 |
+
* Call the init procedures for included packages. Each call should look
|
| 144 |
+
* like this:
|
| 145 |
+
*
|
| 146 |
+
* if (Mod_Init(interp) == TCL_ERROR) {
|
| 147 |
+
* return TCL_ERROR;
|
| 148 |
+
* }
|
| 149 |
+
*
|
| 150 |
+
* where "Mod" is the name of the module. (Dynamically-loadable packages
|
| 151 |
+
* should have the same entry-point name.)
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
/*
|
| 155 |
+
* Call Tcl_CreateObjCommand for application-specific commands, if they
|
| 156 |
+
* weren't already created by the init procedures called above.
|
| 157 |
+
*/
|
| 158 |
+
|
| 159 |
+
/*
|
| 160 |
+
* Specify a user-specific startup file to invoke if the application is
|
| 161 |
+
* run interactively. Typically the startup file is "~/.apprc" where "app"
|
| 162 |
+
* is the name of the application. If this line is deleted then no user-
|
| 163 |
+
* specific startup file will be run under any conditions.
|
| 164 |
+
*/
|
| 165 |
+
|
| 166 |
+
Tcl_ObjSetVar2(interp, Tcl_NewStringObj("tcl_rcFileName", -1), NULL,
|
| 167 |
+
Tcl_NewStringObj("~/.wishrc", -1), TCL_GLOBAL_ONLY);
|
| 168 |
+
return TCL_OK;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/*
|
| 172 |
+
* Local Variables:
|
| 173 |
+
* mode: c
|
| 174 |
+
* c-basic-offset: 4
|
| 175 |
+
* fill-column: 78
|
| 176 |
+
* End:
|
| 177 |
+
*/
|
mplug_owl2/lib/tk8.6/tkfbox.tcl
ADDED
|
@@ -0,0 +1,1241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# tkfbox.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Implements the "TK" standard file selection dialog box. This dialog
|
| 4 |
+
# box is used on the Unix platforms whenever the tk_strictMotif flag is
|
| 5 |
+
# not set.
|
| 6 |
+
#
|
| 7 |
+
# The "TK" standard file selection dialog box is similar to the file
|
| 8 |
+
# selection dialog box on Win95(TM). The user can navigate the
|
| 9 |
+
# directories by clicking on the folder icons or by selecting the
|
| 10 |
+
# "Directory" option menu. The user can select files by clicking on the
|
| 11 |
+
# file icons or by entering a filename in the "Filename:" entry.
|
| 12 |
+
#
|
| 13 |
+
# Copyright (c) 1994-1998 Sun Microsystems, Inc.
|
| 14 |
+
#
|
| 15 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 16 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 17 |
+
#
|
| 18 |
+
|
| 19 |
+
namespace eval ::tk::dialog {}
|
| 20 |
+
namespace eval ::tk::dialog::file {
|
| 21 |
+
namespace import -force ::tk::msgcat::*
|
| 22 |
+
variable showHiddenBtn 0
|
| 23 |
+
variable showHiddenVar 1
|
| 24 |
+
|
| 25 |
+
# Create the images if they did not already exist.
|
| 26 |
+
if {![info exists ::tk::Priv(updirImage)]} {
|
| 27 |
+
set ::tk::Priv(updirImage) [image create photo -data {
|
| 28 |
+
iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/gD+AP7rGN
|
| 29 |
+
SCAAAACXBIWXMAAA3WAAAN1gGQb3mcAAAACXZwQWcAAAAWAAAAFgDcxelYAAAENUlE
|
| 30 |
+
QVQ4y7WUbWiVZRjHf/f9POcc9+Kc5bC2aIq5sGG0XnTzNU13zAIlFMNc9CEhTCKwCC
|
| 31 |
+
JIgt7AglaR0RcrolAKg14+GBbiGL6xZiYyy63cmzvu7MVznnOe537rw7bDyvlBoT/c
|
| 32 |
+
n+6L3/3nf13XLZLJJP+HfICysjKvqqpq+rWKysvLR1tbW+11g+fPn/+bEGIe4KYqCs
|
| 33 |
+
Owu66u7oG2trah6wJrrRc0NTVhjME5h7Vj5pxzCCE4duxYZUdHx/aGhoZmgJ+yb+wF
|
| 34 |
+
uCO19RmAffv25f8LFslkktraWtvU1CS6u7vRWmOtxVpbAPu+T0tLS04pFU/J34Wd3S
|
| 35 |
+
cdFtlfZWeZBU4IcaS5uXn1ZLAEMMY4ay1aa4wx/zpKKYIgoL6+vmjxqoXe5ZLTcsPq
|
| 36 |
+
bTyycjODpe1y3WMrvDAMV14jCuW0VhhjiJQpOJ5w7Zwjk8/y9R+vsHHNNq6oFMrkeX
|
| 37 |
+
BxI+8d2sktap3YvOPD0lRQrH+Z81fE7t3WB4gihVKazsu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IRjWytAAAAJXRF
|
| 52 |
+
WHRjcmVhdGUtZGF0ZQAyMDA5LTA0LTA2VDIxOjI1OjQxLTAzOjAw8s+uCAAAACV0RV
|
| 53 |
+
h0bW9kaWZ5LWRhdGUAMjAwOC0wMS0wM1QxNTowODoyMS0wMjowMJEc/44AAAAZdEVY
|
| 54 |
+
dFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAAElFTkSuQmCC
|
| 55 |
+
}]
|
| 56 |
+
}
|
| 57 |
+
if {![info exists ::tk::Priv(folderImage)]} {
|
| 58 |
+
set ::tk::Priv(folderImage) [image create photo -data {
|
| 59 |
+
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiA
|
| 60 |
+
AAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBl
|
| 61 |
+
Lm9yZ5vuPBoAAAHCSURBVDiNpZAxa5NRFIafc+9XLCni4BC6FBycMnbrLpkcgtDVX6
|
| 62 |
+
C70D/g4lZX/4coxLlgxFkpiiSSUGm/JiXfveee45AmNlhawXc53HvPee55X+l2u/yP
|
| 63 |
+
qt3d3Tfu/viatwt3fzIYDI5uBJhZr9fr3TMzzAx3B+D09PR+v98/7HQ6z5fNOWdCCG
|
| 64 |
+
U4HH6s67oAVDlnV1UmkwmllBUkhMD29nYHeLuEAkyn06qU8qqu64MrgIyqYmZrkHa7
|
| 65 |
+
3drc3KTVahFjJITAaDRiPB4/XFlQVVMtHH5IzJo/P4EA4MyB+erWPQB7++zs7ccYvl
|
| 66 |
+
U5Z08pMW2cl88eIXLZeDUpXzsBkNQ5eP1+p0opmaoCTgzw6fjs6gLLsp58FB60t0Dc
|
| 67 |
+
K1Ul54yIEIMQ43Uj68pquDmCeJVztpwzuBNE2LgBoMVpslHMCUEAFgDVxQbzVAiA+a
|
| 68 |
+
K5uGPmmDtZF3VpoUm2ArhqQaRiUjcMf81p1G60UEVhcjZfAFTVUkrgkS+jc06mDX9n
|
| 69 |
+
vq4YhJ9nlxZExMwMEaHJRutOdWuIIsJFUoBSuTvHJ4YIfP46unV4qdlsjsBRZRtb/X
|
| 70 |
+
fHd5+C8+P7+J8BIoxFwovfRxYhnhxjpzEAAAAASUVORK5CYII=
|
| 71 |
+
}]
|
| 72 |
+
}
|
| 73 |
+
if {![info exists ::tk::Priv(fileImage)]} {
|
| 74 |
+
set ::tk::Priv(fileImage) [image create photo -data {
|
| 75 |
+
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gva
|
| 76 |
+
eTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QQWFA84umAmQgAAANpJREFU
|
| 77 |
+
OMutkj1uhDAQhb8HSLtbISGfgZ+zbJkix0HmFhwhUdocBnMBGvqtTIqIFSReWKK8ai
|
| 78 |
+
x73nwzHrVt+zEMwwvH9FrX9TsA1trpqKy10+yUzME4jnjvAZB0LzXHkojjmDRNVyh3
|
| 79 |
+
A+89zrlVwlKSqKrqVy/J8lAUxSZBSMny4ZLgp54iyPM8UPHGNJ2IomibAKDv+9VlWZ
|
| 80 |
+
bABbgB5/0WQgSSkC4PF2JF4JzbHN430c4vhAm0TyCJruuClefph4yCBCGT3T3Isoy/
|
| 81 |
+
KDHGfDZNcz2SZIx547/0BVRRX7n8uT/sAAAAAElFTkSuQmCC
|
| 82 |
+
}]
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# ::tk::dialog::file:: --
|
| 87 |
+
#
|
| 88 |
+
# Implements the TK file selection dialog. This dialog is used when the
|
| 89 |
+
# tk_strictMotif flag is set to false. This procedure shouldn't be
|
| 90 |
+
# called directly. Call tk_getOpenFile or tk_getSaveFile instead.
|
| 91 |
+
#
|
| 92 |
+
# Arguments:
|
| 93 |
+
# type "open" or "save"
|
| 94 |
+
# args Options parsed by the procedure.
|
| 95 |
+
#
|
| 96 |
+
|
| 97 |
+
proc ::tk::dialog::file:: {type args} {
|
| 98 |
+
variable ::tk::Priv
|
| 99 |
+
variable showHiddenBtn
|
| 100 |
+
set dataName __tk_filedialog
|
| 101 |
+
upvar ::tk::dialog::file::$dataName data
|
| 102 |
+
|
| 103 |
+
Config $dataName $type $args
|
| 104 |
+
|
| 105 |
+
if {$data(-parent) eq "."} {
|
| 106 |
+
set w .$dataName
|
| 107 |
+
} else {
|
| 108 |
+
set w $data(-parent).$dataName
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
# (re)create the dialog box if necessary
|
| 112 |
+
#
|
| 113 |
+
if {![winfo exists $w]} {
|
| 114 |
+
Create $w TkFDialog
|
| 115 |
+
} elseif {[winfo class $w] ne "TkFDialog"} {
|
| 116 |
+
destroy $w
|
| 117 |
+
Create $w TkFDialog
|
| 118 |
+
} else {
|
| 119 |
+
set data(dirMenuBtn) $w.contents.f1.menu
|
| 120 |
+
set data(dirMenu) $w.contents.f1.menu.menu
|
| 121 |
+
set data(upBtn) $w.contents.f1.up
|
| 122 |
+
set data(icons) $w.contents.icons
|
| 123 |
+
set data(ent) $w.contents.f2.ent
|
| 124 |
+
set data(typeMenuLab) $w.contents.f2.lab2
|
| 125 |
+
set data(typeMenuBtn) $w.contents.f2.menu
|
| 126 |
+
set data(typeMenu) $data(typeMenuBtn).m
|
| 127 |
+
set data(okBtn) $w.contents.f2.ok
|
| 128 |
+
set data(cancelBtn) $w.contents.f2.cancel
|
| 129 |
+
set data(hiddenBtn) $w.contents.f2.hidden
|
| 130 |
+
SetSelectMode $w $data(-multiple)
|
| 131 |
+
}
|
| 132 |
+
if {$showHiddenBtn} {
|
| 133 |
+
$data(hiddenBtn) configure -state normal
|
| 134 |
+
grid $data(hiddenBtn)
|
| 135 |
+
} else {
|
| 136 |
+
$data(hiddenBtn) configure -state disabled
|
| 137 |
+
grid remove $data(hiddenBtn)
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
# Make sure subseqent uses of this dialog are independent [Bug 845189]
|
| 141 |
+
unset -nocomplain data(extUsed)
|
| 142 |
+
|
| 143 |
+
# Dialog boxes should be transient with respect to their parent, so that
|
| 144 |
+
# they will always stay on top of their parent window. However, some
|
| 145 |
+
# window managers will create the window as withdrawn if the parent window
|
| 146 |
+
# is withdrawn or iconified. Combined with the grab we put on the window,
|
| 147 |
+
# this can hang the entire application. Therefore we only make the dialog
|
| 148 |
+
# transient if the parent is viewable.
|
| 149 |
+
|
| 150 |
+
if {[winfo viewable [winfo toplevel $data(-parent)]]} {
|
| 151 |
+
wm transient $w $data(-parent)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
# Add traces on the selectPath variable
|
| 155 |
+
#
|
| 156 |
+
|
| 157 |
+
trace add variable data(selectPath) write \
|
| 158 |
+
[list ::tk::dialog::file::SetPath $w]
|
| 159 |
+
$data(dirMenuBtn) configure \
|
| 160 |
+
-textvariable ::tk::dialog::file::${dataName}(selectPath)
|
| 161 |
+
|
| 162 |
+
# Cleanup previous menu
|
| 163 |
+
#
|
| 164 |
+
$data(typeMenu) delete 0 end
|
| 165 |
+
$data(typeMenuBtn) configure -state normal -text ""
|
| 166 |
+
|
| 167 |
+
# Initialize the file types menu
|
| 168 |
+
#
|
| 169 |
+
if {[llength $data(-filetypes)]} {
|
| 170 |
+
# Default type and name to first entry
|
| 171 |
+
set initialtype [lindex $data(-filetypes) 0]
|
| 172 |
+
set initialTypeName [lindex $initialtype 0]
|
| 173 |
+
if {$data(-typevariable) ne ""} {
|
| 174 |
+
upvar #0 $data(-typevariable) typeVariable
|
| 175 |
+
if {[info exists typeVariable]} {
|
| 176 |
+
set initialTypeName $typeVariable
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
foreach type $data(-filetypes) {
|
| 180 |
+
set title [lindex $type 0]
|
| 181 |
+
set filter [lindex $type 1]
|
| 182 |
+
$data(typeMenu) add command -label $title \
|
| 183 |
+
-command [list ::tk::dialog::file::SetFilter $w $type]
|
| 184 |
+
# [string first] avoids glob-pattern char issues
|
| 185 |
+
if {[string first ${initialTypeName} $title] == 0} {
|
| 186 |
+
set initialtype $type
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
SetFilter $w $initialtype
|
| 190 |
+
$data(typeMenuBtn) configure -state normal
|
| 191 |
+
$data(typeMenuLab) configure -state normal
|
| 192 |
+
} else {
|
| 193 |
+
set data(filter) "*"
|
| 194 |
+
$data(typeMenuBtn) configure -state disabled -takefocus 0
|
| 195 |
+
$data(typeMenuLab) configure -state disabled
|
| 196 |
+
}
|
| 197 |
+
UpdateWhenIdle $w
|
| 198 |
+
|
| 199 |
+
# Withdraw the window, then update all the geometry information
|
| 200 |
+
# so we know how big it wants to be, then center the window in the
|
| 201 |
+
# display (Motif style) and de-iconify it.
|
| 202 |
+
|
| 203 |
+
::tk::PlaceWindow $w widget $data(-parent)
|
| 204 |
+
wm title $w $data(-title)
|
| 205 |
+
|
| 206 |
+
# Set a grab and claim the focus too.
|
| 207 |
+
|
| 208 |
+
::tk::SetFocusGrab $w $data(ent)
|
| 209 |
+
$data(ent) delete 0 end
|
| 210 |
+
$data(ent) insert 0 $data(selectFile)
|
| 211 |
+
$data(ent) selection range 0 end
|
| 212 |
+
$data(ent) icursor end
|
| 213 |
+
|
| 214 |
+
# Wait for the user to respond, then restore the focus and return the
|
| 215 |
+
# index of the selected button. Restore the focus before deleting the
|
| 216 |
+
# window, since otherwise the window manager may take the focus away so we
|
| 217 |
+
# can't redirect it. Finally, restore any grab that was in effect.
|
| 218 |
+
|
| 219 |
+
vwait ::tk::Priv(selectFilePath)
|
| 220 |
+
|
| 221 |
+
::tk::RestoreFocusGrab $w $data(ent) withdraw
|
| 222 |
+
|
| 223 |
+
# Cleanup traces on selectPath variable
|
| 224 |
+
#
|
| 225 |
+
|
| 226 |
+
foreach trace [trace info variable data(selectPath)] {
|
| 227 |
+
trace remove variable data(selectPath) {*}$trace
|
| 228 |
+
}
|
| 229 |
+
if {[winfo exists $data(dirMenuBtn)]} {
|
| 230 |
+
$data(dirMenuBtn) configure -textvariable {}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
return $Priv(selectFilePath)
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
# ::tk::dialog::file::Config --
|
| 237 |
+
#
|
| 238 |
+
# Configures the TK filedialog according to the argument list
|
| 239 |
+
#
|
| 240 |
+
proc ::tk::dialog::file::Config {dataName type argList} {
|
| 241 |
+
upvar ::tk::dialog::file::$dataName data
|
| 242 |
+
|
| 243 |
+
set data(type) $type
|
| 244 |
+
|
| 245 |
+
# 0: Delete all variable that were set on data(selectPath) the
|
| 246 |
+
# last time the file dialog is used. The traces may cause troubles
|
| 247 |
+
# if the dialog is now used with a different -parent option.
|
| 248 |
+
|
| 249 |
+
foreach trace [trace info variable data(selectPath)] {
|
| 250 |
+
trace remove variable data(selectPath) {*}$trace
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
# 1: the configuration specs
|
| 254 |
+
#
|
| 255 |
+
set specs {
|
| 256 |
+
{-defaultextension "" "" ""}
|
| 257 |
+
{-filetypes "" "" ""}
|
| 258 |
+
{-initialdir "" "" ""}
|
| 259 |
+
{-initialfile "" "" ""}
|
| 260 |
+
{-parent "" "" "."}
|
| 261 |
+
{-title "" "" ""}
|
| 262 |
+
{-typevariable "" "" ""}
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
# The "-multiple" option is only available for the "open" file dialog.
|
| 266 |
+
#
|
| 267 |
+
if {$type eq "open"} {
|
| 268 |
+
lappend specs {-multiple "" "" "0"}
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
# The "-confirmoverwrite" option is only for the "save" file dialog.
|
| 272 |
+
#
|
| 273 |
+
if {$type eq "save"} {
|
| 274 |
+
lappend specs {-confirmoverwrite "" "" "1"}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
# 2: default values depending on the type of the dialog
|
| 278 |
+
#
|
| 279 |
+
if {![info exists data(selectPath)]} {
|
| 280 |
+
# first time the dialog has been popped up
|
| 281 |
+
set data(selectPath) [pwd]
|
| 282 |
+
set data(selectFile) ""
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
# 3: parse the arguments
|
| 286 |
+
#
|
| 287 |
+
tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList
|
| 288 |
+
|
| 289 |
+
if {$data(-title) eq ""} {
|
| 290 |
+
if {$type eq "open"} {
|
| 291 |
+
set data(-title) [mc "Open"]
|
| 292 |
+
} else {
|
| 293 |
+
set data(-title) [mc "Save As"]
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
# 4: set the default directory and selection according to the -initial
|
| 298 |
+
# settings
|
| 299 |
+
#
|
| 300 |
+
if {$data(-initialdir) ne ""} {
|
| 301 |
+
# Ensure that initialdir is an absolute path name.
|
| 302 |
+
if {[file isdirectory $data(-initialdir)]} {
|
| 303 |
+
set old [pwd]
|
| 304 |
+
cd $data(-initialdir)
|
| 305 |
+
set data(selectPath) [pwd]
|
| 306 |
+
cd $old
|
| 307 |
+
} else {
|
| 308 |
+
set data(selectPath) [pwd]
|
| 309 |
+
}
|
| 310 |
+
}
|
| 311 |
+
set data(selectFile) $data(-initialfile)
|
| 312 |
+
|
| 313 |
+
# 5. Parse the -filetypes option
|
| 314 |
+
#
|
| 315 |
+
set data(origfiletypes) $data(-filetypes)
|
| 316 |
+
set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)]
|
| 317 |
+
|
| 318 |
+
if {![winfo exists $data(-parent)]} {
|
| 319 |
+
return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
|
| 320 |
+
"bad window path name \"$data(-parent)\""
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
# Set -multiple to a one or zero value (not other boolean types like
|
| 324 |
+
# "yes") so we can use it in tests more easily.
|
| 325 |
+
if {$type eq "save"} {
|
| 326 |
+
set data(-multiple) 0
|
| 327 |
+
} elseif {$data(-multiple)} {
|
| 328 |
+
set data(-multiple) 1
|
| 329 |
+
} else {
|
| 330 |
+
set data(-multiple) 0
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
proc ::tk::dialog::file::Create {w class} {
|
| 335 |
+
set dataName [lindex [split $w .] end]
|
| 336 |
+
upvar ::tk::dialog::file::$dataName data
|
| 337 |
+
variable ::tk::Priv
|
| 338 |
+
global tk_library
|
| 339 |
+
|
| 340 |
+
toplevel $w -class $class
|
| 341 |
+
if {[tk windowingsystem] eq "x11"} {wm attributes $w -type dialog}
|
| 342 |
+
pack [ttk::frame $w.contents] -expand 1 -fill both
|
| 343 |
+
#set w $w.contents
|
| 344 |
+
|
| 345 |
+
# f1: the frame with the directory option menu
|
| 346 |
+
#
|
| 347 |
+
set f1 [ttk::frame $w.contents.f1]
|
| 348 |
+
bind [::tk::AmpWidget ttk::label $f1.lab -text [mc "&Directory:"]] \
|
| 349 |
+
<<AltUnderlined>> [list focus $f1.menu]
|
| 350 |
+
|
| 351 |
+
set data(dirMenuBtn) $f1.menu
|
| 352 |
+
if {![info exists data(selectPath)]} {
|
| 353 |
+
set data(selectPath) ""
|
| 354 |
+
}
|
| 355 |
+
set data(dirMenu) $f1.menu.menu
|
| 356 |
+
ttk::menubutton $f1.menu -menu $data(dirMenu) -direction flush \
|
| 357 |
+
-textvariable [format %s(selectPath) ::tk::dialog::file::$dataName]
|
| 358 |
+
menu $data(dirMenu) -tearoff 0
|
| 359 |
+
$data(dirMenu) add radiobutton -label "" -variable \
|
| 360 |
+
[format %s(selectPath) ::tk::dialog::file::$dataName]
|
| 361 |
+
set data(upBtn) [ttk::button $f1.up]
|
| 362 |
+
$data(upBtn) configure -image $Priv(updirImage)
|
| 363 |
+
|
| 364 |
+
$f1.menu configure -takefocus 1;# -highlightthickness 2
|
| 365 |
+
|
| 366 |
+
pack $data(upBtn) -side right -padx 4 -fill both
|
| 367 |
+
pack $f1.lab -side left -padx 4 -fill both
|
| 368 |
+
pack $f1.menu -expand yes -fill both -padx 4
|
| 369 |
+
|
| 370 |
+
# data(icons): the IconList that list the files and directories.
|
| 371 |
+
#
|
| 372 |
+
if {$class eq "TkFDialog"} {
|
| 373 |
+
if { $data(-multiple) } {
|
| 374 |
+
set fNameCaption [mc "File &names:"]
|
| 375 |
+
} else {
|
| 376 |
+
set fNameCaption [mc "File &name:"]
|
| 377 |
+
}
|
| 378 |
+
set fTypeCaption [mc "Files of &type:"]
|
| 379 |
+
set iconListCommand [list ::tk::dialog::file::OkCmd $w]
|
| 380 |
+
} else {
|
| 381 |
+
set fNameCaption [mc "&Selection:"]
|
| 382 |
+
set iconListCommand [list ::tk::dialog::file::chooseDir::DblClick $w]
|
| 383 |
+
}
|
| 384 |
+
set data(icons) [::tk::IconList $w.contents.icons \
|
| 385 |
+
-command $iconListCommand -multiple $data(-multiple)]
|
| 386 |
+
bind $data(icons) <<ListboxSelect>> \
|
| 387 |
+
[list ::tk::dialog::file::ListBrowse $w]
|
| 388 |
+
|
| 389 |
+
# f2: the frame with the OK button, cancel button, "file name" field
|
| 390 |
+
# and file types field.
|
| 391 |
+
#
|
| 392 |
+
set f2 [ttk::frame $w.contents.f2]
|
| 393 |
+
bind [::tk::AmpWidget ttk::label $f2.lab -text $fNameCaption -anchor e]\
|
| 394 |
+
<<AltUnderlined>> [list focus $f2.ent]
|
| 395 |
+
# -pady 0
|
| 396 |
+
set data(ent) [ttk::entry $f2.ent]
|
| 397 |
+
|
| 398 |
+
# The font to use for the icons. The default Canvas font on Unix is just
|
| 399 |
+
# deviant.
|
| 400 |
+
set ::tk::$w.contents.icons(font) [$data(ent) cget -font]
|
| 401 |
+
|
| 402 |
+
# Make the file types bits only if this is a File Dialog
|
| 403 |
+
if {$class eq "TkFDialog"} {
|
| 404 |
+
set data(typeMenuLab) [::tk::AmpWidget ttk::label $f2.lab2 \
|
| 405 |
+
-text $fTypeCaption -anchor e]
|
| 406 |
+
# -pady [$f2.lab cget -pady]
|
| 407 |
+
set data(typeMenuBtn) [ttk::menubutton $f2.menu \
|
| 408 |
+
-menu $f2.menu.m]
|
| 409 |
+
# -indicatoron 1
|
| 410 |
+
set data(typeMenu) [menu $data(typeMenuBtn).m -tearoff 0]
|
| 411 |
+
# $data(typeMenuBtn) configure -takefocus 1 -relief raised -anchor w
|
| 412 |
+
bind $data(typeMenuLab) <<AltUnderlined>> [list \
|
| 413 |
+
focus $data(typeMenuBtn)]
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
# The hidden button is displayed when ::tk::dialog::file::showHiddenBtn is
|
| 417 |
+
# true. Create it disabled so the binding doesn't trigger if it isn't
|
| 418 |
+
# shown.
|
| 419 |
+
if {$class eq "TkFDialog"} {
|
| 420 |
+
set text [mc "Show &Hidden Files and Directories"]
|
| 421 |
+
} else {
|
| 422 |
+
set text [mc "Show &Hidden Directories"]
|
| 423 |
+
}
|
| 424 |
+
set data(hiddenBtn) [::tk::AmpWidget ttk::checkbutton $f2.hidden \
|
| 425 |
+
-text $text -state disabled \
|
| 426 |
+
-variable ::tk::dialog::file::showHiddenVar \
|
| 427 |
+
-command [list ::tk::dialog::file::UpdateWhenIdle $w]]
|
| 428 |
+
# -anchor w -padx 3
|
| 429 |
+
|
| 430 |
+
# the okBtn is created after the typeMenu so that the keyboard traversal
|
| 431 |
+
# is in the right order, and add binding so that we find out when the
|
| 432 |
+
# dialog is destroyed by the user (added here instead of to the overall
|
| 433 |
+
# window so no confusion about how much <Destroy> gets called; exactly
|
| 434 |
+
# once will do). [Bug 987169]
|
| 435 |
+
|
| 436 |
+
set data(okBtn) [::tk::AmpWidget ttk::button $f2.ok \
|
| 437 |
+
-text [mc "&OK"] -default active];# -pady 3]
|
| 438 |
+
bind $data(okBtn) <Destroy> [list ::tk::dialog::file::Destroyed $w]
|
| 439 |
+
set data(cancelBtn) [::tk::AmpWidget ttk::button $f2.cancel \
|
| 440 |
+
-text [mc "&Cancel"] -default normal];# -pady 3]
|
| 441 |
+
|
| 442 |
+
# grid the widgets in f2
|
| 443 |
+
#
|
| 444 |
+
grid $f2.lab $f2.ent $data(okBtn) -padx 4 -pady 3 -sticky ew
|
| 445 |
+
grid configure $f2.ent -padx 2
|
| 446 |
+
if {$class eq "TkFDialog"} {
|
| 447 |
+
grid $data(typeMenuLab) $data(typeMenuBtn) $data(cancelBtn) \
|
| 448 |
+
-padx 4 -sticky ew
|
| 449 |
+
grid configure $data(typeMenuBtn) -padx 0
|
| 450 |
+
grid $data(hiddenBtn) -columnspan 2 -padx 4 -sticky ew
|
| 451 |
+
} else {
|
| 452 |
+
grid $data(hiddenBtn) - $data(cancelBtn) -padx 4 -sticky ew
|
| 453 |
+
}
|
| 454 |
+
grid columnconfigure $f2 1 -weight 1
|
| 455 |
+
|
| 456 |
+
# Pack all the frames together. We are done with widget construction.
|
| 457 |
+
#
|
| 458 |
+
pack $f1 -side top -fill x -pady 4
|
| 459 |
+
pack $f2 -side bottom -pady 4 -fill x
|
| 460 |
+
pack $data(icons) -expand yes -fill both -padx 4 -pady 1
|
| 461 |
+
|
| 462 |
+
# Set up the event handlers that are common to Directory and File Dialogs
|
| 463 |
+
#
|
| 464 |
+
|
| 465 |
+
wm protocol $w WM_DELETE_WINDOW [list ::tk::dialog::file::CancelCmd $w]
|
| 466 |
+
$data(upBtn) configure -command [list ::tk::dialog::file::UpDirCmd $w]
|
| 467 |
+
$data(cancelBtn) configure -command [list ::tk::dialog::file::CancelCmd $w]
|
| 468 |
+
bind $w <Escape> [list $data(cancelBtn) invoke]
|
| 469 |
+
bind $w <Alt-Key> [list tk::AltKeyInDialog $w %A]
|
| 470 |
+
|
| 471 |
+
# Set up event handlers specific to File or Directory Dialogs
|
| 472 |
+
#
|
| 473 |
+
if {$class eq "TkFDialog"} {
|
| 474 |
+
bind $data(ent) <Return> [list ::tk::dialog::file::ActivateEnt $w]
|
| 475 |
+
$data(okBtn) configure -command [list ::tk::dialog::file::OkCmd $w]
|
| 476 |
+
bind $w <Alt-t> [format {
|
| 477 |
+
if {[%s cget -state] eq "normal"} {
|
| 478 |
+
focus %s
|
| 479 |
+
}
|
| 480 |
+
} $data(typeMenuBtn) $data(typeMenuBtn)]
|
| 481 |
+
} else {
|
| 482 |
+
set okCmd [list ::tk::dialog::file::chooseDir::OkCmd $w]
|
| 483 |
+
bind $data(ent) <Return> $okCmd
|
| 484 |
+
$data(okBtn) configure -command $okCmd
|
| 485 |
+
bind $w <Alt-s> [list focus $data(ent)]
|
| 486 |
+
bind $w <Alt-o> [list $data(okBtn) invoke]
|
| 487 |
+
}
|
| 488 |
+
bind $w <Alt-h> [list $data(hiddenBtn) invoke]
|
| 489 |
+
bind $data(ent) <Tab> [list ::tk::dialog::file::CompleteEnt $w]
|
| 490 |
+
|
| 491 |
+
# Build the focus group for all the entries
|
| 492 |
+
#
|
| 493 |
+
::tk::FocusGroup_Create $w
|
| 494 |
+
::tk::FocusGroup_BindIn $w $data(ent) [list \
|
| 495 |
+
::tk::dialog::file::EntFocusIn $w]
|
| 496 |
+
::tk::FocusGroup_BindOut $w $data(ent) [list \
|
| 497 |
+
::tk::dialog::file::EntFocusOut $w]
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
# ::tk::dialog::file::SetSelectMode --
|
| 501 |
+
#
|
| 502 |
+
# Set the select mode of the dialog to single select or multi-select.
|
| 503 |
+
#
|
| 504 |
+
# Arguments:
|
| 505 |
+
# w The dialog path.
|
| 506 |
+
# multi 1 if the dialog is multi-select; 0 otherwise.
|
| 507 |
+
#
|
| 508 |
+
# Results:
|
| 509 |
+
# None.
|
| 510 |
+
|
| 511 |
+
proc ::tk::dialog::file::SetSelectMode {w multi} {
|
| 512 |
+
set dataName __tk_filedialog
|
| 513 |
+
upvar ::tk::dialog::file::$dataName data
|
| 514 |
+
if { $multi } {
|
| 515 |
+
set fNameCaption [mc "File &names:"]
|
| 516 |
+
} else {
|
| 517 |
+
set fNameCaption [mc "File &name:"]
|
| 518 |
+
}
|
| 519 |
+
set iconListCommand [list ::tk::dialog::file::OkCmd $w]
|
| 520 |
+
::tk::SetAmpText $w.contents.f2.lab $fNameCaption
|
| 521 |
+
$data(icons) configure -multiple $multi -command $iconListCommand
|
| 522 |
+
return
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
# ::tk::dialog::file::UpdateWhenIdle --
|
| 526 |
+
#
|
| 527 |
+
# Creates an idle event handler which updates the dialog in idle time.
|
| 528 |
+
# This is important because loading the directory may take a long time
|
| 529 |
+
# and we don't want to load the same directory for multiple times due to
|
| 530 |
+
# multiple concurrent events.
|
| 531 |
+
#
|
| 532 |
+
proc ::tk::dialog::file::UpdateWhenIdle {w} {
|
| 533 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 534 |
+
|
| 535 |
+
if {[info exists data(updateId)]} {
|
| 536 |
+
return
|
| 537 |
+
}
|
| 538 |
+
set data(updateId) [after idle [list ::tk::dialog::file::Update $w]]
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
# ::tk::dialog::file::Update --
|
| 542 |
+
#
|
| 543 |
+
# Loads the files and directories into the IconList widget. Also sets up
|
| 544 |
+
# the directory option menu for quick access to parent directories.
|
| 545 |
+
#
|
| 546 |
+
proc ::tk::dialog::file::Update {w} {
|
| 547 |
+
# This proc may be called within an idle handler. Make sure that the
|
| 548 |
+
# window has not been destroyed before this proc is called
|
| 549 |
+
if {![winfo exists $w]} {
|
| 550 |
+
return
|
| 551 |
+
}
|
| 552 |
+
set class [winfo class $w]
|
| 553 |
+
if {($class ne "TkFDialog") && ($class ne "TkChooseDir")} {
|
| 554 |
+
return
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
set dataName [winfo name $w]
|
| 558 |
+
upvar ::tk::dialog::file::$dataName data
|
| 559 |
+
variable ::tk::Priv
|
| 560 |
+
variable showHiddenVar
|
| 561 |
+
global tk_library
|
| 562 |
+
unset -nocomplain data(updateId)
|
| 563 |
+
|
| 564 |
+
set folder $Priv(folderImage)
|
| 565 |
+
set file $Priv(fileImage)
|
| 566 |
+
|
| 567 |
+
set appPWD [pwd]
|
| 568 |
+
if {[catch {
|
| 569 |
+
cd $data(selectPath)
|
| 570 |
+
}]} then {
|
| 571 |
+
# We cannot change directory to $data(selectPath). $data(selectPath)
|
| 572 |
+
# should have been checked before ::tk::dialog::file::Update is
|
| 573 |
+
# called, so we normally won't come to here. Anyways, give an error
|
| 574 |
+
# and abort action.
|
| 575 |
+
tk_messageBox -type ok -parent $w -icon warning -message [mc \
|
| 576 |
+
"Cannot change to the directory \"%1\$s\".\nPermission denied."\
|
| 577 |
+
$data(selectPath)]
|
| 578 |
+
cd $appPWD
|
| 579 |
+
return
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
# Turn on the busy cursor. BUG?? We haven't disabled X events, though,
|
| 583 |
+
# so the user may still click and cause havoc ...
|
| 584 |
+
#
|
| 585 |
+
set entCursor [$data(ent) cget -cursor]
|
| 586 |
+
set dlgCursor [$w cget -cursor]
|
| 587 |
+
$data(ent) configure -cursor watch
|
| 588 |
+
$w configure -cursor watch
|
| 589 |
+
update idletasks
|
| 590 |
+
|
| 591 |
+
$data(icons) deleteall
|
| 592 |
+
|
| 593 |
+
set showHidden $showHiddenVar
|
| 594 |
+
|
| 595 |
+
# Make the dir list. Note that using an explicit [pwd] (instead of '.') is
|
| 596 |
+
# better in some VFS cases.
|
| 597 |
+
$data(icons) add $folder [GlobFiltered [pwd] d 1]
|
| 598 |
+
|
| 599 |
+
if {$class eq "TkFDialog"} {
|
| 600 |
+
# Make the file list if this is a File Dialog, selecting all but
|
| 601 |
+
# 'd'irectory type files.
|
| 602 |
+
#
|
| 603 |
+
$data(icons) add $file [GlobFiltered [pwd] {f b c l p s}]
|
| 604 |
+
}
|
| 605 |
+
|
| 606 |
+
# Update the Directory: option menu
|
| 607 |
+
#
|
| 608 |
+
set list ""
|
| 609 |
+
set dir ""
|
| 610 |
+
foreach subdir [file split $data(selectPath)] {
|
| 611 |
+
set dir [file join $dir $subdir]
|
| 612 |
+
lappend list $dir
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
$data(dirMenu) delete 0 end
|
| 616 |
+
set var [format %s(selectPath) ::tk::dialog::file::$dataName]
|
| 617 |
+
foreach path $list {
|
| 618 |
+
$data(dirMenu) add command -label $path -command [list set $var $path]
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
# Restore the PWD to the application's PWD
|
| 622 |
+
#
|
| 623 |
+
cd $appPWD
|
| 624 |
+
|
| 625 |
+
if {$class eq "TkFDialog"} {
|
| 626 |
+
# Restore the Open/Save Button if this is a File Dialog
|
| 627 |
+
#
|
| 628 |
+
if {$data(type) eq "open"} {
|
| 629 |
+
::tk::SetAmpText $data(okBtn) [mc "&Open"]
|
| 630 |
+
} else {
|
| 631 |
+
::tk::SetAmpText $data(okBtn) [mc "&Save"]
|
| 632 |
+
}
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
# turn off the busy cursor.
|
| 636 |
+
#
|
| 637 |
+
$data(ent) configure -cursor $entCursor
|
| 638 |
+
$w configure -cursor $dlgCursor
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
# ::tk::dialog::file::SetPathSilently --
|
| 642 |
+
#
|
| 643 |
+
# Sets data(selectPath) without invoking the trace procedure
|
| 644 |
+
#
|
| 645 |
+
proc ::tk::dialog::file::SetPathSilently {w path} {
|
| 646 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 647 |
+
|
| 648 |
+
set cb [list ::tk::dialog::file::SetPath $w]
|
| 649 |
+
trace remove variable data(selectPath) write $cb
|
| 650 |
+
set data(selectPath) $path
|
| 651 |
+
trace add variable data(selectPath) write $cb
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
|
| 655 |
+
# This proc gets called whenever data(selectPath) is set
|
| 656 |
+
#
|
| 657 |
+
proc ::tk::dialog::file::SetPath {w name1 name2 op} {
|
| 658 |
+
if {[winfo exists $w]} {
|
| 659 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 660 |
+
UpdateWhenIdle $w
|
| 661 |
+
# On directory dialogs, we keep the entry in sync with the currentdir.
|
| 662 |
+
if {[winfo class $w] eq "TkChooseDir"} {
|
| 663 |
+
$data(ent) delete 0 end
|
| 664 |
+
$data(ent) insert end $data(selectPath)
|
| 665 |
+
}
|
| 666 |
+
}
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
# This proc gets called whenever data(filter) is set
|
| 670 |
+
#
|
| 671 |
+
proc ::tk::dialog::file::SetFilter {w type} {
|
| 672 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 673 |
+
|
| 674 |
+
set data(filterType) $type
|
| 675 |
+
set data(filter) [lindex $type 1]
|
| 676 |
+
$data(typeMenuBtn) configure -text [lindex $type 0] ;#-indicatoron 1
|
| 677 |
+
|
| 678 |
+
# If we aren't using a default extension, use the one suppled by the
|
| 679 |
+
# filter.
|
| 680 |
+
if {![info exists data(extUsed)]} {
|
| 681 |
+
if {[string length $data(-defaultextension)]} {
|
| 682 |
+
set data(extUsed) 1
|
| 683 |
+
} else {
|
| 684 |
+
set data(extUsed) 0
|
| 685 |
+
}
|
| 686 |
+
}
|
| 687 |
+
|
| 688 |
+
if {!$data(extUsed)} {
|
| 689 |
+
# Get the first extension in the list that matches {^\*\.\w+$} and
|
| 690 |
+
# remove all * from the filter.
|
| 691 |
+
set index [lsearch -regexp $data(filter) {^\*\.\w+$}]
|
| 692 |
+
if {$index >= 0} {
|
| 693 |
+
set data(-defaultextension) \
|
| 694 |
+
[string trimleft [lindex $data(filter) $index] "*"]
|
| 695 |
+
} else {
|
| 696 |
+
# Couldn't find anything! Reset to a safe default...
|
| 697 |
+
set data(-defaultextension) ""
|
| 698 |
+
}
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
$data(icons) see 0
|
| 702 |
+
|
| 703 |
+
UpdateWhenIdle $w
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
# tk::dialog::file::ResolveFile --
|
| 707 |
+
#
|
| 708 |
+
# Interpret the user's text input in a file selection dialog. Performs:
|
| 709 |
+
#
|
| 710 |
+
# (1) ~ substitution
|
| 711 |
+
# (2) resolve all instances of . and ..
|
| 712 |
+
# (3) check for non-existent files/directories
|
| 713 |
+
# (4) check for chdir permissions
|
| 714 |
+
# (5) conversion of environment variable references to their
|
| 715 |
+
# contents (once only)
|
| 716 |
+
#
|
| 717 |
+
# Arguments:
|
| 718 |
+
# context: the current directory you are in
|
| 719 |
+
# text: the text entered by the user
|
| 720 |
+
# defaultext: the default extension to add to files with no extension
|
| 721 |
+
# expandEnv: whether to expand environment variables (yes by default)
|
| 722 |
+
#
|
| 723 |
+
# Return vaue:
|
| 724 |
+
# [list $flag $directory $file]
|
| 725 |
+
#
|
| 726 |
+
# flag = OK : valid input
|
| 727 |
+
# = PATTERN : valid directory/pattern
|
| 728 |
+
# = PATH : the directory does not exist
|
| 729 |
+
# = FILE : the directory exists by the file doesn't exist
|
| 730 |
+
# = CHDIR : Cannot change to the directory
|
| 731 |
+
# = ERROR : Invalid entry
|
| 732 |
+
#
|
| 733 |
+
# directory : valid only if flag = OK or PATTERN or FILE
|
| 734 |
+
# file : valid only if flag = OK or PATTERN
|
| 735 |
+
#
|
| 736 |
+
# directory may not be the same as context, because text may contain a
|
| 737 |
+
# subdirectory name
|
| 738 |
+
#
|
| 739 |
+
proc ::tk::dialog::file::ResolveFile {context text defaultext {expandEnv 1}} {
|
| 740 |
+
set appPWD [pwd]
|
| 741 |
+
|
| 742 |
+
set path [JoinFile $context $text]
|
| 743 |
+
|
| 744 |
+
# If the file has no extension, append the default. Be careful not to do
|
| 745 |
+
# this for directories, otherwise typing a dirname in the box will give
|
| 746 |
+
# back "dirname.extension" instead of trying to change dir.
|
| 747 |
+
if {
|
| 748 |
+
![file isdirectory $path] && ([file ext $path] eq "") &&
|
| 749 |
+
![string match {$*} [file tail $path]]
|
| 750 |
+
} then {
|
| 751 |
+
set path "$path$defaultext"
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
if {[catch {file exists $path}]} {
|
| 755 |
+
# This "if" block can be safely removed if the following code stop
|
| 756 |
+
# generating errors.
|
| 757 |
+
#
|
| 758 |
+
# file exists ~nonsuchuser
|
| 759 |
+
#
|
| 760 |
+
return [list ERROR $path ""]
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
if {[file exists $path]} {
|
| 764 |
+
if {[file isdirectory $path]} {
|
| 765 |
+
if {[catch {cd $path}]} {
|
| 766 |
+
return [list CHDIR $path ""]
|
| 767 |
+
}
|
| 768 |
+
set directory [pwd]
|
| 769 |
+
set file ""
|
| 770 |
+
set flag OK
|
| 771 |
+
cd $appPWD
|
| 772 |
+
} else {
|
| 773 |
+
if {[catch {cd [file dirname $path]}]} {
|
| 774 |
+
return [list CHDIR [file dirname $path] ""]
|
| 775 |
+
}
|
| 776 |
+
set directory [pwd]
|
| 777 |
+
set file [file tail $path]
|
| 778 |
+
set flag OK
|
| 779 |
+
cd $appPWD
|
| 780 |
+
}
|
| 781 |
+
} else {
|
| 782 |
+
set dirname [file dirname $path]
|
| 783 |
+
if {[file exists $dirname]} {
|
| 784 |
+
if {[catch {cd $dirname}]} {
|
| 785 |
+
return [list CHDIR $dirname ""]
|
| 786 |
+
}
|
| 787 |
+
set directory [pwd]
|
| 788 |
+
cd $appPWD
|
| 789 |
+
set file [file tail $path]
|
| 790 |
+
# It's nothing else, so check to see if it is an env-reference
|
| 791 |
+
if {$expandEnv && [string match {$*} $file]} {
|
| 792 |
+
set var [string range $file 1 end]
|
| 793 |
+
if {[info exist ::env($var)]} {
|
| 794 |
+
return [ResolveFile $context $::env($var) $defaultext 0]
|
| 795 |
+
}
|
| 796 |
+
}
|
| 797 |
+
if {[regexp {[*?]} $file]} {
|
| 798 |
+
set flag PATTERN
|
| 799 |
+
} else {
|
| 800 |
+
set flag FILE
|
| 801 |
+
}
|
| 802 |
+
} else {
|
| 803 |
+
set directory $dirname
|
| 804 |
+
set file [file tail $path]
|
| 805 |
+
set flag PATH
|
| 806 |
+
# It's nothing else, so check to see if it is an env-reference
|
| 807 |
+
if {$expandEnv && [string match {$*} $file]} {
|
| 808 |
+
set var [string range $file 1 end]
|
| 809 |
+
if {[info exist ::env($var)]} {
|
| 810 |
+
return [ResolveFile $context $::env($var) $defaultext 0]
|
| 811 |
+
}
|
| 812 |
+
}
|
| 813 |
+
}
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
return [list $flag $directory $file]
|
| 817 |
+
}
|
| 818 |
+
|
| 819 |
+
|
| 820 |
+
# Gets called when the entry box gets keyboard focus. We clear the selection
|
| 821 |
+
# from the icon list . This way the user can be certain that the input in the
|
| 822 |
+
# entry box is the selection.
|
| 823 |
+
#
|
| 824 |
+
proc ::tk::dialog::file::EntFocusIn {w} {
|
| 825 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 826 |
+
|
| 827 |
+
if {[$data(ent) get] ne ""} {
|
| 828 |
+
$data(ent) selection range 0 end
|
| 829 |
+
$data(ent) icursor end
|
| 830 |
+
} else {
|
| 831 |
+
$data(ent) selection clear
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
if {[winfo class $w] eq "TkFDialog"} {
|
| 835 |
+
# If this is a File Dialog, make sure the buttons are labeled right.
|
| 836 |
+
if {$data(type) eq "open"} {
|
| 837 |
+
::tk::SetAmpText $data(okBtn) [mc "&Open"]
|
| 838 |
+
} else {
|
| 839 |
+
::tk::SetAmpText $data(okBtn) [mc "&Save"]
|
| 840 |
+
}
|
| 841 |
+
}
|
| 842 |
+
}
|
| 843 |
+
|
| 844 |
+
proc ::tk::dialog::file::EntFocusOut {w} {
|
| 845 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 846 |
+
|
| 847 |
+
$data(ent) selection clear
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
|
| 851 |
+
# Gets called when user presses Return in the "File name" entry.
|
| 852 |
+
#
|
| 853 |
+
proc ::tk::dialog::file::ActivateEnt {w} {
|
| 854 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 855 |
+
|
| 856 |
+
set text [$data(ent) get]
|
| 857 |
+
if {$data(-multiple)} {
|
| 858 |
+
foreach t $text {
|
| 859 |
+
VerifyFileName $w $t
|
| 860 |
+
}
|
| 861 |
+
} else {
|
| 862 |
+
VerifyFileName $w $text
|
| 863 |
+
}
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
# Verification procedure
|
| 867 |
+
#
|
| 868 |
+
proc ::tk::dialog::file::VerifyFileName {w filename} {
|
| 869 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 870 |
+
|
| 871 |
+
set list [ResolveFile $data(selectPath) $filename $data(-defaultextension)]
|
| 872 |
+
foreach {flag path file} $list {
|
| 873 |
+
break
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
switch -- $flag {
|
| 877 |
+
OK {
|
| 878 |
+
if {$file eq ""} {
|
| 879 |
+
# user has entered an existing (sub)directory
|
| 880 |
+
set data(selectPath) $path
|
| 881 |
+
$data(ent) delete 0 end
|
| 882 |
+
} else {
|
| 883 |
+
SetPathSilently $w $path
|
| 884 |
+
if {$data(-multiple)} {
|
| 885 |
+
lappend data(selectFile) $file
|
| 886 |
+
} else {
|
| 887 |
+
set data(selectFile) $file
|
| 888 |
+
}
|
| 889 |
+
Done $w
|
| 890 |
+
}
|
| 891 |
+
}
|
| 892 |
+
PATTERN {
|
| 893 |
+
set data(selectPath) $path
|
| 894 |
+
set data(filter) $file
|
| 895 |
+
}
|
| 896 |
+
FILE {
|
| 897 |
+
if {$data(type) eq "open"} {
|
| 898 |
+
tk_messageBox -icon warning -type ok -parent $w \
|
| 899 |
+
-message [mc "File \"%1\$s\" does not exist." \
|
| 900 |
+
[file join $path $file]]
|
| 901 |
+
$data(ent) selection range 0 end
|
| 902 |
+
$data(ent) icursor end
|
| 903 |
+
} else {
|
| 904 |
+
SetPathSilently $w $path
|
| 905 |
+
if {$data(-multiple)} {
|
| 906 |
+
lappend data(selectFile) $file
|
| 907 |
+
} else {
|
| 908 |
+
set data(selectFile) $file
|
| 909 |
+
}
|
| 910 |
+
Done $w
|
| 911 |
+
}
|
| 912 |
+
}
|
| 913 |
+
PATH {
|
| 914 |
+
tk_messageBox -icon warning -type ok -parent $w -message \
|
| 915 |
+
[mc "Directory \"%1\$s\" does not exist." $path]
|
| 916 |
+
$data(ent) selection range 0 end
|
| 917 |
+
$data(ent) icursor end
|
| 918 |
+
}
|
| 919 |
+
CHDIR {
|
| 920 |
+
tk_messageBox -type ok -parent $w -icon warning -message \
|
| 921 |
+
[mc "Cannot change to the directory\
|
| 922 |
+
\"%1\$s\".\nPermission denied." $path]
|
| 923 |
+
$data(ent) selection range 0 end
|
| 924 |
+
$data(ent) icursor end
|
| 925 |
+
}
|
| 926 |
+
ERROR {
|
| 927 |
+
tk_messageBox -type ok -parent $w -icon warning -message \
|
| 928 |
+
[mc "Invalid file name \"%1\$s\"." $path]
|
| 929 |
+
$data(ent) selection range 0 end
|
| 930 |
+
$data(ent) icursor end
|
| 931 |
+
}
|
| 932 |
+
}
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
# Gets called when user presses the Alt-s or Alt-o keys.
|
| 936 |
+
#
|
| 937 |
+
proc ::tk::dialog::file::InvokeBtn {w key} {
|
| 938 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 939 |
+
|
| 940 |
+
if {[$data(okBtn) cget -text] eq $key} {
|
| 941 |
+
$data(okBtn) invoke
|
| 942 |
+
}
|
| 943 |
+
}
|
| 944 |
+
|
| 945 |
+
# Gets called when user presses the "parent directory" button
|
| 946 |
+
#
|
| 947 |
+
proc ::tk::dialog::file::UpDirCmd {w} {
|
| 948 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 949 |
+
|
| 950 |
+
if {$data(selectPath) ne "/"} {
|
| 951 |
+
set data(selectPath) [file dirname $data(selectPath)]
|
| 952 |
+
}
|
| 953 |
+
}
|
| 954 |
+
|
| 955 |
+
# Join a file name to a path name. The "file join" command will break if the
|
| 956 |
+
# filename begins with ~
|
| 957 |
+
#
|
| 958 |
+
proc ::tk::dialog::file::JoinFile {path file} {
|
| 959 |
+
if {[string match {~*} $file] && [file exists $path/$file]} {
|
| 960 |
+
return [file join $path ./$file]
|
| 961 |
+
} else {
|
| 962 |
+
return [file join $path $file]
|
| 963 |
+
}
|
| 964 |
+
}
|
| 965 |
+
|
| 966 |
+
# Gets called when user presses the "OK" button
|
| 967 |
+
#
|
| 968 |
+
proc ::tk::dialog::file::OkCmd {w} {
|
| 969 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 970 |
+
|
| 971 |
+
set filenames {}
|
| 972 |
+
foreach item [$data(icons) selection get] {
|
| 973 |
+
lappend filenames [$data(icons) get $item]
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
if {
|
| 977 |
+
([llength $filenames] && !$data(-multiple)) ||
|
| 978 |
+
($data(-multiple) && ([llength $filenames] == 1))
|
| 979 |
+
} then {
|
| 980 |
+
set filename [lindex $filenames 0]
|
| 981 |
+
set file [JoinFile $data(selectPath) $filename]
|
| 982 |
+
if {[file isdirectory $file]} {
|
| 983 |
+
ListInvoke $w [list $filename]
|
| 984 |
+
return
|
| 985 |
+
}
|
| 986 |
+
}
|
| 987 |
+
|
| 988 |
+
ActivateEnt $w
|
| 989 |
+
}
|
| 990 |
+
|
| 991 |
+
# Gets called when user presses the "Cancel" button
|
| 992 |
+
#
|
| 993 |
+
proc ::tk::dialog::file::CancelCmd {w} {
|
| 994 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 995 |
+
variable ::tk::Priv
|
| 996 |
+
|
| 997 |
+
bind $data(okBtn) <Destroy> {}
|
| 998 |
+
set Priv(selectFilePath) ""
|
| 999 |
+
}
|
| 1000 |
+
|
| 1001 |
+
# Gets called when user destroys the dialog directly [Bug 987169]
|
| 1002 |
+
#
|
| 1003 |
+
proc ::tk::dialog::file::Destroyed {w} {
|
| 1004 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 1005 |
+
variable ::tk::Priv
|
| 1006 |
+
|
| 1007 |
+
set Priv(selectFilePath) ""
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
# Gets called when user browses the IconList widget (dragging mouse, arrow
|
| 1011 |
+
# keys, etc)
|
| 1012 |
+
#
|
| 1013 |
+
proc ::tk::dialog::file::ListBrowse {w} {
|
| 1014 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 1015 |
+
|
| 1016 |
+
set text {}
|
| 1017 |
+
foreach item [$data(icons) selection get] {
|
| 1018 |
+
lappend text [$data(icons) get $item]
|
| 1019 |
+
}
|
| 1020 |
+
if {[llength $text] == 0} {
|
| 1021 |
+
return
|
| 1022 |
+
}
|
| 1023 |
+
if {$data(-multiple)} {
|
| 1024 |
+
set newtext {}
|
| 1025 |
+
foreach file $text {
|
| 1026 |
+
set fullfile [JoinFile $data(selectPath) $file]
|
| 1027 |
+
if { ![file isdirectory $fullfile] } {
|
| 1028 |
+
lappend newtext $file
|
| 1029 |
+
}
|
| 1030 |
+
}
|
| 1031 |
+
set text $newtext
|
| 1032 |
+
set isDir 0
|
| 1033 |
+
} else {
|
| 1034 |
+
set text [lindex $text 0]
|
| 1035 |
+
set file [JoinFile $data(selectPath) $text]
|
| 1036 |
+
set isDir [file isdirectory $file]
|
| 1037 |
+
}
|
| 1038 |
+
if {!$isDir} {
|
| 1039 |
+
$data(ent) delete 0 end
|
| 1040 |
+
$data(ent) insert 0 $text
|
| 1041 |
+
|
| 1042 |
+
if {[winfo class $w] eq "TkFDialog"} {
|
| 1043 |
+
if {$data(type) eq "open"} {
|
| 1044 |
+
::tk::SetAmpText $data(okBtn) [mc "&Open"]
|
| 1045 |
+
} else {
|
| 1046 |
+
::tk::SetAmpText $data(okBtn) [mc "&Save"]
|
| 1047 |
+
}
|
| 1048 |
+
}
|
| 1049 |
+
} elseif {[winfo class $w] eq "TkFDialog"} {
|
| 1050 |
+
::tk::SetAmpText $data(okBtn) [mc "&Open"]
|
| 1051 |
+
}
|
| 1052 |
+
}
|
| 1053 |
+
|
| 1054 |
+
# Gets called when user invokes the IconList widget (double-click, Return key,
|
| 1055 |
+
# etc)
|
| 1056 |
+
#
|
| 1057 |
+
proc ::tk::dialog::file::ListInvoke {w filenames} {
|
| 1058 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 1059 |
+
|
| 1060 |
+
if {[llength $filenames] == 0} {
|
| 1061 |
+
return
|
| 1062 |
+
}
|
| 1063 |
+
|
| 1064 |
+
set file [JoinFile $data(selectPath) [lindex $filenames 0]]
|
| 1065 |
+
|
| 1066 |
+
set class [winfo class $w]
|
| 1067 |
+
if {$class eq "TkChooseDir" || [file isdirectory $file]} {
|
| 1068 |
+
set appPWD [pwd]
|
| 1069 |
+
if {[catch {cd $file}]} {
|
| 1070 |
+
tk_messageBox -type ok -parent $w -icon warning -message \
|
| 1071 |
+
[mc "Cannot change to the directory \"%1\$s\".\nPermission denied." $file]
|
| 1072 |
+
} else {
|
| 1073 |
+
cd $appPWD
|
| 1074 |
+
set data(selectPath) $file
|
| 1075 |
+
}
|
| 1076 |
+
} else {
|
| 1077 |
+
if {$data(-multiple)} {
|
| 1078 |
+
set data(selectFile) $filenames
|
| 1079 |
+
} else {
|
| 1080 |
+
set data(selectFile) $file
|
| 1081 |
+
}
|
| 1082 |
+
Done $w
|
| 1083 |
+
}
|
| 1084 |
+
}
|
| 1085 |
+
|
| 1086 |
+
# ::tk::dialog::file::Done --
|
| 1087 |
+
#
|
| 1088 |
+
# Gets called when user has input a valid filename. Pops up a dialog
|
| 1089 |
+
# box to confirm selection when necessary. Sets the
|
| 1090 |
+
# tk::Priv(selectFilePath) variable, which will break the "vwait" loop
|
| 1091 |
+
# in ::tk::dialog::file:: and return the selected filename to the script
|
| 1092 |
+
# that calls tk_getOpenFile or tk_getSaveFile
|
| 1093 |
+
#
|
| 1094 |
+
proc ::tk::dialog::file::Done {w {selectFilePath ""}} {
|
| 1095 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 1096 |
+
variable ::tk::Priv
|
| 1097 |
+
|
| 1098 |
+
if {$selectFilePath eq ""} {
|
| 1099 |
+
if {$data(-multiple)} {
|
| 1100 |
+
set selectFilePath {}
|
| 1101 |
+
foreach f $data(selectFile) {
|
| 1102 |
+
lappend selectFilePath [JoinFile $data(selectPath) $f]
|
| 1103 |
+
}
|
| 1104 |
+
} else {
|
| 1105 |
+
set selectFilePath [JoinFile $data(selectPath) $data(selectFile)]
|
| 1106 |
+
}
|
| 1107 |
+
|
| 1108 |
+
set Priv(selectFile) $data(selectFile)
|
| 1109 |
+
set Priv(selectPath) $data(selectPath)
|
| 1110 |
+
|
| 1111 |
+
if {($data(type) eq "save") && $data(-confirmoverwrite) && [file exists $selectFilePath]} {
|
| 1112 |
+
set reply [tk_messageBox -icon warning -type yesno -parent $w \
|
| 1113 |
+
-message [mc "File \"%1\$s\" already exists.\nDo you want\
|
| 1114 |
+
to overwrite it?" $selectFilePath]]
|
| 1115 |
+
if {$reply eq "no"} {
|
| 1116 |
+
return
|
| 1117 |
+
}
|
| 1118 |
+
}
|
| 1119 |
+
if {
|
| 1120 |
+
[info exists data(-typevariable)] && $data(-typevariable) ne ""
|
| 1121 |
+
&& [info exists data(-filetypes)] && [llength $data(-filetypes)]
|
| 1122 |
+
&& [info exists data(filterType)] && $data(filterType) ne ""
|
| 1123 |
+
} then {
|
| 1124 |
+
upvar #0 $data(-typevariable) typeVariable
|
| 1125 |
+
set typeVariable [lindex $data(origfiletypes) \
|
| 1126 |
+
[lsearch -exact $data(-filetypes) $data(filterType)] 0]
|
| 1127 |
+
}
|
| 1128 |
+
}
|
| 1129 |
+
bind $data(okBtn) <Destroy> {}
|
| 1130 |
+
set Priv(selectFilePath) $selectFilePath
|
| 1131 |
+
}
|
| 1132 |
+
|
| 1133 |
+
# ::tk::dialog::file::GlobFiltered --
|
| 1134 |
+
#
|
| 1135 |
+
# Gets called to do globbing, returning the results and filtering them
|
| 1136 |
+
# according to the current filter (and removing the entries for '.' and
|
| 1137 |
+
# '..' which are never shown). Deals with evil cases such as where the
|
| 1138 |
+
# user is supplying a filter which is an invalid list or where it has an
|
| 1139 |
+
# unbalanced brace. The resulting list will be dictionary sorted.
|
| 1140 |
+
#
|
| 1141 |
+
# Arguments:
|
| 1142 |
+
# dir Which directory to search
|
| 1143 |
+
# type List of filetypes to look for ('d' or 'f b c l p s')
|
| 1144 |
+
# overrideFilter Whether to ignore the filter for this search.
|
| 1145 |
+
#
|
| 1146 |
+
# NB: Assumes that the caller has mapped the state variable to 'data'.
|
| 1147 |
+
#
|
| 1148 |
+
proc ::tk::dialog::file::GlobFiltered {dir type {overrideFilter 0}} {
|
| 1149 |
+
variable showHiddenVar
|
| 1150 |
+
upvar 1 data(filter) filter
|
| 1151 |
+
|
| 1152 |
+
if {$filter eq "*" || $overrideFilter} {
|
| 1153 |
+
set patterns [list *]
|
| 1154 |
+
if {$showHiddenVar} {
|
| 1155 |
+
lappend patterns .*
|
| 1156 |
+
}
|
| 1157 |
+
} elseif {[string is list $filter]} {
|
| 1158 |
+
set patterns $filter
|
| 1159 |
+
} else {
|
| 1160 |
+
# Invalid list; assume we can use non-whitespace sequences as words
|
| 1161 |
+
set patterns [regexp -inline -all {\S+} $filter]
|
| 1162 |
+
}
|
| 1163 |
+
|
| 1164 |
+
set opts [list -tails -directory $dir -type $type -nocomplain]
|
| 1165 |
+
|
| 1166 |
+
set result {}
|
| 1167 |
+
catch {
|
| 1168 |
+
# We have a catch because we might have a really bad pattern (e.g.,
|
| 1169 |
+
# with an unbalanced brace); even [glob -nocomplain] doesn't like it.
|
| 1170 |
+
# Using a catch ensures that it just means we match nothing instead of
|
| 1171 |
+
# throwing a nasty error at the user...
|
| 1172 |
+
foreach f [glob {*}$opts -- {*}$patterns] {
|
| 1173 |
+
if {$f eq "." || $f eq ".."} {
|
| 1174 |
+
continue
|
| 1175 |
+
}
|
| 1176 |
+
# See ticket [1641721], $f might be a link pointing to a dir
|
| 1177 |
+
if {$type != "d" && [file isdir [file join $dir $f]]} {
|
| 1178 |
+
continue
|
| 1179 |
+
}
|
| 1180 |
+
lappend result $f
|
| 1181 |
+
}
|
| 1182 |
+
}
|
| 1183 |
+
return [lsort -dictionary -unique $result]
|
| 1184 |
+
}
|
| 1185 |
+
|
| 1186 |
+
proc ::tk::dialog::file::CompleteEnt {w} {
|
| 1187 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 1188 |
+
set f [$data(ent) get]
|
| 1189 |
+
if {$data(-multiple)} {
|
| 1190 |
+
if {![string is list $f] || [llength $f] != 1} {
|
| 1191 |
+
return -code break
|
| 1192 |
+
}
|
| 1193 |
+
set f [lindex $f 0]
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
# Get list of matching filenames and dirnames
|
| 1197 |
+
set files [if {[winfo class $w] eq "TkFDialog"} {
|
| 1198 |
+
GlobFiltered $data(selectPath) {f b c l p s}
|
| 1199 |
+
}]
|
| 1200 |
+
set dirs2 {}
|
| 1201 |
+
foreach d [GlobFiltered $data(selectPath) d] {lappend dirs2 $d/}
|
| 1202 |
+
|
| 1203 |
+
set targets [concat \
|
| 1204 |
+
[lsearch -glob -all -inline $files $f*] \
|
| 1205 |
+
[lsearch -glob -all -inline $dirs2 $f*]]
|
| 1206 |
+
|
| 1207 |
+
if {[llength $targets] == 1} {
|
| 1208 |
+
# We have a winner!
|
| 1209 |
+
set f [lindex $targets 0]
|
| 1210 |
+
} elseif {$f in $targets || [llength $targets] == 0} {
|
| 1211 |
+
if {[string length $f] > 0} {
|
| 1212 |
+
bell
|
| 1213 |
+
}
|
| 1214 |
+
return
|
| 1215 |
+
} elseif {[llength $targets] > 1} {
|
| 1216 |
+
# Multiple possibles
|
| 1217 |
+
if {[string length $f] == 0} {
|
| 1218 |
+
return
|
| 1219 |
+
}
|
| 1220 |
+
set t0 [lindex $targets 0]
|
| 1221 |
+
for {set len [string length $t0]} {$len>0} {} {
|
| 1222 |
+
set allmatch 1
|
| 1223 |
+
foreach s $targets {
|
| 1224 |
+
if {![string equal -length $len $s $t0]} {
|
| 1225 |
+
set allmatch 0
|
| 1226 |
+
break
|
| 1227 |
+
}
|
| 1228 |
+
}
|
| 1229 |
+
incr len -1
|
| 1230 |
+
if {$allmatch} break
|
| 1231 |
+
}
|
| 1232 |
+
set f [string range $t0 0 $len]
|
| 1233 |
+
}
|
| 1234 |
+
|
| 1235 |
+
if {$data(-multiple)} {
|
| 1236 |
+
set f [list $f]
|
| 1237 |
+
}
|
| 1238 |
+
$data(ent) delete 0 end
|
| 1239 |
+
$data(ent) insert 0 $f
|
| 1240 |
+
return -code break
|
| 1241 |
+
}
|
mplug_owl2/lib/tk8.6/ttk/combobox.tcl
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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TE-WM-TRANSIENT>>:
|
| 5 |
+
#
|
| 6 |
+
# Need to set [wm transient] just before mapping the popdown
|
| 7 |
+
# instead of when it's created, in case a containing frame
|
| 8 |
+
# has been reparented [#1818441].
|
| 9 |
+
#
|
| 10 |
+
# On Windows: setting [wm transient] prevents the parent
|
| 11 |
+
# toplevel from becoming inactive when the popdown is posted
|
| 12 |
+
# (Tk 8.4.8+)
|
| 13 |
+
#
|
| 14 |
+
# On X11: WM_TRANSIENT_FOR on override-redirect windows
|
| 15 |
+
# may be used by compositing managers and by EWMH-aware
|
| 16 |
+
# window managers (even though the older ICCCM spec says
|
| 17 |
+
# it's meaningless).
|
| 18 |
+
#
|
| 19 |
+
# On OSX: [wm transient] does utterly the wrong thing.
|
| 20 |
+
# Instead, we use [MacWindowStyle "help" "noActivates hideOnSuspend"].
|
| 21 |
+
# The "noActivates" attribute prevents the parent toplevel
|
| 22 |
+
# from deactivating when the popdown is posted, and is also
|
| 23 |
+
# necessary for "help" windows to receive mouse events.
|
| 24 |
+
# "hideOnSuspend" makes the popdown disappear (resp. reappear)
|
| 25 |
+
# when the parent toplevel is deactivated (resp. reactivated).
|
| 26 |
+
# (see [#1814778]). Also set [wm resizable 0 0], to prevent
|
| 27 |
+
# TkAqua from shrinking the scrollbar to make room for a grow box
|
| 28 |
+
# that isn't there.
|
| 29 |
+
#
|
| 30 |
+
# In order to work around other platform quirks in TkAqua,
|
| 31 |
+
# [grab] and [focus] are set in <Map> bindings instead of
|
| 32 |
+
# immediately after deiconifying the window.
|
| 33 |
+
#
|
| 34 |
+
|
| 35 |
+
namespace eval ttk::combobox {
|
| 36 |
+
variable Values ;# Values($cb) is -listvariable of listbox widget
|
| 37 |
+
variable State
|
| 38 |
+
set State(entryPress) 0
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
### Combobox bindings.
|
| 42 |
+
#
|
| 43 |
+
# Duplicate the Entry bindings, override if needed:
|
| 44 |
+
#
|
| 45 |
+
|
| 46 |
+
ttk::copyBindings TEntry TCombobox
|
| 47 |
+
|
| 48 |
+
bind TCombobox <Down> { ttk::combobox::Post %W }
|
| 49 |
+
bind TCombobox <Escape> { ttk::combobox::Unpost %W }
|
| 50 |
+
|
| 51 |
+
bind TCombobox <Button-1> { ttk::combobox::Press "" %W %x %y }
|
| 52 |
+
bind TCombobox <Shift-Button-1> { ttk::combobox::Press "s" %W %x %y }
|
| 53 |
+
bind TCombobox <Double-Button-1> { ttk::combobox::Press "2" %W %x %y }
|
| 54 |
+
bind TCombobox <Triple-Button-1> { ttk::combobox::Press "3" %W %x %y }
|
| 55 |
+
bind TCombobox <B1-Motion> { ttk::combobox::Drag %W %x }
|
| 56 |
+
bind TCombobox <Motion> { ttk::combobox::Motion %W %x %y }
|
| 57 |
+
|
| 58 |
+
ttk::bindMouseWheel TCombobox [list ttk::combobox::Scroll %W]
|
| 59 |
+
|
| 60 |
+
bind TCombobox <<TraverseIn>> { ttk::combobox::TraverseIn %W }
|
| 61 |
+
|
| 62 |
+
### Combobox listbox bindings.
|
| 63 |
+
#
|
| 64 |
+
bind ComboboxListbox <ButtonRelease-1> { ttk::combobox::LBSelected %W }
|
| 65 |
+
bind ComboboxListbox <Return> { ttk::combobox::LBSelected %W }
|
| 66 |
+
bind ComboboxListbox <Escape> { ttk::combobox::LBCancel %W }
|
| 67 |
+
bind ComboboxListbox <Tab> { ttk::combobox::LBTab %W next }
|
| 68 |
+
bind ComboboxListbox <<PrevWindow>> { ttk::combobox::LBTab %W prev }
|
| 69 |
+
bind ComboboxListbox <Destroy> { ttk::combobox::LBCleanup %W }
|
| 70 |
+
bind ComboboxListbox <Motion> { ttk::combobox::LBHover %W %x %y }
|
| 71 |
+
bind ComboboxListbox <Map> { focus -force %W }
|
| 72 |
+
|
| 73 |
+
switch -- [tk windowingsystem] {
|
| 74 |
+
win32 {
|
| 75 |
+
# Dismiss listbox when user switches to a different application.
|
| 76 |
+
# NB: *only* do this on Windows (see #1814778)
|
| 77 |
+
bind ComboboxListbox <FocusOut> { ttk::combobox::LBCancel %W }
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
### Combobox popdown window bindings.
|
| 82 |
+
#
|
| 83 |
+
bind ComboboxPopdown <Map> { ttk::combobox::MapPopdown %W }
|
| 84 |
+
bind ComboboxPopdown <Unmap> { ttk::combobox::UnmapPopdown %W }
|
| 85 |
+
bind ComboboxPopdown <Button> \
|
| 86 |
+
{ ttk::combobox::Unpost [winfo parent %W] }
|
| 87 |
+
|
| 88 |
+
### Option database settings.
|
| 89 |
+
#
|
| 90 |
+
|
| 91 |
+
option add *TCombobox*Listbox.font TkTextFont widgetDefault
|
| 92 |
+
option add *TCombobox*Listbox.relief flat widgetDefault
|
| 93 |
+
option add *TCombobox*Listbox.highlightThickness 0 widgetDefault
|
| 94 |
+
|
| 95 |
+
## Platform-specific settings.
|
| 96 |
+
#
|
| 97 |
+
switch -- [tk windowingsystem] {
|
| 98 |
+
x11 {
|
| 99 |
+
option add *TCombobox*Listbox.background white widgetDefault
|
| 100 |
+
}
|
| 101 |
+
aqua {
|
| 102 |
+
option add *TCombobox*Listbox.borderWidth 0 widgetDefault
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
### Binding procedures.
|
| 107 |
+
#
|
| 108 |
+
|
| 109 |
+
## Press $mode $x $y -- Button binding for comboboxes.
|
| 110 |
+
# Either post/unpost the listbox, or perform Entry widget binding,
|
| 111 |
+
# depending on widget state and location of button press.
|
| 112 |
+
#
|
| 113 |
+
proc ttk::combobox::Press {mode w x y} {
|
| 114 |
+
variable State
|
| 115 |
+
|
| 116 |
+
$w instate disabled { return }
|
| 117 |
+
|
| 118 |
+
set State(entryPress) [expr {
|
| 119 |
+
[$w instate !readonly]
|
| 120 |
+
&& [string match *textarea [$w identify element $x $y]]
|
| 121 |
+
}]
|
| 122 |
+
|
| 123 |
+
focus $w
|
| 124 |
+
if {$State(entryPress)} {
|
| 125 |
+
switch -- $mode {
|
| 126 |
+
s { ttk::entry::Shift-Press $w $x ; # Shift }
|
| 127 |
+
2 { ttk::entry::Select $w $x word ; # Double click}
|
| 128 |
+
3 { ttk::entry::Select $w $x line ; # Triple click }
|
| 129 |
+
"" -
|
| 130 |
+
default { ttk::entry::Press $w $x }
|
| 131 |
+
}
|
| 132 |
+
} else {
|
| 133 |
+
Post $w
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
## Drag -- B1-Motion binding for comboboxes.
|
| 138 |
+
# If the initial Button event was handled by Entry binding,
|
| 139 |
+
# perform Entry widget drag binding; otherwise nothing.
|
| 140 |
+
#
|
| 141 |
+
proc ttk::combobox::Drag {w x} {
|
| 142 |
+
variable State
|
| 143 |
+
if {$State(entryPress)} {
|
| 144 |
+
ttk::entry::Drag $w $x
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
## Motion --
|
| 149 |
+
# Set cursor.
|
| 150 |
+
#
|
| 151 |
+
proc ttk::combobox::Motion {w x y} {
|
| 152 |
+
variable State
|
| 153 |
+
ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
|
| 154 |
+
if { [$w identify $x $y] eq "textarea"
|
| 155 |
+
&& [$w instate {!readonly !disabled}]
|
| 156 |
+
} {
|
| 157 |
+
ttk::setCursor $w text
|
| 158 |
+
} else {
|
| 159 |
+
ttk::setCursor $w $State(userConfCursor)
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
## TraverseIn -- receive focus due to keyboard navigation
|
| 164 |
+
# For editable comboboxes, set the selection and insert cursor.
|
| 165 |
+
#
|
| 166 |
+
proc ttk::combobox::TraverseIn {w} {
|
| 167 |
+
$w instate {!readonly !disabled} {
|
| 168 |
+
$w selection range 0 end
|
| 169 |
+
$w icursor end
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
## SelectEntry $cb $index --
|
| 174 |
+
# Set the combobox selection in response to a user action.
|
| 175 |
+
#
|
| 176 |
+
proc ttk::combobox::SelectEntry {cb index} {
|
| 177 |
+
$cb current $index
|
| 178 |
+
$cb selection range 0 end
|
| 179 |
+
$cb icursor end
|
| 180 |
+
event generate $cb <<ComboboxSelected>> -when mark
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
## Scroll -- Mousewheel binding
|
| 184 |
+
#
|
| 185 |
+
proc ttk::combobox::Scroll {cb dir} {
|
| 186 |
+
$cb instate disabled { return }
|
| 187 |
+
set max [llength [$cb cget -values]]
|
| 188 |
+
set current [$cb current]
|
| 189 |
+
incr current $dir
|
| 190 |
+
if {$max != 0 && $current == $current % $max} {
|
| 191 |
+
SelectEntry $cb $current
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
## LBSelected $lb -- Activation binding for listbox
|
| 196 |
+
# Set the combobox value to the currently-selected listbox value
|
| 197 |
+
# and unpost the listbox.
|
| 198 |
+
#
|
| 199 |
+
proc ttk::combobox::LBSelected {lb} {
|
| 200 |
+
set cb [LBMaster $lb]
|
| 201 |
+
LBSelect $lb
|
| 202 |
+
Unpost $cb
|
| 203 |
+
focus $cb
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
## LBCancel --
|
| 207 |
+
# Unpost the listbox.
|
| 208 |
+
#
|
| 209 |
+
proc ttk::combobox::LBCancel {lb} {
|
| 210 |
+
Unpost [LBMaster $lb]
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
## LBTab -- Tab key binding for combobox listbox.
|
| 214 |
+
# Set the selection, and navigate to next/prev widget.
|
| 215 |
+
#
|
| 216 |
+
proc ttk::combobox::LBTab {lb dir} {
|
| 217 |
+
set cb [LBMaster $lb]
|
| 218 |
+
switch -- $dir {
|
| 219 |
+
next { set newFocus [tk_focusNext $cb] }
|
| 220 |
+
prev { set newFocus [tk_focusPrev $cb] }
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
if {$newFocus ne ""} {
|
| 224 |
+
LBSelect $lb
|
| 225 |
+
Unpost $cb
|
| 226 |
+
# The [grab release] call in [Unpost] queues events that later
|
| 227 |
+
# re-set the focus (@@@ NOTE: this might not be true anymore).
|
| 228 |
+
# Set new focus later:
|
| 229 |
+
after 0 [list ttk::traverseTo $newFocus]
|
| 230 |
+
}
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
## LBHover -- <Motion> binding for combobox listbox.
|
| 234 |
+
# Follow selection on mouseover.
|
| 235 |
+
#
|
| 236 |
+
proc ttk::combobox::LBHover {w x y} {
|
| 237 |
+
$w selection clear 0 end
|
| 238 |
+
$w activate @$x,$y
|
| 239 |
+
$w selection set @$x,$y
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
## MapPopdown -- <Map> binding for ComboboxPopdown
|
| 243 |
+
#
|
| 244 |
+
proc ttk::combobox::MapPopdown {w} {
|
| 245 |
+
[winfo parent $w] state pressed
|
| 246 |
+
ttk::globalGrab $w
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
## UnmapPopdown -- <Unmap> binding for ComboboxPopdown
|
| 250 |
+
#
|
| 251 |
+
proc ttk::combobox::UnmapPopdown {w} {
|
| 252 |
+
[winfo parent $w] state !pressed
|
| 253 |
+
ttk::releaseGrab $w
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
## PopdownWindow --
|
| 257 |
+
# Returns the popdown widget associated with a combobox,
|
| 258 |
+
# creating it if necessary.
|
| 259 |
+
#
|
| 260 |
+
proc ttk::combobox::PopdownWindow {cb} {
|
| 261 |
+
if {![winfo exists $cb.popdown]} {
|
| 262 |
+
set poplevel [PopdownToplevel $cb.popdown]
|
| 263 |
+
set popdown [ttk::frame $poplevel.f -style ComboboxPopdownFrame]
|
| 264 |
+
|
| 265 |
+
ttk::scrollbar $popdown.sb \
|
| 266 |
+
-orient vertical -command [list $popdown.l yview]
|
| 267 |
+
listbox $popdown.l \
|
| 268 |
+
-listvariable ttk::combobox::Values($cb) \
|
| 269 |
+
-yscrollcommand [list $popdown.sb set] \
|
| 270 |
+
-exportselection false \
|
| 271 |
+
-selectmode browse \
|
| 272 |
+
-activestyle none \
|
| 273 |
+
;
|
| 274 |
+
|
| 275 |
+
bindtags $popdown.l \
|
| 276 |
+
[list $popdown.l ComboboxListbox Listbox $popdown all]
|
| 277 |
+
|
| 278 |
+
grid $popdown.l -row 0 -column 0 -padx {1 0} -pady 1 -sticky nsew
|
| 279 |
+
grid $popdown.sb -row 0 -column 1 -padx {0 1} -pady 1 -sticky ns
|
| 280 |
+
grid columnconfigure $popdown 0 -weight 1
|
| 281 |
+
grid rowconfigure $popdown 0 -weight 1
|
| 282 |
+
|
| 283 |
+
grid $popdown -sticky news -padx 0 -pady 0
|
| 284 |
+
grid rowconfigure $poplevel 0 -weight 1
|
| 285 |
+
grid columnconfigure $poplevel 0 -weight 1
|
| 286 |
+
}
|
| 287 |
+
return $cb.popdown
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
## PopdownToplevel -- Create toplevel window for the combobox popdown
|
| 291 |
+
#
|
| 292 |
+
# See also <<NOTE-WM-TRANSIENT>>
|
| 293 |
+
#
|
| 294 |
+
proc ttk::combobox::PopdownToplevel {w} {
|
| 295 |
+
toplevel $w -class ComboboxPopdown
|
| 296 |
+
wm withdraw $w
|
| 297 |
+
switch -- [tk windowingsystem] {
|
| 298 |
+
default -
|
| 299 |
+
x11 {
|
| 300 |
+
$w configure -relief flat -borderwidth 0
|
| 301 |
+
wm attributes $w -type combo
|
| 302 |
+
wm overrideredirect $w true
|
| 303 |
+
}
|
| 304 |
+
win32 {
|
| 305 |
+
$w configure -relief flat -borderwidth 0
|
| 306 |
+
wm overrideredirect $w true
|
| 307 |
+
wm attributes $w -topmost 1
|
| 308 |
+
}
|
| 309 |
+
aqua {
|
| 310 |
+
$w configure -relief solid -borderwidth 0
|
| 311 |
+
tk::unsupported::MacWindowStyle style $w \
|
| 312 |
+
help {noActivates hideOnSuspend}
|
| 313 |
+
wm resizable $w 0 0
|
| 314 |
+
}
|
| 315 |
+
}
|
| 316 |
+
return $w
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
## ConfigureListbox --
|
| 320 |
+
# Set listbox values, selection, height, and scrollbar visibility
|
| 321 |
+
# from current combobox values.
|
| 322 |
+
#
|
| 323 |
+
proc ttk::combobox::ConfigureListbox {cb} {
|
| 324 |
+
variable Values
|
| 325 |
+
|
| 326 |
+
set popdown [PopdownWindow $cb].f
|
| 327 |
+
set values [$cb cget -values]
|
| 328 |
+
set current [$cb current]
|
| 329 |
+
if {$current < 0} {
|
| 330 |
+
set current 0 ;# no current entry, highlight first one
|
| 331 |
+
}
|
| 332 |
+
set Values($cb) $values
|
| 333 |
+
$popdown.l selection clear 0 end
|
| 334 |
+
$popdown.l selection set $current
|
| 335 |
+
$popdown.l activate $current
|
| 336 |
+
$popdown.l see $current
|
| 337 |
+
set height [llength $values]
|
| 338 |
+
if {$height > [$cb cget -height]} {
|
| 339 |
+
set height [$cb cget -height]
|
| 340 |
+
grid $popdown.sb
|
| 341 |
+
grid configure $popdown.l -padx {1 0}
|
| 342 |
+
} else {
|
| 343 |
+
grid remove $popdown.sb
|
| 344 |
+
grid configure $popdown.l -padx 1
|
| 345 |
+
}
|
| 346 |
+
$popdown.l configure -height $height
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
## PlacePopdown --
|
| 350 |
+
# Set popdown window geometry.
|
| 351 |
+
#
|
| 352 |
+
# @@@TODO: factor with menubutton::PostPosition
|
| 353 |
+
#
|
| 354 |
+
proc ttk::combobox::PlacePopdown {cb popdown} {
|
| 355 |
+
set x [winfo rootx $cb]
|
| 356 |
+
set y [winfo rooty $cb]
|
| 357 |
+
set w [winfo width $cb]
|
| 358 |
+
set h [winfo height $cb]
|
| 359 |
+
set style [$cb cget -style]
|
| 360 |
+
if { $style eq {} } {
|
| 361 |
+
set style TCombobox
|
| 362 |
+
}
|
| 363 |
+
set postoffset [ttk::style lookup $style -postoffset {} {0 0 0 0}]
|
| 364 |
+
foreach var {x y w h} delta $postoffset {
|
| 365 |
+
incr $var $delta
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
set H [winfo reqheight $popdown]
|
| 369 |
+
if {$y + $h + $H > [winfo screenheight $popdown]} {
|
| 370 |
+
set Y [expr {$y - $H}]
|
| 371 |
+
} else {
|
| 372 |
+
set Y [expr {$y + $h}]
|
| 373 |
+
}
|
| 374 |
+
wm geometry $popdown ${w}x${H}+${x}+${Y}
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
## Post $cb --
|
| 378 |
+
# Pop down the associated listbox.
|
| 379 |
+
#
|
| 380 |
+
proc ttk::combobox::Post {cb} {
|
| 381 |
+
# Don't do anything if disabled:
|
| 382 |
+
#
|
| 383 |
+
$cb instate disabled { return }
|
| 384 |
+
|
| 385 |
+
# ASSERT: ![$cb instate pressed]
|
| 386 |
+
|
| 387 |
+
# Run -postcommand callback:
|
| 388 |
+
#
|
| 389 |
+
uplevel #0 [$cb cget -postcommand]
|
| 390 |
+
|
| 391 |
+
set popdown [PopdownWindow $cb]
|
| 392 |
+
ConfigureListbox $cb
|
| 393 |
+
update idletasks ;# needed for geometry propagation.
|
| 394 |
+
PlacePopdown $cb $popdown
|
| 395 |
+
# See <<NOTE-WM-TRANSIENT>>
|
| 396 |
+
switch -- [tk windowingsystem] {
|
| 397 |
+
x11 - win32 { wm transient $popdown [winfo toplevel $cb] }
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
# Post the listbox:
|
| 401 |
+
#
|
| 402 |
+
wm attribute $popdown -topmost 1
|
| 403 |
+
wm deiconify $popdown
|
| 404 |
+
raise $popdown
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
## Unpost $cb --
|
| 408 |
+
# Unpost the listbox.
|
| 409 |
+
#
|
| 410 |
+
proc ttk::combobox::Unpost {cb} {
|
| 411 |
+
if {[winfo exists $cb.popdown]} {
|
| 412 |
+
wm withdraw $cb.popdown
|
| 413 |
+
}
|
| 414 |
+
grab release $cb.popdown ;# in case of stuck or unexpected grab [#1239190]
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
## LBMaster $lb --
|
| 418 |
+
# Return the combobox main widget that owns the listbox.
|
| 419 |
+
#
|
| 420 |
+
proc ttk::combobox::LBMaster {lb} {
|
| 421 |
+
winfo parent [winfo parent [winfo parent $lb]]
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
## LBSelect $lb --
|
| 425 |
+
# Transfer listbox selection to combobox value.
|
| 426 |
+
#
|
| 427 |
+
proc ttk::combobox::LBSelect {lb} {
|
| 428 |
+
set cb [LBMaster $lb]
|
| 429 |
+
set selection [$lb curselection]
|
| 430 |
+
if {[llength $selection] == 1} {
|
| 431 |
+
SelectEntry $cb [lindex $selection 0]
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
## LBCleanup $lb --
|
| 436 |
+
# <Destroy> binding for combobox listboxes.
|
| 437 |
+
# Cleans up by unsetting the linked textvariable.
|
| 438 |
+
#
|
| 439 |
+
# Note: we can't just use { unset [%W cget -listvariable] }
|
| 440 |
+
# because the widget command is already gone when this binding fires).
|
| 441 |
+
# [winfo parent] still works, fortunately.
|
| 442 |
+
#
|
| 443 |
+
proc ttk::combobox::LBCleanup {lb} {
|
| 444 |
+
variable Values
|
| 445 |
+
unset Values([LBMaster $lb])
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
#*EOF*
|
mplug_owl2/lib/tk8.6/ttk/cursors.tcl
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 4 |
+
# The following cursors are defined:
|
| 5 |
+
#
|
| 6 |
+
# standard -- default cursor for most controls
|
| 7 |
+
# "" -- inherit cursor from parent window
|
| 8 |
+
# none -- no cursor
|
| 9 |
+
#
|
| 10 |
+
# text -- editable widgets (entry, text)
|
| 11 |
+
# link -- hyperlinks within text
|
| 12 |
+
# crosshair -- graphic selection, fine control
|
| 13 |
+
# busy -- operation in progress
|
| 14 |
+
# forbidden -- action not allowed
|
| 15 |
+
#
|
| 16 |
+
# hresize -- horizontal resizing
|
| 17 |
+
# vresize -- vertical resizing
|
| 18 |
+
#
|
| 19 |
+
# Also resize cursors for each of the compass points,
|
| 20 |
+
# {nw,n,ne,w,e,sw,s,se}resize.
|
| 21 |
+
#
|
| 22 |
+
# Platform notes:
|
| 23 |
+
#
|
| 24 |
+
# Windows doesn't distinguish resizing at the 8 compass points,
|
| 25 |
+
# only horizontal, vertical, and the two diagonals.
|
| 26 |
+
#
|
| 27 |
+
# OSX doesn't have resize cursors for nw, ne, sw, or se corners.
|
| 28 |
+
# We use the Tk-defined X11 fallbacks for these.
|
| 29 |
+
#
|
| 30 |
+
# X11 doesn't have a "forbidden" cursor (usually a slashed circle);
|
| 31 |
+
# "pirate" seems to be the conventional cursor for this purpose.
|
| 32 |
+
#
|
| 33 |
+
# Windows has an IDC_HELP cursor, but it's not available from Tk.
|
| 34 |
+
#
|
| 35 |
+
# Tk does not support "none" on Windows.
|
| 36 |
+
#
|
| 37 |
+
|
| 38 |
+
namespace eval ttk {
|
| 39 |
+
|
| 40 |
+
variable Cursors
|
| 41 |
+
|
| 42 |
+
# Use X11 cursor names as defaults, since Tk supplies these
|
| 43 |
+
# on all platforms.
|
| 44 |
+
#
|
| 45 |
+
array set Cursors {
|
| 46 |
+
"" ""
|
| 47 |
+
none none
|
| 48 |
+
|
| 49 |
+
standard left_ptr
|
| 50 |
+
text xterm
|
| 51 |
+
link hand2
|
| 52 |
+
crosshair crosshair
|
| 53 |
+
busy watch
|
| 54 |
+
forbidden pirate
|
| 55 |
+
|
| 56 |
+
hresize sb_h_double_arrow
|
| 57 |
+
vresize sb_v_double_arrow
|
| 58 |
+
|
| 59 |
+
nresize top_side
|
| 60 |
+
sresize bottom_side
|
| 61 |
+
wresize left_side
|
| 62 |
+
eresize right_side
|
| 63 |
+
nwresize top_left_corner
|
| 64 |
+
neresize top_right_corner
|
| 65 |
+
swresize bottom_left_corner
|
| 66 |
+
seresize bottom_right_corner
|
| 67 |
+
move fleur
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
# Platform-specific overrides for Windows and OSX.
|
| 72 |
+
#
|
| 73 |
+
switch [tk windowingsystem] {
|
| 74 |
+
"win32" {
|
| 75 |
+
array set Cursors {
|
| 76 |
+
none {}
|
| 77 |
+
|
| 78 |
+
standard arrow
|
| 79 |
+
text ibeam
|
| 80 |
+
link hand2
|
| 81 |
+
crosshair crosshair
|
| 82 |
+
busy wait
|
| 83 |
+
forbidden no
|
| 84 |
+
|
| 85 |
+
vresize size_ns
|
| 86 |
+
nresize size_ns
|
| 87 |
+
sresize size_ns
|
| 88 |
+
|
| 89 |
+
wresize size_we
|
| 90 |
+
eresize size_we
|
| 91 |
+
hresize size_we
|
| 92 |
+
|
| 93 |
+
nwresize size_nw_se
|
| 94 |
+
swresize size_ne_sw
|
| 95 |
+
|
| 96 |
+
neresize size_ne_sw
|
| 97 |
+
seresize size_nw_se
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
"aqua" {
|
| 102 |
+
array set Cursors {
|
| 103 |
+
standard arrow
|
| 104 |
+
text ibeam
|
| 105 |
+
link pointinghand
|
| 106 |
+
crosshair crosshair
|
| 107 |
+
busy watch
|
| 108 |
+
forbidden notallowed
|
| 109 |
+
|
| 110 |
+
hresize resizeleftright
|
| 111 |
+
vresize resizeupdown
|
| 112 |
+
nresize resizeup
|
| 113 |
+
sresize resizedown
|
| 114 |
+
wresize resizeleft
|
| 115 |
+
eresize resizeright
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
## ttk::cursor $cursor --
|
| 122 |
+
# Return platform-specific cursor for specified symbolic cursor.
|
| 123 |
+
#
|
| 124 |
+
proc ttk::cursor {name} {
|
| 125 |
+
variable Cursors
|
| 126 |
+
return $Cursors($name)
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
## ttk::setCursor $w $cursor --
|
| 130 |
+
# Set the cursor for specified window.
|
| 131 |
+
#
|
| 132 |
+
# [ttk::setCursor] should be used in <Motion> bindings
|
| 133 |
+
# instead of directly calling [$w configure -cursor ...],
|
| 134 |
+
# as the latter always incurs a server round-trip and
|
| 135 |
+
# can lead to high CPU load (see [#1184746])
|
| 136 |
+
#
|
| 137 |
+
|
| 138 |
+
proc ttk::setCursor {w name} {
|
| 139 |
+
variable Cursors
|
| 140 |
+
if {[info exists Cursors($name)]} {
|
| 141 |
+
set cursorname $Cursors($name)
|
| 142 |
+
} else {
|
| 143 |
+
set cursorname $name
|
| 144 |
+
}
|
| 145 |
+
if {[$w cget -cursor] ne $cursorname} {
|
| 146 |
+
$w configure -cursor $cursorname
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
## ttk::saveCursor $w $saveVar $excludeList --
|
| 151 |
+
# Set variable $saveVar to the -cursor value from widget $w,
|
| 152 |
+
# if either:
|
| 153 |
+
# a. $saveVar does not yet exist
|
| 154 |
+
# b. the currently user-specified cursor for $w is not in
|
| 155 |
+
# $excludeList
|
| 156 |
+
|
| 157 |
+
proc ttk::saveCursor {w saveVar excludeList} {
|
| 158 |
+
upvar $saveVar sv
|
| 159 |
+
if {![info exists sv]} {
|
| 160 |
+
set sv [$w cget -cursor]
|
| 161 |
+
}
|
| 162 |
+
if {[$w cget -cursor] ni $excludeList} {
|
| 163 |
+
set sv [$w cget -cursor]
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
## Interactive test harness:
|
| 168 |
+
#
|
| 169 |
+
proc ttk::CursorSampler {f} {
|
| 170 |
+
ttk::frame $f
|
| 171 |
+
|
| 172 |
+
set r 0
|
| 173 |
+
foreach row {
|
| 174 |
+
{nwresize nresize neresize}
|
| 175 |
+
{ wresize move eresize}
|
| 176 |
+
{swresize sresize seresize}
|
| 177 |
+
{text link crosshair}
|
| 178 |
+
{hresize vresize ""}
|
| 179 |
+
{busy forbidden ""}
|
| 180 |
+
{none standard ""}
|
| 181 |
+
} {
|
| 182 |
+
set c 0
|
| 183 |
+
foreach cursor $row {
|
| 184 |
+
set w $f.${r}${c}
|
| 185 |
+
ttk::label $w -text $cursor -cursor [ttk::cursor $cursor] \
|
| 186 |
+
-relief solid -borderwidth 1 -padding 3
|
| 187 |
+
grid $w -row $r -column $c -sticky nswe
|
| 188 |
+
grid columnconfigure $f $c -uniform cols -weight 1
|
| 189 |
+
incr c
|
| 190 |
+
}
|
| 191 |
+
grid rowconfigure $f $r -uniform rows -weight 1
|
| 192 |
+
incr r
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
return $f
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
if {[info exists argv0] && $argv0 eq [info script]} {
|
| 199 |
+
wm title . "[array size ::ttk::Cursors] cursors"
|
| 200 |
+
pack [ttk::CursorSampler .f] -expand true -fill both
|
| 201 |
+
bind . <Escape> [list destroy .]
|
| 202 |
+
focus .f
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
#*EOF*
|