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
- parrot/lib/python3.10/site-packages/matplotlib/__pycache__/widgets.cpython-310.pyc +3 -0
- parrot/lib/python3.10/site-packages/matplotlib/backends/_backend_agg.cpython-310-x86_64-linux-gnu.so +3 -0
- parrot/lib/tk8.6/choosedir.tcl +310 -0
- parrot/lib/tk8.6/demos/anilabel.tcl +160 -0
- parrot/lib/tk8.6/demos/en.msg +97 -0
- parrot/lib/tk8.6/demos/entry2.tcl +46 -0
- parrot/lib/tk8.6/demos/goldberg.tcl +1834 -0
- parrot/lib/tk8.6/demos/icon.tcl +51 -0
- parrot/lib/tk8.6/demos/image2.tcl +108 -0
- parrot/lib/tk8.6/demos/pendulum.tcl +197 -0
- parrot/lib/tk8.6/demos/search.tcl +139 -0
- parrot/lib/tk8.6/demos/toolbar.tcl +92 -0
- parrot/lib/tk8.6/demos/ttkpane.tcl +112 -0
- parrot/lib/tk8.6/demos/ttkscale.tcl +39 -0
- parrot/lib/tk8.6/entry.tcl +699 -0
- parrot/lib/tk8.6/focus.tcl +178 -0
- parrot/lib/tk8.6/menu.tcl +1387 -0
- parrot/lib/tk8.6/mkpsenc.tcl +1488 -0
- parrot/lib/tk8.6/msgbox.tcl +427 -0
- parrot/lib/tk8.6/palette.tcl +244 -0
- parrot/lib/tk8.6/spinbox.tcl +594 -0
- parrot/lib/tk8.6/text.tcl +1242 -0
- parrot/lib/tk8.6/ttk/aquaTheme.tcl +119 -0
- parrot/lib/tk8.6/ttk/button.tcl +83 -0
- parrot/lib/tk8.6/ttk/classicTheme.tcl +115 -0
- parrot/lib/tk8.6/ttk/defaults.tcl +143 -0
- parrot/lib/tk8.6/ttk/entry.tcl +641 -0
- parrot/lib/tk8.6/ttk/menubutton.tcl +233 -0
- parrot/lib/tk8.6/ttk/panedwindow.tcl +91 -0
- parrot/lib/tk8.6/ttk/spinbox.tcl +192 -0
- parrot/lib/tk8.6/ttk/treeview.tcl +383 -0
- parrot/lib/tk8.6/ttk/ttk.tcl +176 -0
- parrot/lib/tk8.6/ttk/vistaTheme.tcl +229 -0
- parrot/lib/tk8.6/xmfbox.tcl +989 -0
- vllm/lib/python3.10/site-packages/setuptools/_vendor/__pycache__/typing_extensions.cpython-310.pyc +3 -0
- vllm/lib/python3.10/site-packages/smmap/__pycache__/buf.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/__init__.py +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/__pycache__/__init__.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/__pycache__/lib.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/__pycache__/test_mman.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/__pycache__/test_tutorial.cpython-310.pyc +0 -0
- vllm/lib/python3.10/site-packages/smmap/test/lib.py +72 -0
- vllm/lib/python3.10/site-packages/smmap/test/test_buf.py +126 -0
- vllm/lib/python3.10/site-packages/smmap/test/test_mman.py +224 -0
- vllm/lib/python3.10/site-packages/smmap/test/test_util.py +105 -0
- vllm/lib/python3.10/site-packages/smmap/util.py +222 -0
- vllm/lib/python3.10/site-packages/zmq/__init__.pxd +1 -0
- vllm/lib/python3.10/site-packages/zmq/__init__.py +94 -0
- vllm/lib/python3.10/site-packages/zmq/__init__.pyi +29 -0
.gitattributes
CHANGED
|
@@ -925,3 +925,6 @@ vllm/lib/python3.10/site-packages/pip/_vendor/distlib/t64-arm.exe filter=lfs dif
|
|
| 925 |
vllm/lib/python3.10/site-packages/pip/_vendor/distlib/w64-arm.exe filter=lfs diff=lfs merge=lfs -text
|
| 926 |
vllm/lib/python3.10/site-packages/pip/_vendor/__pycache__/typing_extensions.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 927 |
vllm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 925 |
vllm/lib/python3.10/site-packages/pip/_vendor/distlib/w64-arm.exe filter=lfs diff=lfs merge=lfs -text
|
| 926 |
vllm/lib/python3.10/site-packages/pip/_vendor/__pycache__/typing_extensions.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 927 |
vllm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 928 |
+
vllm/lib/python3.10/site-packages/setuptools/_vendor/__pycache__/typing_extensions.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 929 |
+
parrot/lib/python3.10/site-packages/matplotlib/backends/_backend_agg.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 930 |
+
parrot/lib/python3.10/site-packages/matplotlib/__pycache__/widgets.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
parrot/lib/python3.10/site-packages/matplotlib/__pycache__/widgets.cpython-310.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc3dbe999cf6a96d5995b474e4fe54f37520e91e27643ae4ef24aca935bc32d5
|
| 3 |
+
size 119913
|
parrot/lib/python3.10/site-packages/matplotlib/backends/_backend_agg.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dac9e7ee7984e7aacc9a3b9280754ebe83cac8559b67c494372636dac3fe00f2
|
| 3 |
+
size 418232
|
parrot/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 |
+
}
|
parrot/lib/tk8.6/demos/anilabel.tcl
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# anilabel.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a toplevel window containing
|
| 4 |
+
# several animated label widgets.
|
| 5 |
+
|
| 6 |
+
if {![info exists widgetDemo]} {
|
| 7 |
+
error "This script should be run from the \"widget\" demo."
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
package require Tk
|
| 11 |
+
|
| 12 |
+
set w .anilabel
|
| 13 |
+
catch {destroy $w}
|
| 14 |
+
toplevel $w
|
| 15 |
+
wm title $w "Animated Label Demonstration"
|
| 16 |
+
wm iconname $w "anilabel"
|
| 17 |
+
positionWindow $w
|
| 18 |
+
|
| 19 |
+
label $w.msg -font $font -wraplength 4i -justify left -text "Four animated labels are displayed below; each of the labels on the left is animated by making the text message inside it appear to scroll, and the label on the right is animated by animating the image that it displays."
|
| 20 |
+
pack $w.msg -side top
|
| 21 |
+
|
| 22 |
+
## See Code / Dismiss buttons
|
| 23 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 24 |
+
pack $btns -side bottom -fill x
|
| 25 |
+
|
| 26 |
+
# Ensure that this this is an array
|
| 27 |
+
array set animationCallbacks {}
|
| 28 |
+
|
| 29 |
+
## This callback is the core of how to do animation in Tcl/Tk; all
|
| 30 |
+
## animations work in basically the same way, with a procedure that
|
| 31 |
+
## uses the [after] command to reschedule itself at some point in the
|
| 32 |
+
## future. Of course, the details of how to update the state will vary
|
| 33 |
+
## according to what is being animated.
|
| 34 |
+
proc RotateLabelText {w interval} {
|
| 35 |
+
global animationCallbacks
|
| 36 |
+
|
| 37 |
+
# Schedule the calling of this procedure again in the future
|
| 38 |
+
set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
|
| 39 |
+
|
| 40 |
+
# We do marquee-like scrolling text by chopping characters off the
|
| 41 |
+
# front of the text and sticking them on the end.
|
| 42 |
+
set text [$w cget -text]
|
| 43 |
+
set newText [string range $text 1 end][string index $text 0]
|
| 44 |
+
$w configure -text $newText
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
## A helper procedure to start the animation happening.
|
| 48 |
+
proc animateLabelText {w text interval} {
|
| 49 |
+
global animationCallbacks
|
| 50 |
+
|
| 51 |
+
# Install the text into the widget
|
| 52 |
+
$w configure -text $text
|
| 53 |
+
|
| 54 |
+
# Schedule the start of the animation loop
|
| 55 |
+
set animationCallbacks($w) [after $interval RotateLabelText $w $interval]
|
| 56 |
+
|
| 57 |
+
# Make sure that the animation stops and is cleaned up after itself
|
| 58 |
+
# when the animated label is destroyed. Note that at this point we
|
| 59 |
+
# cannot manipulate the widget itself, as that has already died.
|
| 60 |
+
bind $w <Destroy> {
|
| 61 |
+
after cancel $animationCallbacks(%W)
|
| 62 |
+
unset animationCallbacks(%W)
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
## Next, a similar pair of procedures to animate a GIF loaded into a
|
| 67 |
+
## photo image.
|
| 68 |
+
proc SelectNextImageFrame {w interval} {
|
| 69 |
+
global animationCallbacks
|
| 70 |
+
set animationCallbacks($w) \
|
| 71 |
+
[after $interval SelectNextImageFrame $w $interval]
|
| 72 |
+
set image [$w cget -image]
|
| 73 |
+
|
| 74 |
+
# The easy way to animate a GIF!
|
| 75 |
+
set idx -1
|
| 76 |
+
scan [$image cget -format] "GIF -index %d" idx
|
| 77 |
+
if {[catch {
|
| 78 |
+
# Note that we get an error if the index is out of range
|
| 79 |
+
$image configure -format "GIF -index [incr idx]"
|
| 80 |
+
}]} then {
|
| 81 |
+
$image configure -format "GIF -index 0"
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
proc animateLabelImage {w imageData interval} {
|
| 85 |
+
global animationCallbacks
|
| 86 |
+
|
| 87 |
+
# Create a multi-frame GIF from base-64-encoded data
|
| 88 |
+
set image [image create photo -format GIF -data $imageData]
|
| 89 |
+
|
| 90 |
+
# Install the image into the widget
|
| 91 |
+
$w configure -image $image
|
| 92 |
+
|
| 93 |
+
# Schedule the start of the animation loop
|
| 94 |
+
set animationCallbacks($w) \
|
| 95 |
+
[after $interval SelectNextImageFrame $w $interval]
|
| 96 |
+
|
| 97 |
+
# Make sure that the animation stops and is cleaned up after itself
|
| 98 |
+
# when the animated label is destroyed. Note that at this point we
|
| 99 |
+
# cannot manipulate the widget itself, as that has already died.
|
| 100 |
+
# Also note that this script is in double-quotes; this is always OK
|
| 101 |
+
# because image names are chosen automatically to be simple words.
|
| 102 |
+
bind $w <Destroy> "
|
| 103 |
+
after cancel \$animationCallbacks(%W)
|
| 104 |
+
unset animationCallbacks(%W)
|
| 105 |
+
rename $image {}
|
| 106 |
+
"
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
# Make some widgets to contain the animations
|
| 110 |
+
labelframe $w.left -text "Scrolling Texts"
|
| 111 |
+
labelframe $w.right -text "GIF Image"
|
| 112 |
+
pack $w.left $w.right -side left -padx 10 -pady 10 -expand yes
|
| 113 |
+
|
| 114 |
+
# This method of scrolling text looks far better with a fixed-width font
|
| 115 |
+
label $w.left.l1 -bd 4 -relief ridge -font fixedFont
|
| 116 |
+
label $w.left.l2 -bd 4 -relief groove -font fixedFont
|
| 117 |
+
label $w.left.l3 -bd 4 -relief flat -font fixedFont -width 18
|
| 118 |
+
pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -padx 10 -pady 10 -anchor w
|
| 119 |
+
# Don't need to do very much with this label except turn off the border
|
| 120 |
+
label $w.right.l -bd 0
|
| 121 |
+
pack $w.right.l -side top -expand yes -padx 10 -pady 10
|
| 122 |
+
|
| 123 |
+
# This is a base-64-encoded animated GIF file.
|
| 124 |
+
set tclPoweredData {
|
| 125 |
+
R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM
|
| 126 |
+
zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm
|
| 127 |
+
mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt
|
| 128 |
+
YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP
|
| 129 |
+
dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM
|
| 130 |
+
ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC
|
| 131 |
+
DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0
|
| 132 |
+
qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6
|
| 133 |
+
NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT
|
| 134 |
+
0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk
|
| 135 |
+
UmRAMgu8OgwQ+uIJgUMVeGXA+I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AALBMANwAHAAUAAAUR
|
| 151 |
+
oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j
|
| 152 |
+
Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7
|
| 153 |
+
ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw==
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
# Finally, set up the text scrolling animation
|
| 157 |
+
animateLabelText $w.left.l1 "* Slow Animation *" 300
|
| 158 |
+
animateLabelText $w.left.l2 "* Fast Animation *" 80
|
| 159 |
+
animateLabelText $w.left.l3 "This is a longer scrolling text in a widget that will not show the whole message at once. " 150
|
| 160 |
+
animateLabelImage $w.right.l $tclPoweredData 100
|
parrot/lib/tk8.6/demos/en.msg
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
::msgcat::mcset en "Widget Demonstration"
|
| 2 |
+
::msgcat::mcset en "tkWidgetDemo"
|
| 3 |
+
::msgcat::mcset en "&File"
|
| 4 |
+
::msgcat::mcset en "About..."
|
| 5 |
+
::msgcat::mcset en "&About..."
|
| 6 |
+
::msgcat::mcset en "<F1>"
|
| 7 |
+
::msgcat::mcset en "&Quit"
|
| 8 |
+
::msgcat::mcset en "Meta+Q" ;# Displayed hotkey
|
| 9 |
+
::msgcat::mcset en "Meta-q" ;# Actual binding sequence
|
| 10 |
+
::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey
|
| 11 |
+
::msgcat::mcset en "Control-q" ;# Actual binding sequence
|
| 12 |
+
::msgcat::mcset en "Variable values"
|
| 13 |
+
::msgcat::mcset en "Variable values:"
|
| 14 |
+
::msgcat::mcset en "OK"
|
| 15 |
+
::msgcat::mcset en "Run the \"%s\" sample program"
|
| 16 |
+
::msgcat::mcset en "Dismiss"
|
| 17 |
+
::msgcat::mcset en "Rerun Demo"
|
| 18 |
+
::msgcat::mcset en "Demo code: %s"
|
| 19 |
+
::msgcat::mcset en "About Widget Demo"
|
| 20 |
+
::msgcat::mcset en "Tk widget demonstration application"
|
| 21 |
+
::msgcat::mcset en "Copyright © %s"
|
| 22 |
+
::msgcat::mcset en "
|
| 23 |
+
@@title
|
| 24 |
+
Tk Widget Demonstrations
|
| 25 |
+
@@newline
|
| 26 |
+
@@normal
|
| 27 |
+
@@newline
|
| 28 |
+
|
| 29 |
+
This application provides a front end for several short scripts
|
| 30 |
+
that demonstrate what you can do with Tk widgets. Each of the
|
| 31 |
+
numbered lines below describes a demonstration; you can click on
|
| 32 |
+
it to invoke the demonstration. Once the demonstration window
|
| 33 |
+
appears, you can click the
|
| 34 |
+
@@bold
|
| 35 |
+
See Code
|
| 36 |
+
@@normal
|
| 37 |
+
button to see the Tcl/Tk code that created the demonstration. If
|
| 38 |
+
you wish, you can edit the code and click the
|
| 39 |
+
@@bold
|
| 40 |
+
Rerun Demo
|
| 41 |
+
@@normal
|
| 42 |
+
button in the code window to reinvoke the demonstration with the
|
| 43 |
+
modified code.
|
| 44 |
+
@@newline
|
| 45 |
+
"
|
| 46 |
+
::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons"
|
| 47 |
+
::msgcat::mcset en "Labels (text and bitmaps)"
|
| 48 |
+
::msgcat::mcset en "Labels and UNICODE text"
|
| 49 |
+
::msgcat::mcset en "Buttons"
|
| 50 |
+
::msgcat::mcset en "Check-buttons (select any of a group)"
|
| 51 |
+
::msgcat::mcset en "Radio-buttons (select one of a group)"
|
| 52 |
+
::msgcat::mcset en "A 15-puzzle game made out of buttons"
|
| 53 |
+
::msgcat::mcset en "Iconic buttons that use bitmaps"
|
| 54 |
+
::msgcat::mcset en "Two labels displaying images"
|
| 55 |
+
::msgcat::mcset en "A simple user interface for viewing images"
|
| 56 |
+
::msgcat::mcset en "Labelled frames"
|
| 57 |
+
::msgcat::mcset en "Listboxes"
|
| 58 |
+
::msgcat::mcset en "The 50 states"
|
| 59 |
+
::msgcat::mcset en "Colors: change the color scheme for the application"
|
| 60 |
+
::msgcat::mcset en "A collection of famous and infamous sayings"
|
| 61 |
+
::msgcat::mcset en "Entries and Spin-boxes"
|
| 62 |
+
::msgcat::mcset en "Entries without scrollbars"
|
| 63 |
+
::msgcat::mcset en "Entries with scrollbars"
|
| 64 |
+
::msgcat::mcset en "Validated entries and password fields"
|
| 65 |
+
::msgcat::mcset en "Spin-boxes"
|
| 66 |
+
::msgcat::mcset en "Simple Rolodex-like form"
|
| 67 |
+
::msgcat::mcset en "Text"
|
| 68 |
+
::msgcat::mcset en "Basic editable text"
|
| 69 |
+
::msgcat::mcset en "Text display styles"
|
| 70 |
+
::msgcat::mcset en "Hypertext (tag bindings)"
|
| 71 |
+
::msgcat::mcset en "A text widget with embedded windows"
|
| 72 |
+
::msgcat::mcset en "A search tool built with a text widget"
|
| 73 |
+
::msgcat::mcset en "Canvases"
|
| 74 |
+
::msgcat::mcset en "The canvas item types"
|
| 75 |
+
::msgcat::mcset en "A simple 2-D plot"
|
| 76 |
+
::msgcat::mcset en "Text items in canvases"
|
| 77 |
+
::msgcat::mcset en "An editor for arrowheads on canvas lines"
|
| 78 |
+
::msgcat::mcset en "A ruler with adjustable tab stops"
|
| 79 |
+
::msgcat::mcset en "A building floor plan"
|
| 80 |
+
::msgcat::mcset en "A simple scrollable canvas"
|
| 81 |
+
::msgcat::mcset en "Scales"
|
| 82 |
+
::msgcat::mcset en "Horizontal scale"
|
| 83 |
+
::msgcat::mcset en "Vertical scale"
|
| 84 |
+
::msgcat::mcset en "Paned Windows"
|
| 85 |
+
::msgcat::mcset en "Horizontal paned window"
|
| 86 |
+
::msgcat::mcset en "Vertical paned window"
|
| 87 |
+
::msgcat::mcset en "Menus"
|
| 88 |
+
::msgcat::mcset en "Menus and cascades (sub-menus)"
|
| 89 |
+
::msgcat::mcset en "Menu-buttons"
|
| 90 |
+
::msgcat::mcset en "Common Dialogs"
|
| 91 |
+
::msgcat::mcset en "Message boxes"
|
| 92 |
+
::msgcat::mcset en "File selection dialog"
|
| 93 |
+
::msgcat::mcset en "Color picker"
|
| 94 |
+
::msgcat::mcset en "Miscellaneous"
|
| 95 |
+
::msgcat::mcset en "The built-in bitmaps"
|
| 96 |
+
::msgcat::mcset en "A dialog box with a local grab"
|
| 97 |
+
::msgcat::mcset en "A dialog box with a global grab"
|
parrot/lib/tk8.6/demos/entry2.tcl
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# entry2.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script is the same as the entry1.tcl script
|
| 4 |
+
# except that it creates scrollbars for the entries.
|
| 5 |
+
|
| 6 |
+
if {![info exists widgetDemo]} {
|
| 7 |
+
error "This script should be run from the \"widget\" demo."
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
package require Tk
|
| 11 |
+
|
| 12 |
+
set w .entry2
|
| 13 |
+
catch {destroy $w}
|
| 14 |
+
toplevel $w
|
| 15 |
+
wm title $w "Entry Demonstration (with scrollbars)"
|
| 16 |
+
wm iconname $w "entry2"
|
| 17 |
+
positionWindow $w
|
| 18 |
+
|
| 19 |
+
label $w.msg -font $font -wraplength 5i -justify left -text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with the middle mouse button pressed."
|
| 20 |
+
pack $w.msg -side top
|
| 21 |
+
|
| 22 |
+
## See Code / Dismiss buttons
|
| 23 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 24 |
+
pack $btns -side bottom -fill x
|
| 25 |
+
|
| 26 |
+
frame $w.frame -borderwidth 10
|
| 27 |
+
pack $w.frame -side top -fill x -expand 1
|
| 28 |
+
|
| 29 |
+
entry $w.frame.e1 -xscrollcommand "$w.frame.s1 set"
|
| 30 |
+
ttk::scrollbar $w.frame.s1 -orient horizontal -command \
|
| 31 |
+
"$w.frame.e1 xview"
|
| 32 |
+
frame $w.frame.spacer1 -width 20 -height 10
|
| 33 |
+
entry $w.frame.e2 -xscrollcommand "$w.frame.s2 set"
|
| 34 |
+
ttk::scrollbar $w.frame.s2 -orient horizontal -command \
|
| 35 |
+
"$w.frame.e2 xview"
|
| 36 |
+
frame $w.frame.spacer2 -width 20 -height 10
|
| 37 |
+
entry $w.frame.e3 -xscrollcommand "$w.frame.s3 set"
|
| 38 |
+
ttk::scrollbar $w.frame.s3 -orient horizontal -command \
|
| 39 |
+
"$w.frame.e3 xview"
|
| 40 |
+
pack $w.frame.e1 $w.frame.s1 $w.frame.spacer1 $w.frame.e2 $w.frame.s2 \
|
| 41 |
+
$w.frame.spacer2 $w.frame.e3 $w.frame.s3 -side top -fill x
|
| 42 |
+
|
| 43 |
+
$w.frame.e1 insert 0 "Initial value"
|
| 44 |
+
$w.frame.e2 insert end "This entry contains a long value, much too long "
|
| 45 |
+
$w.frame.e2 insert end "to fit in the window at one time, so long in fact "
|
| 46 |
+
$w.frame.e2 insert end "that you'll have to scan or scroll to see the end."
|
parrot/lib/tk8.6/demos/goldberg.tcl
ADDED
|
@@ -0,0 +1,1834 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##+#################################################################
|
| 2 |
+
#
|
| 3 |
+
# TkGoldberg.tcl
|
| 4 |
+
# by Keith Vetter, March 13, 2003
|
| 5 |
+
#
|
| 6 |
+
# "Man will always find a difficult means to perform a simple task"
|
| 7 |
+
# Rube Goldberg
|
| 8 |
+
#
|
| 9 |
+
# Reproduced here with permission.
|
| 10 |
+
#
|
| 11 |
+
##+#################################################################
|
| 12 |
+
#
|
| 13 |
+
# Keith Vetter 2003-03-21: this started out as a simple little program
|
| 14 |
+
# but was so much fun that it grew and grew. So I apologize about the
|
| 15 |
+
# size but I just couldn't resist sharing it.
|
| 16 |
+
#
|
| 17 |
+
# This is a whizzlet that does a Rube Goldberg type animation, the
|
| 18 |
+
# design of which comes from an New Years e-card from IncrediMail.
|
| 19 |
+
# That version had nice sound effects which I eschewed. On the other
|
| 20 |
+
# hand, that version was in black and white (actually dark blue and
|
| 21 |
+
# light blue) and this one is fully colorized.
|
| 22 |
+
#
|
| 23 |
+
# One thing I learned from this project is that drawing filled complex
|
| 24 |
+
# objects on a canvas is really hard. More often than not I had to
|
| 25 |
+
# draw each item twice--once with the desired fill color but no
|
| 26 |
+
# outline, and once with no fill but with the outline. Another trick
|
| 27 |
+
# is erasing by drawing with the background color. Having a flood fill
|
| 28 |
+
# command would have been extremely helpful.
|
| 29 |
+
#
|
| 30 |
+
# Two wiki pages were extremely helpful: Drawing rounded rectangles
|
| 31 |
+
# which I generalized into Drawing rounded polygons, and regular
|
| 32 |
+
# polygons which allowed me to convert ovals and arcs into polygons
|
| 33 |
+
# which could then be rotated (see Canvas Rotation). I also wrote
|
| 34 |
+
# Named Colors to aid in the color selection.
|
| 35 |
+
#
|
| 36 |
+
# I could comment on the code, but it's just 26 state machines with
|
| 37 |
+
# lots of canvas create and move calls.
|
| 38 |
+
|
| 39 |
+
if {![info exists widgetDemo]} {
|
| 40 |
+
error "This script should be run from the \"widget\" demo."
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
package require Tk
|
| 44 |
+
|
| 45 |
+
set w .goldberg
|
| 46 |
+
catch {destroy $w}
|
| 47 |
+
toplevel $w
|
| 48 |
+
wm title $w "Tk Goldberg (demonstration)"
|
| 49 |
+
wm iconname $w "goldberg"
|
| 50 |
+
wm resizable $w 0 0
|
| 51 |
+
#positionWindow $w
|
| 52 |
+
|
| 53 |
+
label $w.msg -font {Arial 10} -wraplength 4i -justify left -text "This is a\
|
| 54 |
+
demonstration of just how complex you can make your animations\
|
| 55 |
+
become. Click the ball to start things moving!\n\n\"Man will always\
|
| 56 |
+
find a difficult means to perform a simple task\"\n - Rube Goldberg"
|
| 57 |
+
pack $w.msg -side top
|
| 58 |
+
|
| 59 |
+
###--- End of Boilerplate ---###
|
| 60 |
+
|
| 61 |
+
# Ensure that this this is an array
|
| 62 |
+
array set animationCallbacks {}
|
| 63 |
+
bind $w <Destroy> {
|
| 64 |
+
if {"%W" eq [winfo toplevel %W]} {
|
| 65 |
+
unset S C speed
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
set S(title) "Tk Goldberg"
|
| 70 |
+
set S(speed) 5
|
| 71 |
+
set S(cnt) 0
|
| 72 |
+
set S(message) "\\nWelcome\\nto\\nTcl/Tk"
|
| 73 |
+
array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500}
|
| 74 |
+
|
| 75 |
+
set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5
|
| 76 |
+
set S(mode) $::MSTART
|
| 77 |
+
|
| 78 |
+
# Colors for everything
|
| 79 |
+
set C(fg) black
|
| 80 |
+
set C(bg) cornflowerblue
|
| 81 |
+
|
| 82 |
+
set C(0) white; set C(1a) darkgreen; set C(1b) yellow
|
| 83 |
+
set C(2) red; set C(3a) green; set C(3b) darkblue
|
| 84 |
+
set C(4) $C(fg); set C(5a) brown; set C(5b) white
|
| 85 |
+
set C(6) magenta; set C(7) green; set C(8) $C(fg)
|
| 86 |
+
set C(9) blue4; set C(10a) white; set C(10b) cyan
|
| 87 |
+
set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2
|
| 88 |
+
set C(13a) yellow; set C(13b) red; set C(14) white
|
| 89 |
+
set C(15a) green; set C(15b) yellow; set C(16) gray65
|
| 90 |
+
set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50
|
| 91 |
+
set C(20) cyan; set C(21) gray65; set C(22) $C(20)
|
| 92 |
+
set C(23a) blue; set C(23b) red; set C(23c) yellow
|
| 93 |
+
set C(24a) red; set C(24b) white;
|
| 94 |
+
set C(24c) black; set C(26) $C(0);
|
| 95 |
+
|
| 96 |
+
proc DoDisplay {w} {
|
| 97 |
+
global S C
|
| 98 |
+
|
| 99 |
+
ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5
|
| 100 |
+
pack [frame $w.screen -bd 2 -relief raised] \
|
| 101 |
+
-side left -fill both -expand 1
|
| 102 |
+
|
| 103 |
+
canvas $w.c -width 860 -height 730 -bg $C(bg) -highlightthickness 0
|
| 104 |
+
$w.c config -scrollregion {0 0 1000 1000} ;# Kludge: move everything up
|
| 105 |
+
$w.c yview moveto .05
|
| 106 |
+
pack $w.c -in $w.screen -side top -fill both -expand 1
|
| 107 |
+
|
| 108 |
+
bind $w.c <Button-3> [list $w.pause invoke]
|
| 109 |
+
bind $w.c <Destroy> {
|
| 110 |
+
after cancel $animationCallbacks(goldberg)
|
| 111 |
+
unset animationCallbacks(goldberg)
|
| 112 |
+
}
|
| 113 |
+
DoCtrlFrame $w
|
| 114 |
+
DoDetailFrame $w
|
| 115 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 116 |
+
ttk::button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2
|
| 117 |
+
} else {
|
| 118 |
+
button $w.show -text "\xbb" -command [list ShowCtrl $w] -width 2 -highlightbackground $C(bg)
|
| 119 |
+
}
|
| 120 |
+
place $w.show -in $w.c -relx 1 -rely 0 -anchor ne
|
| 121 |
+
update
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
proc DoCtrlFrame {w} {
|
| 125 |
+
global S
|
| 126 |
+
ttk::button $w.start -text "Start" -command [list DoButton $w 0]
|
| 127 |
+
ttk::checkbutton $w.pause -text "Pause" -command [list DoButton $w 1] \
|
| 128 |
+
-variable S(pause)
|
| 129 |
+
ttk::button $w.step -text "Single Step" -command [list DoButton $w 2]
|
| 130 |
+
ttk::button $w.bstep -text "Big Step" -command [list DoButton $w 4]
|
| 131 |
+
ttk::button $w.reset -text "Reset" -command [list DoButton $w 3]
|
| 132 |
+
ttk::labelframe $w.details
|
| 133 |
+
raise $w.details
|
| 134 |
+
set S(details) 0
|
| 135 |
+
ttk::checkbutton $w.details.cb -text "Details" -variable S(details)
|
| 136 |
+
ttk::labelframe $w.message -text "Message"
|
| 137 |
+
ttk::entry $w.message.e -textvariable S(message) -justify center
|
| 138 |
+
ttk::labelframe $w.speed -text "Speed: 0"
|
| 139 |
+
ttk::scale $w.speed.scale -orient horizontal -from 1 -to 10 -variable S(speed)
|
| 140 |
+
ttk::button $w.about -text About -command [list About $w]
|
| 141 |
+
|
| 142 |
+
grid $w.start -in $w.ctrl -row 0 -sticky ew
|
| 143 |
+
grid rowconfigure $w.ctrl 1 -minsize 10
|
| 144 |
+
grid $w.pause -in $w.ctrl -row 2 -sticky ew
|
| 145 |
+
grid $w.step -in $w.ctrl -sticky ew -pady 2
|
| 146 |
+
grid $w.bstep -in $w.ctrl -sticky ew
|
| 147 |
+
grid $w.reset -in $w.ctrl -sticky ew -pady 2
|
| 148 |
+
grid rowconfigure $w.ctrl 10 -minsize 18
|
| 149 |
+
grid $w.details -in $w.ctrl -row 11 -sticky ew
|
| 150 |
+
grid rowconfigure $w.ctrl 11 -minsize 20
|
| 151 |
+
$w.details configure -labelwidget $w.details.cb
|
| 152 |
+
grid [ttk::frame $w.details.b -height 1] ;# Work around minor bug
|
| 153 |
+
raise $w.details
|
| 154 |
+
raise $w.details.cb
|
| 155 |
+
grid rowconfigure $w.ctrl 50 -weight 1
|
| 156 |
+
trace add variable ::S(mode) write [list ActiveGUI $w]
|
| 157 |
+
trace add variable ::S(details) write [list ActiveGUI $w]
|
| 158 |
+
trace add variable ::S(speed) write [list ActiveGUI $w]
|
| 159 |
+
|
| 160 |
+
grid $w.message -in $w.ctrl -row 98 -sticky ew -pady 5
|
| 161 |
+
grid $w.message.e -sticky nsew
|
| 162 |
+
grid $w.speed -in $w.ctrl -row 99 -sticky ew -pady {0 5}
|
| 163 |
+
pack $w.speed.scale -fill both -expand 1
|
| 164 |
+
grid $w.about -in $w.ctrl -row 100 -sticky ew
|
| 165 |
+
bind $w.reset <Button-3> {set S(mode) -1} ;# Debugging
|
| 166 |
+
|
| 167 |
+
## See Code / Dismiss buttons hack!
|
| 168 |
+
set btns [addSeeDismiss $w.ctrl.buttons $w]
|
| 169 |
+
grid [ttk::separator $w.ctrl.sep] -sticky ew -pady 4
|
| 170 |
+
set i 0
|
| 171 |
+
foreach b [winfo children $btns] {
|
| 172 |
+
if {[winfo class $b] eq "TButton"} {
|
| 173 |
+
grid [set b2 [ttk::button $w.ctrl.b[incr i]]] -sticky ew
|
| 174 |
+
foreach b3 [$b configure] {
|
| 175 |
+
set b3 [lindex $b3 0]
|
| 176 |
+
# Some options are read-only; ignore those errors
|
| 177 |
+
catch {$b2 configure $b3 [$b cget $b3]}
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
destroy $btns
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
proc DoDetailFrame {w} {
|
| 185 |
+
set w2 $w.details.f
|
| 186 |
+
ttk::frame $w2
|
| 187 |
+
|
| 188 |
+
ttk::label $w2.l -textvariable S(cnt) -background white
|
| 189 |
+
grid $w2.l - - - -sticky ew -row 0
|
| 190 |
+
for {set i 1} {1} {incr i} {
|
| 191 |
+
if {[info procs "Move$i"] eq ""} break
|
| 192 |
+
ttk::label $w2.l$i -text $i -anchor e -width 2 -background white
|
| 193 |
+
ttk::label $w2.ll$i -textvariable STEP($i) -width 5 -background white
|
| 194 |
+
set row [expr {($i + 1) / 2}]
|
| 195 |
+
set col [expr {(($i + 1) & 1) * 2}]
|
| 196 |
+
grid $w2.l$i -sticky ew -row $row -column $col
|
| 197 |
+
grid $w2.ll$i -sticky ew -row $row -column [incr col]
|
| 198 |
+
}
|
| 199 |
+
grid columnconfigure $w2 1 -weight 1
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
# Map or unmap the ctrl window
|
| 203 |
+
proc ShowCtrl {w} {
|
| 204 |
+
if {[winfo ismapped $w.ctrl]} {
|
| 205 |
+
pack forget $w.ctrl
|
| 206 |
+
$w.show config -text "\xbb"
|
| 207 |
+
} else {
|
| 208 |
+
pack $w.ctrl -side right -fill both -ipady 5
|
| 209 |
+
$w.show config -text "\xab"
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
proc DrawAll {w} {
|
| 214 |
+
ResetStep
|
| 215 |
+
$w.c delete all
|
| 216 |
+
for {set i 0} {1} {incr i} {
|
| 217 |
+
set p "Draw$i"
|
| 218 |
+
if {[info procs $p] eq ""} break
|
| 219 |
+
$p $w
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
proc ActiveGUI {w var1 var2 op} {
|
| 224 |
+
global S MGO MSTART MDONE
|
| 225 |
+
array set z {0 disabled 1 normal}
|
| 226 |
+
|
| 227 |
+
set m $S(mode)
|
| 228 |
+
set S(pause) [expr {$m == 2}]
|
| 229 |
+
$w.start config -state $z([expr {$m != $MGO}])
|
| 230 |
+
$w.pause config -state $z([expr {$m != $MSTART && $m != $MDONE}])
|
| 231 |
+
$w.step config -state $z([expr {$m != $MGO && $m != $MDONE}])
|
| 232 |
+
$w.bstep config -state $z([expr {$m != $MGO && $m != $MDONE}])
|
| 233 |
+
$w.reset config -state $z([expr {$m != $MSTART}])
|
| 234 |
+
|
| 235 |
+
if {$S(details)} {
|
| 236 |
+
grid $w.details.f -sticky ew
|
| 237 |
+
} else {
|
| 238 |
+
grid forget $w.details.f
|
| 239 |
+
}
|
| 240 |
+
set S(speed) [expr {round($S(speed))}]
|
| 241 |
+
$w.speed config -text "Speed: $S(speed)"
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
proc Start {} {
|
| 245 |
+
global S MGO
|
| 246 |
+
set S(mode) $MGO
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
proc DoButton {w what} {
|
| 250 |
+
global S MDONE MGO MSSTEP MBSTEP MPAUSE
|
| 251 |
+
|
| 252 |
+
if {$what == 0} { ;# Start
|
| 253 |
+
if {$S(mode) == $MDONE} {
|
| 254 |
+
Reset $w
|
| 255 |
+
}
|
| 256 |
+
set S(mode) $MGO
|
| 257 |
+
} elseif {$what == 1} { ;# Pause
|
| 258 |
+
set S(mode) [expr {$S(pause) ? $MPAUSE : $MGO}]
|
| 259 |
+
} elseif {$what == 2} { ;# Step
|
| 260 |
+
set S(mode) $MSSTEP
|
| 261 |
+
} elseif {$what == 3} { ;# Reset
|
| 262 |
+
Reset $w
|
| 263 |
+
} elseif {$what == 4} { ;# Big step
|
| 264 |
+
set S(mode) $MBSTEP
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
proc Go {w {who {}}} {
|
| 269 |
+
global S speed animationCallbacks MGO MPAUSE MSSTEP MBSTEP
|
| 270 |
+
|
| 271 |
+
set now [clock clicks -milliseconds]
|
| 272 |
+
catch {after cancel $animationCallbacks(goldberg)}
|
| 273 |
+
if {$who ne ""} { ;# Start here for debugging
|
| 274 |
+
set S(active) $who
|
| 275 |
+
set S(mode) $MGO
|
| 276 |
+
}
|
| 277 |
+
if {$S(mode) == -1} return ;# Debugging
|
| 278 |
+
set n 0
|
| 279 |
+
if {$S(mode) != $MPAUSE} { ;# Not paused
|
| 280 |
+
set n [NextStep $w] ;# Do the next move
|
| 281 |
+
}
|
| 282 |
+
if {$S(mode) == $MSSTEP} { ;# Single step
|
| 283 |
+
set S(mode) $MPAUSE
|
| 284 |
+
}
|
| 285 |
+
if {$S(mode) == $MBSTEP && $n} { ;# Big step
|
| 286 |
+
set S(mode) $MSSTEP
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
set elapsed [expr {[clock click -milliseconds] - $now}]
|
| 290 |
+
set delay [expr {$speed($S(speed)) - $elapsed}]
|
| 291 |
+
if {$delay <= 0} {
|
| 292 |
+
set delay 1
|
| 293 |
+
}
|
| 294 |
+
set animationCallbacks(goldberg) [after $delay [list Go $w]]
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
# NextStep: drives the next step of the animation
|
| 298 |
+
proc NextStep {w} {
|
| 299 |
+
global S MSTART MDONE
|
| 300 |
+
set rval 0 ;# Return value
|
| 301 |
+
|
| 302 |
+
if {$S(mode) != $MSTART && $S(mode) != $MDONE} {
|
| 303 |
+
incr S(cnt)
|
| 304 |
+
}
|
| 305 |
+
set alive {}
|
| 306 |
+
foreach {who} $S(active) {
|
| 307 |
+
set n ["Move$who" $w]
|
| 308 |
+
if {$n & 1} { ;# This guy still alive
|
| 309 |
+
lappend alive $who
|
| 310 |
+
}
|
| 311 |
+
if {$n & 2} { ;# Next guy is active
|
| 312 |
+
lappend alive [expr {$who + 1}]
|
| 313 |
+
set rval 1
|
| 314 |
+
}
|
| 315 |
+
if {$n & 4} { ;# End of puzzle flag
|
| 316 |
+
set S(mode) $MDONE ;# Done mode
|
| 317 |
+
set S(active) {} ;# No more animation
|
| 318 |
+
return 1
|
| 319 |
+
}
|
| 320 |
+
}
|
| 321 |
+
set S(active) $alive
|
| 322 |
+
return $rval
|
| 323 |
+
}
|
| 324 |
+
proc About {w} {
|
| 325 |
+
set msg "$::S(title)\nby Keith Vetter, March 2003\n(Reproduced by kind\
|
| 326 |
+
permission of the author)\n\n\"Man will always find a difficult\
|
| 327 |
+
means to perform a simple task.\"\nRube Goldberg"
|
| 328 |
+
tk_messageBox -parent $w -message $msg -title About
|
| 329 |
+
}
|
| 330 |
+
################################################################
|
| 331 |
+
#
|
| 332 |
+
# All the drawing and moving routines
|
| 333 |
+
#
|
| 334 |
+
|
| 335 |
+
# START HERE! banner
|
| 336 |
+
proc Draw0 {w} {
|
| 337 |
+
set color $::C(0)
|
| 338 |
+
set xy {579 119}
|
| 339 |
+
$w.c create text $xy -text "START HERE!" -fill $color -anchor w \
|
| 340 |
+
-tag I0 -font {{Times Roman} 12 italic bold}
|
| 341 |
+
set xy {719 119 763 119}
|
| 342 |
+
$w.c create line $xy -tag I0 -fill $color -width 5 -arrow last \
|
| 343 |
+
-arrowshape {18 18 5}
|
| 344 |
+
$w.c bind I0 <Button-1> Start
|
| 345 |
+
}
|
| 346 |
+
proc Move0 {w {step {}}} {
|
| 347 |
+
set step [GetStep 0 $step]
|
| 348 |
+
|
| 349 |
+
if {$::S(mode) > $::MSTART} { ;# Start the ball rolling
|
| 350 |
+
MoveAbs $w I0 {-100 -100} ;# Hide the banner
|
| 351 |
+
return 2
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
set pos {
|
| 355 |
+
{673 119} {678 119} {683 119} {688 119}
|
| 356 |
+
{693 119} {688 119} {683 119} {678 119}
|
| 357 |
+
}
|
| 358 |
+
set step [expr {$step % [llength $pos]}]
|
| 359 |
+
MoveAbs $w I0 [lindex $pos $step]
|
| 360 |
+
return 1
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
# Dropping ball
|
| 364 |
+
proc Draw1 {w} {
|
| 365 |
+
set color $::C(1a)
|
| 366 |
+
set color2 $::C(1b)
|
| 367 |
+
set xy {844 133 800 133 800 346 820 346 820 168 844 168 844 133}
|
| 368 |
+
$w.c create poly $xy -width 3 -fill $color -outline {}
|
| 369 |
+
set xy {771 133 685 133 685 168 751 168 751 346 771 346 771 133}
|
| 370 |
+
$w.c create poly $xy -width 3 -fill $color -outline {}
|
| 371 |
+
|
| 372 |
+
set xy [box 812 122 9]
|
| 373 |
+
$w.c create oval $xy -tag I1 -fill $color2 -outline {}
|
| 374 |
+
$w.c bind I1 <Button-1> Start
|
| 375 |
+
}
|
| 376 |
+
proc Move1 {w {step {}}} {
|
| 377 |
+
set step [GetStep 1 $step]
|
| 378 |
+
set pos {
|
| 379 |
+
{807 122} {802 122} {797 123} {793 124} {789 129} {785 153}
|
| 380 |
+
{785 203} {785 278 x} {785 367} {810 392} {816 438} {821 503}
|
| 381 |
+
{824 585 y} {838 587} {848 593} {857 601} {-100 -100}
|
| 382 |
+
}
|
| 383 |
+
if {$step >= [llength $pos]} {
|
| 384 |
+
return 0
|
| 385 |
+
}
|
| 386 |
+
set where [lindex $pos $step]
|
| 387 |
+
MoveAbs $w I1 $where
|
| 388 |
+
|
| 389 |
+
if {[lindex $where 2] eq "y"} {
|
| 390 |
+
Move15a $w
|
| 391 |
+
}
|
| 392 |
+
if {[lindex $where 2] eq "x"} {
|
| 393 |
+
return 3
|
| 394 |
+
}
|
| 395 |
+
return 1
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
# Lighting the match
|
| 399 |
+
proc Draw2 {w} {
|
| 400 |
+
set color red
|
| 401 |
+
set color $::C(2)
|
| 402 |
+
set xy {750 369 740 392 760 392} ;# Fulcrum
|
| 403 |
+
$w.c create poly $xy -fill $::C(fg) -outline $::C(fg)
|
| 404 |
+
set xy {628 335 660 383} ;# Strike box
|
| 405 |
+
$w.c create rect $xy -fill {} -outline $::C(fg)
|
| 406 |
+
for {set y 0} {$y < 3} {incr y} {
|
| 407 |
+
set yy [expr {335+$y*16}]
|
| 408 |
+
$w.c create bitmap 628 $yy -bitmap gray25 -anchor nw \
|
| 409 |
+
-foreground $::C(fg)
|
| 410 |
+
$w.c create bitmap 644 $yy -bitmap gray25 -anchor nw \
|
| 411 |
+
-foreground $::C(fg)
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
set xy {702 366 798 366} ;# Lever
|
| 415 |
+
$w.c create line $xy -fill $::C(fg) -width 6 -tag I2_0
|
| 416 |
+
set xy {712 363 712 355} ;# R strap
|
| 417 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I2_1
|
| 418 |
+
set xy {705 363 705 355} ;# L strap
|
| 419 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I2_2
|
| 420 |
+
set xy {679 356 679 360 717 360 717 356 679 356} ;# Match stick
|
| 421 |
+
$w.c create line $xy -fill $::C(fg) -tag I2_3
|
| 422 |
+
|
| 423 |
+
#set xy {662 352 680 365} ;# Match head
|
| 424 |
+
set xy {
|
| 425 |
+
671 352 677.4 353.9 680 358.5 677.4 363.1 671 365 664.6 363.1
|
| 426 |
+
662 358.5 664.6 353.9
|
| 427 |
+
}
|
| 428 |
+
$w.c create poly $xy -fill $color -outline $color -tag I2_4
|
| 429 |
+
}
|
| 430 |
+
proc Move2 {w {step {}}} {
|
| 431 |
+
set step [GetStep 2 $step]
|
| 432 |
+
|
| 433 |
+
set stages {0 0 1 2 0 2 1 0 1 2 0 2 1}
|
| 434 |
+
set xy(0) {
|
| 435 |
+
686 333 692 323 682 316 674 309 671 295 668 307 662 318 662 328
|
| 436 |
+
671 336
|
| 437 |
+
}
|
| 438 |
+
set xy(1) {687 331 698 322 703 295 680 320 668 297 663 311 661 327 671 335}
|
| 439 |
+
set xy(2) {
|
| 440 |
+
686 331 704 322 688 300 678 283 678 283 674 298 666 309 660 324
|
| 441 |
+
672 336
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
if {$step >= [llength $stages]} {
|
| 445 |
+
$w.c delete I2
|
| 446 |
+
return 0
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
if {$step == 0} { ;# Rotate the match
|
| 450 |
+
set beta 20
|
| 451 |
+
lassign [Anchor $w I2_0 s] Ox Oy ;# Where to pivot
|
| 452 |
+
for {set i 0} {[$w.c find withtag I2_$i] ne ""} {incr i} {
|
| 453 |
+
RotateItem $w I2_$i $Ox $Oy $beta
|
| 454 |
+
}
|
| 455 |
+
$w.c create poly -tag I2 -smooth 1 -fill $::C(2) ;# For the flame
|
| 456 |
+
return 1
|
| 457 |
+
}
|
| 458 |
+
$w.c coords I2 $xy([lindex $stages $step])
|
| 459 |
+
return [expr {$step == 7 ? 3 : 1}]
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
# Weight and pulleys
|
| 463 |
+
proc Draw3 {w} {
|
| 464 |
+
set color $::C(3a)
|
| 465 |
+
set color2 $::C(3b)
|
| 466 |
+
|
| 467 |
+
set xy {602 296 577 174 518 174}
|
| 468 |
+
foreach {x y} $xy { ;# 3 Pulleys
|
| 469 |
+
$w.c create oval [box $x $y 13] -fill $color -outline $::C(fg) \
|
| 470 |
+
-width 3
|
| 471 |
+
$w.c create oval [box $x $y 2] -fill $::C(fg) -outline $::C(fg)
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
set xy {750 309 670 309} ;# Wall to flame
|
| 475 |
+
$w.c create line $xy -tag I3_s -width 3 -fill $::C(fg) -smooth 1
|
| 476 |
+
set xy {670 309 650 309} ;# Flame to pulley 1
|
| 477 |
+
$w.c create line $xy -tag I3_0 -width 3 -fill $::C(fg)
|
| 478 |
+
set xy {650 309 600 309} ;# Flame to pulley 1
|
| 479 |
+
$w.c create line $xy -tag I3_1 -width 3 -fill $::C(fg)
|
| 480 |
+
set xy {589 296 589 235} ;# Pulley 1 half way to 2
|
| 481 |
+
$w.c create line $xy -tag I3_2 -width 3 -fill $::C(fg)
|
| 482 |
+
set xy {589 235 589 174} ;# Pulley 1 other half to 2
|
| 483 |
+
$w.c create line $xy -width 3 -fill $::C(fg)
|
| 484 |
+
set xy {577 161 518 161} ;# Across the top
|
| 485 |
+
$w.c create line $xy -width 3 -fill $::C(fg)
|
| 486 |
+
set xy {505 174 505 205} ;# Down to weight
|
| 487 |
+
$w.c create line $xy -tag I3_w -width 3 -fill $::C(fg)
|
| 488 |
+
|
| 489 |
+
# Draw the weight as 2 circles, two rectangles and 1 rounded rectangle
|
| 490 |
+
set xy {515 207 495 207}
|
| 491 |
+
foreach {x1 y1 x2 y2} $xy {
|
| 492 |
+
$w.c create oval [box $x1 $y1 6] -tag I3_ -fill $color2 \
|
| 493 |
+
-outline $color2
|
| 494 |
+
$w.c create oval [box $x2 $y2 6] -tag I3_ -fill $color2 \
|
| 495 |
+
-outline $color2
|
| 496 |
+
incr y1 -6; incr y2 6
|
| 497 |
+
$w.c create rect $x1 $y1 $x2 $y2 -tag I3_ -fill $color2 \
|
| 498 |
+
-outline $color2
|
| 499 |
+
}
|
| 500 |
+
set xy {492 220 518 263}
|
| 501 |
+
set xy [RoundRect $w $xy 15]
|
| 502 |
+
$w.c create poly $xy -smooth 1 -tag I3_ -fill $color2 -outline $color2
|
| 503 |
+
set xy {500 217 511 217}
|
| 504 |
+
$w.c create line $xy -tag I3_ -fill $color2 -width 10
|
| 505 |
+
|
| 506 |
+
set xy {502 393 522 393 522 465} ;# Bottom weight target
|
| 507 |
+
$w.c create line $xy -tag I3__ -fill $::C(fg) -join miter -width 10
|
| 508 |
+
}
|
| 509 |
+
proc Move3 {w {step {}}} {
|
| 510 |
+
set step [GetStep 3 $step]
|
| 511 |
+
|
| 512 |
+
set pos {{505 247} {505 297} {505 386.5} {505 386.5}}
|
| 513 |
+
set rope(0) {750 309 729 301 711 324 690 300}
|
| 514 |
+
set rope(1) {750 309 737 292 736 335 717 315 712 320}
|
| 515 |
+
set rope(2) {750 309 737 309 740 343 736 351 725 340}
|
| 516 |
+
set rope(3) {750 309 738 321 746 345 742 356}
|
| 517 |
+
|
| 518 |
+
if {$step >= [llength $pos]} {
|
| 519 |
+
return 0
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
$w.c delete "I3_$step" ;# Delete part of the rope
|
| 523 |
+
MoveAbs $w I3_ [lindex $pos $step] ;# Move weight down
|
| 524 |
+
$w.c coords I3_s $rope($step) ;# Flapping rope end
|
| 525 |
+
$w.c coords I3_w [concat 505 174 [lindex $pos $step]]
|
| 526 |
+
if {$step == 2} {
|
| 527 |
+
$w.c move I3__ 0 30
|
| 528 |
+
return 2
|
| 529 |
+
}
|
| 530 |
+
return 1
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
# Cage and door
|
| 534 |
+
proc Draw4 {w} {
|
| 535 |
+
set color $::C(4)
|
| 536 |
+
lassign {527 356 611 464} x0 y0 x1 y1
|
| 537 |
+
|
| 538 |
+
for {set y $y0} {$y <= $y1} {incr y 12} { ;# Horizontal bars
|
| 539 |
+
$w.c create line $x0 $y $x1 $y -fill $color -width 1
|
| 540 |
+
}
|
| 541 |
+
for {set x $x0} {$x <= $x1} {incr x 12} { ;# Vertical bars
|
| 542 |
+
$w.c create line $x $y0 $x $y1 -fill $color -width 1
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
set xy {518 464 518 428} ;# Swing gate
|
| 546 |
+
$w.c create line $xy -tag I4 -fill $color -width 3
|
| 547 |
+
}
|
| 548 |
+
proc Move4 {w {step {}}} {
|
| 549 |
+
set step [GetStep 4 $step]
|
| 550 |
+
|
| 551 |
+
set angles {-10 -20 -30 -30}
|
| 552 |
+
if {$step >= [llength $angles]} {
|
| 553 |
+
return 0
|
| 554 |
+
}
|
| 555 |
+
RotateItem $w I4 518 464 [lindex $angles $step]
|
| 556 |
+
$w.c raise I4
|
| 557 |
+
return [expr {$step == 3 ? 3 : 1}]
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
# Mouse
|
| 561 |
+
proc Draw5 {w} {
|
| 562 |
+
set color $::C(5a)
|
| 563 |
+
set color2 $::C(5b)
|
| 564 |
+
set xy {377 248 410 248 410 465 518 465} ;# Mouse course
|
| 565 |
+
lappend xy 518 428 451 428 451 212 377 212
|
| 566 |
+
$w.c create poly $xy -fill $color2 -outline $::C(fg) -width 3
|
| 567 |
+
|
| 568 |
+
set xy {
|
| 569 |
+
534.5 445.5 541 440 552 436 560 436 569 440 574 446 575 452 574 454
|
| 570 |
+
566 456 554 456 545 456 537 454 530 452
|
| 571 |
+
}
|
| 572 |
+
$w.c create poly $xy -tag {I5 I5_0} -fill $color
|
| 573 |
+
set xy {573 452 592 458 601 460 613 456} ;# Tail
|
| 574 |
+
$w.c create line $xy -tag {I5 I5_1} -fill $color -smooth 1 -width 3
|
| 575 |
+
set xy [box 540 446 2] ;# Eye
|
| 576 |
+
set xy {540 444 541 445 541 447 540 448 538 447 538 445}
|
| 577 |
+
#.c create oval $xy -tag {I5 I5_2} -fill $::C(bg) -outline {}
|
| 578 |
+
$w.c create poly $xy -tag {I5 I5_2} -fill $::C(bg) -outline {} -smooth 1
|
| 579 |
+
set xy {538 454 535 461} ;# Front leg
|
| 580 |
+
$w.c create line $xy -tag {I5 I5_3} -fill $color -width 2
|
| 581 |
+
set xy {566 455 569 462} ;# Back leg
|
| 582 |
+
$w.c create line $xy -tag {I5 I5_4} -fill $color -width 2
|
| 583 |
+
set xy {544 455 545 460} ;# 2nd front leg
|
| 584 |
+
$w.c create line $xy -tag {I5 I5_5} -fill $color -width 2
|
| 585 |
+
set xy {560 455 558 460} ;# 2nd back leg
|
| 586 |
+
$w.c create line $xy -tag {I5 I5_6} -fill $color -width 2
|
| 587 |
+
}
|
| 588 |
+
proc Move5 {w {step {}}} {
|
| 589 |
+
set step [GetStep 5 $step]
|
| 590 |
+
|
| 591 |
+
set pos {
|
| 592 |
+
{553 452} {533 452} {513 452} {493 452} {473 452}
|
| 593 |
+
{463 442 30} {445.5 441.5 30} {425.5 434.5 30} {422 414} {422 394}
|
| 594 |
+
{422 374} {422 354} {422 334} {422 314} {422 294}
|
| 595 |
+
{422 274 -30} {422 260.5 -30 x} {422.5 248.5 -28} {425 237}
|
| 596 |
+
}
|
| 597 |
+
if {$step >= [llength $pos]} {
|
| 598 |
+
return 0
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
lassign [lindex $pos $step] x y beta next
|
| 602 |
+
MoveAbs $w I5 [list $x $y]
|
| 603 |
+
if {$beta ne ""} {
|
| 604 |
+
lassign [Centroid $w I5_0] Ox Oy
|
| 605 |
+
foreach id {0 1 2 3 4 5 6} {
|
| 606 |
+
RotateItem $w I5_$id $Ox $Oy $beta
|
| 607 |
+
}
|
| 608 |
+
}
|
| 609 |
+
if {$next eq "x"} {
|
| 610 |
+
return 3
|
| 611 |
+
}
|
| 612 |
+
return 1
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
# Dropping gumballs
|
| 616 |
+
array set XY6 {
|
| 617 |
+
-1 {366 207} -2 {349 204} -3 {359 193} -4 {375 192} -5 {340 190}
|
| 618 |
+
-6 {349 177} -7 {366 177} -8 {380 176} -9 {332 172} -10 {342 161}
|
| 619 |
+
-11 {357 164} -12 {372 163} -13 {381 149} -14 {364 151} -15 {349 146}
|
| 620 |
+
-16 {333 148} 0 {357 219}
|
| 621 |
+
1 {359 261} 2 {359 291} 3 {359 318} 4 {361 324} 5 {365 329} 6 {367 334}
|
| 622 |
+
7 {367 340} 8 {366 346} 9 {364 350} 10 {361 355} 11 {359 370} 12 {359 391}
|
| 623 |
+
13,0 {360 456} 13,1 {376 456} 13,2 {346 456} 13,3 {330 456}
|
| 624 |
+
13,4 {353 444} 13,5 {368 443} 13,6 {339 442} 13,7 {359 431}
|
| 625 |
+
13,8 {380 437} 13,9 {345 428} 13,10 {328 434} 13,11 {373 424}
|
| 626 |
+
13,12 {331 420} 13,13 {360 417} 13,14 {345 412} 13,15 {376 410}
|
| 627 |
+
13,16 {360 403}
|
| 628 |
+
}
|
| 629 |
+
proc Draw6 {w} {
|
| 630 |
+
set color $::C(6)
|
| 631 |
+
set xy {324 130 391 204} ;# Ball holder
|
| 632 |
+
set xy [RoundRect $w $xy 10]
|
| 633 |
+
$w.c create poly $xy -smooth 1 -outline $::C(fg) -width 3 -fill $color
|
| 634 |
+
set xy {339 204 376 253} ;# Below the ball holder
|
| 635 |
+
$w.c create rect $xy -fill {} -outline $::C(fg) -width 3 -fill $color \
|
| 636 |
+
-tag I6c
|
| 637 |
+
set xy [box 346 339 28]
|
| 638 |
+
$w.c create oval $xy -fill $color -outline {} ;# Rotor
|
| 639 |
+
$w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
|
| 640 |
+
-start 80 -extent 205
|
| 641 |
+
$w.c create arc $xy -outline $::C(fg) -width 2 -style arc \
|
| 642 |
+
-start -41 -extent 85
|
| 643 |
+
|
| 644 |
+
set xy [box 346 339 15] ;# Center of rotor
|
| 645 |
+
$w.c create oval $xy -outline $::C(fg) -fill $::C(fg) -tag I6m
|
| 646 |
+
set xy {352 312 352 254 368 254 368 322} ;# Top drop to rotor
|
| 647 |
+
$w.c create poly $xy -fill $color -outline {}
|
| 648 |
+
$w.c create line $xy -fill $::C(fg) -width 2
|
| 649 |
+
|
| 650 |
+
set xy {353 240 367 300} ;# Poke bottom hole
|
| 651 |
+
$w.c create rect $xy -fill $color -outline {}
|
| 652 |
+
set xy {341 190 375 210} ;# Poke another hole
|
| 653 |
+
$w.c create rect $xy -fill $color -outline {}
|
| 654 |
+
|
| 655 |
+
set xy {368 356 368 403 389 403 389 464 320 464 320 403 352 403 352 366}
|
| 656 |
+
$w.c create poly $xy -fill $color -outline {} -width 2 ;# Below rotor
|
| 657 |
+
$w.c create line $xy -fill $::C(fg) -width 2
|
| 658 |
+
set xy [box 275 342 7] ;# On/off rotor
|
| 659 |
+
$w.c create oval $xy -outline $::C(fg) -fill $::C(fg)
|
| 660 |
+
set xy {276 334 342 325} ;# Fan belt top
|
| 661 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 662 |
+
set xy {276 349 342 353} ;# Fan belt bottom
|
| 663 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 664 |
+
|
| 665 |
+
set xy {337 212 337 247} ;# What the mouse pushes
|
| 666 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
|
| 667 |
+
set xy {392 212 392 247}
|
| 668 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I6_
|
| 669 |
+
set xy {337 230 392 230}
|
| 670 |
+
$w.c create line $xy -fill $::C(fg) -width 7 -tag I6_
|
| 671 |
+
|
| 672 |
+
set who -1 ;# All the balls
|
| 673 |
+
set colors {red cyan orange green blue darkblue}
|
| 674 |
+
lappend colors {*}$colors {*}$colors
|
| 675 |
+
|
| 676 |
+
for {set i 0} {$i < 17} {incr i} {
|
| 677 |
+
set loc [expr {-1 * $i}]
|
| 678 |
+
set color [lindex $colors $i]
|
| 679 |
+
$w.c create oval [box {*}$::XY6($loc) 5] -fill $color \
|
| 680 |
+
-outline $color -tag I6_b$i
|
| 681 |
+
}
|
| 682 |
+
Draw6a $w 12 ;# The wheel
|
| 683 |
+
}
|
| 684 |
+
proc Draw6a {w beta} {
|
| 685 |
+
$w.c delete I6_0
|
| 686 |
+
lassign {346 339} Ox Oy
|
| 687 |
+
for {set i 0} {$i < 4} {incr i} {
|
| 688 |
+
set b [expr {$beta + $i * 45}]
|
| 689 |
+
lassign [RotateC 28 0 0 0 $b] x y
|
| 690 |
+
set xy [list [expr {$Ox+$x}] [expr {$Oy+$y}] \
|
| 691 |
+
[expr {$Ox-$x}] [expr {$Oy-$y}]]
|
| 692 |
+
$w.c create line $xy -tag I6_0 -fill $::C(fg) -width 2
|
| 693 |
+
}
|
| 694 |
+
}
|
| 695 |
+
proc Move6 {w {step {}}} {
|
| 696 |
+
set step [GetStep 6 $step]
|
| 697 |
+
if {$step > 62} {
|
| 698 |
+
return 0
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
if {$step < 2} { ;# Open gate for balls to drop
|
| 702 |
+
$w.c move I6_ -7 0
|
| 703 |
+
if {$step == 1} { ;# Poke a hole
|
| 704 |
+
set xy {348 226 365 240}
|
| 705 |
+
$w.c create rect $xy -fill [$w.c itemcget I6c -fill] -outline {}
|
| 706 |
+
}
|
| 707 |
+
return 1
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
set s [expr {$step - 1}] ;# Do the gumball drop dance
|
| 711 |
+
for {set i 0} {$i <= int(($s-1) / 3)} {incr i} {
|
| 712 |
+
set tag "I6_b$i"
|
| 713 |
+
if {[$w.c find withtag $tag] eq ""} break
|
| 714 |
+
set loc [expr {$s - 3 * $i}]
|
| 715 |
+
|
| 716 |
+
if {[info exists ::XY6($loc,$i)]} {
|
| 717 |
+
MoveAbs $w $tag $::XY6($loc,$i)
|
| 718 |
+
} elseif {[info exists ::XY6($loc)]} {
|
| 719 |
+
MoveAbs $w $tag $::XY6($loc)
|
| 720 |
+
}
|
| 721 |
+
}
|
| 722 |
+
if {($s % 3) == 1} {
|
| 723 |
+
set first [expr {($s + 2) / 3}]
|
| 724 |
+
for {set i $first} {1} {incr i} {
|
| 725 |
+
set tag "I6_b$i"
|
| 726 |
+
if {[$w.c find withtag $tag] eq ""} break
|
| 727 |
+
set loc [expr {$first - $i}]
|
| 728 |
+
MoveAbs $w $tag $::XY6($loc)
|
| 729 |
+
}
|
| 730 |
+
}
|
| 731 |
+
if {$s >= 3} { ;# Rotate the motor
|
| 732 |
+
set idx [expr {$s % 3}]
|
| 733 |
+
#Draw6a $w [lindex {12 35 64} $idx]
|
| 734 |
+
Draw6a $w [expr {12 + $s * 15}]
|
| 735 |
+
}
|
| 736 |
+
return [expr {$s == 3 ? 3 : 1}]
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
# On/off switch
|
| 740 |
+
proc Draw7 {w} {
|
| 741 |
+
set color $::C(7)
|
| 742 |
+
set xy {198 306 277 374} ;# Box
|
| 743 |
+
$w.c create rect $xy -outline $::C(fg) -width 2 -fill $color -tag I7z
|
| 744 |
+
$w.c lower I7z
|
| 745 |
+
set xy {275 343 230 349}
|
| 746 |
+
$w.c create line $xy -tag I7 -fill $::C(fg) -arrow last \
|
| 747 |
+
-arrowshape {23 23 8} -width 6
|
| 748 |
+
set xy {225 324} ;# On button
|
| 749 |
+
$w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
|
| 750 |
+
set xy {218 323} ;# On text
|
| 751 |
+
set font {{Times Roman} 8}
|
| 752 |
+
$w.c create text $xy -text "on" -anchor e -fill $::C(fg) -font $font
|
| 753 |
+
set xy {225 350} ;# Off button
|
| 754 |
+
$w.c create oval [box {*}$xy 3] -fill $::C(fg) -outline $::C(fg)
|
| 755 |
+
set xy {218 349} ;# Off button
|
| 756 |
+
$w.c create text $xy -text "off" -anchor e -fill $::C(fg) -font $font
|
| 757 |
+
}
|
| 758 |
+
proc Move7 {w {step {}}} {
|
| 759 |
+
set step [GetStep 7 $step]
|
| 760 |
+
set numsteps 30
|
| 761 |
+
if {$step > $numsteps} {
|
| 762 |
+
return 0
|
| 763 |
+
}
|
| 764 |
+
set beta [expr {30.0 / $numsteps}]
|
| 765 |
+
RotateItem $w I7 275 343 $beta
|
| 766 |
+
|
| 767 |
+
return [expr {$step == $numsteps ? 3 : 1}]
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
# Electricity to the fan
|
| 771 |
+
proc Draw8 {w} {
|
| 772 |
+
Sine $w 271 248 271 306 5 8 -tag I8_s -fill $::C(8) -width 3
|
| 773 |
+
}
|
| 774 |
+
proc Move8 {w {step {}}} {
|
| 775 |
+
set step [GetStep 8 $step]
|
| 776 |
+
|
| 777 |
+
if {$step > 3} {
|
| 778 |
+
return 0
|
| 779 |
+
}
|
| 780 |
+
if {$step == 0} {
|
| 781 |
+
Sparkle $w [Anchor $w I8_s s] I8
|
| 782 |
+
return 1
|
| 783 |
+
|
| 784 |
+
} elseif {$step == 1} {
|
| 785 |
+
MoveAbs $w I8 [Anchor $w I8_s c]
|
| 786 |
+
} elseif {$step == 2} {
|
| 787 |
+
MoveAbs $w I8 [Anchor $w I8_s n]
|
| 788 |
+
} else {
|
| 789 |
+
$w.c delete I8
|
| 790 |
+
}
|
| 791 |
+
return [expr {$step == 2 ? 3 : 1}]
|
| 792 |
+
}
|
| 793 |
+
|
| 794 |
+
# Fan
|
| 795 |
+
proc Draw9 {w} {
|
| 796 |
+
set color $::C(9)
|
| 797 |
+
set xy {266 194 310 220}
|
| 798 |
+
$w.c create oval $xy -outline $color -fill $color
|
| 799 |
+
set xy {280 209 296 248}
|
| 800 |
+
$w.c create oval $xy -outline $color -fill $color
|
| 801 |
+
set xy {288 249 252 249 260 240 280 234 296 234 316 240 324 249 288 249}
|
| 802 |
+
$w.c create poly $xy -fill $color -smooth 1
|
| 803 |
+
|
| 804 |
+
set xy {248 205 265 214 264 205 265 196} ;# Spinner
|
| 805 |
+
$w.c create poly $xy -fill $color
|
| 806 |
+
|
| 807 |
+
set xy {255 206 265 234} ;# Fan blades
|
| 808 |
+
$w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
|
| 809 |
+
set xy {255 176 265 204}
|
| 810 |
+
$w.c create oval $xy -fill {} -outline $::C(fg) -width 3 -tag I9_0
|
| 811 |
+
set xy {255 206 265 220}
|
| 812 |
+
$w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
|
| 813 |
+
set xy {255 190 265 204}
|
| 814 |
+
$w.c create oval $xy -fill {} -outline $::C(fg) -width 1 -tag I9_1
|
| 815 |
+
}
|
| 816 |
+
proc Move9 {w {step {}}} {
|
| 817 |
+
set step [GetStep 9 $step]
|
| 818 |
+
|
| 819 |
+
if {$step & 1} {
|
| 820 |
+
$w.c itemconfig I9_0 -width 4
|
| 821 |
+
$w.c itemconfig I9_1 -width 1
|
| 822 |
+
$w.c lower I9_1 I9_0
|
| 823 |
+
} else {
|
| 824 |
+
$w.c itemconfig I9_0 -width 1
|
| 825 |
+
$w.c itemconfig I9_1 -width 4
|
| 826 |
+
$w.c lower I9_0 I9_1
|
| 827 |
+
}
|
| 828 |
+
if {$step == 0} {
|
| 829 |
+
return 3
|
| 830 |
+
}
|
| 831 |
+
return 1
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
# Boat
|
| 835 |
+
proc Draw10 {w} {
|
| 836 |
+
set color $::C(10a)
|
| 837 |
+
set color2 $::C(10b)
|
| 838 |
+
set xy {191 230 233 230 233 178 191 178} ;# Sail
|
| 839 |
+
$w.c create poly $xy -fill $color -width 3 -outline $::C(fg) -tag I10
|
| 840 |
+
set xy [box 209 204 31] ;# Front
|
| 841 |
+
$w.c create arc $xy -outline {} -fill $color -style pie \
|
| 842 |
+
-start 120 -extent 120 -tag I10
|
| 843 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
|
| 844 |
+
-start 120 -extent 120 -tag I10
|
| 845 |
+
set xy [box 249 204 31] ;# Back
|
| 846 |
+
$w.c create arc $xy -outline {} -fill $::C(bg) -width 3 -style pie \
|
| 847 |
+
-start 120 -extent 120 -tag I10
|
| 848 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
|
| 849 |
+
-start 120 -extent 120 -tag I10
|
| 850 |
+
|
| 851 |
+
set xy {200 171 200 249} ;# Mast
|
| 852 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I10
|
| 853 |
+
set xy {159 234 182 234} ;# Bow sprit
|
| 854 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I10
|
| 855 |
+
set xy {180 234 180 251 220 251} ;# Hull
|
| 856 |
+
$w.c create line $xy -fill $::C(fg) -width 6 -tag I10
|
| 857 |
+
|
| 858 |
+
set xy {92 255 221 255} ;# Waves
|
| 859 |
+
Sine $w {*}$xy 2 25 -fill $color2 -width 1 -tag I10w
|
| 860 |
+
|
| 861 |
+
set xy [lrange [$w.c coords I10w] 4 end-4] ;# Water
|
| 862 |
+
set xy [concat $xy 222 266 222 277 99 277]
|
| 863 |
+
$w.c create poly $xy -fill $color2 -outline $color2
|
| 864 |
+
set xy {222 266 222 277 97 277 97 266} ;# Water bottom
|
| 865 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 866 |
+
|
| 867 |
+
set xy [box 239 262 17]
|
| 868 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
|
| 869 |
+
-start 95 -extent 103
|
| 870 |
+
set xy [box 76 266 21]
|
| 871 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 190
|
| 872 |
+
}
|
| 873 |
+
proc Move10 {w {step {}}} {
|
| 874 |
+
set step [GetStep 10 $step]
|
| 875 |
+
set pos {
|
| 876 |
+
{195 212} {193 212} {190 212} {186 212} {181 212} {176 212}
|
| 877 |
+
{171 212} {166 212} {161 212} {156 212} {151 212} {147 212} {142 212}
|
| 878 |
+
{137 212} {132 212 x} {127 212} {121 212} {116 212} {111 212}
|
| 879 |
+
}
|
| 880 |
+
|
| 881 |
+
if {$step >= [llength $pos]} {
|
| 882 |
+
return 0
|
| 883 |
+
}
|
| 884 |
+
set where [lindex $pos $step]
|
| 885 |
+
MoveAbs $w I10 $where
|
| 886 |
+
|
| 887 |
+
if {[lindex $where 2] eq "x"} {
|
| 888 |
+
return 3
|
| 889 |
+
}
|
| 890 |
+
return 1
|
| 891 |
+
}
|
| 892 |
+
|
| 893 |
+
# 2nd ball drop
|
| 894 |
+
proc Draw11 {w} {
|
| 895 |
+
set color $::C(11a)
|
| 896 |
+
set color2 $::C(11b)
|
| 897 |
+
set xy {23 264 55 591} ;# Color the down tube
|
| 898 |
+
$w.c create rect $xy -fill $color -outline {}
|
| 899 |
+
set xy [box 71 460 48] ;# Color the outer loop
|
| 900 |
+
$w.c create oval $xy -fill $color -outline {}
|
| 901 |
+
|
| 902 |
+
set xy {55 264 55 458} ;# Top right side
|
| 903 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 904 |
+
set xy {55 504 55 591} ;# Bottom right side
|
| 905 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 906 |
+
set xy [box 71 460 48] ;# Outer loop
|
| 907 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
|
| 908 |
+
-start 110 -extent -290 -tag I11i
|
| 909 |
+
set xy [box 71 460 16] ;# Inner loop
|
| 910 |
+
$w.c create oval $xy -outline $::C(fg) -fill {} -width 3 -tag I11i
|
| 911 |
+
$w.c create oval $xy -outline $::C(fg) -fill $::C(bg) -width 3
|
| 912 |
+
|
| 913 |
+
set xy {23 264 23 591} ;# Left side
|
| 914 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 915 |
+
set xy [box 1 266 23] ;# Top left curve
|
| 916 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc -extent 90
|
| 917 |
+
|
| 918 |
+
set xy [box 75 235 9] ;# The ball
|
| 919 |
+
$w.c create oval $xy -fill $color2 -outline {} -width 3 -tag I11
|
| 920 |
+
}
|
| 921 |
+
proc Move11 {w {step {}}} {
|
| 922 |
+
set step [GetStep 11 $step]
|
| 923 |
+
set pos {
|
| 924 |
+
{75 235} {70 235} {65 237} {56 240} {46 247} {38 266} {38 296}
|
| 925 |
+
{38 333} {38 399} {38 475} {74 496} {105 472} {100 437} {65 423}
|
| 926 |
+
{-100 -100} {38 505} {38 527 x} {38 591}
|
| 927 |
+
}
|
| 928 |
+
|
| 929 |
+
if {$step >= [llength $pos]} {
|
| 930 |
+
return 0
|
| 931 |
+
}
|
| 932 |
+
set where [lindex $pos $step]
|
| 933 |
+
MoveAbs $w I11 $where
|
| 934 |
+
if {[lindex $where 2] eq "x"} {
|
| 935 |
+
return 3
|
| 936 |
+
}
|
| 937 |
+
return 1
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
# Hand
|
| 941 |
+
proc Draw12 {w} {
|
| 942 |
+
set xy {20 637 20 617 20 610 20 590 40 590 40 590 60 590 60 610 60 610}
|
| 943 |
+
lappend xy 60 610 65 620 60 631 ;# Thumb
|
| 944 |
+
lappend xy 60 631 60 637 60 662 60 669 52 669 56 669 50 669 50 662 50 637
|
| 945 |
+
|
| 946 |
+
set y0 637 ;# Bumps for fingers
|
| 947 |
+
set y1 645
|
| 948 |
+
for {set x 50} {$x > 20} {incr x -10} {
|
| 949 |
+
set x1 [expr {$x - 5}]
|
| 950 |
+
set x2 [expr {$x - 10}]
|
| 951 |
+
lappend xy $x $y0 $x1 $y1 $x2 $y0
|
| 952 |
+
}
|
| 953 |
+
$w.c create poly $xy -fill $::C(12) -outline $::C(fg) -smooth 1 -tag I12 \
|
| 954 |
+
-width 3
|
| 955 |
+
}
|
| 956 |
+
proc Move12 {w {step {}}} {
|
| 957 |
+
set step [GetStep 12 $step]
|
| 958 |
+
set pos {{42.5 641 x}}
|
| 959 |
+
if {$step >= [llength $pos]} {
|
| 960 |
+
return 0
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
set where [lindex $pos $step]
|
| 964 |
+
MoveAbs $w I12 $where
|
| 965 |
+
if {[lindex $where 2] eq "x"} {
|
| 966 |
+
return 3
|
| 967 |
+
}
|
| 968 |
+
return 1
|
| 969 |
+
}
|
| 970 |
+
|
| 971 |
+
# Fax
|
| 972 |
+
proc Draw13 {w} {
|
| 973 |
+
set color $::C(13a)
|
| 974 |
+
set xy {86 663 149 663 149 704 50 704 50 681 64 681 86 671}
|
| 975 |
+
set xy2 {784 663 721 663 721 704 820 704 820 681 806 681 784 671}
|
| 976 |
+
set radii {2 9 9 8 5 5 2}
|
| 977 |
+
|
| 978 |
+
RoundPoly $w.c $xy $radii -width 3 -outline $::C(fg) -fill $color
|
| 979 |
+
RoundPoly $w.c $xy2 $radii -width 3 -outline $::C(fg) -fill $color
|
| 980 |
+
|
| 981 |
+
set xy {56 677}
|
| 982 |
+
$w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
|
| 983 |
+
-tag I13
|
| 984 |
+
set xy {809 677}
|
| 985 |
+
$w.c create rect [box {*}$xy 4] -fill {} -outline $::C(fg) -width 3 \
|
| 986 |
+
-tag I13R
|
| 987 |
+
|
| 988 |
+
set xy {112 687} ;# Label
|
| 989 |
+
$w.c create text $xy -text "FAX" -fill $::C(fg) \
|
| 990 |
+
-font {{Times Roman} 12 bold}
|
| 991 |
+
set xy {762 687}
|
| 992 |
+
$w.c create text $xy -text "FAX" -fill $::C(fg) \
|
| 993 |
+
-font {{Times Roman} 12 bold}
|
| 994 |
+
|
| 995 |
+
set xy {138 663 148 636 178 636} ;# Paper guide
|
| 996 |
+
$w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
|
| 997 |
+
set xy {732 663 722 636 692 636}
|
| 998 |
+
$w.c create line $xy -smooth 1 -fill $::C(fg) -width 3
|
| 999 |
+
|
| 1000 |
+
Sine $w 149 688 720 688 5 15 -tag I13_s -fill $::C(fg) -width 3
|
| 1001 |
+
}
|
| 1002 |
+
proc Move13 {w {step {}}} {
|
| 1003 |
+
set step [GetStep 13 $step]
|
| 1004 |
+
set numsteps 7
|
| 1005 |
+
|
| 1006 |
+
if {$step == $numsteps+2} {
|
| 1007 |
+
MoveAbs $w I13_star {-100 -100}
|
| 1008 |
+
$w.c itemconfig I13R -fill $::C(13b) -width 2
|
| 1009 |
+
return 2
|
| 1010 |
+
}
|
| 1011 |
+
if {$step == 0} { ;# Button down
|
| 1012 |
+
$w.c delete I13
|
| 1013 |
+
Sparkle $w {-100 -100} I13_star ;# Create off screen
|
| 1014 |
+
return 1
|
| 1015 |
+
}
|
| 1016 |
+
lassign [Anchor $w I13_s w] x0 y0
|
| 1017 |
+
lassign [Anchor $w I13_s e] x1 y1
|
| 1018 |
+
set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
|
| 1019 |
+
MoveAbs $w I13_star [list $x $y0]
|
| 1020 |
+
return 1
|
| 1021 |
+
}
|
| 1022 |
+
|
| 1023 |
+
# Paper in fax
|
| 1024 |
+
proc Draw14 {w} {
|
| 1025 |
+
set color $::C(14)
|
| 1026 |
+
set xy {102 661 113 632 130 618} ;# Left paper edge
|
| 1027 |
+
$w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_0
|
| 1028 |
+
set xy {148 629 125 640 124 662} ;# Right paper edge
|
| 1029 |
+
$w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14L_1
|
| 1030 |
+
Draw14a $w L
|
| 1031 |
+
|
| 1032 |
+
set xy {
|
| 1033 |
+
768.0 662.5 767.991316225 662.433786215 767.926187912 662.396880171
|
| 1034 |
+
}
|
| 1035 |
+
$w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_0
|
| 1036 |
+
$w.c lower I14R_0
|
| 1037 |
+
# NB. these numbers are VERY sensitive, you must start with final size
|
| 1038 |
+
# and shrink down to get the values
|
| 1039 |
+
set xy {
|
| 1040 |
+
745.947897349 662.428358855 745.997829056 662.452239237 746.0 662.5
|
| 1041 |
+
}
|
| 1042 |
+
$w.c create line $xy -smooth 1 -fill $color -width 3 -tag I14R_1
|
| 1043 |
+
$w.c lower I14R_1
|
| 1044 |
+
}
|
| 1045 |
+
proc Draw14a {w side} {
|
| 1046 |
+
set color $::C(14)
|
| 1047 |
+
set xy [$w.c coords I14${side}_0]
|
| 1048 |
+
set xy2 [$w.c coords I14${side}_1]
|
| 1049 |
+
lassign $xy x0 y0 x1 y1 x2 y2
|
| 1050 |
+
lassign $xy2 x3 y3 x4 y4 x5 y5
|
| 1051 |
+
set zz [concat \
|
| 1052 |
+
$x0 $y0 $x0 $y0 $xy $x2 $y2 $x2 $y2 \
|
| 1053 |
+
$x3 $y3 $x3 $y3 $xy2 $x5 $y5 $x5 $y5]
|
| 1054 |
+
$w.c delete I14$side
|
| 1055 |
+
$w.c create poly $zz -tag I14$side -smooth 1 -fill $color -outline $color \
|
| 1056 |
+
-width 3
|
| 1057 |
+
$w.c lower I14$side
|
| 1058 |
+
}
|
| 1059 |
+
proc Move14 {w {step {}}} {
|
| 1060 |
+
set step [GetStep 14 $step]
|
| 1061 |
+
|
| 1062 |
+
# Paper going down
|
| 1063 |
+
set sc [expr {.9 - .05*$step}]
|
| 1064 |
+
if {$sc < .3} {
|
| 1065 |
+
$w.c delete I14L
|
| 1066 |
+
return 0
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
lassign [$w.c coords I14L_0] Ox Oy
|
| 1070 |
+
$w.c scale I14L_0 $Ox $Oy $sc $sc
|
| 1071 |
+
lassign [lrange [$w.c coords I14L_1] end-1 end] Ox Oy
|
| 1072 |
+
$w.c scale I14L_1 $Ox $Oy $sc $sc
|
| 1073 |
+
Draw14a $w L
|
| 1074 |
+
|
| 1075 |
+
# Paper going up
|
| 1076 |
+
set sc [expr {.35 + .05*$step}]
|
| 1077 |
+
set sc [expr {1 / $sc}]
|
| 1078 |
+
|
| 1079 |
+
lassign [$w.c coords I14R_0] Ox Oy
|
| 1080 |
+
$w.c scale I14R_0 $Ox $Oy $sc $sc
|
| 1081 |
+
lassign [lrange [$w.c coords I14R_1] end-1 end] Ox Oy
|
| 1082 |
+
$w.c scale I14R_1 $Ox $Oy $sc $sc
|
| 1083 |
+
Draw14a $w R
|
| 1084 |
+
|
| 1085 |
+
return [expr {$step == 10 ? 3 : 1}]
|
| 1086 |
+
}
|
| 1087 |
+
|
| 1088 |
+
# Light beam
|
| 1089 |
+
proc Draw15 {w} {
|
| 1090 |
+
set color $::C(15a)
|
| 1091 |
+
set xy {824 599 824 585 820 585 829 585}
|
| 1092 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I15a
|
| 1093 |
+
set xy {789 599 836 643}
|
| 1094 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 3
|
| 1095 |
+
set xy {778 610 788 632}
|
| 1096 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 3
|
| 1097 |
+
set xy {766 617 776 625}
|
| 1098 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 3
|
| 1099 |
+
|
| 1100 |
+
set xy {633 600 681 640}
|
| 1101 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 3
|
| 1102 |
+
set xy {635 567 657 599}
|
| 1103 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 2
|
| 1104 |
+
set xy {765 557 784 583}
|
| 1105 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 2
|
| 1106 |
+
|
| 1107 |
+
Sine $w 658 580 765 580 3 15 -tag I15_s -fill $::C(fg) -width 3
|
| 1108 |
+
}
|
| 1109 |
+
proc Move15a {w} {
|
| 1110 |
+
set color $::C(15b)
|
| 1111 |
+
$w.c scale I15a 824 599 1 .3 ;# Button down
|
| 1112 |
+
set xy {765 621 681 621}
|
| 1113 |
+
$w.c create line $xy -dash "-" -width 3 -fill $color -tag I15
|
| 1114 |
+
}
|
| 1115 |
+
proc Move15 {w {step {}}} {
|
| 1116 |
+
set step [GetStep 15 $step]
|
| 1117 |
+
set numsteps 6
|
| 1118 |
+
|
| 1119 |
+
if {$step == $numsteps+2} {
|
| 1120 |
+
MoveAbs $w I15_star {-100 -100}
|
| 1121 |
+
return 2
|
| 1122 |
+
}
|
| 1123 |
+
if {$step == 0} { ;# Break the light beam
|
| 1124 |
+
Sparkle $w {-100 -100} I15_star
|
| 1125 |
+
set xy {765 621 745 621}
|
| 1126 |
+
$w.c coords I15 $xy
|
| 1127 |
+
return 1
|
| 1128 |
+
}
|
| 1129 |
+
lassign [Anchor $w I15_s w] x0 y0
|
| 1130 |
+
lassign [Anchor $w I15_s e] x1 y1
|
| 1131 |
+
set x [expr {$x0 + ($x1-$x0) * ($step - 1) / double($numsteps)}]
|
| 1132 |
+
MoveAbs $w I15_star [list $x $y0]
|
| 1133 |
+
return 1
|
| 1134 |
+
}
|
| 1135 |
+
|
| 1136 |
+
# Bell
|
| 1137 |
+
proc Draw16 {w} {
|
| 1138 |
+
set color $::C(16)
|
| 1139 |
+
set xy {722 485 791 556}
|
| 1140 |
+
$w.c create rect $xy -fill {} -outline $::C(fg) -width 3
|
| 1141 |
+
set xy [box 752 515 25] ;# Bell
|
| 1142 |
+
$w.c create oval $xy -fill $color -outline black -tag I16b -width 2
|
| 1143 |
+
set xy [box 752 515 5] ;# Bell button
|
| 1144 |
+
$w.c create oval $xy -fill black -outline black -tag I16b
|
| 1145 |
+
|
| 1146 |
+
set xy {784 523 764 549} ;# Clapper
|
| 1147 |
+
$w.c create line $xy -width 3 -tag I16c -fill $::C(fg)
|
| 1148 |
+
set xy [box 784 523 4]
|
| 1149 |
+
$w.c create oval $xy -fill $::C(fg) -outline $::C(fg) -tag I16d
|
| 1150 |
+
}
|
| 1151 |
+
proc Move16 {w {step {}}} {
|
| 1152 |
+
set step [GetStep 16 $step]
|
| 1153 |
+
|
| 1154 |
+
# Note: we never stop
|
| 1155 |
+
lassign {760 553} Ox Oy
|
| 1156 |
+
if {$step & 1} {
|
| 1157 |
+
set beta 12
|
| 1158 |
+
$w.c move I16b 3 0
|
| 1159 |
+
} else {
|
| 1160 |
+
set beta -12
|
| 1161 |
+
$w.c move I16b -3 0
|
| 1162 |
+
}
|
| 1163 |
+
RotateItem $w I16c $Ox $Oy $beta
|
| 1164 |
+
RotateItem $w I16d $Ox $Oy $beta
|
| 1165 |
+
|
| 1166 |
+
return [expr {$step == 1 ? 3 : 1}]
|
| 1167 |
+
}
|
| 1168 |
+
|
| 1169 |
+
# Cat
|
| 1170 |
+
proc Draw17 {w} {
|
| 1171 |
+
set color $::C(17)
|
| 1172 |
+
|
| 1173 |
+
set xy {584 556 722 556}
|
| 1174 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 1175 |
+
set xy {584 485 722 485}
|
| 1176 |
+
$w.c create line $xy -fill $::C(fg) -width 3
|
| 1177 |
+
|
| 1178 |
+
set xy {664 523 717 549} ;# Body
|
| 1179 |
+
$w.c create arc $xy -outline $::C(fg) -fill $color -width 3 \
|
| 1180 |
+
-style chord -start 128 -extent -260 -tag I17
|
| 1181 |
+
|
| 1182 |
+
set xy {709 554 690 543} ;# Paw
|
| 1183 |
+
$w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
|
| 1184 |
+
set xy {657 544 676 555}
|
| 1185 |
+
$w.c create oval $xy -outline $::C(fg) -fill $color -width 3 -tag I17
|
| 1186 |
+
|
| 1187 |
+
set xy [box 660 535 15] ;# Lower face
|
| 1188 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -style arc \
|
| 1189 |
+
-start 150 -extent 240 -tag I17_
|
| 1190 |
+
$w.c create arc $xy -outline {} -fill $color -width 1 -style chord \
|
| 1191 |
+
-start 150 -extent 240 -tag I17_
|
| 1192 |
+
set xy {674 529 670 513 662 521 658 521 650 513 647 529} ;# Ears
|
| 1193 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1194 |
+
$w.c create poly $xy -fill $color -outline {} -width 1 -tag {I17_ I17_c}
|
| 1195 |
+
set xy {652 542 628 539} ;# Whiskers
|
| 1196 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1197 |
+
set xy {652 543 632 545}
|
| 1198 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1199 |
+
set xy {652 546 632 552}
|
| 1200 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1201 |
+
|
| 1202 |
+
set xy {668 543 687 538}
|
| 1203 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
|
| 1204 |
+
set xy {668 544 688 546}
|
| 1205 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
|
| 1206 |
+
set xy {668 547 688 553}
|
| 1207 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag {I17_ I17w}
|
| 1208 |
+
|
| 1209 |
+
set xy {649 530 654 538 659 530} ;# Left eye
|
| 1210 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
|
| 1211 |
+
set xy {671 530 666 538 661 530} ;# Right eye
|
| 1212 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
|
| 1213 |
+
set xy {655 543 660 551 665 543} ;# Mouth
|
| 1214 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -smooth 1 -tag I17
|
| 1215 |
+
}
|
| 1216 |
+
proc Move17 {w {step {}}} {
|
| 1217 |
+
set step [GetStep 17 $step]
|
| 1218 |
+
|
| 1219 |
+
if {$step == 0} {
|
| 1220 |
+
$w.c delete I17 ;# Delete most of the cat
|
| 1221 |
+
set xy {655 543 660 535 665 543} ;# Mouth
|
| 1222 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
|
| 1223 |
+
set xy [box 654 530 4] ;# Left eye
|
| 1224 |
+
$w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
|
| 1225 |
+
set xy [box 666 530 4] ;# Right eye
|
| 1226 |
+
$w.c create oval $xy -outline $::C(fg) -width 3 -fill {} -tag I17_
|
| 1227 |
+
|
| 1228 |
+
$w.c move I17_ 0 -20 ;# Move face up
|
| 1229 |
+
set xy {652 528 652 554} ;# Front leg
|
| 1230 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1231 |
+
set xy {670 528 670 554} ;# 2nd front leg
|
| 1232 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1233 |
+
|
| 1234 |
+
set xy {
|
| 1235 |
+
675 506 694 489 715 513 715 513 715 513 716 525 716 525 716 525
|
| 1236 |
+
706 530 695 530 679 535 668 527 668 527 668 527 675 522 676 517
|
| 1237 |
+
677 512
|
| 1238 |
+
} ;# Body
|
| 1239 |
+
$w.c create poly $xy -fill [$w.c itemcget I17_c -fill] \
|
| 1240 |
+
-outline $::C(fg) -width 3 -smooth 1 -tag I17_
|
| 1241 |
+
set xy {716 514 716 554} ;# Back leg
|
| 1242 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1243 |
+
set xy {694 532 694 554} ;# 2nd back leg
|
| 1244 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I17_
|
| 1245 |
+
set xy {715 514 718 506 719 495 716 488};# Tail
|
| 1246 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -smooth 1 -tag I17_
|
| 1247 |
+
|
| 1248 |
+
$w.c raise I17w ;# Make whiskers visible
|
| 1249 |
+
$w.c move I17_ -5 0 ;# Move away from wall a bit
|
| 1250 |
+
return 2
|
| 1251 |
+
}
|
| 1252 |
+
return 0
|
| 1253 |
+
}
|
| 1254 |
+
|
| 1255 |
+
# Sling shot
|
| 1256 |
+
proc Draw18 {w} {
|
| 1257 |
+
set color $::C(18)
|
| 1258 |
+
set xy {721 506 627 506} ;# Sling hold
|
| 1259 |
+
$w.c create line $xy -width 4 -fill $::C(fg) -tag I18
|
| 1260 |
+
|
| 1261 |
+
set xy {607 500 628 513} ;# Sling rock
|
| 1262 |
+
$w.c create oval $xy -fill $color -outline {} -tag I18a
|
| 1263 |
+
|
| 1264 |
+
set xy {526 513 606 507 494 502} ;# Sling band
|
| 1265 |
+
$w.c create line $xy -fill $::C(fg) -width 4 -tag I18b
|
| 1266 |
+
set xy { 485 490 510 540 510 575 510 540 535 491 } ;# Sling
|
| 1267 |
+
$w.c create line $xy -fill $::C(fg) -width 6
|
| 1268 |
+
}
|
| 1269 |
+
proc Move18 {w {step {}}} {
|
| 1270 |
+
set step [GetStep 18 $step]
|
| 1271 |
+
|
| 1272 |
+
set pos {
|
| 1273 |
+
{587 506} {537 506} {466 506} {376 506} {266 506 x} {136 506}
|
| 1274 |
+
{16 506} {-100 -100}
|
| 1275 |
+
}
|
| 1276 |
+
|
| 1277 |
+
set b(0) {490 502 719 507 524 512} ;# Band collapsing
|
| 1278 |
+
set b(1) {
|
| 1279 |
+
491 503 524 557 563 505 559 496 546 506 551 525 553 536 538 534
|
| 1280 |
+
532 519 529 499
|
| 1281 |
+
}
|
| 1282 |
+
set b(2) {491 503 508 563 542 533 551 526 561 539 549 550 530 500}
|
| 1283 |
+
set b(3) {491 503 508 563 530 554 541 562 525 568 519 544 530 501}
|
| 1284 |
+
|
| 1285 |
+
if {$step >= [llength $pos]} {
|
| 1286 |
+
return 0
|
| 1287 |
+
}
|
| 1288 |
+
|
| 1289 |
+
if {$step == 0} {
|
| 1290 |
+
$w.c delete I18
|
| 1291 |
+
$w.c itemconfig I18b -smooth 1
|
| 1292 |
+
}
|
| 1293 |
+
if {[info exists b($step)]} {
|
| 1294 |
+
$w.c coords I18b $b($step)
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
+
set where [lindex $pos $step]
|
| 1298 |
+
MoveAbs $w I18a $where
|
| 1299 |
+
if {[lindex $where 2] eq "x"} {
|
| 1300 |
+
return 3
|
| 1301 |
+
}
|
| 1302 |
+
return 1
|
| 1303 |
+
}
|
| 1304 |
+
|
| 1305 |
+
# Water pipe
|
| 1306 |
+
proc Draw19 {w} {
|
| 1307 |
+
set color $::C(19)
|
| 1308 |
+
set xx {249 181 155 118 86 55 22 0}
|
| 1309 |
+
foreach {x1 x2} $xx {
|
| 1310 |
+
$w.c create rect $x1 453 $x2 467 -fill $color -outline {} -tag I19
|
| 1311 |
+
$w.c create line $x1 453 $x2 453 -fill $::C(fg) -width 1;# Pipe top
|
| 1312 |
+
$w.c create line $x1 467 $x2 467 -fill $::C(fg) -width 1;# Pipe bottom
|
| 1313 |
+
}
|
| 1314 |
+
$w.c raise I11i
|
| 1315 |
+
|
| 1316 |
+
set xy [box 168 460 16] ;# Bulge by the joint
|
| 1317 |
+
$w.c create oval $xy -fill $color -outline {}
|
| 1318 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
|
| 1319 |
+
-start 21 -extent 136
|
| 1320 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 -style arc \
|
| 1321 |
+
-start -21 -extent -130
|
| 1322 |
+
|
| 1323 |
+
set xy {249 447 255 473} ;# First joint 26x6
|
| 1324 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1325 |
+
|
| 1326 |
+
set xy [box 257 433 34] ;# Bend up
|
| 1327 |
+
$w.c create arc $xy -outline {} -fill $color -width 1 \
|
| 1328 |
+
-style pie -start 0 -extent -91
|
| 1329 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1330 |
+
-style arc -start 0 -extent -90
|
| 1331 |
+
set xy [box 257 433 20]
|
| 1332 |
+
$w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
|
| 1333 |
+
-style pie -start 0 -extent -92
|
| 1334 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1335 |
+
-style arc -start 0 -extent -90
|
| 1336 |
+
set xy [box 257 421 34] ;# Bend left
|
| 1337 |
+
$w.c create arc $xy -outline {} -fill $color -width 1 \
|
| 1338 |
+
-style pie -start 1 -extent 91
|
| 1339 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1340 |
+
-style arc -start 0 -extent 90
|
| 1341 |
+
set xy [box 257 421 20]
|
| 1342 |
+
$w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
|
| 1343 |
+
-style pie -start 0 -extent 90
|
| 1344 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1345 |
+
-style arc -start 0 -extent 90
|
| 1346 |
+
set xy [box 243 421 34] ;# Bend down
|
| 1347 |
+
$w.c create arc $xy -outline {} -fill $color -width 1 \
|
| 1348 |
+
-style pie -start 90 -extent 90
|
| 1349 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1350 |
+
-style arc -start 90 -extent 90
|
| 1351 |
+
set xy [box 243 421 20]
|
| 1352 |
+
$w.c create arc $xy -outline {} -fill $::C(bg) -width 1 \
|
| 1353 |
+
-style pie -start 90 -extent 90
|
| 1354 |
+
$w.c create arc $xy -outline $::C(fg) -width 1 \
|
| 1355 |
+
-style arc -start 90 -extent 90
|
| 1356 |
+
|
| 1357 |
+
set xy {270 427 296 433} ;# 2nd joint bottom
|
| 1358 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1359 |
+
set xy {270 421 296 427} ;# 2nd joint top
|
| 1360 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1361 |
+
set xy {249 382 255 408} ;# Third joint right
|
| 1362 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1363 |
+
set xy {243 382 249 408} ;# Third joint left
|
| 1364 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1365 |
+
set xy {203 420 229 426} ;# Last joint
|
| 1366 |
+
$w.c create rect $xy -fill $color -outline $::C(fg) -width 1
|
| 1367 |
+
|
| 1368 |
+
set xy [box 168 460 6] ;# Handle joint
|
| 1369 |
+
$w.c create oval $xy -fill $::C(fg) -outline {} -tag I19a
|
| 1370 |
+
set xy {168 460 168 512} ;# Handle bar
|
| 1371 |
+
$w.c create line $xy -fill $::C(fg) -width 5 -tag I19b
|
| 1372 |
+
}
|
| 1373 |
+
proc Move19 {w {step {}}} {
|
| 1374 |
+
set step [GetStep 19 $step]
|
| 1375 |
+
|
| 1376 |
+
set angles {30 30 30}
|
| 1377 |
+
if {$step == [llength $angles]} {
|
| 1378 |
+
return 2
|
| 1379 |
+
}
|
| 1380 |
+
|
| 1381 |
+
RotateItem $w I19b {*}[Centroid $w I19a] [lindex $angles $step]
|
| 1382 |
+
return 1
|
| 1383 |
+
}
|
| 1384 |
+
|
| 1385 |
+
# Water pouring
|
| 1386 |
+
proc Draw20 {w} {
|
| 1387 |
+
}
|
| 1388 |
+
proc Move20 {w {step {}}} {
|
| 1389 |
+
set step [GetStep 20 $step]
|
| 1390 |
+
|
| 1391 |
+
set pos {451 462 473 484 496 504 513 523 532}
|
| 1392 |
+
set freq {20 40 40 40 40 40 40 40 40}
|
| 1393 |
+
set pos {
|
| 1394 |
+
{451 20} {462 40} {473 40} {484 40} {496 40} {504 40} {513 40}
|
| 1395 |
+
{523 40} {532 40 x}
|
| 1396 |
+
}
|
| 1397 |
+
if {$step >= [llength $pos]} {
|
| 1398 |
+
return 0
|
| 1399 |
+
}
|
| 1400 |
+
|
| 1401 |
+
$w.c delete I20
|
| 1402 |
+
set where [lindex $pos $step]
|
| 1403 |
+
lassign $where y f
|
| 1404 |
+
H2O $w $y $f
|
| 1405 |
+
if {[lindex $where 2] eq "x"} {
|
| 1406 |
+
return 3
|
| 1407 |
+
}
|
| 1408 |
+
return 1
|
| 1409 |
+
}
|
| 1410 |
+
proc H2O {w y f} {
|
| 1411 |
+
set color $::C(20)
|
| 1412 |
+
$w.c delete I20
|
| 1413 |
+
|
| 1414 |
+
Sine $w 208 428 208 $y 4 $f -tag {I20 I20s} -width 3 -fill $color \
|
| 1415 |
+
-smooth 1
|
| 1416 |
+
$w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
|
| 1417 |
+
-tag {I20 I20a}
|
| 1418 |
+
$w.c create line [$w.c coords I20s] -width 3 -fill $color -smooth 1 \
|
| 1419 |
+
-tag {I20 I20b}
|
| 1420 |
+
$w.c move I20a 8 0
|
| 1421 |
+
$w.c move I20b 16 0
|
| 1422 |
+
}
|
| 1423 |
+
|
| 1424 |
+
# Bucket
|
| 1425 |
+
proc Draw21 {w} {
|
| 1426 |
+
set color $::C(21)
|
| 1427 |
+
set xy {217 451 244 490} ;# Right handle
|
| 1428 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
|
| 1429 |
+
set xy {201 467 182 490} ;# Left handle
|
| 1430 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -tag I21_a
|
| 1431 |
+
|
| 1432 |
+
set xy {245 490 237 535} ;# Right side
|
| 1433 |
+
set xy2 {189 535 181 490} ;# Left side
|
| 1434 |
+
$w.c create poly [concat $xy $xy2] -fill $color -outline {} \
|
| 1435 |
+
-tag {I21 I21f}
|
| 1436 |
+
$w.c create line $xy -fill $::C(fg) -width 2 -tag I21
|
| 1437 |
+
$w.c create line $xy2 -fill $::C(fg) -width 2 -tag I21
|
| 1438 |
+
|
| 1439 |
+
set xy {182 486 244 498} ;# Top
|
| 1440 |
+
$w.c create oval $xy -fill $color -outline {} -width 2 -tag {I21 I21f}
|
| 1441 |
+
$w.c create oval $xy -fill {} -outline $::C(fg) -width 2 -tag {I21 I21t}
|
| 1442 |
+
set xy {189 532 237 540} ;# Bottom
|
| 1443 |
+
$w.c create oval $xy -fill $color -outline $::C(fg) -width 2 \
|
| 1444 |
+
-tag {I21 I21b}
|
| 1445 |
+
}
|
| 1446 |
+
proc Move21 {w {step {}}} {
|
| 1447 |
+
set step [GetStep 21 $step]
|
| 1448 |
+
|
| 1449 |
+
set numsteps 30
|
| 1450 |
+
if {$step >= $numsteps} {
|
| 1451 |
+
return 0
|
| 1452 |
+
}
|
| 1453 |
+
|
| 1454 |
+
lassign [$w.c coords I21b] x1 y1 x2 y2
|
| 1455 |
+
#lassign [$w.c coords I21t] X1 Y1 X2 Y2
|
| 1456 |
+
lassign {183 492 243 504} X1 Y1 X2 Y2
|
| 1457 |
+
|
| 1458 |
+
set f [expr {$step / double($numsteps)}]
|
| 1459 |
+
set y2 [expr {$y2 - 3}]
|
| 1460 |
+
set xx1 [expr {$x1 + ($X1 - $x1) * $f}]
|
| 1461 |
+
set yy1 [expr {$y1 + ($Y1 - $y1) * $f}]
|
| 1462 |
+
set xx2 [expr {$x2 + ($X2 - $x2) * $f}]
|
| 1463 |
+
set yy2 [expr {$y2 + ($Y2 - $y2) * $f}]
|
| 1464 |
+
#H2O $w $yy1 40
|
| 1465 |
+
|
| 1466 |
+
$w.c itemconfig I21b -fill $::C(20)
|
| 1467 |
+
$w.c delete I21w
|
| 1468 |
+
$w.c create poly $x2 $y2 $x1 $y1 $xx1 $yy1 $xx2 $yy1 -tag {I21 I21w} \
|
| 1469 |
+
-outline {} -fill $::C(20)
|
| 1470 |
+
$w.c lower I21w I21
|
| 1471 |
+
$w.c raise I21b
|
| 1472 |
+
$w.c lower I21f
|
| 1473 |
+
|
| 1474 |
+
return [expr {$step == $numsteps-1 ? 3 : 1}]
|
| 1475 |
+
}
|
| 1476 |
+
|
| 1477 |
+
# Bucket drop
|
| 1478 |
+
proc Draw22 {w} {
|
| 1479 |
+
}
|
| 1480 |
+
proc Move22 {w {step {}}} {
|
| 1481 |
+
set step [GetStep 22 $step]
|
| 1482 |
+
set pos {{213 513} {213 523} {213 543 x} {213 583} {213 593}}
|
| 1483 |
+
|
| 1484 |
+
if {$step == 0} {$w.c itemconfig I21f -fill $::C(22)}
|
| 1485 |
+
if {$step >= [llength $pos]} {
|
| 1486 |
+
return 0
|
| 1487 |
+
}
|
| 1488 |
+
set where [lindex $pos $step]
|
| 1489 |
+
MoveAbs $w I21 $where
|
| 1490 |
+
H2O $w [lindex $where 1] 40
|
| 1491 |
+
$w.c delete I21_a ;# Delete handles
|
| 1492 |
+
|
| 1493 |
+
if {[lindex $where 2] eq "x"} {
|
| 1494 |
+
return 3
|
| 1495 |
+
}
|
| 1496 |
+
return 1
|
| 1497 |
+
}
|
| 1498 |
+
|
| 1499 |
+
# Blow dart
|
| 1500 |
+
proc Draw23 {w} {
|
| 1501 |
+
set color $::C(23a)
|
| 1502 |
+
set color2 $::C(23b)
|
| 1503 |
+
set color3 $::C(23c)
|
| 1504 |
+
|
| 1505 |
+
set xy {185 623 253 650} ;# Block
|
| 1506 |
+
$w.c create rect $xy -fill black -outline $::C(fg) -width 2 -tag I23a
|
| 1507 |
+
set xy {187 592 241 623} ;# Balloon
|
| 1508 |
+
$w.c create oval $xy -outline {} -fill $color -tag I23b
|
| 1509 |
+
$w.c create arc $xy -outline $::C(fg) -width 3 -tag I23b \
|
| 1510 |
+
-style arc -start 12 -extent 336
|
| 1511 |
+
set xy {239 604 258 589 258 625 239 610} ;# Balloon nozzle
|
| 1512 |
+
$w.c create poly $xy -outline {} -fill $color -tag I23b
|
| 1513 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I23b
|
| 1514 |
+
|
| 1515 |
+
set xy {285 611 250 603} ;# Dart body
|
| 1516 |
+
$w.c create oval $xy -fill $color2 -outline $::C(fg) -width 3 -tag I23d
|
| 1517 |
+
set xy {249 596 249 618 264 607 249 596} ;# Dart tail
|
| 1518 |
+
$w.c create poly $xy -fill $color3 -outline $::C(fg) -width 3 -tag I23d
|
| 1519 |
+
set xy {249 607 268 607} ;# Dart detail
|
| 1520 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
|
| 1521 |
+
set xy {285 607 305 607} ;# Dart needle
|
| 1522 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I23d
|
| 1523 |
+
}
|
| 1524 |
+
proc Move23 {w {step {}}} {
|
| 1525 |
+
set step [GetStep 23 $step]
|
| 1526 |
+
|
| 1527 |
+
set pos {
|
| 1528 |
+
{277 607} {287 607} {307 607 x} {347 607} {407 607} {487 607}
|
| 1529 |
+
{587 607} {687 607} {787 607} {-100 -100}
|
| 1530 |
+
}
|
| 1531 |
+
|
| 1532 |
+
if {$step >= [llength $pos]} {
|
| 1533 |
+
return 0
|
| 1534 |
+
}
|
| 1535 |
+
if {$step <= 1} {
|
| 1536 |
+
$w.c scale I23b {*}[Anchor $w I23a n] .9 .5
|
| 1537 |
+
}
|
| 1538 |
+
set where [lindex $pos $step]
|
| 1539 |
+
MoveAbs $w I23d $where
|
| 1540 |
+
|
| 1541 |
+
if {[lindex $where 2] eq "x"} {
|
| 1542 |
+
return 3
|
| 1543 |
+
}
|
| 1544 |
+
return 1
|
| 1545 |
+
}
|
| 1546 |
+
|
| 1547 |
+
# Balloon
|
| 1548 |
+
proc Draw24 {w} {
|
| 1549 |
+
set color $::C(24a)
|
| 1550 |
+
set xy {366 518 462 665} ;# Balloon
|
| 1551 |
+
$w.c create oval $xy -fill $color -outline $::C(fg) -width 3 -tag I24
|
| 1552 |
+
set xy {414 666 414 729} ;# String
|
| 1553 |
+
$w.c create line $xy -fill $::C(fg) -width 3 -tag I24
|
| 1554 |
+
set xy {410 666 404 673 422 673 418 666} ;# Nozzle
|
| 1555 |
+
$w.c create poly $xy -fill $color -outline $::C(fg) -width 3 -tag I24
|
| 1556 |
+
|
| 1557 |
+
set xy {387 567 390 549 404 542} ;# Reflections
|
| 1558 |
+
$w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
|
| 1559 |
+
set xy {395 568 399 554 413 547}
|
| 1560 |
+
$w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
|
| 1561 |
+
set xy {403 570 396 555 381 553}
|
| 1562 |
+
$w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
|
| 1563 |
+
set xy {408 564 402 547 386 545}
|
| 1564 |
+
$w.c create line $xy -fill $::C(fg) -smooth 1 -width 2 -tag I24
|
| 1565 |
+
}
|
| 1566 |
+
proc Move24 {w {step {}}} {
|
| 1567 |
+
global S
|
| 1568 |
+
set step [GetStep 24 $step]
|
| 1569 |
+
|
| 1570 |
+
if {$step > 4} {
|
| 1571 |
+
return 0
|
| 1572 |
+
} elseif {$step == 4} {
|
| 1573 |
+
return 2
|
| 1574 |
+
}
|
| 1575 |
+
|
| 1576 |
+
if {$step == 0} {
|
| 1577 |
+
$w.c delete I24 ;# Exploding balloon
|
| 1578 |
+
set xy {
|
| 1579 |
+
347 465 361 557 271 503 272 503 342 574 259 594 259 593 362 626
|
| 1580 |
+
320 737 320 740 398 691 436 738 436 739 476 679 528 701 527 702
|
| 1581 |
+
494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508
|
| 1582 |
+
431 441 431 440 400 502 347 465 347 465
|
| 1583 |
+
}
|
| 1584 |
+
$w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \
|
| 1585 |
+
-width 10 -smooth 1
|
| 1586 |
+
set msg [subst $S(message)]
|
| 1587 |
+
$w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \
|
| 1588 |
+
-fill $::C(24c) \
|
| 1589 |
+
-justify center -font {{Times Roman} 18 bold}
|
| 1590 |
+
return 1
|
| 1591 |
+
}
|
| 1592 |
+
|
| 1593 |
+
$w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold]
|
| 1594 |
+
$w.c move I24 0 -60
|
| 1595 |
+
$w.c scale I24 {*}[Centroid $w I24] 1.25 1.25
|
| 1596 |
+
return 1
|
| 1597 |
+
}
|
| 1598 |
+
|
| 1599 |
+
# Displaying the message
|
| 1600 |
+
proc Move25 {w {step {}}} {
|
| 1601 |
+
global S
|
| 1602 |
+
set step [GetStep 25 $step]
|
| 1603 |
+
if {$step == 0} {
|
| 1604 |
+
set ::XY(25) [clock clicks -milliseconds]
|
| 1605 |
+
return 1
|
| 1606 |
+
}
|
| 1607 |
+
set elapsed [expr {[clock clicks -milliseconds] - $::XY(25)}]
|
| 1608 |
+
if {$elapsed < 5000} {
|
| 1609 |
+
return 1
|
| 1610 |
+
}
|
| 1611 |
+
return 2
|
| 1612 |
+
}
|
| 1613 |
+
|
| 1614 |
+
# Collapsing balloon
|
| 1615 |
+
proc Move26 {w {step {}}} {
|
| 1616 |
+
global S
|
| 1617 |
+
set step [GetStep 26 $step]
|
| 1618 |
+
|
| 1619 |
+
if {$step >= 3} {
|
| 1620 |
+
$w.c delete I24 I26
|
| 1621 |
+
$w.c create text 430 755 -anchor s -tag I26 \
|
| 1622 |
+
-fill $::C(26) \
|
| 1623 |
+
-text "click to continue" -font {{Times Roman} 24 bold}
|
| 1624 |
+
bind $w.c <Button-1> [list Reset $w]
|
| 1625 |
+
return 4
|
| 1626 |
+
}
|
| 1627 |
+
|
| 1628 |
+
$w.c scale I24 {*}[Centroid $w I24] .8 .8
|
| 1629 |
+
$w.c move I24 0 60
|
| 1630 |
+
$w.c itemconfig I24t -font [list {Times Roman} [expr {30 - 6*$step}] bold]
|
| 1631 |
+
return 1
|
| 1632 |
+
}
|
| 1633 |
+
|
| 1634 |
+
################################################################
|
| 1635 |
+
#
|
| 1636 |
+
# Helper functions
|
| 1637 |
+
#
|
| 1638 |
+
|
| 1639 |
+
proc box {x y r} {
|
| 1640 |
+
return [list [expr {$x-$r}] [expr {$y-$r}] [expr {$x+$r}] [expr {$y+$r}]]
|
| 1641 |
+
}
|
| 1642 |
+
|
| 1643 |
+
proc MoveAbs {w item xy} {
|
| 1644 |
+
lassign $xy x y
|
| 1645 |
+
lassign [Centroid $w $item] Ox Oy
|
| 1646 |
+
set dx [expr {$x - $Ox}]
|
| 1647 |
+
set dy [expr {$y - $Oy}]
|
| 1648 |
+
$w.c move $item $dx $dy
|
| 1649 |
+
}
|
| 1650 |
+
|
| 1651 |
+
proc RotateItem {w item Ox Oy beta} {
|
| 1652 |
+
set xy [$w.c coords $item]
|
| 1653 |
+
set xy2 {}
|
| 1654 |
+
foreach {x y} $xy {
|
| 1655 |
+
lappend xy2 {*}[RotateC $x $y $Ox $Oy $beta]
|
| 1656 |
+
}
|
| 1657 |
+
$w.c coords $item $xy2
|
| 1658 |
+
}
|
| 1659 |
+
|
| 1660 |
+
proc RotateC {x y Ox Oy beta} {
|
| 1661 |
+
# rotates vector (Ox,Oy)->(x,y) by beta degrees clockwise
|
| 1662 |
+
|
| 1663 |
+
set x [expr {$x - $Ox}] ;# Shift to origin
|
| 1664 |
+
set y [expr {$y - $Oy}]
|
| 1665 |
+
|
| 1666 |
+
set beta [expr {$beta * atan(1) * 4 / 180.0}] ;# Radians
|
| 1667 |
+
set xx [expr {$x * cos($beta) - $y * sin($beta)}] ;# Rotate
|
| 1668 |
+
set yy [expr {$x * sin($beta) + $y * cos($beta)}]
|
| 1669 |
+
|
| 1670 |
+
set xx [expr {$xx + $Ox}] ;# Shift back
|
| 1671 |
+
set yy [expr {$yy + $Oy}]
|
| 1672 |
+
|
| 1673 |
+
return [list $xx $yy]
|
| 1674 |
+
}
|
| 1675 |
+
|
| 1676 |
+
proc Reset {w} {
|
| 1677 |
+
global S
|
| 1678 |
+
DrawAll $w
|
| 1679 |
+
bind $w.c <Button-1> {}
|
| 1680 |
+
set S(mode) $::MSTART
|
| 1681 |
+
set S(active) 0
|
| 1682 |
+
}
|
| 1683 |
+
|
| 1684 |
+
# Each Move## keeps its state info in STEP, this retrieves and increments it
|
| 1685 |
+
proc GetStep {who step} {
|
| 1686 |
+
global STEP
|
| 1687 |
+
if {$step ne ""} {
|
| 1688 |
+
set STEP($who) $step
|
| 1689 |
+
} elseif {![info exists STEP($who)] || $STEP($who) eq ""} {
|
| 1690 |
+
set STEP($who) 0
|
| 1691 |
+
} else {
|
| 1692 |
+
incr STEP($who)
|
| 1693 |
+
}
|
| 1694 |
+
return $STEP($who)
|
| 1695 |
+
}
|
| 1696 |
+
|
| 1697 |
+
proc ResetStep {} {
|
| 1698 |
+
global STEP
|
| 1699 |
+
set ::S(cnt) 0
|
| 1700 |
+
foreach a [array names STEP] {
|
| 1701 |
+
set STEP($a) ""
|
| 1702 |
+
}
|
| 1703 |
+
}
|
| 1704 |
+
|
| 1705 |
+
proc Sine {w x0 y0 x1 y1 amp freq args} {
|
| 1706 |
+
set PI [expr {4 * atan(1)}]
|
| 1707 |
+
set step 2
|
| 1708 |
+
set xy {}
|
| 1709 |
+
if {$y0 == $y1} { ;# Horizontal
|
| 1710 |
+
for {set x $x0} {$x <= $x1} {incr x $step} {
|
| 1711 |
+
set beta [expr {($x - $x0) * 2 * $PI / $freq}]
|
| 1712 |
+
set y [expr {$y0 + $amp * sin($beta)}]
|
| 1713 |
+
lappend xy $x $y
|
| 1714 |
+
}
|
| 1715 |
+
} else {
|
| 1716 |
+
for {set y $y0} {$y <= $y1} {incr y $step} {
|
| 1717 |
+
set beta [expr {($y - $y0) * 2 * $PI / $freq}]
|
| 1718 |
+
set x [expr {$x0 + $amp * sin($beta)}]
|
| 1719 |
+
lappend xy $x $y
|
| 1720 |
+
}
|
| 1721 |
+
}
|
| 1722 |
+
return [$w.c create line $xy {*}$args]
|
| 1723 |
+
}
|
| 1724 |
+
|
| 1725 |
+
proc RoundRect {w xy radius args} {
|
| 1726 |
+
lassign $xy x0 y0 x3 y3
|
| 1727 |
+
set r [winfo pixels $w.c $radius]
|
| 1728 |
+
set d [expr {2 * $r}]
|
| 1729 |
+
|
| 1730 |
+
# Make sure that the radius of the curve is less than 3/8 size of the box!
|
| 1731 |
+
set maxr 0.75
|
| 1732 |
+
if {$d > $maxr * ($x3 - $x0)} {
|
| 1733 |
+
set d [expr {$maxr * ($x3 - $x0)}]
|
| 1734 |
+
}
|
| 1735 |
+
if {$d > $maxr * ($y3 - $y0)} {
|
| 1736 |
+
set d [expr {$maxr * ($y3 - $y0)}]
|
| 1737 |
+
}
|
| 1738 |
+
|
| 1739 |
+
set x1 [expr { $x0 + $d }]
|
| 1740 |
+
set x2 [expr { $x3 - $d }]
|
| 1741 |
+
set y1 [expr { $y0 + $d }]
|
| 1742 |
+
set y2 [expr { $y3 - $d }]
|
| 1743 |
+
|
| 1744 |
+
set xy [list $x0 $y0 $x1 $y0 $x2 $y0 $x3 $y0 $x3 $y1 $x3 $y2]
|
| 1745 |
+
lappend xy $x3 $y3 $x2 $y3 $x1 $y3 $x0 $y3 $x0 $y2 $x0 $y1
|
| 1746 |
+
return $xy
|
| 1747 |
+
}
|
| 1748 |
+
|
| 1749 |
+
proc RoundPoly {canv xy radii args} {
|
| 1750 |
+
set lenXY [llength $xy]
|
| 1751 |
+
set lenR [llength $radii]
|
| 1752 |
+
if {$lenXY != 2*$lenR} {
|
| 1753 |
+
error "wrong number of vertices and radii"
|
| 1754 |
+
}
|
| 1755 |
+
|
| 1756 |
+
set knots {}
|
| 1757 |
+
lassign [lrange $xy end-1 end] x0 y0
|
| 1758 |
+
lassign $xy x1 y1
|
| 1759 |
+
lappend xy {*}[lrange $xy 0 1]
|
| 1760 |
+
|
| 1761 |
+
for {set i 0} {$i < $lenXY} {incr i 2} {
|
| 1762 |
+
set radius [lindex $radii [expr {$i/2}]]
|
| 1763 |
+
set r [winfo pixels $canv $radius]
|
| 1764 |
+
|
| 1765 |
+
lassign [lrange $xy [expr {$i + 2}] [expr {$i + 3}]] x2 y2
|
| 1766 |
+
set z [_RoundPoly2 $x0 $y0 $x1 $y1 $x2 $y2 $r]
|
| 1767 |
+
lappend knots {*}$z
|
| 1768 |
+
|
| 1769 |
+
lassign [list $x1 $y1] x0 y0
|
| 1770 |
+
lassign [list $x2 $y2] x1 y1
|
| 1771 |
+
}
|
| 1772 |
+
set n [$canv create polygon $knots -smooth 1 {*}$args]
|
| 1773 |
+
return $n
|
| 1774 |
+
}
|
| 1775 |
+
|
| 1776 |
+
proc _RoundPoly2 {x0 y0 x1 y1 x2 y2 radius} {
|
| 1777 |
+
set d [expr {2 * $radius}]
|
| 1778 |
+
set maxr 0.75
|
| 1779 |
+
|
| 1780 |
+
set v1x [expr {$x0 - $x1}]
|
| 1781 |
+
set v1y [expr {$y0 - $y1}]
|
| 1782 |
+
set v2x [expr {$x2 - $x1}]
|
| 1783 |
+
set v2y [expr {$y2 - $y1}]
|
| 1784 |
+
|
| 1785 |
+
set vlen1 [expr {sqrt($v1x*$v1x + $v1y*$v1y)}]
|
| 1786 |
+
set vlen2 [expr {sqrt($v2x*$v2x + $v2y*$v2y)}]
|
| 1787 |
+
if {$d > $maxr * $vlen1} {
|
| 1788 |
+
set d [expr {$maxr * $vlen1}]
|
| 1789 |
+
}
|
| 1790 |
+
if {$d > $maxr * $vlen2} {
|
| 1791 |
+
set d [expr {$maxr * $vlen2}]
|
| 1792 |
+
}
|
| 1793 |
+
|
| 1794 |
+
lappend xy [expr {$x1 + $d * $v1x/$vlen1}] [expr {$y1 + $d * $v1y/$vlen1}]
|
| 1795 |
+
lappend xy $x1 $y1
|
| 1796 |
+
lappend xy [expr {$x1 + $d * $v2x/$vlen2}] [expr {$y1 + $d * $v2y/$vlen2}]
|
| 1797 |
+
|
| 1798 |
+
return $xy
|
| 1799 |
+
}
|
| 1800 |
+
|
| 1801 |
+
proc Sparkle {w Oxy tag} {
|
| 1802 |
+
set xy {299 283 298 302 295 314 271 331 239 310 242 292 256 274 281 273}
|
| 1803 |
+
foreach {x y} $xy {
|
| 1804 |
+
$w.c create line 271 304 $x $y -fill white -width 3 -tag $tag
|
| 1805 |
+
}
|
| 1806 |
+
MoveAbs $w $tag $Oxy
|
| 1807 |
+
}
|
| 1808 |
+
|
| 1809 |
+
proc Centroid {w item} {
|
| 1810 |
+
return [Anchor $w $item c]
|
| 1811 |
+
}
|
| 1812 |
+
|
| 1813 |
+
proc Anchor {w item where} {
|
| 1814 |
+
lassign [$w.c bbox $item] x1 y1 x2 y2
|
| 1815 |
+
if {[string match *n* $where]} {
|
| 1816 |
+
set y $y1
|
| 1817 |
+
} elseif {[string match *s* $where]} {
|
| 1818 |
+
set y $y2
|
| 1819 |
+
} else {
|
| 1820 |
+
set y [expr {($y1 + $y2) / 2.0}]
|
| 1821 |
+
}
|
| 1822 |
+
if {[string match *w* $where]} {
|
| 1823 |
+
set x $x1
|
| 1824 |
+
} elseif {[string match *e* $where]} {
|
| 1825 |
+
set x $x2
|
| 1826 |
+
} else {
|
| 1827 |
+
set x [expr {($x1 + $x2) / 2.0}]
|
| 1828 |
+
}
|
| 1829 |
+
return [list $x $y]
|
| 1830 |
+
}
|
| 1831 |
+
|
| 1832 |
+
DoDisplay $w
|
| 1833 |
+
Reset $w
|
| 1834 |
+
Go $w ;# Start everything going
|
parrot/lib/tk8.6/demos/icon.tcl
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# icon.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a toplevel window containing
|
| 4 |
+
# buttons that display bitmaps instead of text.
|
| 5 |
+
|
| 6 |
+
if {![info exists widgetDemo]} {
|
| 7 |
+
error "This script should be run from the \"widget\" demo."
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
package require Tk
|
| 11 |
+
|
| 12 |
+
set w .icon
|
| 13 |
+
catch {destroy $w}
|
| 14 |
+
toplevel $w
|
| 15 |
+
wm title $w "Iconic Button Demonstration"
|
| 16 |
+
wm iconname $w "icon"
|
| 17 |
+
positionWindow $w
|
| 18 |
+
|
| 19 |
+
label $w.msg -font $font -wraplength 5i -justify left -text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected."
|
| 20 |
+
pack $w.msg -side top
|
| 21 |
+
|
| 22 |
+
## See Code / Dismiss buttons
|
| 23 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 24 |
+
pack $btns -side bottom -fill x
|
| 25 |
+
|
| 26 |
+
# Main widget program sets variable tk_demoDirectory
|
| 27 |
+
image create bitmap flagup \
|
| 28 |
+
-file [file join $tk_demoDirectory images flagup.xbm] \
|
| 29 |
+
-maskfile [file join $tk_demoDirectory images flagup.xbm]
|
| 30 |
+
image create bitmap flagdown \
|
| 31 |
+
-file [file join $tk_demoDirectory images flagdown.xbm] \
|
| 32 |
+
-maskfile [file join $tk_demoDirectory images flagdown.xbm]
|
| 33 |
+
frame $w.frame -borderwidth 10
|
| 34 |
+
pack $w.frame -side top
|
| 35 |
+
|
| 36 |
+
checkbutton $w.frame.b1 -image flagdown -selectimage flagup \
|
| 37 |
+
-indicatoron 0
|
| 38 |
+
$w.frame.b1 configure -selectcolor [$w.frame.b1 cget -background]
|
| 39 |
+
checkbutton $w.frame.b2 \
|
| 40 |
+
-bitmap @[file join $tk_demoDirectory images letters.xbm] \
|
| 41 |
+
-indicatoron 0 -selectcolor SeaGreen1
|
| 42 |
+
frame $w.frame.left
|
| 43 |
+
pack $w.frame.left $w.frame.b1 $w.frame.b2 -side left -expand yes -padx 5m
|
| 44 |
+
|
| 45 |
+
radiobutton $w.frame.left.b3 \
|
| 46 |
+
-bitmap @[file join $tk_demoDirectory images letters.xbm] \
|
| 47 |
+
-variable letters -value full
|
| 48 |
+
radiobutton $w.frame.left.b4 \
|
| 49 |
+
-bitmap @[file join $tk_demoDirectory images noletter.xbm] \
|
| 50 |
+
-variable letters -value empty
|
| 51 |
+
pack $w.frame.left.b3 $w.frame.left.b4 -side top -expand yes
|
parrot/lib/tk8.6/demos/image2.tcl
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# image2.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a simple collection of widgets
|
| 4 |
+
# that allow you to select and view images in a Tk label.
|
| 5 |
+
|
| 6 |
+
if {![info exists widgetDemo]} {
|
| 7 |
+
error "This script should be run from the \"widget\" demo."
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
package require Tk
|
| 11 |
+
|
| 12 |
+
# loadDir --
|
| 13 |
+
# This procedure reloads the directory listbox from the directory
|
| 14 |
+
# named in the demo's entry.
|
| 15 |
+
#
|
| 16 |
+
# Arguments:
|
| 17 |
+
# w - Name of the toplevel window of the demo.
|
| 18 |
+
|
| 19 |
+
proc loadDir w {
|
| 20 |
+
global dirName
|
| 21 |
+
|
| 22 |
+
$w.f.list delete 0 end
|
| 23 |
+
foreach i [lsort [glob -type f -directory $dirName *]] {
|
| 24 |
+
$w.f.list insert end [file tail $i]
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
# selectAndLoadDir --
|
| 29 |
+
# This procedure pops up a dialog to ask for a directory to load into
|
| 30 |
+
# the listobx and (if the user presses OK) reloads the directory
|
| 31 |
+
# listbox from the directory named in the demo's entry.
|
| 32 |
+
#
|
| 33 |
+
# Arguments:
|
| 34 |
+
# w - Name of the toplevel window of the demo.
|
| 35 |
+
|
| 36 |
+
proc selectAndLoadDir w {
|
| 37 |
+
global dirName
|
| 38 |
+
set dir [tk_chooseDirectory -initialdir $dirName -parent $w -mustexist 1]
|
| 39 |
+
if {$dir ne ""} {
|
| 40 |
+
set dirName $dir
|
| 41 |
+
loadDir $w
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
# loadImage --
|
| 46 |
+
# Given the name of the toplevel window of the demo and the mouse
|
| 47 |
+
# position, extracts the directory entry under the mouse and loads
|
| 48 |
+
# that file into a photo image for display.
|
| 49 |
+
#
|
| 50 |
+
# Arguments:
|
| 51 |
+
# w - Name of the toplevel window of the demo.
|
| 52 |
+
# x, y- Mouse position within the listbox.
|
| 53 |
+
|
| 54 |
+
proc loadImage {w x y} {
|
| 55 |
+
global dirName
|
| 56 |
+
|
| 57 |
+
set file [file join $dirName [$w.f.list get @$x,$y]]
|
| 58 |
+
if {[catch {
|
| 59 |
+
image2a configure -file $file
|
| 60 |
+
}]} then {
|
| 61 |
+
# Mark the file as not loadable
|
| 62 |
+
$w.f.list itemconfigure @$x,$y -bg \#c00000 -selectbackground \#ff0000
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
set w .image2
|
| 67 |
+
catch {destroy $w}
|
| 68 |
+
toplevel $w
|
| 69 |
+
wm title $w "Image Demonstration #2"
|
| 70 |
+
wm iconname $w "Image2"
|
| 71 |
+
positionWindow $w
|
| 72 |
+
|
| 73 |
+
label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then type Return to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
|
| 74 |
+
pack $w.msg -side top
|
| 75 |
+
|
| 76 |
+
## See Code / Dismiss buttons
|
| 77 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 78 |
+
pack $btns -side bottom -fill x
|
| 79 |
+
|
| 80 |
+
frame $w.mid
|
| 81 |
+
pack $w.mid -fill both -expand 1
|
| 82 |
+
|
| 83 |
+
labelframe $w.dir -text "Directory:"
|
| 84 |
+
# Main widget program sets variable tk_demoDirectory
|
| 85 |
+
set dirName [file join $tk_demoDirectory images]
|
| 86 |
+
entry $w.dir.e -width 30 -textvariable dirName
|
| 87 |
+
button $w.dir.b -pady 0 -padx 2m -text "Select Dir." \
|
| 88 |
+
-command "selectAndLoadDir $w"
|
| 89 |
+
bind $w.dir.e <Return> "loadDir $w"
|
| 90 |
+
pack $w.dir.e -side left -fill both -padx 2m -pady 2m -expand true
|
| 91 |
+
pack $w.dir.b -side left -fill y -padx {0 2m} -pady 2m
|
| 92 |
+
labelframe $w.f -text "File:" -padx 2m -pady 2m
|
| 93 |
+
|
| 94 |
+
listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set"
|
| 95 |
+
ttk::scrollbar $w.f.scroll -command "$w.f.list yview"
|
| 96 |
+
pack $w.f.list $w.f.scroll -side left -fill y -expand 1
|
| 97 |
+
$w.f.list insert 0 earth.gif earthris.gif teapot.ppm
|
| 98 |
+
bind $w.f.list <Double-Button-1> "loadImage $w %x %y"
|
| 99 |
+
|
| 100 |
+
catch {image delete image2a}
|
| 101 |
+
image create photo image2a
|
| 102 |
+
labelframe $w.image -text "Image:"
|
| 103 |
+
label $w.image.image -image image2a
|
| 104 |
+
pack $w.image.image -padx 2m -pady 2m
|
| 105 |
+
|
| 106 |
+
grid $w.dir - -sticky ew -padx 1m -pady 1m -in $w.mid
|
| 107 |
+
grid $w.f $w.image -sticky nw -padx 1m -pady 1m -in $w.mid
|
| 108 |
+
grid columnconfigure $w.mid 1 -weight 1
|
parrot/lib/tk8.6/demos/pendulum.tcl
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pendulum.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration illustrates how Tcl/Tk can be used to construct
|
| 4 |
+
# simulations of physical systems.
|
| 5 |
+
|
| 6 |
+
if {![info exists widgetDemo]} {
|
| 7 |
+
error "This script should be run from the \"widget\" demo."
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
package require Tk
|
| 11 |
+
|
| 12 |
+
set w .pendulum
|
| 13 |
+
catch {destroy $w}
|
| 14 |
+
toplevel $w
|
| 15 |
+
wm title $w "Pendulum Animation Demonstration"
|
| 16 |
+
wm iconname $w "pendulum"
|
| 17 |
+
positionWindow $w
|
| 18 |
+
|
| 19 |
+
label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows how Tcl/Tk can be used to carry out animations that are linked to simulations of physical systems. In the left canvas is a graphical representation of the physical system itself, a simple pendulum, and in the right canvas is a graph of the phase space of the system, which is a plot of the angle (relative to the vertical) against the angular velocity. The pendulum bob may be repositioned by clicking and dragging anywhere on the left canvas."
|
| 20 |
+
pack $w.msg
|
| 21 |
+
|
| 22 |
+
## See Code / Dismiss buttons
|
| 23 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 24 |
+
pack $btns -side bottom -fill x
|
| 25 |
+
|
| 26 |
+
# Create some structural widgets
|
| 27 |
+
pack [panedwindow $w.p] -fill both -expand 1
|
| 28 |
+
$w.p add [labelframe $w.p.l1 -text "Pendulum Simulation"]
|
| 29 |
+
$w.p add [labelframe $w.p.l2 -text "Phase Space"]
|
| 30 |
+
|
| 31 |
+
# Create the canvas containing the graphical representation of the
|
| 32 |
+
# simulated system.
|
| 33 |
+
canvas $w.c -width 320 -height 200 -background white -bd 2 -relief sunken
|
| 34 |
+
$w.c create text 5 5 -anchor nw -text "Click to Adjust Bob Start Position"
|
| 35 |
+
# Coordinates of these items don't matter; they will be set properly below
|
| 36 |
+
$w.c create line 0 25 320 25 -tags plate -fill grey50 -width 2
|
| 37 |
+
$w.c create oval 155 20 165 30 -tags pivot -fill grey50 -outline {}
|
| 38 |
+
$w.c create line 1 1 1 1 -tags rod -fill black -width 3
|
| 39 |
+
$w.c create oval 1 1 2 2 -tags bob -fill yellow -outline black
|
| 40 |
+
pack $w.c -in $w.p.l1 -fill both -expand true
|
| 41 |
+
|
| 42 |
+
# Create the canvas containing the phase space graph; this consists of
|
| 43 |
+
# a line that gets gradually paler as it ages, which is an extremely
|
| 44 |
+
# effective visual trick.
|
| 45 |
+
canvas $w.k -width 320 -height 200 -background white -bd 2 -relief sunken
|
| 46 |
+
$w.k create line 160 200 160 0 -fill grey75 -arrow last -tags y_axis
|
| 47 |
+
$w.k create line 0 100 320 100 -fill grey75 -arrow last -tags x_axis
|
| 48 |
+
for {set i 90} {$i>=0} {incr i -10} {
|
| 49 |
+
# Coordinates of these items don't matter; they will be set properly below
|
| 50 |
+
$w.k create line 0 0 1 1 -smooth true -tags graph$i -fill grey$i
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$w.k create text 0 0 -anchor ne -text "\u03b8" -tags label_theta
|
| 54 |
+
$w.k create text 0 0 -anchor ne -text "\u03b4\u03b8" -tags label_dtheta
|
| 55 |
+
pack $w.k -in $w.p.l2 -fill both -expand true
|
| 56 |
+
|
| 57 |
+
# Initialize some variables
|
| 58 |
+
set points {}
|
| 59 |
+
set Theta 45.0
|
| 60 |
+
set dTheta 0.0
|
| 61 |
+
set pi 3.1415926535897933
|
| 62 |
+
set length 150
|
| 63 |
+
set home 160
|
| 64 |
+
|
| 65 |
+
# This procedure makes the pendulum appear at the correct place on the
|
| 66 |
+
# canvas. If the additional arguments "at $x $y" are passed (the 'at'
|
| 67 |
+
# is really just syntactic sugar) instead of computing the position of
|
| 68 |
+
# the pendulum from the length of the pendulum rod and its angle, the
|
| 69 |
+
# length and angle are computed in reverse from the given location
|
| 70 |
+
# (which is taken to be the centre of the pendulum bob.)
|
| 71 |
+
proc showPendulum {canvas {at {}} {x {}} {y {}}} {
|
| 72 |
+
global Theta dTheta pi length home
|
| 73 |
+
if {$at eq "at" && ($x!=$home || $y!=25)} {
|
| 74 |
+
set dTheta 0.0
|
| 75 |
+
set x2 [expr {$x - $home}]
|
| 76 |
+
set y2 [expr {$y - 25}]
|
| 77 |
+
set length [expr {hypot($x2, $y2)}]
|
| 78 |
+
set Theta [expr {atan2($x2, $y2) * 180/$pi}]
|
| 79 |
+
} else {
|
| 80 |
+
set angle [expr {$Theta * $pi/180}]
|
| 81 |
+
set x [expr {$home + $length*sin($angle)}]
|
| 82 |
+
set y [expr {25 + $length*cos($angle)}]
|
| 83 |
+
}
|
| 84 |
+
$canvas coords rod $home 25 $x $y
|
| 85 |
+
$canvas coords bob [expr {$x - 15}] [expr {$y - 15}] \
|
| 86 |
+
[expr {$x + 15}] [expr {$y + 15}]
|
| 87 |
+
}
|
| 88 |
+
showPendulum $w.c
|
| 89 |
+
|
| 90 |
+
# Update the phase-space graph according to the current angle and the
|
| 91 |
+
# rate at which the angle is changing (the first derivative with
|
| 92 |
+
# respect to time.)
|
| 93 |
+
proc showPhase {canvas} {
|
| 94 |
+
global Theta dTheta points psw psh
|
| 95 |
+
lappend points [expr {$Theta + $psw}] [expr {-20*$dTheta + $psh}]
|
| 96 |
+
if {[llength $points] > 100} {
|
| 97 |
+
set points [lrange $points end-99 end]
|
| 98 |
+
}
|
| 99 |
+
for {set i 0} {$i<100} {incr i 10} {
|
| 100 |
+
set list [lrange $points end-[expr {$i-1}] end-[expr {$i-12}]]
|
| 101 |
+
if {[llength $list] >= 4} {
|
| 102 |
+
$canvas coords graph$i $list
|
| 103 |
+
}
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
# Set up some bindings on the canvases. Note that when the user
|
| 108 |
+
# clicks we stop the animation until they release the mouse
|
| 109 |
+
# button. Also note that both canvases are sensitive to <Configure>
|
| 110 |
+
# events, which allows them to find out when they have been resized by
|
| 111 |
+
# the user.
|
| 112 |
+
bind $w.c <Destroy> {
|
| 113 |
+
after cancel $animationCallbacks(pendulum)
|
| 114 |
+
unset animationCallbacks(pendulum)
|
| 115 |
+
}
|
| 116 |
+
bind $w.c <Button-1> {
|
| 117 |
+
after cancel $animationCallbacks(pendulum)
|
| 118 |
+
showPendulum %W at %x %y
|
| 119 |
+
}
|
| 120 |
+
bind $w.c <B1-Motion> {
|
| 121 |
+
showPendulum %W at %x %y
|
| 122 |
+
}
|
| 123 |
+
bind $w.c <ButtonRelease-1> {
|
| 124 |
+
showPendulum %W at %x %y
|
| 125 |
+
set animationCallbacks(pendulum) [after 15 repeat [winfo toplevel %W]]
|
| 126 |
+
}
|
| 127 |
+
bind $w.c <Configure> {
|
| 128 |
+
%W coords plate 0 25 %w 25
|
| 129 |
+
set home [expr {%w/2}]
|
| 130 |
+
%W coords pivot [expr {$home - 5}] 20 [expr {$home + 5}] 30
|
| 131 |
+
}
|
| 132 |
+
bind $w.k <Configure> {
|
| 133 |
+
set psh [expr {%h/2}]
|
| 134 |
+
set psw [expr {%w/2}]
|
| 135 |
+
%W coords x_axis 2 $psh [expr {%w - 2}] $psh
|
| 136 |
+
%W coords y_axis $psw [expr {%h - 2}] $psw 2
|
| 137 |
+
%W coords label_dtheta [expr {$psw - 4}] 6
|
| 138 |
+
%W coords label_theta [expr {%w - 6}] [expr {$psh + 4}]
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
# This procedure is the "business" part of the simulation that does
|
| 142 |
+
# simple numerical integration of the formula for a simple rotational
|
| 143 |
+
# pendulum.
|
| 144 |
+
proc recomputeAngle {} {
|
| 145 |
+
global Theta dTheta pi length
|
| 146 |
+
set scaling [expr {3000.0/$length/$length}]
|
| 147 |
+
|
| 148 |
+
# To estimate the integration accurately, we really need to
|
| 149 |
+
# compute the end-point of our time-step. But to do *that*, we
|
| 150 |
+
# need to estimate the integration accurately! So we try this
|
| 151 |
+
# technique, which is inaccurate, but better than doing it in a
|
| 152 |
+
# single step. What we really want is bound up in the
|
| 153 |
+
# differential equation:
|
| 154 |
+
# .. - sin theta
|
| 155 |
+
# theta + theta = -----------
|
| 156 |
+
# length
|
| 157 |
+
# But my math skills are not good enough to solve this!
|
| 158 |
+
|
| 159 |
+
# first estimate
|
| 160 |
+
set firstDDTheta [expr {-sin($Theta * $pi/180)*$scaling}]
|
| 161 |
+
set midDTheta [expr {$dTheta + $firstDDTheta}]
|
| 162 |
+
set midTheta [expr {$Theta + ($dTheta + $midDTheta)/2}]
|
| 163 |
+
# second estimate
|
| 164 |
+
set midDDTheta [expr {-sin($midTheta * $pi/180)*$scaling}]
|
| 165 |
+
set midDTheta [expr {$dTheta + ($firstDDTheta + $midDDTheta)/2}]
|
| 166 |
+
set midTheta [expr {$Theta + ($dTheta + $midDTheta)/2}]
|
| 167 |
+
# Now we do a double-estimate approach for getting the final value
|
| 168 |
+
# first estimate
|
| 169 |
+
set midDDTheta [expr {-sin($midTheta * $pi/180)*$scaling}]
|
| 170 |
+
set lastDTheta [expr {$midDTheta + $midDDTheta}]
|
| 171 |
+
set lastTheta [expr {$midTheta + ($midDTheta + $lastDTheta)/2}]
|
| 172 |
+
# second estimate
|
| 173 |
+
set lastDDTheta [expr {-sin($lastTheta * $pi/180)*$scaling}]
|
| 174 |
+
set lastDTheta [expr {$midDTheta + ($midDDTheta + $lastDDTheta)/2}]
|
| 175 |
+
set lastTheta [expr {$midTheta + ($midDTheta + $lastDTheta)/2}]
|
| 176 |
+
# Now put the values back in our globals
|
| 177 |
+
set dTheta $lastDTheta
|
| 178 |
+
set Theta $lastTheta
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
# This method ties together the simulation engine and the graphical
|
| 182 |
+
# display code that visualizes it.
|
| 183 |
+
proc repeat w {
|
| 184 |
+
global animationCallbacks
|
| 185 |
+
|
| 186 |
+
# Simulate
|
| 187 |
+
recomputeAngle
|
| 188 |
+
|
| 189 |
+
# Update the display
|
| 190 |
+
showPendulum $w.c
|
| 191 |
+
showPhase $w.k
|
| 192 |
+
|
| 193 |
+
# Reschedule ourselves
|
| 194 |
+
set animationCallbacks(pendulum) [after 15 [list repeat $w]]
|
| 195 |
+
}
|
| 196 |
+
# Start the simulation after a short pause
|
| 197 |
+
set animationCallbacks(pendulum) [after 500 [list repeat $w]]
|
parrot/lib/tk8.6/demos/search.tcl
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# search.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a collection of widgets that
|
| 4 |
+
# allow you to load a file into a text widget, then perform searches
|
| 5 |
+
# on that file.
|
| 6 |
+
|
| 7 |
+
if {![info exists widgetDemo]} {
|
| 8 |
+
error "This script should be run from the \"widget\" demo."
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
package require Tk
|
| 12 |
+
|
| 13 |
+
# textLoadFile --
|
| 14 |
+
# This procedure below loads a file into a text widget, discarding
|
| 15 |
+
# the previous contents of the widget. Tags for the old widget are
|
| 16 |
+
# not affected, however.
|
| 17 |
+
#
|
| 18 |
+
# Arguments:
|
| 19 |
+
# w - The window into which to load the file. Must be a
|
| 20 |
+
# text widget.
|
| 21 |
+
# file - The name of the file to load. Must be readable.
|
| 22 |
+
|
| 23 |
+
proc textLoadFile {w file} {
|
| 24 |
+
set f [open $file]
|
| 25 |
+
$w delete 1.0 end
|
| 26 |
+
while {![eof $f]} {
|
| 27 |
+
$w insert end [read $f 10000]
|
| 28 |
+
}
|
| 29 |
+
close $f
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
# textSearch --
|
| 33 |
+
# Search for all instances of a given string in a text widget and
|
| 34 |
+
# apply a given tag to each instance found.
|
| 35 |
+
#
|
| 36 |
+
# Arguments:
|
| 37 |
+
# w - The window in which to search. Must be a text widget.
|
| 38 |
+
# string - The string to search for. The search is done using
|
| 39 |
+
# exact matching only; no special characters.
|
| 40 |
+
# tag - Tag to apply to each instance of a matching string.
|
| 41 |
+
|
| 42 |
+
proc textSearch {w string tag} {
|
| 43 |
+
$w tag remove search 0.0 end
|
| 44 |
+
if {$string == ""} {
|
| 45 |
+
return
|
| 46 |
+
}
|
| 47 |
+
set cur 1.0
|
| 48 |
+
while 1 {
|
| 49 |
+
set cur [$w search -count length $string $cur end]
|
| 50 |
+
if {$cur == ""} {
|
| 51 |
+
break
|
| 52 |
+
}
|
| 53 |
+
$w tag add $tag $cur "$cur + $length char"
|
| 54 |
+
set cur [$w index "$cur + $length char"]
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
# textToggle --
|
| 59 |
+
# This procedure is invoked repeatedly to invoke two commands at
|
| 60 |
+
# periodic intervals. It normally reschedules itself after each
|
| 61 |
+
# execution but if an error occurs (e.g. because the window was
|
| 62 |
+
# deleted) then it doesn't reschedule itself.
|
| 63 |
+
#
|
| 64 |
+
# Arguments:
|
| 65 |
+
# cmd1 - Command to execute when procedure is called.
|
| 66 |
+
# sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
|
| 67 |
+
# cmd2 - Command to execute in the *next* invocation of this
|
| 68 |
+
# procedure.
|
| 69 |
+
# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
|
| 70 |
+
|
| 71 |
+
proc textToggle {cmd1 sleep1 cmd2 sleep2} {
|
| 72 |
+
catch {
|
| 73 |
+
eval $cmd1
|
| 74 |
+
after $sleep1 [list textToggle $cmd2 $sleep2 $cmd1 $sleep1]
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
set w .search
|
| 79 |
+
catch {destroy $w}
|
| 80 |
+
toplevel $w
|
| 81 |
+
wm title $w "Text Demonstration - Search and Highlight"
|
| 82 |
+
wm iconname $w "search"
|
| 83 |
+
positionWindow $w
|
| 84 |
+
|
| 85 |
+
## See Code / Dismiss buttons
|
| 86 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 87 |
+
pack $btns -side bottom -fill x
|
| 88 |
+
|
| 89 |
+
frame $w.file
|
| 90 |
+
label $w.file.label -text "File name:" -width 13 -anchor w
|
| 91 |
+
entry $w.file.entry -width 40 -textvariable fileName
|
| 92 |
+
button $w.file.button -text "Load File" \
|
| 93 |
+
-command "textLoadFile $w.text \$fileName"
|
| 94 |
+
pack $w.file.label $w.file.entry -side left
|
| 95 |
+
pack $w.file.button -side left -pady 5 -padx 10
|
| 96 |
+
bind $w.file.entry <Return> "
|
| 97 |
+
textLoadFile $w.text \$fileName
|
| 98 |
+
focus $w.string.entry
|
| 99 |
+
"
|
| 100 |
+
focus $w.file.entry
|
| 101 |
+
|
| 102 |
+
frame $w.string
|
| 103 |
+
label $w.string.label -text "Search string:" -width 13 -anchor w
|
| 104 |
+
entry $w.string.entry -width 40 -textvariable searchString
|
| 105 |
+
button $w.string.button -text "Highlight" \
|
| 106 |
+
-command "textSearch $w.text \$searchString search"
|
| 107 |
+
pack $w.string.label $w.string.entry -side left
|
| 108 |
+
pack $w.string.button -side left -pady 5 -padx 10
|
| 109 |
+
bind $w.string.entry <Return> "textSearch $w.text \$searchString search"
|
| 110 |
+
|
| 111 |
+
text $w.text -yscrollcommand "$w.scroll set" -setgrid true
|
| 112 |
+
ttk::scrollbar $w.scroll -command "$w.text yview"
|
| 113 |
+
pack $w.file $w.string -side top -fill x
|
| 114 |
+
pack $w.scroll -side right -fill y
|
| 115 |
+
pack $w.text -expand yes -fill both
|
| 116 |
+
|
| 117 |
+
# Set up display styles for text highlighting.
|
| 118 |
+
|
| 119 |
+
if {[winfo depth $w] > 1} {
|
| 120 |
+
textToggle "$w.text tag configure search -background \
|
| 121 |
+
#ce5555 -foreground white" 800 "$w.text tag configure \
|
| 122 |
+
search -background {} -foreground {}" 200
|
| 123 |
+
} else {
|
| 124 |
+
textToggle "$w.text tag configure search -background \
|
| 125 |
+
black -foreground white" 800 "$w.text tag configure \
|
| 126 |
+
search -background {} -foreground {}" 200
|
| 127 |
+
}
|
| 128 |
+
$w.text insert 1.0 \
|
| 129 |
+
{This window demonstrates how to use the tagging facilities in text
|
| 130 |
+
widgets to implement a searching mechanism. First, type a file name
|
| 131 |
+
in the top entry, then type <Return> or click on "Load File". Then
|
| 132 |
+
type a string in the lower entry and type <Return> or click on
|
| 133 |
+
"Load File". This will cause all of the instances of the string to
|
| 134 |
+
be tagged with the tag "search", and it will arrange for the tag's
|
| 135 |
+
display attributes to change to make all of the strings blink.}
|
| 136 |
+
$w.text mark set insert 0.0
|
| 137 |
+
|
| 138 |
+
set fileName ""
|
| 139 |
+
set searchString ""
|
parrot/lib/tk8.6/demos/toolbar.tcl
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# toolbar.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a toolbar that can be torn off.
|
| 4 |
+
|
| 5 |
+
if {![info exists widgetDemo]} {
|
| 6 |
+
error "This script should be run from the \"widget\" demo."
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
package require Tk
|
| 10 |
+
|
| 11 |
+
set w .toolbar
|
| 12 |
+
destroy $w
|
| 13 |
+
toplevel $w
|
| 14 |
+
wm title $w "Toolbar Demonstration"
|
| 15 |
+
wm iconname $w "toolbar"
|
| 16 |
+
positionWindow $w
|
| 17 |
+
|
| 18 |
+
ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\
|
| 19 |
+
a toolbar that is styled correctly and which can be torn off. The\
|
| 20 |
+
buttons are configured to be \u201Ctoolbar style\u201D buttons by\
|
| 21 |
+
telling them that they are to use the Toolbutton style. At the left\
|
| 22 |
+
end of the toolbar is a simple marker that the cursor changes to a\
|
| 23 |
+
movement icon over; drag that away from the toolbar to tear off the\
|
| 24 |
+
whole toolbar into a separate toplevel widget. When the dragged-off\
|
| 25 |
+
toolbar is no longer needed, just close it like any normal toplevel\
|
| 26 |
+
and it will reattach to the window it was torn off from."
|
| 27 |
+
|
| 28 |
+
## Set up the toolbar hull
|
| 29 |
+
set t [frame $w.toolbar] ;# Must be a frame!
|
| 30 |
+
ttk::separator $w.sep
|
| 31 |
+
ttk::frame $t.tearoff -cursor fleur
|
| 32 |
+
ttk::separator $t.tearoff.to -orient vertical
|
| 33 |
+
ttk::separator $t.tearoff.to2 -orient vertical
|
| 34 |
+
pack $t.tearoff.to -fill y -expand 1 -padx 4 -side left
|
| 35 |
+
pack $t.tearoff.to2 -fill y -expand 1 -side left
|
| 36 |
+
ttk::frame $t.contents
|
| 37 |
+
grid $t.tearoff $t.contents -sticky nsew
|
| 38 |
+
grid columnconfigure $t $t.contents -weight 1
|
| 39 |
+
grid columnconfigure $t.contents 1000 -weight 1
|
| 40 |
+
|
| 41 |
+
## Bindings so that the toolbar can be torn off and reattached
|
| 42 |
+
bind $t.tearoff <B1-Motion> [list tearoff $t %X %Y]
|
| 43 |
+
bind $t.tearoff.to <B1-Motion> [list tearoff $t %X %Y]
|
| 44 |
+
bind $t.tearoff.to2 <B1-Motion> [list tearoff $t %X %Y]
|
| 45 |
+
proc tearoff {w x y} {
|
| 46 |
+
if {[string match $w* [winfo containing $x $y]]} {
|
| 47 |
+
return
|
| 48 |
+
}
|
| 49 |
+
grid remove $w
|
| 50 |
+
grid remove $w.tearoff
|
| 51 |
+
wm manage $w
|
| 52 |
+
wm protocol $w WM_DELETE_WINDOW [list untearoff $w]
|
| 53 |
+
}
|
| 54 |
+
proc untearoff {w} {
|
| 55 |
+
wm forget $w
|
| 56 |
+
grid $w.tearoff
|
| 57 |
+
grid $w
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
## Toolbar contents
|
| 61 |
+
ttk::button $t.button -text "Button" -style Toolbutton -command [list \
|
| 62 |
+
$w.txt insert end "Button Pressed\n"]
|
| 63 |
+
ttk::checkbutton $t.check -text "Check" -variable check -style Toolbutton \
|
| 64 |
+
-command [concat [list $w.txt insert end] {"check is $check\n"}]
|
| 65 |
+
ttk::menubutton $t.menu -text "Menu" -menu $t.menu.m
|
| 66 |
+
ttk::combobox $t.combo -value [lsort [font families]] -state readonly
|
| 67 |
+
menu $t.menu.m
|
| 68 |
+
$t.menu.m add command -label "Just" -command [list $w.txt insert end Just\n]
|
| 69 |
+
$t.menu.m add command -label "An" -command [list $w.txt insert end An\n]
|
| 70 |
+
$t.menu.m add command -label "Example" \
|
| 71 |
+
-command [list $w.txt insert end Example\n]
|
| 72 |
+
bind $t.combo <<ComboboxSelected>> [list changeFont $w.txt $t.combo]
|
| 73 |
+
proc changeFont {txt combo} {
|
| 74 |
+
$txt configure -font [list [$combo get] 10]
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
## Some content for the rest of the toplevel
|
| 78 |
+
text $w.txt -width 40 -height 10
|
| 79 |
+
interp alias {} doInsert {} $w.txt insert end ;# Make bindings easy to write
|
| 80 |
+
|
| 81 |
+
## Arrange contents
|
| 82 |
+
grid $t.button $t.check $t.menu $t.combo -in $t.contents -padx 2 -pady 4 -sticky ns
|
| 83 |
+
grid $t -sticky ew
|
| 84 |
+
grid $w.sep -sticky ew
|
| 85 |
+
grid $w.msg -sticky ew
|
| 86 |
+
grid $w.txt -sticky nsew
|
| 87 |
+
grid rowconfigure $w $w.txt -weight 1
|
| 88 |
+
grid columnconfigure $w $w.txt -weight 1
|
| 89 |
+
|
| 90 |
+
## See Code / Dismiss buttons
|
| 91 |
+
set btns [addSeeDismiss $w.buttons $w]
|
| 92 |
+
grid $btns -sticky ew
|
parrot/lib/tk8.6/demos/ttkpane.tcl
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ttkpane.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script creates a Ttk pane with some content.
|
| 4 |
+
|
| 5 |
+
if {![info exists widgetDemo]} {
|
| 6 |
+
error "This script should be run from the \"widget\" demo."
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
package require Tk
|
| 10 |
+
|
| 11 |
+
set w .ttkpane
|
| 12 |
+
catch {destroy $w}
|
| 13 |
+
toplevel $w
|
| 14 |
+
wm title $w "Themed Nested Panes"
|
| 15 |
+
wm iconname $w "ttkpane"
|
| 16 |
+
positionWindow $w
|
| 17 |
+
|
| 18 |
+
ttk::label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows off a nested set of themed paned windows. Their sizes can be changed by grabbing the area between each contained pane and dragging the divider."
|
| 19 |
+
pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
|
| 20 |
+
|
| 21 |
+
## See Code / Dismiss
|
| 22 |
+
pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
|
| 23 |
+
|
| 24 |
+
ttk::frame $w.f
|
| 25 |
+
pack $w.f -fill both -expand 1
|
| 26 |
+
set w $w.f
|
| 27 |
+
ttk::panedwindow $w.outer -orient horizontal
|
| 28 |
+
$w.outer add [ttk::panedwindow $w.outer.inLeft -orient vertical]
|
| 29 |
+
$w.outer add [ttk::panedwindow $w.outer.inRight -orient vertical]
|
| 30 |
+
$w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.top -text Button]
|
| 31 |
+
$w.outer.inLeft add [ttk::labelframe $w.outer.inLeft.bot -text Clocks]
|
| 32 |
+
$w.outer.inRight add [ttk::labelframe $w.outer.inRight.top -text Progress]
|
| 33 |
+
$w.outer.inRight add [ttk::labelframe $w.outer.inRight.bot -text Text]
|
| 34 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 35 |
+
foreach i [list inLeft.top inLeft.bot inRight.top inRight.bot] {
|
| 36 |
+
$w.outer.$i configure -padding 3
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
# Fill the button pane
|
| 41 |
+
ttk::button $w.outer.inLeft.top.b -text "Press Me" -command {
|
| 42 |
+
tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \
|
| 43 |
+
-parent .ttkpane -title "Button Pressed"
|
| 44 |
+
}
|
| 45 |
+
pack $w.outer.inLeft.top.b -padx 2 -pady 5
|
| 46 |
+
|
| 47 |
+
# Fill the clocks pane
|
| 48 |
+
set i 0
|
| 49 |
+
proc every {delay script} {
|
| 50 |
+
uplevel #0 $script
|
| 51 |
+
after $delay [list every $delay $script]
|
| 52 |
+
}
|
| 53 |
+
set testzones {
|
| 54 |
+
:Europe/Berlin
|
| 55 |
+
:America/Argentina/Buenos_Aires
|
| 56 |
+
:Africa/Johannesburg
|
| 57 |
+
:Europe/London
|
| 58 |
+
:America/Los_Angeles
|
| 59 |
+
:Europe/Moscow
|
| 60 |
+
:America/New_York
|
| 61 |
+
:Asia/Singapore
|
| 62 |
+
:Australia/Sydney
|
| 63 |
+
:Asia/Tokyo
|
| 64 |
+
}
|
| 65 |
+
# Force a pre-load of all the timezones needed; otherwise can end up
|
| 66 |
+
# poor-looking synch problems!
|
| 67 |
+
set zones {}
|
| 68 |
+
foreach zone $testzones {
|
| 69 |
+
if {![catch {clock format 0 -timezone $zone}]} {
|
| 70 |
+
lappend zones $zone
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
if {[llength $zones] < 2} { lappend zones -0200 :GMT :UTC +0200 }
|
| 74 |
+
foreach zone $zones {
|
| 75 |
+
set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]]
|
| 76 |
+
if {$i} {
|
| 77 |
+
pack [ttk::separator $w.outer.inLeft.bot.s$i] -fill x
|
| 78 |
+
}
|
| 79 |
+
ttk::label $w.outer.inLeft.bot.l$i -text $city -anchor w
|
| 80 |
+
ttk::label $w.outer.inLeft.bot.t$i -textvariable time($zone) -anchor w
|
| 81 |
+
pack $w.outer.inLeft.bot.l$i $w.outer.inLeft.bot.t$i -fill x
|
| 82 |
+
every 1000 "set time($zone) \[clock format \[clock seconds\] -timezone $zone -format %T\]"
|
| 83 |
+
incr i
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
# Fill the progress pane
|
| 87 |
+
ttk::progressbar $w.outer.inRight.top.progress -mode indeterminate
|
| 88 |
+
pack $w.outer.inRight.top.progress -fill both -expand 1
|
| 89 |
+
$w.outer.inRight.top.progress start
|
| 90 |
+
|
| 91 |
+
# Fill the text pane
|
| 92 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 93 |
+
# The trick with the ttk::frame makes the text widget look like it fits with
|
| 94 |
+
# the current Ttk theme despite not being a themed widget itself. It is done
|
| 95 |
+
# by styling the frame like an entry, turning off the border in the text
|
| 96 |
+
# widget, and putting the text widget in the frame with enough space to allow
|
| 97 |
+
# the surrounding border to show through (2 pixels seems to be enough).
|
| 98 |
+
ttk::frame $w.outer.inRight.bot.f -style TEntry
|
| 99 |
+
text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
|
| 100 |
+
pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f -pady 2 -padx 2
|
| 101 |
+
ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
|
| 102 |
+
pack $w.sb -side right -fill y -in $w.outer.inRight.bot
|
| 103 |
+
pack $w.outer.inRight.bot.f -fill both -expand 1
|
| 104 |
+
pack $w.outer -fill both -expand 1
|
| 105 |
+
} else {
|
| 106 |
+
text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
|
| 107 |
+
ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
|
| 108 |
+
pack $w.sb -side right -fill y -in $w.outer.inRight.bot
|
| 109 |
+
pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot
|
| 110 |
+
pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10}
|
| 111 |
+
}
|
| 112 |
+
|
parrot/lib/tk8.6/demos/ttkscale.tcl
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ttkscale.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This demonstration script shows an example with a horizontal scale.
|
| 4 |
+
|
| 5 |
+
if {![info exists widgetDemo]} {
|
| 6 |
+
error "This script should be run from the \"widget\" demo."
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
package require Tk
|
| 10 |
+
|
| 11 |
+
set w .ttkscale
|
| 12 |
+
catch {destroy $w}
|
| 13 |
+
toplevel $w -bg [ttk::style lookup TLabel -background]
|
| 14 |
+
wm title $w "Themed Scale Demonstration"
|
| 15 |
+
wm iconname $w "ttkscale"
|
| 16 |
+
positionWindow $w
|
| 17 |
+
|
| 18 |
+
pack [ttk::frame [set w $w.contents]] -fill both -expand 1
|
| 19 |
+
|
| 20 |
+
ttk::label $w.msg -font $font -wraplength 3.5i -justify left -text "A label tied to a horizontal scale is displayed below. If you click or drag mouse button 1 in the scale, you can change the contents of the label; a callback command is used to couple the slider to both the text and the coloring of the label."
|
| 21 |
+
pack $w.msg -side top -padx .5c
|
| 22 |
+
|
| 23 |
+
## See Code / Dismiss buttons
|
| 24 |
+
set btns [addSeeDismiss $w.buttons [winfo toplevel $w]]
|
| 25 |
+
pack $btns -side bottom -fill x
|
| 26 |
+
|
| 27 |
+
ttk::frame $w.frame -borderwidth 10
|
| 28 |
+
pack $w.frame -side top -fill x
|
| 29 |
+
|
| 30 |
+
# List of colors from rainbox; "Indigo" is not a standard color
|
| 31 |
+
set colorList {Red Orange Yellow Green Blue Violet}
|
| 32 |
+
ttk::label $w.frame.label
|
| 33 |
+
ttk::scale $w.frame.scale -from 0 -to 5 -command [list apply {{w idx} {
|
| 34 |
+
set c [lindex $::colorList [tcl::mathfunc::int $idx]]
|
| 35 |
+
$w.frame.label configure -foreground $c -text "Color: $c"
|
| 36 |
+
}} $w]
|
| 37 |
+
# Trigger the setting of the label's text
|
| 38 |
+
$w.frame.scale set 0
|
| 39 |
+
pack $w.frame.label $w.frame.scale
|
parrot/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 [string index [$w cget -show] 0] \
|
| 696 |
+
[string length $entryString]]
|
| 697 |
+
}
|
| 698 |
+
return $entryString
|
| 699 |
+
}
|
parrot/lib/tk8.6/focus.tcl
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
}
|
parrot/lib/tk8.6/menu.tcl
ADDED
|
@@ -0,0 +1,1387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
#
|
| 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 |
+
}
|
parrot/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
|
| 1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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 |
+
}
|
parrot/lib/tk8.6/palette.tcl
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# palette.tcl --
|
| 2 |
+
#
|
| 3 |
+
# This file contains procedures that change the color palette used
|
| 4 |
+
# by Tk.
|
| 5 |
+
#
|
| 6 |
+
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
|
| 7 |
+
#
|
| 8 |
+
# See the file "license.terms" for information on usage and redistribution
|
| 9 |
+
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
| 10 |
+
#
|
| 11 |
+
|
| 12 |
+
# ::tk_setPalette --
|
| 13 |
+
# Changes the default color scheme for a Tk application by setting
|
| 14 |
+
# default colors in the option database and by modifying all of the
|
| 15 |
+
# color options for existing widgets that have the default value.
|
| 16 |
+
#
|
| 17 |
+
# Arguments:
|
| 18 |
+
# The arguments consist of either a single color name, which
|
| 19 |
+
# will be used as the new background color (all other colors will
|
| 20 |
+
# be computed from this) or an even number of values consisting of
|
| 21 |
+
# option names and values. The name for an option is the one used
|
| 22 |
+
# for the option database, such as activeForeground, not -activeforeground.
|
| 23 |
+
|
| 24 |
+
proc ::tk_setPalette {args} {
|
| 25 |
+
if {[winfo depth .] == 1} {
|
| 26 |
+
# Just return on monochrome displays, otherwise errors will occur
|
| 27 |
+
return
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# Create an array that has the complete new palette. If some colors
|
| 31 |
+
# aren't specified, compute them from other colors that are specified.
|
| 32 |
+
|
| 33 |
+
if {[llength $args] == 1} {
|
| 34 |
+
set new(background) [lindex $args 0]
|
| 35 |
+
} else {
|
| 36 |
+
array set new $args
|
| 37 |
+
}
|
| 38 |
+
if {![info exists new(background)]} {
|
| 39 |
+
return -code error -errorcode {TK SET_PALETTE BACKGROUND} \
|
| 40 |
+
"must specify a background color"
|
| 41 |
+
}
|
| 42 |
+
set bg [winfo rgb . $new(background)]
|
| 43 |
+
if {![info exists new(foreground)]} {
|
| 44 |
+
# Note that the range of each value in the triple returned by
|
| 45 |
+
# [winfo rgb] is 0-65535, and your eyes are more sensitive to
|
| 46 |
+
# green than to red, and more to red than to blue.
|
| 47 |
+
foreach {r g b} $bg {break}
|
| 48 |
+
if {$r+1.5*$g+0.5*$b > 100000} {
|
| 49 |
+
set new(foreground) black
|
| 50 |
+
} else {
|
| 51 |
+
set new(foreground) white
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
lassign [winfo rgb . $new(foreground)] fg_r fg_g fg_b
|
| 55 |
+
lassign $bg bg_r bg_g bg_b
|
| 56 |
+
set darkerBg [format #%02x%02x%02x [expr {(9*$bg_r)/2560}] \
|
| 57 |
+
[expr {(9*$bg_g)/2560}] [expr {(9*$bg_b)/2560}]]
|
| 58 |
+
|
| 59 |
+
foreach i {activeForeground insertBackground selectForeground \
|
| 60 |
+
highlightColor} {
|
| 61 |
+
if {![info exists new($i)]} {
|
| 62 |
+
set new($i) $new(foreground)
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
if {![info exists new(disabledForeground)]} {
|
| 66 |
+
set new(disabledForeground) [format #%02x%02x%02x \
|
| 67 |
+
[expr {(3*$bg_r + $fg_r)/1024}] \
|
| 68 |
+
[expr {(3*$bg_g + $fg_g)/1024}] \
|
| 69 |
+
[expr {(3*$bg_b + $fg_b)/1024}]]
|
| 70 |
+
}
|
| 71 |
+
if {![info exists new(highlightBackground)]} {
|
| 72 |
+
set new(highlightBackground) $new(background)
|
| 73 |
+
}
|
| 74 |
+
if {![info exists new(activeBackground)]} {
|
| 75 |
+
# Pick a default active background that islighter than the
|
| 76 |
+
# normal background. To do this, round each color component
|
| 77 |
+
# up by 15% or 1/3 of the way to full white, whichever is
|
| 78 |
+
# greater.
|
| 79 |
+
|
| 80 |
+
foreach i {0 1 2} color $bg {
|
| 81 |
+
set light($i) [expr {$color/256}]
|
| 82 |
+
set inc1 [expr {($light($i)*15)/100}]
|
| 83 |
+
set inc2 [expr {(255-$light($i))/3}]
|
| 84 |
+
if {$inc1 > $inc2} {
|
| 85 |
+
incr light($i) $inc1
|
| 86 |
+
} else {
|
| 87 |
+
incr light($i) $inc2
|
| 88 |
+
}
|
| 89 |
+
if {$light($i) > 255} {
|
| 90 |
+
set light($i) 255
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
set new(activeBackground) [format #%02x%02x%02x $light(0) \
|
| 94 |
+
$light(1) $light(2)]
|
| 95 |
+
}
|
| 96 |
+
if {![info exists new(selectBackground)]} {
|
| 97 |
+
set new(selectBackground) $darkerBg
|
| 98 |
+
}
|
| 99 |
+
if {![info exists new(troughColor)]} {
|
| 100 |
+
set new(troughColor) $darkerBg
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
# let's make one of each of the widgets so we know what the
|
| 104 |
+
# defaults are currently for this platform.
|
| 105 |
+
toplevel .___tk_set_palette
|
| 106 |
+
wm withdraw .___tk_set_palette
|
| 107 |
+
foreach q {
|
| 108 |
+
button canvas checkbutton entry frame label labelframe
|
| 109 |
+
listbox menubutton menu message radiobutton scale scrollbar
|
| 110 |
+
spinbox text
|
| 111 |
+
} {
|
| 112 |
+
$q .___tk_set_palette.$q
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
# Walk the widget hierarchy, recoloring all existing windows.
|
| 116 |
+
# The option database must be set according to what we do here,
|
| 117 |
+
# but it breaks things if we set things in the database while
|
| 118 |
+
# we are changing colors...so, ::tk::RecolorTree now returns the
|
| 119 |
+
# option database changes that need to be made, and they
|
| 120 |
+
# need to be evalled here to take effect.
|
| 121 |
+
# We have to walk the whole widget tree instead of just
|
| 122 |
+
# relying on the widgets we've created above to do the work
|
| 123 |
+
# because different extensions may provide other kinds
|
| 124 |
+
# of widgets that we don't currently know about, so we'll
|
| 125 |
+
# walk the whole hierarchy just in case.
|
| 126 |
+
|
| 127 |
+
eval [tk::RecolorTree . new]
|
| 128 |
+
|
| 129 |
+
destroy .___tk_set_palette
|
| 130 |
+
|
| 131 |
+
# Change the option database so that future windows will get the
|
| 132 |
+
# same colors.
|
| 133 |
+
|
| 134 |
+
foreach option [array names new] {
|
| 135 |
+
option add *$option $new($option) widgetDefault
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
# Save the options in the variable ::tk::Palette, for use the
|
| 139 |
+
# next time we change the options.
|
| 140 |
+
|
| 141 |
+
array set ::tk::Palette [array get new]
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
# ::tk::RecolorTree --
|
| 145 |
+
# This procedure changes the colors in a window and all of its
|
| 146 |
+
# descendants, according to information provided by the colors
|
| 147 |
+
# argument. This looks at the defaults provided by the option
|
| 148 |
+
# database, if it exists, and if not, then it looks at the default
|
| 149 |
+
# value of the widget itself.
|
| 150 |
+
#
|
| 151 |
+
# Arguments:
|
| 152 |
+
# w - The name of a window. This window and all its
|
| 153 |
+
# descendants are recolored.
|
| 154 |
+
# colors - The name of an array variable in the caller,
|
| 155 |
+
# which contains color information. Each element
|
| 156 |
+
# is named after a widget configuration option, and
|
| 157 |
+
# each value is the value for that option.
|
| 158 |
+
|
| 159 |
+
proc ::tk::RecolorTree {w colors} {
|
| 160 |
+
upvar $colors c
|
| 161 |
+
set result {}
|
| 162 |
+
set prototype .___tk_set_palette.[string tolower [winfo class $w]]
|
| 163 |
+
if {![winfo exists $prototype]} {
|
| 164 |
+
unset prototype
|
| 165 |
+
}
|
| 166 |
+
foreach dbOption [array names c] {
|
| 167 |
+
set option -[string tolower $dbOption]
|
| 168 |
+
set class [string replace $dbOption 0 0 [string toupper \
|
| 169 |
+
[string index $dbOption 0]]]
|
| 170 |
+
if {![catch {$w configure $option} value]} {
|
| 171 |
+
# if the option database has a preference for this
|
| 172 |
+
# dbOption, then use it, otherwise use the defaults
|
| 173 |
+
# for the widget.
|
| 174 |
+
set defaultcolor [option get $w $dbOption $class]
|
| 175 |
+
if {$defaultcolor eq "" || \
|
| 176 |
+
([info exists prototype] && \
|
| 177 |
+
[$prototype cget $option] ne "$defaultcolor")} {
|
| 178 |
+
set defaultcolor [lindex $value 3]
|
| 179 |
+
}
|
| 180 |
+
if {$defaultcolor ne ""} {
|
| 181 |
+
set defaultcolor [winfo rgb . $defaultcolor]
|
| 182 |
+
}
|
| 183 |
+
set chosencolor [lindex $value 4]
|
| 184 |
+
if {$chosencolor ne ""} {
|
| 185 |
+
set chosencolor [winfo rgb . $chosencolor]
|
| 186 |
+
}
|
| 187 |
+
if {[string match $defaultcolor $chosencolor]} {
|
| 188 |
+
# Change the option database so that future windows will get
|
| 189 |
+
# the same colors.
|
| 190 |
+
append result ";\noption add [list \
|
| 191 |
+
*[winfo class $w].$dbOption $c($dbOption) 60]"
|
| 192 |
+
$w configure $option $c($dbOption)
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
foreach child [winfo children $w] {
|
| 197 |
+
append result ";\n[::tk::RecolorTree $child c]"
|
| 198 |
+
}
|
| 199 |
+
return $result
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
# ::tk::Darken --
|
| 203 |
+
# Given a color name, computes a new color value that darkens (or
|
| 204 |
+
# brightens) the given color by a given percent.
|
| 205 |
+
#
|
| 206 |
+
# Arguments:
|
| 207 |
+
# color - Name of starting color.
|
| 208 |
+
# percent - Integer telling how much to brighten or darken as a
|
| 209 |
+
# percent: 50 means darken by 50%, 110 means brighten
|
| 210 |
+
# by 10%.
|
| 211 |
+
|
| 212 |
+
proc ::tk::Darken {color percent} {
|
| 213 |
+
if {$percent < 0} {
|
| 214 |
+
return #000000
|
| 215 |
+
} elseif {$percent > 200} {
|
| 216 |
+
return #ffffff
|
| 217 |
+
} elseif {$percent <= 100} {
|
| 218 |
+
lassign [winfo rgb . $color] r g b
|
| 219 |
+
set r [expr {($r/256)*$percent/100}]
|
| 220 |
+
set g [expr {($g/256)*$percent/100}]
|
| 221 |
+
set b [expr {($b/256)*$percent/100}]
|
| 222 |
+
} elseif {$percent > 100} {
|
| 223 |
+
lassign [winfo rgb . $color] r g b
|
| 224 |
+
set r [expr {255 - ((65535-$r)/256)*(200-$percent)/100}]
|
| 225 |
+
set g [expr {255 - ((65535-$g)/256)*(200-$percent)/100}]
|
| 226 |
+
set b [expr {255 - ((65535-$b)/256)*(200-$percent)/100}]
|
| 227 |
+
}
|
| 228 |
+
return [format #%02x%02x%02x $r $g $b]
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
# ::tk_bisque --
|
| 232 |
+
# Reset the Tk color palette to the old "bisque" colors.
|
| 233 |
+
#
|
| 234 |
+
# Arguments:
|
| 235 |
+
# None.
|
| 236 |
+
|
| 237 |
+
proc ::tk_bisque {} {
|
| 238 |
+
tk_setPalette activeBackground #e6ceb1 activeForeground black \
|
| 239 |
+
background #ffe4c4 disabledForeground #b0b0b0 foreground black \
|
| 240 |
+
highlightBackground #ffe4c4 highlightColor black \
|
| 241 |
+
insertBackground black \
|
| 242 |
+
selectBackground #e6ceb1 selectForeground black \
|
| 243 |
+
troughColor #cdb79e
|
| 244 |
+
}
|
parrot/lib/tk8.6/spinbox.tcl
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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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 |
+
}
|
parrot/lib/tk8.6/text.tcl
ADDED
|
@@ -0,0 +1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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(y)]} {
|
| 1234 |
+
set Priv(y) $y
|
| 1235 |
+
}
|
| 1236 |
+
if {($x != $Priv(x)) || ($y != $Priv(y))} {
|
| 1237 |
+
set Priv(mouseMoved) 1
|
| 1238 |
+
}
|
| 1239 |
+
if {[info exists Priv(mouseMoved)] && $Priv(mouseMoved)} {
|
| 1240 |
+
$w scan dragto $x $y
|
| 1241 |
+
}
|
| 1242 |
+
}
|
parrot/lib/tk8.6/ttk/aquaTheme.tcl
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Aqua theme (OSX native look and feel)
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
namespace eval ttk::theme::aqua {
|
| 6 |
+
ttk::style theme settings aqua {
|
| 7 |
+
|
| 8 |
+
ttk::style configure . \
|
| 9 |
+
-font TkDefaultFont \
|
| 10 |
+
-background systemWindowBackgroundColor \
|
| 11 |
+
-foreground systemLabelColor \
|
| 12 |
+
-selectbackground systemSelectedTextBackgroundColor \
|
| 13 |
+
-selectforeground systemSelectedTextColor \
|
| 14 |
+
-selectborderwidth 0 \
|
| 15 |
+
-insertwidth 1
|
| 16 |
+
|
| 17 |
+
ttk::style map . \
|
| 18 |
+
-foreground {
|
| 19 |
+
disabled systemDisabledControlTextColor
|
| 20 |
+
background systemLabelColor} \
|
| 21 |
+
-selectbackground {
|
| 22 |
+
background systemSelectedTextBackgroundColor
|
| 23 |
+
!focus systemSelectedTextBackgroundColor} \
|
| 24 |
+
-selectforeground {
|
| 25 |
+
background systemSelectedTextColor
|
| 26 |
+
!focus systemSelectedTextColor}
|
| 27 |
+
|
| 28 |
+
# Button
|
| 29 |
+
ttk::style configure TButton -anchor center -width -6 \
|
| 30 |
+
-foreground systemControlTextColor
|
| 31 |
+
ttk::style map TButton \
|
| 32 |
+
-foreground {
|
| 33 |
+
pressed white
|
| 34 |
+
{alternate !pressed !background} white}
|
| 35 |
+
ttk::style configure TMenubutton -anchor center -padding {2 0 0 2}
|
| 36 |
+
ttk::style configure Toolbutton -anchor center
|
| 37 |
+
|
| 38 |
+
# For Entry, Combobox and Spinbox widgets the selected text background
|
| 39 |
+
# is the "Highlight color" selected in preferences when the widget
|
| 40 |
+
# has focus. It is a gray color when the widget does not have focus or
|
| 41 |
+
# the window does not have focus. (The background state implies !focus
|
| 42 |
+
# so we only need to specify !focus.)
|
| 43 |
+
|
| 44 |
+
# Entry
|
| 45 |
+
ttk::style configure TEntry \
|
| 46 |
+
-foreground systemTextColor \
|
| 47 |
+
-background systemTextBackgroundColor
|
| 48 |
+
ttk::style map TEntry \
|
| 49 |
+
-foreground {
|
| 50 |
+
disabled systemDisabledControlTextColor
|
| 51 |
+
} \
|
| 52 |
+
-selectbackground {
|
| 53 |
+
!focus systemUnemphasizedSelectedTextBackgroundColor
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
# Combobox:
|
| 57 |
+
ttk::style map TCombobox \
|
| 58 |
+
-foreground {
|
| 59 |
+
disabled systemDisabledControlTextColor
|
| 60 |
+
} \
|
| 61 |
+
-selectbackground {
|
| 62 |
+
!focus systemUnemphasizedSelectedTextBackgroundColor
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
# Spinbox
|
| 66 |
+
ttk::style configure TSpinbox \
|
| 67 |
+
-foreground systemTextColor \
|
| 68 |
+
-background systemTextBackgroundColor
|
| 69 |
+
ttk::style map TSpinbox \
|
| 70 |
+
-foreground {
|
| 71 |
+
disabled systemDisabledControlTextColor
|
| 72 |
+
} \
|
| 73 |
+
-selectbackground {
|
| 74 |
+
!focus systemUnemphasizedSelectedTextBackgroundColor
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
# Workaround for #1100117:
|
| 78 |
+
# Actually, on Aqua we probably shouldn't stipple images in
|
| 79 |
+
# disabled buttons even if it did work...
|
| 80 |
+
ttk::style configure . -stipple {}
|
| 81 |
+
|
| 82 |
+
# Notebook
|
| 83 |
+
ttk::style configure TNotebook -tabmargins {10 0} -tabposition n
|
| 84 |
+
ttk::style configure TNotebook -padding {18 8 18 17}
|
| 85 |
+
ttk::style configure TNotebook.Tab -padding {12 3 12 2}
|
| 86 |
+
ttk::style configure TNotebook.Tab -foreground systemControlTextColor
|
| 87 |
+
ttk::style map TNotebook.Tab \
|
| 88 |
+
-foreground {
|
| 89 |
+
background systemControlTextColor
|
| 90 |
+
disabled systemDisabledControlTextColor
|
| 91 |
+
selected systemSelectedTabTextColor}
|
| 92 |
+
|
| 93 |
+
# Treeview:
|
| 94 |
+
ttk::style configure Heading \
|
| 95 |
+
-font TkHeadingFont \
|
| 96 |
+
-foreground systemTextColor \
|
| 97 |
+
-background systemWindowBackgroundColor
|
| 98 |
+
ttk::style configure Treeview -rowheight 18 \
|
| 99 |
+
-background systemTextBackgroundColor \
|
| 100 |
+
-foreground systemTextColor \
|
| 101 |
+
-fieldbackground systemTextBackgroundColor
|
| 102 |
+
ttk::style map Treeview \
|
| 103 |
+
-background {
|
| 104 |
+
selected systemSelectedTextBackgroundColor
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
# Enable animation for ttk::progressbar widget:
|
| 108 |
+
ttk::style configure TProgressbar -period 100 -maxphase 120
|
| 109 |
+
|
| 110 |
+
# For Aqua, labelframe labels should appear outside the border,
|
| 111 |
+
# with a 14 pixel inset and 4 pixels spacing between border and label
|
| 112 |
+
# (ref: Apple Human Interface Guidelines / Controls / Grouping Controls)
|
| 113 |
+
#
|
| 114 |
+
ttk::style configure TLabelframe \
|
| 115 |
+
-labeloutside true -labelmargins {14 0 14 4}
|
| 116 |
+
|
| 117 |
+
# TODO: panedwindow sashes should be 9 pixels (HIG:Controls:Split Views)
|
| 118 |
+
}
|
| 119 |
+
}
|
parrot/lib/tk8.6/ttk/button.tcl
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Bindings for Buttons, Checkbuttons, and Radiobuttons.
|
| 3 |
+
#
|
| 4 |
+
# Notes: <Button1-Leave>, <Button1-Enter> only control the "pressed"
|
| 5 |
+
# state; widgets remain "active" if the pointer is dragged out.
|
| 6 |
+
# This doesn't seem to be conventional, but it's a nice way
|
| 7 |
+
# to provide extra feedback while the grab is active.
|
| 8 |
+
# (If the button is released off the widget, the grab deactivates and
|
| 9 |
+
# we get a <Leave> event then, which turns off the "active" state)
|
| 10 |
+
#
|
| 11 |
+
# Normally, <ButtonRelease> and <ButtonN-Enter/Leave> events are
|
| 12 |
+
# delivered to the widget which received the initial <Button>
|
| 13 |
+
# event. However, Tk [grab]s (#1223103) and menu interactions
|
| 14 |
+
# (#1222605) can interfere with this. To guard against spurious
|
| 15 |
+
# <Button1-Enter> events, the <Button1-Enter> binding only sets
|
| 16 |
+
# the pressed state if the button is currently active.
|
| 17 |
+
#
|
| 18 |
+
|
| 19 |
+
namespace eval ttk::button {}
|
| 20 |
+
|
| 21 |
+
bind TButton <Enter> { %W instate !disabled {%W state active} }
|
| 22 |
+
bind TButton <Leave> { %W state !active }
|
| 23 |
+
bind TButton <space> { ttk::button::activate %W }
|
| 24 |
+
bind TButton <<Invoke>> { ttk::button::activate %W }
|
| 25 |
+
|
| 26 |
+
bind TButton <Button-1> \
|
| 27 |
+
{ %W instate !disabled { ttk::clickToFocus %W; %W state pressed } }
|
| 28 |
+
bind TButton <ButtonRelease-1> \
|
| 29 |
+
{ %W instate pressed { %W state !pressed; %W instate !disabled { %W invoke } } }
|
| 30 |
+
bind TButton <Button1-Leave> \
|
| 31 |
+
{ %W state !pressed }
|
| 32 |
+
bind TButton <Button1-Enter> \
|
| 33 |
+
{ %W instate {active !disabled} { %W state pressed } }
|
| 34 |
+
|
| 35 |
+
# Checkbuttons and Radiobuttons have the same bindings as Buttons:
|
| 36 |
+
#
|
| 37 |
+
ttk::copyBindings TButton TCheckbutton
|
| 38 |
+
ttk::copyBindings TButton TRadiobutton
|
| 39 |
+
|
| 40 |
+
# ...plus a few more:
|
| 41 |
+
|
| 42 |
+
bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 }
|
| 43 |
+
bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 }
|
| 44 |
+
|
| 45 |
+
# bind TCheckbutton <plus> { %W select }
|
| 46 |
+
# bind TCheckbutton <minus> { %W deselect }
|
| 47 |
+
|
| 48 |
+
# activate --
|
| 49 |
+
# Simulate a button press: temporarily set the state to 'pressed',
|
| 50 |
+
# then invoke the button.
|
| 51 |
+
#
|
| 52 |
+
proc ttk::button::activate {w} {
|
| 53 |
+
$w instate disabled { return }
|
| 54 |
+
set oldState [$w state pressed]
|
| 55 |
+
update idletasks; after 100 ;# block event loop to avoid reentrancy
|
| 56 |
+
$w state $oldState
|
| 57 |
+
$w invoke
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
# RadioTraverse -- up/down keyboard traversal for radiobutton groups.
|
| 61 |
+
# Set focus to previous/next radiobutton in a group.
|
| 62 |
+
# A radiobutton group consists of all the radiobuttons with
|
| 63 |
+
# the same parent and -variable; this is a pretty good heuristic
|
| 64 |
+
# that works most of the time.
|
| 65 |
+
#
|
| 66 |
+
proc ttk::button::RadioTraverse {w dir} {
|
| 67 |
+
set group [list]
|
| 68 |
+
foreach sibling [winfo children [winfo parent $w]] {
|
| 69 |
+
if { [winfo class $sibling] eq "TRadiobutton"
|
| 70 |
+
&& [$sibling cget -variable] eq [$w cget -variable]
|
| 71 |
+
&& ![$sibling instate disabled]
|
| 72 |
+
} {
|
| 73 |
+
lappend group $sibling
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
if {![llength $group]} { # Shouldn't happen, but can.
|
| 78 |
+
return
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
set pos [expr {([lsearch -exact $group $w] + $dir) % [llength $group]}]
|
| 82 |
+
tk::TabToWindow [lindex $group $pos]
|
| 83 |
+
}
|
parrot/lib/tk8.6/ttk/classicTheme.tcl
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# "classic" Tk theme.
|
| 3 |
+
#
|
| 4 |
+
# Implements Tk's traditional Motif-like look and feel.
|
| 5 |
+
#
|
| 6 |
+
|
| 7 |
+
namespace eval ttk::theme::classic {
|
| 8 |
+
|
| 9 |
+
variable colors; array set colors {
|
| 10 |
+
-frame "#d9d9d9"
|
| 11 |
+
-window "#ffffff"
|
| 12 |
+
-activebg "#ececec"
|
| 13 |
+
-troughbg "#c3c3c3"
|
| 14 |
+
-selectbg "#c3c3c3"
|
| 15 |
+
-selectfg "#000000"
|
| 16 |
+
-disabledfg "#a3a3a3"
|
| 17 |
+
-indicator "#b03060"
|
| 18 |
+
-altindicator "#b05e5e"
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
ttk::style theme settings classic {
|
| 22 |
+
ttk::style configure "." \
|
| 23 |
+
-font TkDefaultFont \
|
| 24 |
+
-background $colors(-frame) \
|
| 25 |
+
-foreground black \
|
| 26 |
+
-selectbackground $colors(-selectbg) \
|
| 27 |
+
-selectforeground $colors(-selectfg) \
|
| 28 |
+
-troughcolor $colors(-troughbg) \
|
| 29 |
+
-indicatorcolor $colors(-frame) \
|
| 30 |
+
-highlightcolor $colors(-frame) \
|
| 31 |
+
-highlightthickness 1 \
|
| 32 |
+
-selectborderwidth 1 \
|
| 33 |
+
-insertwidth 2 \
|
| 34 |
+
;
|
| 35 |
+
|
| 36 |
+
# To match pre-Xft X11 appearance, use:
|
| 37 |
+
# ttk::style configure . -font {Helvetica 12 bold}
|
| 38 |
+
|
| 39 |
+
ttk::style map "." -background \
|
| 40 |
+
[list disabled $colors(-frame) active $colors(-activebg)]
|
| 41 |
+
ttk::style map "." -foreground \
|
| 42 |
+
[list disabled $colors(-disabledfg)]
|
| 43 |
+
|
| 44 |
+
ttk::style map "." -highlightcolor [list focus black]
|
| 45 |
+
|
| 46 |
+
ttk::style configure TButton \
|
| 47 |
+
-anchor center -padding "3m 1m" -relief raised -shiftrelief 1
|
| 48 |
+
ttk::style map TButton -relief [list {!disabled pressed} sunken]
|
| 49 |
+
|
| 50 |
+
ttk::style configure TCheckbutton -indicatorrelief raised
|
| 51 |
+
ttk::style map TCheckbutton \
|
| 52 |
+
-indicatorcolor [list \
|
| 53 |
+
pressed $colors(-frame) \
|
| 54 |
+
alternate $colors(-altindicator) \
|
| 55 |
+
selected $colors(-indicator)] \
|
| 56 |
+
-indicatorrelief {alternate raised selected sunken pressed sunken} \
|
| 57 |
+
;
|
| 58 |
+
|
| 59 |
+
ttk::style configure TRadiobutton -indicatorrelief raised
|
| 60 |
+
ttk::style map TRadiobutton \
|
| 61 |
+
-indicatorcolor [list \
|
| 62 |
+
pressed $colors(-frame) \
|
| 63 |
+
alternate $colors(-altindicator) \
|
| 64 |
+
selected $colors(-indicator)] \
|
| 65 |
+
-indicatorrelief {alternate raised selected sunken pressed sunken} \
|
| 66 |
+
;
|
| 67 |
+
|
| 68 |
+
ttk::style configure TMenubutton -relief raised -padding "3m 1m"
|
| 69 |
+
|
| 70 |
+
ttk::style configure TEntry -relief sunken -padding 1 -font TkTextFont
|
| 71 |
+
ttk::style map TEntry -fieldbackground \
|
| 72 |
+
[list readonly $colors(-frame) disabled $colors(-frame)]
|
| 73 |
+
ttk::style configure TCombobox -padding 1
|
| 74 |
+
ttk::style map TCombobox -fieldbackground \
|
| 75 |
+
[list readonly $colors(-frame) disabled $colors(-frame)]
|
| 76 |
+
ttk::style configure ComboboxPopdownFrame \
|
| 77 |
+
-relief solid -borderwidth 1
|
| 78 |
+
|
| 79 |
+
ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0}
|
| 80 |
+
ttk::style map TSpinbox -fieldbackground \
|
| 81 |
+
[list readonly $colors(-frame) disabled $colors(-frame)]
|
| 82 |
+
|
| 83 |
+
ttk::style configure TLabelframe -borderwidth 2 -relief groove
|
| 84 |
+
|
| 85 |
+
ttk::style configure TScrollbar -relief raised
|
| 86 |
+
ttk::style map TScrollbar -relief {{pressed !disabled} sunken}
|
| 87 |
+
|
| 88 |
+
ttk::style configure TScale -sliderrelief raised
|
| 89 |
+
ttk::style map TScale -sliderrelief {{pressed !disabled} sunken}
|
| 90 |
+
|
| 91 |
+
ttk::style configure TProgressbar -background SteelBlue
|
| 92 |
+
ttk::style configure TNotebook.Tab \
|
| 93 |
+
-padding {3m 1m} \
|
| 94 |
+
-background $colors(-troughbg)
|
| 95 |
+
ttk::style map TNotebook.Tab -background [list selected $colors(-frame)]
|
| 96 |
+
|
| 97 |
+
# Treeview:
|
| 98 |
+
ttk::style configure Heading -font TkHeadingFont -relief raised
|
| 99 |
+
ttk::style configure Treeview -background $colors(-window)
|
| 100 |
+
ttk::style map Treeview \
|
| 101 |
+
-background [list disabled $colors(-frame)\
|
| 102 |
+
selected $colors(-selectbg)] \
|
| 103 |
+
-foreground [list disabled $colors(-disabledfg) \
|
| 104 |
+
selected $colors(-selectfg)]
|
| 105 |
+
|
| 106 |
+
#
|
| 107 |
+
# Toolbar buttons:
|
| 108 |
+
#
|
| 109 |
+
ttk::style configure Toolbutton -padding 2 -relief flat -shiftrelief 2
|
| 110 |
+
ttk::style map Toolbutton -relief \
|
| 111 |
+
{disabled flat selected sunken pressed sunken active raised}
|
| 112 |
+
ttk::style map Toolbutton -background \
|
| 113 |
+
[list pressed $colors(-troughbg) active $colors(-activebg)]
|
| 114 |
+
}
|
| 115 |
+
}
|
parrot/lib/tk8.6/ttk/defaults.tcl
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Settings for default theme.
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
namespace eval ttk::theme::default {
|
| 6 |
+
variable colors
|
| 7 |
+
array set colors {
|
| 8 |
+
-frame "#d9d9d9"
|
| 9 |
+
-foreground "#000000"
|
| 10 |
+
-window "#ffffff"
|
| 11 |
+
-text "#000000"
|
| 12 |
+
-activebg "#ececec"
|
| 13 |
+
-selectbg "#4a6984"
|
| 14 |
+
-selectfg "#ffffff"
|
| 15 |
+
-darker "#c3c3c3"
|
| 16 |
+
-disabledfg "#a3a3a3"
|
| 17 |
+
-indicator "#4a6984"
|
| 18 |
+
-disabledindicator "#a3a3a3"
|
| 19 |
+
-altindicator "#9fbdd8"
|
| 20 |
+
-disabledaltindicator "#c0c0c0"
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
ttk::style theme settings default {
|
| 24 |
+
|
| 25 |
+
ttk::style configure "." \
|
| 26 |
+
-borderwidth 1 \
|
| 27 |
+
-background $colors(-frame) \
|
| 28 |
+
-foreground $colors(-foreground) \
|
| 29 |
+
-troughcolor $colors(-darker) \
|
| 30 |
+
-font TkDefaultFont \
|
| 31 |
+
-selectborderwidth 1 \
|
| 32 |
+
-selectbackground $colors(-selectbg) \
|
| 33 |
+
-selectforeground $colors(-selectfg) \
|
| 34 |
+
-insertwidth 1 \
|
| 35 |
+
-indicatordiameter 10 \
|
| 36 |
+
;
|
| 37 |
+
|
| 38 |
+
ttk::style map "." -background \
|
| 39 |
+
[list disabled $colors(-frame) active $colors(-activebg)]
|
| 40 |
+
ttk::style map "." -foreground \
|
| 41 |
+
[list disabled $colors(-disabledfg)]
|
| 42 |
+
|
| 43 |
+
ttk::style configure TButton \
|
| 44 |
+
-anchor center -padding "3 3" -width -9 \
|
| 45 |
+
-relief raised -shiftrelief 1
|
| 46 |
+
ttk::style map TButton -relief [list {!disabled pressed} sunken]
|
| 47 |
+
|
| 48 |
+
ttk::style configure TCheckbutton \
|
| 49 |
+
-indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1
|
| 50 |
+
ttk::style map TCheckbutton -indicatorcolor \
|
| 51 |
+
[list pressed $colors(-activebg) \
|
| 52 |
+
{!disabled alternate} $colors(-altindicator) \
|
| 53 |
+
{disabled alternate} $colors(-disabledaltindicator) \
|
| 54 |
+
{!disabled selected} $colors(-indicator) \
|
| 55 |
+
{disabled selected} $colors(-disabledindicator)]
|
| 56 |
+
ttk::style map TCheckbutton -indicatorrelief \
|
| 57 |
+
[list alternate raised]
|
| 58 |
+
|
| 59 |
+
ttk::style configure TRadiobutton \
|
| 60 |
+
-indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1
|
| 61 |
+
ttk::style map TRadiobutton -indicatorcolor \
|
| 62 |
+
[list pressed $colors(-activebg) \
|
| 63 |
+
{!disabled alternate} $colors(-altindicator) \
|
| 64 |
+
{disabled alternate} $colors(-disabledaltindicator) \
|
| 65 |
+
{!disabled selected} $colors(-indicator) \
|
| 66 |
+
{disabled selected} $colors(-disabledindicator)]
|
| 67 |
+
ttk::style map TRadiobutton -indicatorrelief \
|
| 68 |
+
[list alternate raised]
|
| 69 |
+
|
| 70 |
+
ttk::style configure TMenubutton \
|
| 71 |
+
-relief raised -padding "10 3"
|
| 72 |
+
|
| 73 |
+
ttk::style configure TEntry \
|
| 74 |
+
-relief sunken -fieldbackground white -padding 1
|
| 75 |
+
ttk::style map TEntry -fieldbackground \
|
| 76 |
+
[list readonly $colors(-frame) disabled $colors(-frame)]
|
| 77 |
+
|
| 78 |
+
ttk::style configure TCombobox -arrowsize 12 -padding 1
|
| 79 |
+
ttk::style map TCombobox -fieldbackground \
|
| 80 |
+
[list readonly $colors(-frame) disabled $colors(-frame)] \
|
| 81 |
+
-arrowcolor [list disabled $colors(-disabledfg)]
|
| 82 |
+
|
| 83 |
+
ttk::style configure TSpinbox -arrowsize 10 -padding {2 0 10 0}
|
| 84 |
+
ttk::style map TSpinbox -fieldbackground \
|
| 85 |
+
[list readonly $colors(-frame) disabled $colors(-frame)] \
|
| 86 |
+
-arrowcolor [list disabled $colors(-disabledfg)]
|
| 87 |
+
|
| 88 |
+
ttk::style configure TLabelframe \
|
| 89 |
+
-relief groove -borderwidth 2
|
| 90 |
+
|
| 91 |
+
ttk::style configure TScrollbar \
|
| 92 |
+
-width 12 -arrowsize 12
|
| 93 |
+
ttk::style map TScrollbar \
|
| 94 |
+
-arrowcolor [list disabled $colors(-disabledfg)]
|
| 95 |
+
|
| 96 |
+
ttk::style configure TScale \
|
| 97 |
+
-sliderrelief raised
|
| 98 |
+
ttk::style configure TProgressbar \
|
| 99 |
+
-background $colors(-selectbg)
|
| 100 |
+
|
| 101 |
+
ttk::style configure TNotebook.Tab \
|
| 102 |
+
-padding {4 2} -background $colors(-darker)
|
| 103 |
+
ttk::style map TNotebook.Tab \
|
| 104 |
+
-background [list selected $colors(-frame)]
|
| 105 |
+
|
| 106 |
+
# Treeview.
|
| 107 |
+
#
|
| 108 |
+
ttk::style configure Heading -font TkHeadingFont -relief raised
|
| 109 |
+
ttk::style configure Treeview \
|
| 110 |
+
-background $colors(-window) \
|
| 111 |
+
-foreground $colors(-text) ;
|
| 112 |
+
ttk::style map Treeview \
|
| 113 |
+
-background [list disabled $colors(-frame)\
|
| 114 |
+
selected $colors(-selectbg)] \
|
| 115 |
+
-foreground [list disabled $colors(-disabledfg) \
|
| 116 |
+
selected $colors(-selectfg)]
|
| 117 |
+
|
| 118 |
+
# Combobox popdown frame
|
| 119 |
+
ttk::style layout ComboboxPopdownFrame {
|
| 120 |
+
ComboboxPopdownFrame.border -sticky nswe
|
| 121 |
+
}
|
| 122 |
+
ttk::style configure ComboboxPopdownFrame \
|
| 123 |
+
-borderwidth 1 -relief solid
|
| 124 |
+
|
| 125 |
+
#
|
| 126 |
+
# Toolbar buttons:
|
| 127 |
+
#
|
| 128 |
+
ttk::style layout Toolbutton {
|
| 129 |
+
Toolbutton.border -children {
|
| 130 |
+
Toolbutton.padding -children {
|
| 131 |
+
Toolbutton.label
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
ttk::style configure Toolbutton \
|
| 137 |
+
-padding 2 -relief flat
|
| 138 |
+
ttk::style map Toolbutton -relief \
|
| 139 |
+
[list disabled flat selected sunken pressed sunken active raised]
|
| 140 |
+
ttk::style map Toolbutton -background \
|
| 141 |
+
[list pressed $colors(-darker) active $colors(-activebg)]
|
| 142 |
+
}
|
| 143 |
+
}
|
parrot/lib/tk8.6/ttk/entry.tcl
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# DERIVED FROM: tk/library/entry.tcl r1.22
|
| 3 |
+
#
|
| 4 |
+
# Copyright (c) 1992-1994 The Regents of the University of California.
|
| 5 |
+
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
| 6 |
+
# Copyright (c) 2004, Joe English
|
| 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 |
+
namespace eval ttk {
|
| 13 |
+
namespace eval entry {
|
| 14 |
+
variable State
|
| 15 |
+
|
| 16 |
+
set State(x) 0
|
| 17 |
+
set State(selectMode) none
|
| 18 |
+
set State(anchor) 0
|
| 19 |
+
set State(scanX) 0
|
| 20 |
+
set State(scanIndex) 0
|
| 21 |
+
set State(scanMoved) 0
|
| 22 |
+
|
| 23 |
+
# Button-2 scan speed is (scanNum/scanDen) characters
|
| 24 |
+
# per pixel of mouse movement.
|
| 25 |
+
# The standard Tk entry widget uses the equivalent of
|
| 26 |
+
# scanNum = 10, scanDen = average character width.
|
| 27 |
+
# I don't know why that was chosen.
|
| 28 |
+
#
|
| 29 |
+
set State(scanNum) 1
|
| 30 |
+
set State(scanDen) 1
|
| 31 |
+
set State(deadband) 3 ;# #pixels for mouse-moved deadband.
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
### Option database settings.
|
| 36 |
+
#
|
| 37 |
+
option add *TEntry.cursor [ttk::cursor text] widgetDefault
|
| 38 |
+
|
| 39 |
+
### Bindings.
|
| 40 |
+
#
|
| 41 |
+
# Removed the following standard Tk bindings:
|
| 42 |
+
#
|
| 43 |
+
# <Control-space>, <Control-Shift-space>,
|
| 44 |
+
# <Select>, <Shift-Select>:
|
| 45 |
+
# Ttk entry widget doesn't use selection anchor.
|
| 46 |
+
# <Insert>:
|
| 47 |
+
# Inserts PRIMARY selection (on non-Windows platforms).
|
| 48 |
+
# This is inconsistent with typical platform bindings.
|
| 49 |
+
# <Double-Shift-Button-1>, <Triple-Shift-Button-1>:
|
| 50 |
+
# These don't do the right thing to start with.
|
| 51 |
+
# <Meta-b>, <Meta-d>, <Meta-f>,
|
| 52 |
+
# <Meta-BackSpace>, <Meta-Delete>:
|
| 53 |
+
# Judgment call. If <Meta> happens to be assigned to the Alt key,
|
| 54 |
+
# these could conflict with application accelerators.
|
| 55 |
+
# (Plus, who has a Meta key these days?)
|
| 56 |
+
# <Control-t>:
|
| 57 |
+
# Another judgment call. If anyone misses this, let me know
|
| 58 |
+
# and I'll put it back.
|
| 59 |
+
#
|
| 60 |
+
|
| 61 |
+
## Clipboard events:
|
| 62 |
+
#
|
| 63 |
+
bind TEntry <<Cut>> { ttk::entry::Cut %W }
|
| 64 |
+
bind TEntry <<Copy>> { ttk::entry::Copy %W }
|
| 65 |
+
bind TEntry <<Paste>> { ttk::entry::Paste %W }
|
| 66 |
+
bind TEntry <<Clear>> { ttk::entry::Clear %W }
|
| 67 |
+
|
| 68 |
+
## Button1 bindings:
|
| 69 |
+
# Used for selection and navigation.
|
| 70 |
+
#
|
| 71 |
+
bind TEntry <Button-1> { ttk::entry::Press %W %x }
|
| 72 |
+
bind TEntry <Shift-Button-1> { ttk::entry::Shift-Press %W %x }
|
| 73 |
+
bind TEntry <Double-Button-1> { ttk::entry::Select %W %x word }
|
| 74 |
+
bind TEntry <Triple-Button-1> { ttk::entry::Select %W %x line }
|
| 75 |
+
bind TEntry <B1-Motion> { ttk::entry::Drag %W %x }
|
| 76 |
+
|
| 77 |
+
bind TEntry <B1-Leave> { ttk::entry::DragOut %W %m }
|
| 78 |
+
bind TEntry <B1-Enter> { ttk::entry::DragIn %W }
|
| 79 |
+
bind TEntry <ButtonRelease-1> { ttk::entry::Release %W }
|
| 80 |
+
|
| 81 |
+
bind TEntry <<ToggleSelection>> {
|
| 82 |
+
%W instate {!readonly !disabled} { %W icursor @%x ; focus %W }
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
## Button2 (Button3 on Aqua) bindings:
|
| 86 |
+
# Used for scanning and primary transfer.
|
| 87 |
+
# Note: ButtonRelease-2 (ButtonRelease-3 on Aqua)
|
| 88 |
+
# is mapped to <<PasteSelection>> in tk.tcl.
|
| 89 |
+
#
|
| 90 |
+
if {[tk windowingsystem] ne "aqua"} {
|
| 91 |
+
bind TEntry <Button-2> { ttk::entry::ScanMark %W %x }
|
| 92 |
+
bind TEntry <B2-Motion> { ttk::entry::ScanDrag %W %x }
|
| 93 |
+
bind TEntry <ButtonRelease-2> { ttk::entry::ScanRelease %W %x }
|
| 94 |
+
} else {
|
| 95 |
+
bind TEntry <Button-3> { ttk::entry::ScanMark %W %x }
|
| 96 |
+
bind TEntry <B3-Motion> { ttk::entry::ScanDrag %W %x }
|
| 97 |
+
bind TEntry <ButtonRelease-3> { ttk::entry::ScanRelease %W %x }
|
| 98 |
+
}
|
| 99 |
+
bind TEntry <<PasteSelection>> { ttk::entry::ScanRelease %W %x }
|
| 100 |
+
|
| 101 |
+
## Keyboard navigation bindings:
|
| 102 |
+
#
|
| 103 |
+
bind TEntry <<PrevChar>> { ttk::entry::Move %W prevchar }
|
| 104 |
+
bind TEntry <<NextChar>> { ttk::entry::Move %W nextchar }
|
| 105 |
+
bind TEntry <<PrevWord>> { ttk::entry::Move %W prevword }
|
| 106 |
+
bind TEntry <<NextWord>> { ttk::entry::Move %W nextword }
|
| 107 |
+
bind TEntry <<LineStart>> { ttk::entry::Move %W home }
|
| 108 |
+
bind TEntry <<LineEnd>> { ttk::entry::Move %W end }
|
| 109 |
+
|
| 110 |
+
bind TEntry <<SelectPrevChar>> { ttk::entry::Extend %W prevchar }
|
| 111 |
+
bind TEntry <<SelectNextChar>> { ttk::entry::Extend %W nextchar }
|
| 112 |
+
bind TEntry <<SelectPrevWord>> { ttk::entry::Extend %W prevword }
|
| 113 |
+
bind TEntry <<SelectNextWord>> { ttk::entry::Extend %W nextword }
|
| 114 |
+
bind TEntry <<SelectLineStart>> { ttk::entry::Extend %W home }
|
| 115 |
+
bind TEntry <<SelectLineEnd>> { ttk::entry::Extend %W end }
|
| 116 |
+
|
| 117 |
+
bind TEntry <<SelectAll>> { %W selection range 0 end }
|
| 118 |
+
bind TEntry <<SelectNone>> { %W selection clear }
|
| 119 |
+
|
| 120 |
+
bind TEntry <<TraverseIn>> { %W selection range 0 end; %W icursor end }
|
| 121 |
+
|
| 122 |
+
## Edit bindings:
|
| 123 |
+
#
|
| 124 |
+
bind TEntry <Key> { ttk::entry::Insert %W %A }
|
| 125 |
+
bind TEntry <Delete> { ttk::entry::Delete %W }
|
| 126 |
+
bind TEntry <BackSpace> { ttk::entry::Backspace %W }
|
| 127 |
+
|
| 128 |
+
# Ignore all Alt, Meta, and Control keypresses unless explicitly bound.
|
| 129 |
+
# Otherwise, the <Key> class binding will fire and insert the character.
|
| 130 |
+
# Ditto for Escape, Return, and Tab.
|
| 131 |
+
#
|
| 132 |
+
bind TEntry <Alt-Key> {# nothing}
|
| 133 |
+
bind TEntry <Meta-Key> {# nothing}
|
| 134 |
+
bind TEntry <Control-Key> {# nothing}
|
| 135 |
+
bind TEntry <Escape> {# nothing}
|
| 136 |
+
bind TEntry <Return> {# nothing}
|
| 137 |
+
bind TEntry <KP_Enter> {# nothing}
|
| 138 |
+
bind TEntry <Tab> {# nothing}
|
| 139 |
+
|
| 140 |
+
# Argh. Apparently on Windows, the NumLock modifier is interpreted
|
| 141 |
+
# as a Command modifier.
|
| 142 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 143 |
+
bind TEntry <Command-Key> {# nothing}
|
| 144 |
+
bind TEntry <Mod4-Key> {# nothing}
|
| 145 |
+
}
|
| 146 |
+
# Tk-on-Cocoa generates characters for these two keys. [Bug 2971663]
|
| 147 |
+
bind TEntry <<PrevLine>> {# nothing}
|
| 148 |
+
bind TEntry <<NextLine>> {# nothing}
|
| 149 |
+
|
| 150 |
+
## Additional emacs-like bindings:
|
| 151 |
+
#
|
| 152 |
+
bind TEntry <Control-d> { ttk::entry::Delete %W }
|
| 153 |
+
bind TEntry <Control-h> { ttk::entry::Backspace %W }
|
| 154 |
+
bind TEntry <Control-k> { %W delete insert end }
|
| 155 |
+
|
| 156 |
+
# Bindings for IME text input.
|
| 157 |
+
|
| 158 |
+
bind TEntry <<TkStartIMEMarkedText>> {
|
| 159 |
+
dict set ::tk::Priv(IMETextMark) "%W" [%W index insert]
|
| 160 |
+
}
|
| 161 |
+
bind TEntry <<TkEndIMEMarkedText>> {
|
| 162 |
+
if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } {
|
| 163 |
+
bell
|
| 164 |
+
} else {
|
| 165 |
+
%W selection range $mark insert
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
bind TEntry <<TkClearIMEMarkedText>> {
|
| 169 |
+
%W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert]
|
| 170 |
+
}
|
| 171 |
+
bind TEntry <<TkAccentBackspace>> {
|
| 172 |
+
ttk::entry::Backspace %W
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
### Clipboard procedures.
|
| 176 |
+
#
|
| 177 |
+
|
| 178 |
+
## EntrySelection -- Return the selected text of the entry.
|
| 179 |
+
# Raises an error if there is no selection.
|
| 180 |
+
#
|
| 181 |
+
proc ttk::entry::EntrySelection {w} {
|
| 182 |
+
set entryString [string range [$w get] [$w index sel.first] \
|
| 183 |
+
[expr {[$w index sel.last] - 1}]]
|
| 184 |
+
if {[$w cget -show] ne ""} {
|
| 185 |
+
return [string repeat [string index [$w cget -show] 0] \
|
| 186 |
+
[string length $entryString]]
|
| 187 |
+
}
|
| 188 |
+
return $entryString
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
## Paste -- Insert clipboard contents at current insert point.
|
| 192 |
+
#
|
| 193 |
+
proc ttk::entry::Paste {w} {
|
| 194 |
+
catch {
|
| 195 |
+
set clipboard [::tk::GetSelection $w CLIPBOARD]
|
| 196 |
+
PendingDelete $w
|
| 197 |
+
$w insert insert $clipboard
|
| 198 |
+
See $w insert
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
## Copy -- Copy selection to clipboard.
|
| 203 |
+
#
|
| 204 |
+
proc ttk::entry::Copy {w} {
|
| 205 |
+
if {![catch {EntrySelection $w} selection]} {
|
| 206 |
+
clipboard clear -displayof $w
|
| 207 |
+
clipboard append -displayof $w $selection
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
## Clear -- Delete the selection.
|
| 212 |
+
#
|
| 213 |
+
proc ttk::entry::Clear {w} {
|
| 214 |
+
catch { $w delete sel.first sel.last }
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
## Cut -- Copy selection to clipboard then delete it.
|
| 218 |
+
#
|
| 219 |
+
proc ttk::entry::Cut {w} {
|
| 220 |
+
Copy $w; Clear $w
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
### Navigation procedures.
|
| 224 |
+
#
|
| 225 |
+
|
| 226 |
+
## ClosestGap -- Find closest boundary between characters.
|
| 227 |
+
# Returns the index of the character just after the boundary.
|
| 228 |
+
#
|
| 229 |
+
proc ttk::entry::ClosestGap {w x} {
|
| 230 |
+
set pos [$w index @$x]
|
| 231 |
+
set bbox [$w bbox $pos]
|
| 232 |
+
if {$x - [lindex $bbox 0] > [lindex $bbox 2]/2} {
|
| 233 |
+
incr pos
|
| 234 |
+
}
|
| 235 |
+
return $pos
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
## See $index -- Make sure that the character at $index is visible.
|
| 239 |
+
#
|
| 240 |
+
proc ttk::entry::See {w {index insert}} {
|
| 241 |
+
set c [$w index $index]
|
| 242 |
+
# @@@ OR: check [$w index left] / [$w index right]
|
| 243 |
+
if {$c < [$w index @0] || $c >= [$w index @[winfo width $w]]} {
|
| 244 |
+
$w xview $c
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
## NextWord -- Find the next word position.
|
| 249 |
+
# Note: The "next word position" follows platform conventions:
|
| 250 |
+
# either the next end-of-word position, or the start-of-word
|
| 251 |
+
# position following the next end-of-word position.
|
| 252 |
+
#
|
| 253 |
+
set ::ttk::entry::State(startNext) \
|
| 254 |
+
[string equal [tk windowingsystem] "win32"]
|
| 255 |
+
|
| 256 |
+
proc ttk::entry::NextWord {w start} {
|
| 257 |
+
# the check on [winfo class] is because the spinbox and combobox also use this proc
|
| 258 |
+
if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
|
| 259 |
+
return end
|
| 260 |
+
}
|
| 261 |
+
variable State
|
| 262 |
+
set pos [tcl_endOfWord [$w get] [$w index $start]]
|
| 263 |
+
if {$pos >= 0 && $State(startNext)} {
|
| 264 |
+
set pos [tcl_startOfNextWord [$w get] $pos]
|
| 265 |
+
}
|
| 266 |
+
if {$pos < 0} {
|
| 267 |
+
return end
|
| 268 |
+
}
|
| 269 |
+
return $pos
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
## PrevWord -- Find the previous word position.
|
| 273 |
+
#
|
| 274 |
+
proc ttk::entry::PrevWord {w start} {
|
| 275 |
+
# the check on [winfo class] is because the spinbox and combobox also use this proc
|
| 276 |
+
if {[winfo class $w] eq "TEntry" && [$w cget -show] ne ""} {
|
| 277 |
+
return 0
|
| 278 |
+
}
|
| 279 |
+
set pos [tcl_startOfPreviousWord [$w get] [$w index $start]]
|
| 280 |
+
if {$pos < 0} {
|
| 281 |
+
return 0
|
| 282 |
+
}
|
| 283 |
+
return $pos
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
## RelIndex -- Compute character/word/line-relative index.
|
| 287 |
+
#
|
| 288 |
+
proc ttk::entry::RelIndex {w where {index insert}} {
|
| 289 |
+
switch -- $where {
|
| 290 |
+
prevchar { expr {[$w index $index] - 1} }
|
| 291 |
+
nextchar { expr {[$w index $index] + 1} }
|
| 292 |
+
prevword { PrevWord $w $index }
|
| 293 |
+
nextword { NextWord $w $index }
|
| 294 |
+
home { return 0 }
|
| 295 |
+
end { $w index end }
|
| 296 |
+
default { error "Bad relative index $index" }
|
| 297 |
+
}
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
## Move -- Move insert cursor to relative location.
|
| 301 |
+
# Also clears the selection, if any, and makes sure
|
| 302 |
+
# that the insert cursor is visible.
|
| 303 |
+
#
|
| 304 |
+
proc ttk::entry::Move {w where} {
|
| 305 |
+
$w icursor [RelIndex $w $where]
|
| 306 |
+
$w selection clear
|
| 307 |
+
See $w insert
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
### Selection procedures.
|
| 311 |
+
#
|
| 312 |
+
|
| 313 |
+
## ExtendTo -- Extend the selection to the specified index.
|
| 314 |
+
#
|
| 315 |
+
# The other end of the selection (the anchor) is determined as follows:
|
| 316 |
+
#
|
| 317 |
+
# (1) if there is no selection, the anchor is the insert cursor;
|
| 318 |
+
# (2) if the index is outside the selection, grow the selection;
|
| 319 |
+
# (3) if the insert cursor is at one end of the selection, anchor the other end
|
| 320 |
+
# (4) otherwise anchor the start of the selection
|
| 321 |
+
#
|
| 322 |
+
# The insert cursor is placed at the new end of the selection.
|
| 323 |
+
#
|
| 324 |
+
# Returns: selection anchor.
|
| 325 |
+
#
|
| 326 |
+
proc ttk::entry::ExtendTo {w index} {
|
| 327 |
+
set index [$w index $index]
|
| 328 |
+
set insert [$w index insert]
|
| 329 |
+
|
| 330 |
+
# Figure out selection anchor:
|
| 331 |
+
if {![$w selection present]} {
|
| 332 |
+
set anchor $insert
|
| 333 |
+
} else {
|
| 334 |
+
set selfirst [$w index sel.first]
|
| 335 |
+
set sellast [$w index sel.last]
|
| 336 |
+
|
| 337 |
+
if { ($index < $selfirst)
|
| 338 |
+
|| ($insert == $selfirst && $index <= $sellast)
|
| 339 |
+
} {
|
| 340 |
+
set anchor $sellast
|
| 341 |
+
} else {
|
| 342 |
+
set anchor $selfirst
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
# Extend selection:
|
| 347 |
+
if {$anchor < $index} {
|
| 348 |
+
$w selection range $anchor $index
|
| 349 |
+
} else {
|
| 350 |
+
$w selection range $index $anchor
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
$w icursor $index
|
| 354 |
+
return $anchor
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
## Extend -- Extend the selection to a relative position, show insert cursor
|
| 358 |
+
#
|
| 359 |
+
proc ttk::entry::Extend {w where} {
|
| 360 |
+
ExtendTo $w [RelIndex $w $where]
|
| 361 |
+
See $w
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
### Button 1 binding procedures.
|
| 365 |
+
#
|
| 366 |
+
# Double-clicking followed by a drag enters "word-select" mode.
|
| 367 |
+
# Triple-clicking enters "line-select" mode.
|
| 368 |
+
#
|
| 369 |
+
|
| 370 |
+
## Press -- Button-1 binding.
|
| 371 |
+
# Set the insertion cursor, claim the input focus, set up for
|
| 372 |
+
# future drag operations.
|
| 373 |
+
#
|
| 374 |
+
proc ttk::entry::Press {w x} {
|
| 375 |
+
variable State
|
| 376 |
+
|
| 377 |
+
$w icursor [ClosestGap $w $x]
|
| 378 |
+
$w selection clear
|
| 379 |
+
$w instate !disabled { focus $w }
|
| 380 |
+
|
| 381 |
+
# Set up for future drag, double-click, or triple-click.
|
| 382 |
+
set State(x) $x
|
| 383 |
+
set State(selectMode) char
|
| 384 |
+
set State(anchor) [$w index insert]
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
## Shift-Press -- Shift-Button-1 binding.
|
| 388 |
+
# Extends the selection, sets anchor for future drag operations.
|
| 389 |
+
#
|
| 390 |
+
proc ttk::entry::Shift-Press {w x} {
|
| 391 |
+
variable State
|
| 392 |
+
|
| 393 |
+
focus $w
|
| 394 |
+
set anchor [ExtendTo $w @$x]
|
| 395 |
+
|
| 396 |
+
set State(x) $x
|
| 397 |
+
set State(selectMode) char
|
| 398 |
+
set State(anchor) $anchor
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
## Select $w $x $mode -- Binding for double- and triple- clicks.
|
| 402 |
+
# Selects a word or line (according to mode),
|
| 403 |
+
# and sets the selection mode for subsequent drag operations.
|
| 404 |
+
#
|
| 405 |
+
proc ttk::entry::Select {w x mode} {
|
| 406 |
+
variable State
|
| 407 |
+
set cur [ClosestGap $w $x]
|
| 408 |
+
|
| 409 |
+
switch -- $mode {
|
| 410 |
+
word { WordSelect $w $cur $cur }
|
| 411 |
+
line { LineSelect $w $cur $cur }
|
| 412 |
+
char { # no-op }
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
set State(anchor) $cur
|
| 416 |
+
set State(selectMode) $mode
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
## Drag -- Button1 motion binding.
|
| 420 |
+
#
|
| 421 |
+
proc ttk::entry::Drag {w x} {
|
| 422 |
+
variable State
|
| 423 |
+
set State(x) $x
|
| 424 |
+
DragTo $w $x
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
## DragTo $w $x -- Extend selection to $x based on current selection mode.
|
| 428 |
+
#
|
| 429 |
+
proc ttk::entry::DragTo {w x} {
|
| 430 |
+
variable State
|
| 431 |
+
|
| 432 |
+
set cur [ClosestGap $w $x]
|
| 433 |
+
switch $State(selectMode) {
|
| 434 |
+
char { CharSelect $w $State(anchor) $cur }
|
| 435 |
+
word { WordSelect $w $State(anchor) $cur }
|
| 436 |
+
line { LineSelect $w $State(anchor) $cur }
|
| 437 |
+
none { # no-op }
|
| 438 |
+
}
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
## <B1-Leave> binding:
|
| 442 |
+
# Begin autoscroll.
|
| 443 |
+
#
|
| 444 |
+
proc ttk::entry::DragOut {w mode} {
|
| 445 |
+
variable State
|
| 446 |
+
if {$State(selectMode) ne "none" && $mode eq "NotifyNormal"} {
|
| 447 |
+
ttk::Repeatedly ttk::entry::AutoScroll $w
|
| 448 |
+
}
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
## <B1-Enter> binding
|
| 452 |
+
# Suspend autoscroll.
|
| 453 |
+
#
|
| 454 |
+
proc ttk::entry::DragIn {w} {
|
| 455 |
+
ttk::CancelRepeat
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
## <ButtonRelease-1> binding
|
| 459 |
+
#
|
| 460 |
+
proc ttk::entry::Release {w} {
|
| 461 |
+
variable State
|
| 462 |
+
set State(selectMode) none
|
| 463 |
+
ttk::CancelRepeat ;# suspend autoscroll
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
## AutoScroll
|
| 467 |
+
# Called repeatedly when the mouse is outside an entry window
|
| 468 |
+
# with Button 1 down. Scroll the window left or right,
|
| 469 |
+
# depending on where the mouse left the window, and extend
|
| 470 |
+
# the selection according to the current selection mode.
|
| 471 |
+
#
|
| 472 |
+
# TODO: AutoScroll should repeat faster (50ms) than normal autorepeat.
|
| 473 |
+
# TODO: Need a way for Repeat scripts to cancel themselves.
|
| 474 |
+
#
|
| 475 |
+
proc ttk::entry::AutoScroll {w} {
|
| 476 |
+
variable State
|
| 477 |
+
if {![winfo exists $w]} return
|
| 478 |
+
set x $State(x)
|
| 479 |
+
if {$x > [winfo width $w]} {
|
| 480 |
+
$w xview scroll 2 units
|
| 481 |
+
DragTo $w $x
|
| 482 |
+
} elseif {$x < 0} {
|
| 483 |
+
$w xview scroll -2 units
|
| 484 |
+
DragTo $w $x
|
| 485 |
+
}
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
## CharSelect -- select characters between index $from and $to
|
| 489 |
+
#
|
| 490 |
+
proc ttk::entry::CharSelect {w from to} {
|
| 491 |
+
if {$to <= $from} {
|
| 492 |
+
$w selection range $to $from
|
| 493 |
+
} else {
|
| 494 |
+
$w selection range $from $to
|
| 495 |
+
}
|
| 496 |
+
$w icursor $to
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
## WordSelect -- Select whole words between index $from and $to
|
| 500 |
+
#
|
| 501 |
+
proc ttk::entry::WordSelect {w from to} {
|
| 502 |
+
if {$to < $from} {
|
| 503 |
+
set first [WordBack [$w get] $to]
|
| 504 |
+
set last [WordForward [$w get] $from]
|
| 505 |
+
$w icursor $first
|
| 506 |
+
} else {
|
| 507 |
+
set first [WordBack [$w get] $from]
|
| 508 |
+
set last [WordForward [$w get] $to]
|
| 509 |
+
$w icursor $last
|
| 510 |
+
}
|
| 511 |
+
$w selection range $first $last
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
## WordBack, WordForward -- helper routines for WordSelect.
|
| 515 |
+
#
|
| 516 |
+
proc ttk::entry::WordBack {text index} {
|
| 517 |
+
if {[set pos [tcl_wordBreakBefore $text $index]] < 0} { return 0 }
|
| 518 |
+
return $pos
|
| 519 |
+
}
|
| 520 |
+
proc ttk::entry::WordForward {text index} {
|
| 521 |
+
if {[set pos [tcl_wordBreakAfter $text $index]] < 0} { return end }
|
| 522 |
+
return $pos
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
## LineSelect -- Select the entire line.
|
| 526 |
+
#
|
| 527 |
+
proc ttk::entry::LineSelect {w _ _} {
|
| 528 |
+
variable State
|
| 529 |
+
$w selection range 0 end
|
| 530 |
+
$w icursor end
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
### Button 2 binding procedures.
|
| 534 |
+
#
|
| 535 |
+
|
| 536 |
+
## ScanMark -- Button-2 binding.
|
| 537 |
+
# Marks the start of a scan or primary transfer operation.
|
| 538 |
+
#
|
| 539 |
+
proc ttk::entry::ScanMark {w x} {
|
| 540 |
+
variable State
|
| 541 |
+
set State(scanX) $x
|
| 542 |
+
set State(scanIndex) [$w index @0]
|
| 543 |
+
set State(scanMoved) 0
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
## ScanDrag -- Button2 motion binding.
|
| 547 |
+
#
|
| 548 |
+
proc ttk::entry::ScanDrag {w x} {
|
| 549 |
+
variable State
|
| 550 |
+
|
| 551 |
+
set dx [expr {$State(scanX) - $x}]
|
| 552 |
+
if {abs($dx) > $State(deadband)} {
|
| 553 |
+
set State(scanMoved) 1
|
| 554 |
+
}
|
| 555 |
+
set left [expr {$State(scanIndex) + ($dx*$State(scanNum))/$State(scanDen)}]
|
| 556 |
+
$w xview $left
|
| 557 |
+
|
| 558 |
+
if {$left != [set newLeft [$w index @0]]} {
|
| 559 |
+
# We've scanned past one end of the entry;
|
| 560 |
+
# reset the mark so that the text will start dragging again
|
| 561 |
+
# as soon as the mouse reverses direction.
|
| 562 |
+
#
|
| 563 |
+
set State(scanX) $x
|
| 564 |
+
set State(scanIndex) $newLeft
|
| 565 |
+
}
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
## ScanRelease -- Button2 release binding.
|
| 569 |
+
# Do a primary transfer if the mouse has not moved since the button press.
|
| 570 |
+
#
|
| 571 |
+
proc ttk::entry::ScanRelease {w x} {
|
| 572 |
+
variable State
|
| 573 |
+
if {!$State(scanMoved)} {
|
| 574 |
+
$w instate {!disabled !readonly} {
|
| 575 |
+
$w icursor [ClosestGap $w $x]
|
| 576 |
+
catch {$w insert insert [::tk::GetSelection $w PRIMARY]}
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
### Insertion and deletion procedures.
|
| 582 |
+
#
|
| 583 |
+
|
| 584 |
+
## PendingDelete -- Delete selection prior to insert.
|
| 585 |
+
# If the entry currently has a selection, delete it and
|
| 586 |
+
# set the insert position to where the selection was.
|
| 587 |
+
# Returns: 1 if pending delete occurred, 0 if nothing was selected.
|
| 588 |
+
#
|
| 589 |
+
proc ttk::entry::PendingDelete {w} {
|
| 590 |
+
if {[$w selection present]} {
|
| 591 |
+
$w icursor sel.first
|
| 592 |
+
$w delete sel.first sel.last
|
| 593 |
+
return 1
|
| 594 |
+
}
|
| 595 |
+
return 0
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
## Insert -- Insert text into the entry widget.
|
| 599 |
+
# If a selection is present, the new text replaces it.
|
| 600 |
+
# Otherwise, the new text is inserted at the insert cursor.
|
| 601 |
+
#
|
| 602 |
+
proc ttk::entry::Insert {w s} {
|
| 603 |
+
if {$s eq ""} { return }
|
| 604 |
+
PendingDelete $w
|
| 605 |
+
$w insert insert $s
|
| 606 |
+
See $w insert
|
| 607 |
+
}
|
| 608 |
+
|
| 609 |
+
## Backspace -- Backspace over the character just before the insert cursor.
|
| 610 |
+
# If there is a selection, delete that instead.
|
| 611 |
+
# If the new insert position is offscreen to the left,
|
| 612 |
+
# scroll to place the cursor at about the middle of the window.
|
| 613 |
+
#
|
| 614 |
+
proc ttk::entry::Backspace {w} {
|
| 615 |
+
if {[PendingDelete $w]} {
|
| 616 |
+
See $w
|
| 617 |
+
return
|
| 618 |
+
}
|
| 619 |
+
set x [expr {[$w index insert] - 1}]
|
| 620 |
+
if {$x < 0} { return }
|
| 621 |
+
|
| 622 |
+
$w delete $x
|
| 623 |
+
|
| 624 |
+
if {[$w index @0] >= [$w index insert]} {
|
| 625 |
+
set range [$w xview]
|
| 626 |
+
set left [lindex $range 0]
|
| 627 |
+
set right [lindex $range 1]
|
| 628 |
+
$w xview moveto [expr {$left - ($right - $left)/2.0}]
|
| 629 |
+
}
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
## Delete -- Delete the character after the insert cursor.
|
| 633 |
+
# If there is a selection, delete that instead.
|
| 634 |
+
#
|
| 635 |
+
proc ttk::entry::Delete {w} {
|
| 636 |
+
if {![PendingDelete $w]} {
|
| 637 |
+
$w delete insert
|
| 638 |
+
}
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
#*EOF*
|
parrot/lib/tk8.6/ttk/menubutton.tcl
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Bindings for Menubuttons.
|
| 3 |
+
#
|
| 4 |
+
# Menubuttons have three interaction modes:
|
| 5 |
+
#
|
| 6 |
+
# Pulldown: Press menubutton, drag over menu, release to activate menu entry
|
| 7 |
+
# Popdown: Click menubutton to post menu
|
| 8 |
+
# Keyboard: <space> or accelerator key to post menu
|
| 9 |
+
#
|
| 10 |
+
# (In addition, when menu system is active, "dropdown" -- menu posts
|
| 11 |
+
# on mouse-over. Ttk menubuttons don't implement this).
|
| 12 |
+
#
|
| 13 |
+
# For keyboard and popdown mode, we hand off to tk_popup and let
|
| 14 |
+
# the built-in Tk bindings handle the rest of the interaction.
|
| 15 |
+
#
|
| 16 |
+
# ON X11:
|
| 17 |
+
#
|
| 18 |
+
# Standard Tk menubuttons use a global grab on the menubutton.
|
| 19 |
+
# This won't work for Ttk menubuttons in pulldown mode,
|
| 20 |
+
# since we need to process the final <ButtonRelease> event,
|
| 21 |
+
# and this might be delivered to the menu. So instead we
|
| 22 |
+
# rely on the passive grab that occurs on <Button> events,
|
| 23 |
+
# and transition to popdown mode when the mouse is released
|
| 24 |
+
# or dragged outside the menubutton.
|
| 25 |
+
#
|
| 26 |
+
# ON WINDOWS:
|
| 27 |
+
#
|
| 28 |
+
# I'm not sure what the hell is going on here. [$menu post] apparently
|
| 29 |
+
# sets up some kind of internal grab for native menus.
|
| 30 |
+
# On this platform, just use [tk_popup] for all menu actions.
|
| 31 |
+
#
|
| 32 |
+
# ON MACOS:
|
| 33 |
+
#
|
| 34 |
+
# Same probably applies here.
|
| 35 |
+
#
|
| 36 |
+
|
| 37 |
+
namespace eval ttk {
|
| 38 |
+
namespace eval menubutton {
|
| 39 |
+
variable State
|
| 40 |
+
array set State {
|
| 41 |
+
pulldown 0
|
| 42 |
+
oldcursor {}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
bind TMenubutton <Enter> { %W instate !disabled {%W state active } }
|
| 48 |
+
bind TMenubutton <Leave> { %W state !active }
|
| 49 |
+
bind TMenubutton <space> { ttk::menubutton::Popdown %W }
|
| 50 |
+
bind TMenubutton <<Invoke>> { ttk::menubutton::Popdown %W }
|
| 51 |
+
|
| 52 |
+
if {[tk windowingsystem] eq "x11"} {
|
| 53 |
+
bind TMenubutton <Button-1> { ttk::menubutton::Pulldown %W }
|
| 54 |
+
bind TMenubutton <ButtonRelease-1> { ttk::menubutton::TransferGrab %W }
|
| 55 |
+
bind TMenubutton <B1-Leave> { ttk::menubutton::TransferGrab %W }
|
| 56 |
+
} else {
|
| 57 |
+
bind TMenubutton <Button-1> \
|
| 58 |
+
{ %W state pressed ; ttk::menubutton::Popdown %W }
|
| 59 |
+
bind TMenubutton <ButtonRelease-1> \
|
| 60 |
+
{ if {[winfo exists %W]} { %W state !pressed } }
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
# PostPosition --
|
| 64 |
+
# Returns x and y coordinates and a menu item index.
|
| 65 |
+
# If the index is not an empty string the menu should
|
| 66 |
+
# be posted so that the upper left corner of the indexed
|
| 67 |
+
# menu item is located at the point (x, y). Otherwise
|
| 68 |
+
# the top left corner of the menu itself should be located
|
| 69 |
+
# at that point.
|
| 70 |
+
#
|
| 71 |
+
# TODO: adjust menu width to be at least as wide as the button
|
| 72 |
+
# for -direction above, below.
|
| 73 |
+
#
|
| 74 |
+
|
| 75 |
+
if {[tk windowingsystem] eq "aqua"} {
|
| 76 |
+
proc ::ttk::menubutton::PostPosition {mb menu} {
|
| 77 |
+
set menuPad 5
|
| 78 |
+
set buttonPad 1
|
| 79 |
+
set bevelPad 4
|
| 80 |
+
set mh [winfo reqheight $menu]
|
| 81 |
+
set bh [expr {[winfo height $mb]} + $buttonPad]
|
| 82 |
+
set bbh [expr {[winfo height $mb]} + $bevelPad]
|
| 83 |
+
set mw [winfo reqwidth $menu]
|
| 84 |
+
set bw [winfo width $mb]
|
| 85 |
+
set entry [::tk::MenuFindName $menu [$mb cget -text]]
|
| 86 |
+
if {$entry < 0} {
|
| 87 |
+
set entry 0
|
| 88 |
+
}
|
| 89 |
+
set x [winfo rootx $mb]
|
| 90 |
+
set y [winfo rooty $mb]
|
| 91 |
+
switch [$mb cget -direction] {
|
| 92 |
+
above {
|
| 93 |
+
set entry ""
|
| 94 |
+
incr y [expr {-$mh + 2 * $menuPad}]
|
| 95 |
+
}
|
| 96 |
+
below {
|
| 97 |
+
set entry ""
|
| 98 |
+
incr y $bh
|
| 99 |
+
}
|
| 100 |
+
left {
|
| 101 |
+
incr y $menuPad
|
| 102 |
+
incr x -$mw
|
| 103 |
+
}
|
| 104 |
+
right {
|
| 105 |
+
incr y $menuPad
|
| 106 |
+
incr x $bw
|
| 107 |
+
}
|
| 108 |
+
default { # flush
|
| 109 |
+
incr y $bbh
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
return [list $x $y $entry]
|
| 113 |
+
}
|
| 114 |
+
} else {
|
| 115 |
+
proc ::ttk::menubutton::PostPosition {mb menu} {
|
| 116 |
+
set mh [expr {[winfo reqheight $menu]}]
|
| 117 |
+
set bh [expr {[winfo height $mb]}]
|
| 118 |
+
set mw [expr {[winfo reqwidth $menu]}]
|
| 119 |
+
set bw [expr {[winfo width $mb]}]
|
| 120 |
+
if {[tk windowingsystem] eq "win32"} {
|
| 121 |
+
incr mh 6
|
| 122 |
+
incr mw 16
|
| 123 |
+
}
|
| 124 |
+
set entry [::tk::MenuFindName $menu [$mb cget -text]]
|
| 125 |
+
if {$entry < 0} {
|
| 126 |
+
set entry 0
|
| 127 |
+
}
|
| 128 |
+
set x [winfo rootx $mb]
|
| 129 |
+
set y [winfo rooty $mb]
|
| 130 |
+
switch [$mb cget -direction] {
|
| 131 |
+
above {
|
| 132 |
+
set entry ""
|
| 133 |
+
incr y -$mh
|
| 134 |
+
# if we go offscreen to the top, show as 'below'
|
| 135 |
+
if {$y < [winfo vrooty $mb]} {
|
| 136 |
+
set y [expr {[winfo vrooty $mb] + [winfo rooty $mb]\
|
| 137 |
+
+ [winfo reqheight $mb]}]
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
below {
|
| 141 |
+
set entry ""
|
| 142 |
+
incr y $bh
|
| 143 |
+
# if we go offscreen to the bottom, show as 'above'
|
| 144 |
+
if {($y + $mh) > ([winfo vrooty $mb] + [winfo vrootheight $mb])} {
|
| 145 |
+
set y [expr {[winfo vrooty $mb] + [winfo rooty $mb] - $mh}]
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
left {
|
| 149 |
+
incr x -$mw
|
| 150 |
+
}
|
| 151 |
+
right {
|
| 152 |
+
incr x $bw
|
| 153 |
+
}
|
| 154 |
+
default { # flush
|
| 155 |
+
incr x [expr {([winfo width $mb] - [winfo reqwidth $menu])/ 2}]
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
return [list $x $y $entry]
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
# Popdown --
|
| 163 |
+
# Post the menu and set a grab on the menu.
|
| 164 |
+
#
|
| 165 |
+
proc ttk::menubutton::Popdown {mb} {
|
| 166 |
+
if {[$mb instate disabled] || [set menu [$mb cget -menu]] eq ""} {
|
| 167 |
+
return
|
| 168 |
+
}
|
| 169 |
+
foreach {x y entry} [PostPosition $mb $menu] { break }
|
| 170 |
+
tk_popup $menu $x $y $entry
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
# Pulldown (X11 only) --
|
| 174 |
+
# Called when Button1 is pressed on a menubutton.
|
| 175 |
+
# Posts the menu; a subsequent ButtonRelease
|
| 176 |
+
# or Leave event will set a grab on the menu.
|
| 177 |
+
#
|
| 178 |
+
proc ttk::menubutton::Pulldown {mb} {
|
| 179 |
+
variable State
|
| 180 |
+
if {[$mb instate disabled] || [set menu [$mb cget -menu]] eq ""} {
|
| 181 |
+
return
|
| 182 |
+
}
|
| 183 |
+
set State(pulldown) 1
|
| 184 |
+
set State(oldcursor) [$mb cget -cursor]
|
| 185 |
+
|
| 186 |
+
$mb state pressed
|
| 187 |
+
$mb configure -cursor [$menu cget -cursor]
|
| 188 |
+
foreach {x y entry} [PostPosition $mb $menu] { break }
|
| 189 |
+
if {$entry >= 0} {
|
| 190 |
+
$menu post $x $y $entry
|
| 191 |
+
} else {
|
| 192 |
+
$menu post $x $y
|
| 193 |
+
}
|
| 194 |
+
tk_menuSetFocus $menu
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
# TransferGrab (X11 only) --
|
| 198 |
+
# Switch from pulldown mode (menubutton has an implicit grab)
|
| 199 |
+
# to popdown mode (menu has an explicit grab).
|
| 200 |
+
#
|
| 201 |
+
proc ttk::menubutton::TransferGrab {mb} {
|
| 202 |
+
variable State
|
| 203 |
+
if {$State(pulldown)} {
|
| 204 |
+
$mb configure -cursor $State(oldcursor)
|
| 205 |
+
$mb state {!pressed !active}
|
| 206 |
+
set State(pulldown) 0
|
| 207 |
+
|
| 208 |
+
set menu [$mb cget -menu]
|
| 209 |
+
foreach {x y entry} [PostPosition $mb $menu] { break }
|
| 210 |
+
tk_popup $menu [winfo rootx $menu] [winfo rooty $menu]
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
# FindMenuEntry --
|
| 215 |
+
# Hack to support tk_optionMenus.
|
| 216 |
+
# Returns the index of the menu entry with a matching -label,
|
| 217 |
+
# "" if not found.
|
| 218 |
+
#
|
| 219 |
+
proc ttk::menubutton::FindMenuEntry {menu s} {
|
| 220 |
+
set last [$menu index last]
|
| 221 |
+
if {$last eq "none" || $last < 0} {
|
| 222 |
+
return ""
|
| 223 |
+
}
|
| 224 |
+
for {set i 0} {$i <= $last} {incr i} {
|
| 225 |
+
if {![catch {$menu entrycget $i -label} label]
|
| 226 |
+
&& ($label eq $s)} {
|
| 227 |
+
return $i
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
return ""
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
#*EOF*
|
parrot/lib/tk8.6/ttk/panedwindow.tcl
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Bindings for ttk::panedwindow widget.
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
namespace eval ttk::panedwindow {
|
| 6 |
+
variable State
|
| 7 |
+
array set State {
|
| 8 |
+
pressed 0
|
| 9 |
+
pressX -
|
| 10 |
+
pressY -
|
| 11 |
+
sash -
|
| 12 |
+
sashPos -
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
## Bindings:
|
| 17 |
+
#
|
| 18 |
+
bind TPanedwindow <Button-1> { ttk::panedwindow::Press %W %x %y }
|
| 19 |
+
bind TPanedwindow <B1-Motion> { ttk::panedwindow::Drag %W %x %y }
|
| 20 |
+
bind TPanedwindow <ButtonRelease-1> { ttk::panedwindow::Release %W %x %y }
|
| 21 |
+
|
| 22 |
+
bind TPanedwindow <Motion> { ttk::panedwindow::SetCursor %W %x %y }
|
| 23 |
+
bind TPanedwindow <Enter> { ttk::panedwindow::SetCursor %W %x %y }
|
| 24 |
+
bind TPanedwindow <Leave> { ttk::panedwindow::ResetCursor %W }
|
| 25 |
+
# See <<NOTE-PW-LEAVE-NOTIFYINFERIOR>>
|
| 26 |
+
bind TPanedwindow <<EnteredChild>> { ttk::panedwindow::ResetCursor %W }
|
| 27 |
+
|
| 28 |
+
## Sash movement:
|
| 29 |
+
#
|
| 30 |
+
proc ttk::panedwindow::Press {w x y} {
|
| 31 |
+
variable State
|
| 32 |
+
|
| 33 |
+
set sash [$w identify $x $y]
|
| 34 |
+
if {$sash eq ""} {
|
| 35 |
+
set State(pressed) 0
|
| 36 |
+
return
|
| 37 |
+
}
|
| 38 |
+
set State(pressed) 1
|
| 39 |
+
set State(pressX) $x
|
| 40 |
+
set State(pressY) $y
|
| 41 |
+
set State(sash) $sash
|
| 42 |
+
set State(sashPos) [$w sashpos $sash]
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
proc ttk::panedwindow::Drag {w x y} {
|
| 46 |
+
variable State
|
| 47 |
+
if {!$State(pressed)} { return }
|
| 48 |
+
switch -glob -- [$w cget -orient] {
|
| 49 |
+
h* { set delta [expr {$x - $State(pressX)}] }
|
| 50 |
+
v* { set delta [expr {$y - $State(pressY)}] }
|
| 51 |
+
}
|
| 52 |
+
$w sashpos $State(sash) [expr {$State(sashPos) + $delta}]
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
proc ttk::panedwindow::Release {w x y} {
|
| 56 |
+
variable State
|
| 57 |
+
set State(pressed) 0
|
| 58 |
+
SetCursor $w $x $y
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
## Cursor management:
|
| 62 |
+
#
|
| 63 |
+
proc ttk::panedwindow::ResetCursor {w} {
|
| 64 |
+
variable State
|
| 65 |
+
|
| 66 |
+
ttk::saveCursor $w State(userConfCursor) \
|
| 67 |
+
[list [ttk::cursor hresize] [ttk::cursor vresize]]
|
| 68 |
+
|
| 69 |
+
if {!$State(pressed)} {
|
| 70 |
+
ttk::setCursor $w $State(userConfCursor)
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
proc ttk::panedwindow::SetCursor {w x y} {
|
| 75 |
+
variable State
|
| 76 |
+
|
| 77 |
+
ttk::saveCursor $w State(userConfCursor) \
|
| 78 |
+
[list [ttk::cursor hresize] [ttk::cursor vresize]]
|
| 79 |
+
|
| 80 |
+
set cursor $State(userConfCursor)
|
| 81 |
+
if {[llength [$w identify $x $y]]} {
|
| 82 |
+
# Assume we're over a sash.
|
| 83 |
+
switch -glob -- [$w cget -orient] {
|
| 84 |
+
h* { set cursor hresize }
|
| 85 |
+
v* { set cursor vresize }
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
ttk::setCursor $w $cursor
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
#*EOF*
|
parrot/lib/tk8.6/ttk/spinbox.tcl
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
|
| 5 |
+
namespace eval ttk::spinbox { }
|
| 6 |
+
|
| 7 |
+
### Spinbox bindings.
|
| 8 |
+
#
|
| 9 |
+
# Duplicate the Entry bindings, override if needed:
|
| 10 |
+
#
|
| 11 |
+
|
| 12 |
+
ttk::copyBindings TEntry TSpinbox
|
| 13 |
+
|
| 14 |
+
bind TSpinbox <Motion> { ttk::spinbox::Motion %W %x %y }
|
| 15 |
+
bind TSpinbox <Button-1> { ttk::spinbox::Press %W %x %y }
|
| 16 |
+
bind TSpinbox <ButtonRelease-1> { ttk::spinbox::Release %W }
|
| 17 |
+
bind TSpinbox <Double-Button-1> { ttk::spinbox::DoubleClick %W %x %y }
|
| 18 |
+
bind TSpinbox <Triple-Button-1> {} ;# disable TEntry triple-click
|
| 19 |
+
|
| 20 |
+
bind TSpinbox <Up> { event generate %W <<Increment>> }
|
| 21 |
+
bind TSpinbox <Down> { event generate %W <<Decrement>> }
|
| 22 |
+
|
| 23 |
+
bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 }
|
| 24 |
+
bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 }
|
| 25 |
+
|
| 26 |
+
ttk::bindMouseWheel TSpinbox [list ttk::spinbox::MouseWheel %W]
|
| 27 |
+
|
| 28 |
+
## Motion --
|
| 29 |
+
# Sets cursor.
|
| 30 |
+
#
|
| 31 |
+
proc ttk::spinbox::Motion {w x y} {
|
| 32 |
+
variable State
|
| 33 |
+
ttk::saveCursor $w State(userConfCursor) [ttk::cursor text]
|
| 34 |
+
if { [$w identify $x $y] eq "textarea"
|
| 35 |
+
&& [$w instate {!readonly !disabled}]
|
| 36 |
+
} {
|
| 37 |
+
ttk::setCursor $w text
|
| 38 |
+
} else {
|
| 39 |
+
ttk::setCursor $w $State(userConfCursor)
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
## Press --
|
| 44 |
+
#
|
| 45 |
+
proc ttk::spinbox::Press {w x y} {
|
| 46 |
+
if {[$w instate disabled]} { return }
|
| 47 |
+
focus $w
|
| 48 |
+
switch -glob -- [$w identify $x $y] {
|
| 49 |
+
*textarea { ttk::entry::Press $w $x }
|
| 50 |
+
*rightarrow -
|
| 51 |
+
*uparrow { ttk::Repeatedly event generate $w <<Increment>> }
|
| 52 |
+
*leftarrow -
|
| 53 |
+
*downarrow { ttk::Repeatedly event generate $w <<Decrement>> }
|
| 54 |
+
*spinbutton {
|
| 55 |
+
if {$y * 2 >= [winfo height $w]} {
|
| 56 |
+
set event <<Decrement>>
|
| 57 |
+
} else {
|
| 58 |
+
set event <<Increment>>
|
| 59 |
+
}
|
| 60 |
+
ttk::Repeatedly event generate $w $event
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
## DoubleClick --
|
| 66 |
+
# Select all if over the text area; otherwise same as Press.
|
| 67 |
+
#
|
| 68 |
+
proc ttk::spinbox::DoubleClick {w x y} {
|
| 69 |
+
if {[$w instate disabled]} { return }
|
| 70 |
+
|
| 71 |
+
switch -glob -- [$w identify $x $y] {
|
| 72 |
+
*textarea { SelectAll $w }
|
| 73 |
+
* { Press $w $x $y }
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
proc ttk::spinbox::Release {w} {
|
| 78 |
+
ttk::CancelRepeat
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
## MouseWheel --
|
| 82 |
+
# Mousewheel callback. Turn these into <<Increment>> (-1, up)
|
| 83 |
+
# or <<Decrement> (+1, down) events.
|
| 84 |
+
#
|
| 85 |
+
proc ttk::spinbox::MouseWheel {w dir} {
|
| 86 |
+
if {[$w instate disabled]} { return }
|
| 87 |
+
if {$dir < 0} {
|
| 88 |
+
event generate $w <<Increment>>
|
| 89 |
+
} else {
|
| 90 |
+
event generate $w <<Decrement>>
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
## SelectAll --
|
| 95 |
+
# Select widget contents.
|
| 96 |
+
#
|
| 97 |
+
proc ttk::spinbox::SelectAll {w} {
|
| 98 |
+
$w selection range 0 end
|
| 99 |
+
$w icursor end
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
## Limit --
|
| 103 |
+
# Limit $v to lie between $min and $max
|
| 104 |
+
#
|
| 105 |
+
proc ttk::spinbox::Limit {v min max} {
|
| 106 |
+
if {$v < $min} { return $min }
|
| 107 |
+
if {$v > $max} { return $max }
|
| 108 |
+
return $v
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
## Wrap --
|
| 112 |
+
# Adjust $v to lie between $min and $max, wrapping if out of bounds.
|
| 113 |
+
#
|
| 114 |
+
proc ttk::spinbox::Wrap {v min max} {
|
| 115 |
+
if {$v < $min} { return $max }
|
| 116 |
+
if {$v > $max} { return $min }
|
| 117 |
+
return $v
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
## Adjust --
|
| 121 |
+
# Limit or wrap spinbox value depending on -wrap.
|
| 122 |
+
#
|
| 123 |
+
proc ttk::spinbox::Adjust {w v min max} {
|
| 124 |
+
if {[$w cget -wrap]} {
|
| 125 |
+
return [Wrap $v $min $max]
|
| 126 |
+
} else {
|
| 127 |
+
return [Limit $v $min $max]
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
## Spin --
|
| 132 |
+
# Handle <<Increment>> and <<Decrement>> events.
|
| 133 |
+
# If -values is specified, cycle through the list.
|
| 134 |
+
# Otherwise cycle through numeric range based on
|
| 135 |
+
# -from, -to, and -increment.
|
| 136 |
+
#
|
| 137 |
+
proc ttk::spinbox::Spin {w dir} {
|
| 138 |
+
variable State
|
| 139 |
+
|
| 140 |
+
if {[$w instate disabled]} { return }
|
| 141 |
+
|
| 142 |
+
if {![info exists State($w,values.length)]} {
|
| 143 |
+
set State($w,values.index) -1
|
| 144 |
+
set State($w,values.last) {}
|
| 145 |
+
}
|
| 146 |
+
set State($w,values) [$w cget -values]
|
| 147 |
+
set State($w,values.length) [llength $State($w,values)]
|
| 148 |
+
|
| 149 |
+
if {$State($w,values.length) > 0} {
|
| 150 |
+
set value [$w get]
|
| 151 |
+
set current $State($w,values.index)
|
| 152 |
+
if {$value ne $State($w,values.last)} {
|
| 153 |
+
set current [lsearch -exact $State($w,values) $value]
|
| 154 |
+
if {$current < 0} {set current -1}
|
| 155 |
+
}
|
| 156 |
+
set State($w,values.index) [Adjust $w [expr {$current + $dir}] 0 \
|
| 157 |
+
[expr {$State($w,values.length) - 1}]]
|
| 158 |
+
set State($w,values.last) [lindex $State($w,values) $State($w,values.index)]
|
| 159 |
+
$w set $State($w,values.last)
|
| 160 |
+
} else {
|
| 161 |
+
if {[catch {
|
| 162 |
+
set v [expr {[scan [$w get] %f] + $dir * [$w cget -increment]}]
|
| 163 |
+
}]} {
|
| 164 |
+
set v [$w cget -from]
|
| 165 |
+
}
|
| 166 |
+
$w set [FormatValue $w [Adjust $w $v [$w cget -from] [$w cget -to]]]
|
| 167 |
+
}
|
| 168 |
+
SelectAll $w
|
| 169 |
+
uplevel #0 [$w cget -command]
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
## FormatValue --
|
| 173 |
+
# Reformat numeric value based on -format.
|
| 174 |
+
#
|
| 175 |
+
proc ttk::spinbox::FormatValue {w val} {
|
| 176 |
+
set fmt [$w cget -format]
|
| 177 |
+
if {$fmt eq ""} {
|
| 178 |
+
# Try to guess a suitable -format based on -increment.
|
| 179 |
+
set delta [expr {abs([$w cget -increment])}]
|
| 180 |
+
if {0 < $delta && $delta < 1} {
|
| 181 |
+
# NB: This guesses wrong if -increment has more than 1
|
| 182 |
+
# significant digit itself, e.g., -increment 0.25
|
| 183 |
+
set nsd [expr {int(ceil(-log10($delta)))}]
|
| 184 |
+
set fmt "%.${nsd}f"
|
| 185 |
+
} else {
|
| 186 |
+
set fmt "%.0f"
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
return [format $fmt $val]
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
#*EO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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# ttk::treeview widget bindings and utilities.
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
namespace eval ttk::treeview {
|
| 6 |
+
variable State
|
| 7 |
+
|
| 8 |
+
# Enter/Leave/Motion
|
| 9 |
+
#
|
| 10 |
+
set State(activeWidget) {}
|
| 11 |
+
set State(activeHeading) {}
|
| 12 |
+
|
| 13 |
+
# Press/drag/release:
|
| 14 |
+
#
|
| 15 |
+
set State(pressMode) none
|
| 16 |
+
set State(pressX) 0
|
| 17 |
+
|
| 18 |
+
# For pressMode == "resize"
|
| 19 |
+
set State(resizeColumn) #0
|
| 20 |
+
|
| 21 |
+
# For pressmode == "heading"
|
| 22 |
+
set State(heading) {}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
### Widget bindings.
|
| 26 |
+
#
|
| 27 |
+
|
| 28 |
+
bind Treeview <Motion> { ttk::treeview::Motion %W %x %y }
|
| 29 |
+
bind Treeview <B1-Leave> { #nothing }
|
| 30 |
+
bind Treeview <Leave> { ttk::treeview::ActivateHeading {} {}}
|
| 31 |
+
bind Treeview <Button-1> { ttk::treeview::Press %W %x %y }
|
| 32 |
+
bind Treeview <Double-Button-1> { ttk::treeview::DoubleClick %W %x %y }
|
| 33 |
+
bind Treeview <ButtonRelease-1> { ttk::treeview::Release %W %x %y }
|
| 34 |
+
bind Treeview <B1-Motion> { ttk::treeview::Drag %W %x %y }
|
| 35 |
+
bind Treeview <Up> { ttk::treeview::Keynav %W up }
|
| 36 |
+
bind Treeview <Down> { ttk::treeview::Keynav %W down }
|
| 37 |
+
bind Treeview <Right> { ttk::treeview::Keynav %W right }
|
| 38 |
+
bind Treeview <Left> { ttk::treeview::Keynav %W left }
|
| 39 |
+
bind Treeview <Prior> { %W yview scroll -1 pages }
|
| 40 |
+
bind Treeview <Next> { %W yview scroll 1 pages }
|
| 41 |
+
bind Treeview <Return> { ttk::treeview::ToggleFocus %W }
|
| 42 |
+
bind Treeview <space> { ttk::treeview::ToggleFocus %W }
|
| 43 |
+
|
| 44 |
+
bind Treeview <Shift-Button-1> \
|
| 45 |
+
{ ttk::treeview::Select %W %x %y extend }
|
| 46 |
+
bind Treeview <<ToggleSelection>> \
|
| 47 |
+
{ ttk::treeview::Select %W %x %y toggle }
|
| 48 |
+
|
| 49 |
+
ttk::copyBindings TtkScrollable Treeview
|
| 50 |
+
|
| 51 |
+
### Binding procedures.
|
| 52 |
+
#
|
| 53 |
+
|
| 54 |
+
## Keynav -- Keyboard navigation
|
| 55 |
+
#
|
| 56 |
+
# @@@ TODO: verify/rewrite up and down code.
|
| 57 |
+
#
|
| 58 |
+
proc ttk::treeview::Keynav {w dir} {
|
| 59 |
+
set focus [$w focus]
|
| 60 |
+
if {$focus eq ""} { return }
|
| 61 |
+
|
| 62 |
+
switch -- $dir {
|
| 63 |
+
up {
|
| 64 |
+
if {[set up [$w prev $focus]] eq ""} {
|
| 65 |
+
set focus [$w parent $focus]
|
| 66 |
+
} else {
|
| 67 |
+
while {[$w item $up -open] && [llength [$w children $up]]} {
|
| 68 |
+
set up [lindex [$w children $up] end]
|
| 69 |
+
}
|
| 70 |
+
set focus $up
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
down {
|
| 74 |
+
if {[$w item $focus -open] && [llength [$w children $focus]]} {
|
| 75 |
+
set focus [lindex [$w children $focus] 0]
|
| 76 |
+
} else {
|
| 77 |
+
set up $focus
|
| 78 |
+
while {$up ne "" && [set down [$w next $up]] eq ""} {
|
| 79 |
+
set up [$w parent $up]
|
| 80 |
+
}
|
| 81 |
+
set focus $down
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
left {
|
| 85 |
+
if {[$w item $focus -open] && [llength [$w children $focus]]} {
|
| 86 |
+
CloseItem $w $focus
|
| 87 |
+
} else {
|
| 88 |
+
set focus [$w parent $focus]
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
right {
|
| 92 |
+
OpenItem $w $focus
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
if {$focus != {}} {
|
| 97 |
+
SelectOp $w $focus choose
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
## Motion -- pointer motion binding.
|
| 102 |
+
# Sets cursor, active element ...
|
| 103 |
+
#
|
| 104 |
+
proc ttk::treeview::Motion {w x y} {
|
| 105 |
+
variable State
|
| 106 |
+
|
| 107 |
+
ttk::saveCursor $w State(userConfCursor) [ttk::cursor hresize]
|
| 108 |
+
|
| 109 |
+
set cursor $State(userConfCursor)
|
| 110 |
+
set activeHeading {}
|
| 111 |
+
|
| 112 |
+
switch -- [$w identify region $x $y] {
|
| 113 |
+
separator { set cursor hresize }
|
| 114 |
+
heading { set activeHeading [$w identify column $x $y] }
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
ttk::setCursor $w $cursor
|
| 118 |
+
ActivateHeading $w $activeHeading
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
## ActivateHeading -- track active heading element
|
| 122 |
+
#
|
| 123 |
+
proc ttk::treeview::ActivateHeading {w heading} {
|
| 124 |
+
variable State
|
| 125 |
+
|
| 126 |
+
if {$w != $State(activeWidget) || $heading != $State(activeHeading)} {
|
| 127 |
+
if {[winfo exists $State(activeWidget)] && $State(activeHeading) != {}} {
|
| 128 |
+
# It may happen that $State(activeHeading) no longer corresponds
|
| 129 |
+
# to an existing display column. This happens for instance when
|
| 130 |
+
# changing -displaycolumns in a bound script when this change
|
| 131 |
+
# triggers a <Leave> event. A proc checking if the display column
|
| 132 |
+
# $State(activeHeading) is really still present or not could be
|
| 133 |
+
# written but it would need to check several special cases:
|
| 134 |
+
# a. -displaycolumns "#all" or being an explicit columns list
|
| 135 |
+
# b. column #0 display is not governed by the -displaycolumn
|
| 136 |
+
# list but by the value of the -show option
|
| 137 |
+
# --> Let's rather catch the following line.
|
| 138 |
+
catch {$State(activeWidget) heading $State(activeHeading) state !active}
|
| 139 |
+
}
|
| 140 |
+
if {$heading != {}} {
|
| 141 |
+
$w heading $heading state active
|
| 142 |
+
}
|
| 143 |
+
set State(activeHeading) $heading
|
| 144 |
+
set State(activeWidget) $w
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
## Select $w $x $y $selectop
|
| 149 |
+
# Binding procedure for selection operations.
|
| 150 |
+
# See "Selection modes", below.
|
| 151 |
+
#
|
| 152 |
+
proc ttk::treeview::Select {w x y op} {
|
| 153 |
+
if {[set item [$w identify row $x $y]] ne "" } {
|
| 154 |
+
SelectOp $w $item $op
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
## DoubleClick -- Double-Button-1 binding.
|
| 159 |
+
#
|
| 160 |
+
proc ttk::treeview::DoubleClick {w x y} {
|
| 161 |
+
if {[set row [$w identify row $x $y]] ne ""} {
|
| 162 |
+
Toggle $w $row
|
| 163 |
+
} else {
|
| 164 |
+
Press $w $x $y ;# perform single-click action
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
## Press -- Button binding.
|
| 169 |
+
#
|
| 170 |
+
proc ttk::treeview::Press {w x y} {
|
| 171 |
+
focus $w
|
| 172 |
+
switch -- [$w identify region $x $y] {
|
| 173 |
+
nothing { }
|
| 174 |
+
heading { heading.press $w $x $y }
|
| 175 |
+
separator { resize.press $w $x $y }
|
| 176 |
+
tree -
|
| 177 |
+
cell {
|
| 178 |
+
set item [$w identify item $x $y]
|
| 179 |
+
SelectOp $w $item choose
|
| 180 |
+
switch -glob -- [$w identify element $x $y] {
|
| 181 |
+
*indicator -
|
| 182 |
+
*disclosure { Toggle $w $item }
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
## Drag -- B1-Motion binding
|
| 189 |
+
#
|
| 190 |
+
proc ttk::treeview::Drag {w x y} {
|
| 191 |
+
variable State
|
| 192 |
+
switch $State(pressMode) {
|
| 193 |
+
resize { resize.drag $w $x }
|
| 194 |
+
heading { heading.drag $w $x $y }
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
proc ttk::treeview::Release {w x y} {
|
| 199 |
+
variable State
|
| 200 |
+
switch $State(pressMode) {
|
| 201 |
+
resize { resize.release $w $x }
|
| 202 |
+
heading { heading.release $w }
|
| 203 |
+
}
|
| 204 |
+
set State(pressMode) none
|
| 205 |
+
Motion $w $x $y
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
### Interactive column resizing.
|
| 209 |
+
#
|
| 210 |
+
proc ttk::treeview::resize.press {w x y} {
|
| 211 |
+
variable State
|
| 212 |
+
set State(pressMode) "resize"
|
| 213 |
+
set State(resizeColumn) [$w identify column $x $y]
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
proc ttk::treeview::resize.drag {w x} {
|
| 217 |
+
variable State
|
| 218 |
+
$w drag $State(resizeColumn) $x
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
proc ttk::treeview::resize.release {w x} {
|
| 222 |
+
$w drop
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
### Heading activation.
|
| 226 |
+
#
|
| 227 |
+
|
| 228 |
+
proc ttk::treeview::heading.press {w x y} {
|
| 229 |
+
variable State
|
| 230 |
+
set column [$w identify column $x $y]
|
| 231 |
+
set State(pressMode) "heading"
|
| 232 |
+
set State(heading) $column
|
| 233 |
+
$w heading $column state pressed
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
proc ttk::treeview::heading.drag {w x y} {
|
| 237 |
+
variable State
|
| 238 |
+
if { [$w identify region $x $y] eq "heading"
|
| 239 |
+
&& [$w identify column $x $y] eq $State(heading)
|
| 240 |
+
} {
|
| 241 |
+
$w heading $State(heading) state pressed
|
| 242 |
+
} else {
|
| 243 |
+
$w heading $State(heading) state !pressed
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
proc ttk::treeview::heading.release {w} {
|
| 248 |
+
variable State
|
| 249 |
+
if {[lsearch -exact [$w heading $State(heading) state] pressed] >= 0} {
|
| 250 |
+
after 0 [$w heading $State(heading) -command]
|
| 251 |
+
}
|
| 252 |
+
$w heading $State(heading) state !pressed
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
### Selection modes.
|
| 256 |
+
#
|
| 257 |
+
|
| 258 |
+
## SelectOp $w $item [ choose | extend | toggle ] --
|
| 259 |
+
# Dispatch to appropriate selection operation
|
| 260 |
+
# depending on current value of -selectmode.
|
| 261 |
+
#
|
| 262 |
+
proc ttk::treeview::SelectOp {w item op} {
|
| 263 |
+
select.$op.[$w cget -selectmode] $w $item
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
## -selectmode none:
|
| 267 |
+
#
|
| 268 |
+
proc ttk::treeview::select.choose.none {w item} { $w focus $item; $w see $item }
|
| 269 |
+
proc ttk::treeview::select.toggle.none {w item} { $w focus $item; $w see $item }
|
| 270 |
+
proc ttk::treeview::select.extend.none {w item} { $w focus $item; $w see $item }
|
| 271 |
+
|
| 272 |
+
## -selectmode browse:
|
| 273 |
+
#
|
| 274 |
+
proc ttk::treeview::select.choose.browse {w item} { BrowseTo $w $item }
|
| 275 |
+
proc ttk::treeview::select.toggle.browse {w item} { BrowseTo $w $item }
|
| 276 |
+
proc ttk::treeview::select.extend.browse {w item} { BrowseTo $w $item }
|
| 277 |
+
|
| 278 |
+
## -selectmode multiple:
|
| 279 |
+
#
|
| 280 |
+
proc ttk::treeview::select.choose.extended {w item} {
|
| 281 |
+
BrowseTo $w $item
|
| 282 |
+
}
|
| 283 |
+
proc ttk::treeview::select.toggle.extended {w item} {
|
| 284 |
+
$w selection toggle [list $item]
|
| 285 |
+
}
|
| 286 |
+
proc ttk::treeview::select.extend.extended {w item} {
|
| 287 |
+
if {[set anchor [$w focus]] ne ""} {
|
| 288 |
+
$w selection set [between $w $anchor $item]
|
| 289 |
+
} else {
|
| 290 |
+
BrowseTo $w $item
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
### Tree structure utilities.
|
| 295 |
+
#
|
| 296 |
+
|
| 297 |
+
## between $tv $item1 $item2 --
|
| 298 |
+
# Returns a list of all items between $item1 and $item2,
|
| 299 |
+
# in preorder traversal order. $item1 and $item2 may be
|
| 300 |
+
# in either order.
|
| 301 |
+
#
|
| 302 |
+
# NOTES:
|
| 303 |
+
# This routine is O(N) in the size of the tree.
|
| 304 |
+
# There's probably a way to do this that's O(N) in the number
|
| 305 |
+
# of items returned, but I'm not clever enough to figure it out.
|
| 306 |
+
#
|
| 307 |
+
proc ttk::treeview::between {tv item1 item2} {
|
| 308 |
+
variable between [list]
|
| 309 |
+
variable selectingBetween 0
|
| 310 |
+
ScanBetween $tv $item1 $item2 {}
|
| 311 |
+
return $between
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
## ScanBetween --
|
| 315 |
+
# Recursive worker routine for ttk::treeview::between
|
| 316 |
+
#
|
| 317 |
+
proc ttk::treeview::ScanBetween {tv item1 item2 item} {
|
| 318 |
+
variable between
|
| 319 |
+
variable selectingBetween
|
| 320 |
+
|
| 321 |
+
if {$item eq $item1 || $item eq $item2} {
|
| 322 |
+
lappend between $item
|
| 323 |
+
set selectingBetween [expr {!$selectingBetween}]
|
| 324 |
+
} elseif {$selectingBetween} {
|
| 325 |
+
lappend between $item
|
| 326 |
+
}
|
| 327 |
+
foreach child [$tv children $item] {
|
| 328 |
+
ScanBetween $tv $item1 $item2 $child
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
### User interaction utilities.
|
| 333 |
+
#
|
| 334 |
+
|
| 335 |
+
## OpenItem, CloseItem -- Set the open state of an item, generate event
|
| 336 |
+
#
|
| 337 |
+
|
| 338 |
+
proc ttk::treeview::OpenItem {w item} {
|
| 339 |
+
$w focus $item
|
| 340 |
+
event generate $w <<TreeviewOpen>>
|
| 341 |
+
$w item $item -open true
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
proc ttk::treeview::CloseItem {w item} {
|
| 345 |
+
$w item $item -open false
|
| 346 |
+
$w focus $item
|
| 347 |
+
event generate $w <<TreeviewClose>>
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
## Toggle -- toggle opened/closed state of item
|
| 351 |
+
#
|
| 352 |
+
proc ttk::treeview::Toggle {w item} {
|
| 353 |
+
# don't allow toggling on indicators that
|
| 354 |
+
# are not present in front of leaf items
|
| 355 |
+
if {[$w children $item] == {}} {
|
| 356 |
+
return
|
| 357 |
+
}
|
| 358 |
+
# not a leaf, toggle!
|
| 359 |
+
if {[$w item $item -open]} {
|
| 360 |
+
CloseItem $w $item
|
| 361 |
+
} else {
|
| 362 |
+
OpenItem $w $item
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
|
| 366 |
+
## ToggleFocus -- toggle opened/closed state of focus item
|
| 367 |
+
#
|
| 368 |
+
proc ttk::treeview::ToggleFocus {w} {
|
| 369 |
+
set item [$w focus]
|
| 370 |
+
if {$item ne ""} {
|
| 371 |
+
Toggle $w $item
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
## BrowseTo -- navigate to specified item; set focus and selection
|
| 376 |
+
#
|
| 377 |
+
proc ttk::treeview::BrowseTo {w item} {
|
| 378 |
+
$w see $item
|
| 379 |
+
$w focus $item
|
| 380 |
+
$w selection set [list $item]
|
| 381 |
+
}
|
| 382 |
+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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Ttk widget set initialization script.
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
### Source library scripts.
|
| 6 |
+
#
|
| 7 |
+
|
| 8 |
+
namespace eval ::ttk {
|
| 9 |
+
variable library
|
| 10 |
+
if {![info exists library]} {
|
| 11 |
+
set library [file dirname [info script]]
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
source -encoding utf-8 [file join $::ttk::library fonts.tcl]
|
| 16 |
+
source -encoding utf-8 [file join $::ttk::library cursors.tcl]
|
| 17 |
+
source -encoding utf-8 [file join $::ttk::library utils.tcl]
|
| 18 |
+
|
| 19 |
+
## ttk::deprecated $old $new --
|
| 20 |
+
# Define $old command as a deprecated alias for $new command
|
| 21 |
+
# $old and $new must be fully namespace-qualified.
|
| 22 |
+
#
|
| 23 |
+
proc ttk::deprecated {old new} {
|
| 24 |
+
interp alias {} $old {} ttk::do'deprecate $old $new
|
| 25 |
+
}
|
| 26 |
+
## do'deprecate --
|
| 27 |
+
# Implementation procedure for deprecated commands --
|
| 28 |
+
# issue a warning (once), then re-alias old to new.
|
| 29 |
+
#
|
| 30 |
+
proc ttk::do'deprecate {old new args} {
|
| 31 |
+
deprecated'warning $old $new
|
| 32 |
+
interp alias {} $old {} $new
|
| 33 |
+
uplevel 1 [linsert $args 0 $new]
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
## deprecated'warning --
|
| 37 |
+
# Gripe about use of deprecated commands.
|
| 38 |
+
#
|
| 39 |
+
proc ttk::deprecated'warning {old new} {
|
| 40 |
+
puts stderr "$old deprecated -- use $new instead"
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
### Backward-compatibility.
|
| 44 |
+
#
|
| 45 |
+
#
|
| 46 |
+
# Make [package require tile] an effective no-op;
|
| 47 |
+
# see SF#3016598 for discussion.
|
| 48 |
+
#
|
| 49 |
+
package ifneeded tile 0.8.6 { package provide tile 0.8.6 }
|
| 50 |
+
|
| 51 |
+
# ttk::panedwindow used to be named ttk::paned. Keep the alias for now.
|
| 52 |
+
#
|
| 53 |
+
::ttk::deprecated ::ttk::paned ::ttk::panedwindow
|
| 54 |
+
|
| 55 |
+
### ::ttk::ThemeChanged --
|
| 56 |
+
# Called from [::ttk::style theme use].
|
| 57 |
+
# Sends a <<ThemeChanged>> virtual event to all widgets.
|
| 58 |
+
#
|
| 59 |
+
proc ::ttk::ThemeChanged {} {
|
| 60 |
+
set Q .
|
| 61 |
+
while {[llength $Q]} {
|
| 62 |
+
set QN [list]
|
| 63 |
+
foreach w $Q {
|
| 64 |
+
event generate $w <<ThemeChanged>>
|
| 65 |
+
foreach child [winfo children $w] {
|
| 66 |
+
lappend QN $child
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
set Q $QN
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
### Public API.
|
| 74 |
+
#
|
| 75 |
+
|
| 76 |
+
proc ::ttk::themes {{ptn *}} {
|
| 77 |
+
set themes [list]
|
| 78 |
+
|
| 79 |
+
foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
|
| 80 |
+
lappend themes [namespace tail $pkg]
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return $themes
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
## ttk::setTheme $theme --
|
| 87 |
+
# Set the current theme to $theme, loading it if necessary.
|
| 88 |
+
#
|
| 89 |
+
proc ::ttk::setTheme {theme} {
|
| 90 |
+
variable currentTheme ;# @@@ Temp -- [::ttk::style theme use] doesn't work
|
| 91 |
+
if {$theme ni [::ttk::style theme names]} {
|
| 92 |
+
package require ttk::theme::$theme
|
| 93 |
+
}
|
| 94 |
+
::ttk::style theme use $theme
|
| 95 |
+
set currentTheme $theme
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
### Load widget bindings.
|
| 99 |
+
#
|
| 100 |
+
source -encoding utf-8 [file join $::ttk::library button.tcl]
|
| 101 |
+
source -encoding utf-8 [file join $::ttk::library menubutton.tcl]
|
| 102 |
+
source -encoding utf-8 [file join $::ttk::library scrollbar.tcl]
|
| 103 |
+
source -encoding utf-8 [file join $::ttk::library scale.tcl]
|
| 104 |
+
source -encoding utf-8 [file join $::ttk::library progress.tcl]
|
| 105 |
+
source -encoding utf-8 [file join $::ttk::library notebook.tcl]
|
| 106 |
+
source -encoding utf-8 [file join $::ttk::library panedwindow.tcl]
|
| 107 |
+
source -encoding utf-8 [file join $::ttk::library entry.tcl]
|
| 108 |
+
source -encoding utf-8 [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
|
| 109 |
+
source -encoding utf-8 [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
|
| 110 |
+
source -encoding utf-8 [file join $::ttk::library treeview.tcl]
|
| 111 |
+
source -encoding utf-8 [file join $::ttk::library sizegrip.tcl]
|
| 112 |
+
|
| 113 |
+
## Label and Labelframe bindings:
|
| 114 |
+
# (not enough to justify their own file...)
|
| 115 |
+
#
|
| 116 |
+
bind TLabelframe <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
|
| 117 |
+
bind TLabel <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
|
| 118 |
+
|
| 119 |
+
### Load settings for built-in themes:
|
| 120 |
+
#
|
| 121 |
+
proc ttk::LoadThemes {} {
|
| 122 |
+
variable library
|
| 123 |
+
|
| 124 |
+
# "default" always present:
|
| 125 |
+
uplevel #0 [list source -encoding utf-8 [file join $library defaults.tcl]]
|
| 126 |
+
|
| 127 |
+
set builtinThemes [style theme names]
|
| 128 |
+
foreach {theme scripts} {
|
| 129 |
+
classic classicTheme.tcl
|
| 130 |
+
alt altTheme.tcl
|
| 131 |
+
clam clamTheme.tcl
|
| 132 |
+
winnative winTheme.tcl
|
| 133 |
+
xpnative {xpTheme.tcl vistaTheme.tcl}
|
| 134 |
+
aqua aquaTheme.tcl
|
| 135 |
+
} {
|
| 136 |
+
if {[lsearch -exact $builtinThemes $theme] >= 0} {
|
| 137 |
+
foreach script $scripts {
|
| 138 |
+
uplevel #0 [list source -encoding utf-8 [file join $library $script]]
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
ttk::LoadThemes; rename ::ttk::LoadThemes {}
|
| 145 |
+
|
| 146 |
+
### Select platform-specific default theme:
|
| 147 |
+
#
|
| 148 |
+
# Notes:
|
| 149 |
+
# + On OSX, aqua theme is the default
|
| 150 |
+
# + On Windows, xpnative takes precedence over winnative if available.
|
| 151 |
+
# + On X11, users can use the X resource database to
|
| 152 |
+
# specify a preferred theme (*TkTheme: themeName);
|
| 153 |
+
# otherwise "default" is used.
|
| 154 |
+
#
|
| 155 |
+
|
| 156 |
+
proc ttk::DefaultTheme {} {
|
| 157 |
+
set preferred [list aqua vista xpnative winnative]
|
| 158 |
+
|
| 159 |
+
set userTheme [option get . tkTheme TkTheme]
|
| 160 |
+
if {$userTheme ne {} && ![catch {
|
| 161 |
+
uplevel #0 [list package require ttk::theme::$userTheme]
|
| 162 |
+
}]} {
|
| 163 |
+
return $userTheme
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
foreach theme $preferred {
|
| 167 |
+
if {[package provide ttk::theme::$theme] ne ""} {
|
| 168 |
+
return $theme
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
return "default"
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
ttk::setTheme [ttk::DefaultTheme] ; rename ttk::DefaultTheme {}
|
| 175 |
+
|
| 176 |
+
#*EOF*
|
parrot/lib/tk8.6/ttk/vistaTheme.tcl
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Settings for Microsoft Windows Vista and Server 2008
|
| 3 |
+
#
|
| 4 |
+
|
| 5 |
+
# The Vista theme can only be defined on Windows Vista and above. The theme
|
| 6 |
+
# is created in C due to the need to assign a theme-enabled function for
|
| 7 |
+
# detecting when themeing is disabled. On systems that cannot support the
|
| 8 |
+
# Vista theme, there will be no such theme created and we must not
|
| 9 |
+
# evaluate this script.
|
| 10 |
+
|
| 11 |
+
if {"vista" ni [ttk::style theme names]} {
|
| 12 |
+
return
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
namespace eval ttk::theme::vista {
|
| 16 |
+
|
| 17 |
+
ttk::style theme settings vista {
|
| 18 |
+
|
| 19 |
+
ttk::style configure . \
|
| 20 |
+
-background SystemButtonFace \
|
| 21 |
+
-foreground SystemWindowText \
|
| 22 |
+
-selectforeground SystemHighlightText \
|
| 23 |
+
-selectbackground SystemHighlight \
|
| 24 |
+
-insertcolor SystemWindowText \
|
| 25 |
+
-font TkDefaultFont \
|
| 26 |
+
;
|
| 27 |
+
|
| 28 |
+
ttk::style map "." \
|
| 29 |
+
-foreground [list disabled SystemGrayText] \
|
| 30 |
+
;
|
| 31 |
+
|
| 32 |
+
ttk::style configure TButton -anchor center -padding {1 1} -width -11
|
| 33 |
+
ttk::style configure TRadiobutton -padding 2
|
| 34 |
+
ttk::style configure TCheckbutton -padding 2
|
| 35 |
+
ttk::style configure TMenubutton -padding {8 4}
|
| 36 |
+
|
| 37 |
+
ttk::style element create Menubutton.dropdown vsapi \
|
| 38 |
+
TOOLBAR 4 {{selected active} 6 {selected !active} 5
|
| 39 |
+
disabled 4 pressed 3 active 2 {} 1} \
|
| 40 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 41 |
+
|
| 42 |
+
ttk::style configure TNotebook -tabmargins {2 2 2 0}
|
| 43 |
+
ttk::style map TNotebook.Tab \
|
| 44 |
+
-expand [list selected {2 2 2 2}]
|
| 45 |
+
|
| 46 |
+
# Treeview:
|
| 47 |
+
ttk::style configure Heading -font TkHeadingFont
|
| 48 |
+
ttk::style configure Treeview -background SystemWindow
|
| 49 |
+
ttk::style map Treeview \
|
| 50 |
+
-background [list disabled SystemButtonFace \
|
| 51 |
+
selected SystemHighlight] \
|
| 52 |
+
-foreground [list disabled SystemGrayText \
|
| 53 |
+
selected SystemHighlightText]
|
| 54 |
+
|
| 55 |
+
# Label and Toolbutton
|
| 56 |
+
ttk::style configure TLabelframe.Label -foreground SystemButtonText
|
| 57 |
+
|
| 58 |
+
ttk::style configure Toolbutton -padding {4 4}
|
| 59 |
+
|
| 60 |
+
# Combobox
|
| 61 |
+
ttk::style configure TCombobox -padding 2
|
| 62 |
+
ttk::style element create Combobox.border vsapi \
|
| 63 |
+
COMBOBOX 4 {disabled 4 focus 3 active 2 hover 2 {} 1}
|
| 64 |
+
ttk::style element create Combobox.background vsapi \
|
| 65 |
+
EDIT 3 {disabled 3 readonly 5 focus 4 hover 2 {} 1}
|
| 66 |
+
ttk::style element create Combobox.rightdownarrow vsapi \
|
| 67 |
+
COMBOBOX 6 {disabled 4 pressed 3 active 2 {} 1} \
|
| 68 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 69 |
+
ttk::style layout TCombobox {
|
| 70 |
+
Combobox.border -sticky nswe -border 0 -children {
|
| 71 |
+
Combobox.rightdownarrow -side right -sticky ns
|
| 72 |
+
Combobox.padding -sticky nswe -children {
|
| 73 |
+
Combobox.background -sticky nswe -children {
|
| 74 |
+
Combobox.focus -sticky nswe -children {
|
| 75 |
+
Combobox.textarea -sticky nswe
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
# Vista.Combobox droplist frame
|
| 82 |
+
ttk::style element create ComboboxPopdownFrame.background vsapi\
|
| 83 |
+
LISTBOX 3 {disabled 4 active 3 focus 2 {} 1}
|
| 84 |
+
ttk::style layout ComboboxPopdownFrame {
|
| 85 |
+
ComboboxPopdownFrame.background -sticky news -border 1 -children {
|
| 86 |
+
ComboboxPopdownFrame.padding -sticky news
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
ttk::style map TCombobox \
|
| 90 |
+
-selectbackground [list !focus SystemWindow] \
|
| 91 |
+
-selectforeground [list !focus SystemWindowText] \
|
| 92 |
+
-foreground [list \
|
| 93 |
+
disabled SystemGrayText \
|
| 94 |
+
{readonly focus} SystemHighlightText \
|
| 95 |
+
] \
|
| 96 |
+
-focusfill [list {readonly focus} SystemHighlight] \
|
| 97 |
+
;
|
| 98 |
+
|
| 99 |
+
# Entry
|
| 100 |
+
ttk::style configure TEntry -padding {1 1 1 1} ;# Needs lookup
|
| 101 |
+
ttk::style element create Entry.field vsapi \
|
| 102 |
+
EDIT 6 {disabled 4 focus 3 hover 2 {} 1} -padding {2 2 2 2}
|
| 103 |
+
ttk::style element create Entry.background vsapi \
|
| 104 |
+
EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}
|
| 105 |
+
ttk::style layout TEntry {
|
| 106 |
+
Entry.field -sticky news -border 0 -children {
|
| 107 |
+
Entry.background -sticky news -children {
|
| 108 |
+
Entry.padding -sticky news -children {
|
| 109 |
+
Entry.textarea -sticky news
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
ttk::style map TEntry \
|
| 115 |
+
-selectbackground [list !focus SystemWindow] \
|
| 116 |
+
-selectforeground [list !focus SystemWindowText] \
|
| 117 |
+
;
|
| 118 |
+
|
| 119 |
+
# Spinbox
|
| 120 |
+
ttk::style configure TSpinbox -padding 0
|
| 121 |
+
ttk::style element create Spinbox.field vsapi \
|
| 122 |
+
EDIT 9 {disabled 4 focus 3 hover 2 {} 1} -padding {1 1 1 2}
|
| 123 |
+
ttk::style element create Spinbox.background vsapi \
|
| 124 |
+
EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}
|
| 125 |
+
ttk::style element create Spinbox.innerbg vsapi \
|
| 126 |
+
EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}\
|
| 127 |
+
-padding {2 0 15 2}
|
| 128 |
+
ttk::style element create Spinbox.uparrow vsapi \
|
| 129 |
+
SPIN 1 {disabled 4 pressed 3 active 2 {} 1} \
|
| 130 |
+
-padding 1 -halfheight 1 \
|
| 131 |
+
-syssize { SM_CXVSCROLL SM_CYVSCROLL }
|
| 132 |
+
ttk::style element create Spinbox.downarrow vsapi \
|
| 133 |
+
SPIN 2 {disabled 4 pressed 3 active 2 {} 1} \
|
| 134 |
+
-padding 1 -halfheight 1 \
|
| 135 |
+
-syssize { SM_CXVSCROLL SM_CYVSCROLL }
|
| 136 |
+
ttk::style layout TSpinbox {
|
| 137 |
+
Spinbox.field -sticky nswe -children {
|
| 138 |
+
Spinbox.background -sticky news -children {
|
| 139 |
+
Spinbox.padding -sticky news -children {
|
| 140 |
+
Spinbox.innerbg -sticky news -children {
|
| 141 |
+
Spinbox.textarea
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
Spinbox.uparrow -side top -sticky ens
|
| 145 |
+
Spinbox.downarrow -side bottom -sticky ens
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
ttk::style map TSpinbox \
|
| 150 |
+
-selectbackground [list !focus SystemWindow] \
|
| 151 |
+
-selectforeground [list !focus SystemWindowText] \
|
| 152 |
+
;
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
# SCROLLBAR elements (Vista includes a state for 'hover')
|
| 156 |
+
ttk::style element create Vertical.Scrollbar.uparrow vsapi \
|
| 157 |
+
SCROLLBAR 1 {disabled 4 pressed 3 active 2 hover 17 {} 1} \
|
| 158 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 159 |
+
ttk::style element create Vertical.Scrollbar.downarrow vsapi \
|
| 160 |
+
SCROLLBAR 1 {disabled 8 pressed 7 active 6 hover 18 {} 5} \
|
| 161 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 162 |
+
ttk::style element create Vertical.Scrollbar.trough vsapi \
|
| 163 |
+
SCROLLBAR 7 {disabled 4 pressed 3 active 2 hover 5 {} 1}
|
| 164 |
+
ttk::style element create Vertical.Scrollbar.thumb vsapi \
|
| 165 |
+
SCROLLBAR 3 {disabled 4 pressed 3 active 2 hover 5 {} 1} \
|
| 166 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 167 |
+
ttk::style element create Vertical.Scrollbar.grip vsapi \
|
| 168 |
+
SCROLLBAR 9 {disabled 4 pressed 3 active 2 hover 5 {} 1} \
|
| 169 |
+
-syssize {SM_CXVSCROLL SM_CYVSCROLL}
|
| 170 |
+
ttk::style element create Horizontal.Scrollbar.leftarrow vsapi \
|
| 171 |
+
SCROLLBAR 1 {disabled 12 pressed 11 active 10 hover 19 {} 9} \
|
| 172 |
+
-syssize {SM_CXHSCROLL SM_CYHSCROLL}
|
| 173 |
+
ttk::style element create Horizontal.Scrollbar.rightarrow vsapi \
|
| 174 |
+
SCROLLBAR 1 {disabled 16 pressed 15 active 14 hover 20 {} 13} \
|
| 175 |
+
-syssize {SM_CXHSCROLL SM_CYHSCROLL}
|
| 176 |
+
ttk::style element create Horizontal.Scrollbar.trough vsapi \
|
| 177 |
+
SCROLLBAR 5 {disabled 4 pressed 3 active 2 hover 5 {} 1}
|
| 178 |
+
ttk::style element create Horizontal.Scrollbar.thumb vsapi \
|
| 179 |
+
SCROLLBAR 2 {disabled 4 pressed 3 active 2 hover 5 {} 1} \
|
| 180 |
+
-syssize {SM_CXHSCROLL SM_CYHSCROLL}
|
| 181 |
+
ttk::style element create Horizontal.Scrollbar.grip vsapi \
|
| 182 |
+
SCROLLBAR 8 {disabled 4 pressed 3 active 2 hover 5 {} 1}
|
| 183 |
+
|
| 184 |
+
# Progressbar
|
| 185 |
+
ttk::style element create Horizontal.Progressbar.pbar vsapi \
|
| 186 |
+
PROGRESS 3 {{} 1} -padding 8
|
| 187 |
+
ttk::style layout Horizontal.TProgressbar {
|
| 188 |
+
Horizontal.Progressbar.trough -sticky nswe -children {
|
| 189 |
+
Horizontal.Progressbar.pbar -side left -sticky ns
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
ttk::style element create Vertical.Progressbar.pbar vsapi \
|
| 193 |
+
PROGRESS 3 {{} 1} -padding 8
|
| 194 |
+
ttk::style layout Vertical.TProgressbar {
|
| 195 |
+
Vertical.Progressbar.trough -sticky nswe -children {
|
| 196 |
+
Vertical.Progressbar.pbar -side bottom -sticky we
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
# Scale
|
| 201 |
+
ttk::style element create Horizontal.Scale.slider vsapi \
|
| 202 |
+
TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
|
| 203 |
+
-width 6 -height 12
|
| 204 |
+
ttk::style layout Horizontal.TScale {
|
| 205 |
+
Scale.focus -sticky nswe -children {
|
| 206 |
+
Horizontal.Scale.trough -sticky nswe -children {
|
| 207 |
+
Horizontal.Scale.track -sticky we
|
| 208 |
+
Horizontal.Scale.slider -side left -sticky {}
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
ttk::style element create Vertical.Scale.slider vsapi \
|
| 213 |
+
TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
|
| 214 |
+
-width 12 -height 6
|
| 215 |
+
ttk::style layout Vertical.TScale {
|
| 216 |
+
Scale.focus -sticky nswe -children {
|
| 217 |
+
Vertical.Scale.trough -sticky nswe -children {
|
| 218 |
+
Vertical.Scale.track -sticky ns
|
| 219 |
+
Vertical.Scale.slider -side top -sticky {}
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
# Treeview
|
| 225 |
+
ttk::style configure Item -padding {4 0 0 0}
|
| 226 |
+
|
| 227 |
+
package provide ttk::theme::vista 1.0
|
| 228 |
+
}
|
| 229 |
+
}
|
parrot/lib/tk8.6/xmfbox.tcl
ADDED
|
@@ -0,0 +1,989 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# xmfbox.tcl --
|
| 2 |
+
#
|
| 3 |
+
# Implements the "Motif" style file selection dialog for the
|
| 4 |
+
# Unix platform. This implementation is used only if the
|
| 5 |
+
# "::tk_strictMotif" flag is set.
|
| 6 |
+
#
|
| 7 |
+
# Copyright (c) 1996 Sun Microsystems, Inc.
|
| 8 |
+
# Copyright (c) 1998-2000 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 |
+
namespace eval ::tk::dialog {}
|
| 14 |
+
namespace eval ::tk::dialog::file {}
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
# ::tk::MotifFDialog --
|
| 18 |
+
#
|
| 19 |
+
# Implements a file dialog similar to the standard Motif file
|
| 20 |
+
# selection box.
|
| 21 |
+
#
|
| 22 |
+
# Arguments:
|
| 23 |
+
# type "open" or "save"
|
| 24 |
+
# args Options parsed by the procedure.
|
| 25 |
+
#
|
| 26 |
+
# Results:
|
| 27 |
+
# When -multiple is set to 0, this returns the absolute pathname
|
| 28 |
+
# of the selected file. (NOTE: This is not the same as a single
|
| 29 |
+
# element list.)
|
| 30 |
+
#
|
| 31 |
+
# When -multiple is set to > 0, this returns a Tcl list of absolute
|
| 32 |
+
# pathnames. The argument for -multiple is ignored, but for consistency
|
| 33 |
+
# with Windows it defines the maximum amount of memory to allocate for
|
| 34 |
+
# the returned filenames.
|
| 35 |
+
|
| 36 |
+
proc ::tk::MotifFDialog {type args} {
|
| 37 |
+
variable ::tk::Priv
|
| 38 |
+
set dataName __tk_filedialog
|
| 39 |
+
upvar ::tk::dialog::file::$dataName data
|
| 40 |
+
|
| 41 |
+
set w [MotifFDialog_Create $dataName $type $args]
|
| 42 |
+
|
| 43 |
+
# Set a grab and claim the focus too.
|
| 44 |
+
|
| 45 |
+
::tk::SetFocusGrab $w $data(sEnt)
|
| 46 |
+
$data(sEnt) selection range 0 end
|
| 47 |
+
|
| 48 |
+
# Wait for the user to respond, then restore the focus and
|
| 49 |
+
# return the index of the selected button. Restore the focus
|
| 50 |
+
# before deleting the window, since otherwise the window manager
|
| 51 |
+
# may take the focus away so we can't redirect it. Finally,
|
| 52 |
+
# restore any grab that was in effect.
|
| 53 |
+
|
| 54 |
+
vwait ::tk::Priv(selectFilePath)
|
| 55 |
+
set result $Priv(selectFilePath)
|
| 56 |
+
::tk::RestoreFocusGrab $w $data(sEnt) withdraw
|
| 57 |
+
|
| 58 |
+
return $result
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
# ::tk::MotifFDialog_Create --
|
| 62 |
+
#
|
| 63 |
+
# Creates the Motif file dialog (if it doesn't exist yet) and
|
| 64 |
+
# initialize the internal data structure associated with the
|
| 65 |
+
# dialog.
|
| 66 |
+
#
|
| 67 |
+
# This procedure is used by ::tk::MotifFDialog to create the
|
| 68 |
+
# dialog. It's also used by the test suite to test the Motif
|
| 69 |
+
# file dialog implementation. User code shouldn't call this
|
| 70 |
+
# procedure directly.
|
| 71 |
+
#
|
| 72 |
+
# Arguments:
|
| 73 |
+
# dataName Name of the global "data" array for the file dialog.
|
| 74 |
+
# type "Save" or "Open"
|
| 75 |
+
# argList Options parsed by the procedure.
|
| 76 |
+
#
|
| 77 |
+
# Results:
|
| 78 |
+
# Pathname of the file dialog.
|
| 79 |
+
|
| 80 |
+
proc ::tk::MotifFDialog_Create {dataName type argList} {
|
| 81 |
+
upvar ::tk::dialog::file::$dataName data
|
| 82 |
+
|
| 83 |
+
MotifFDialog_Config $dataName $type $argList
|
| 84 |
+
|
| 85 |
+
if {$data(-parent) eq "."} {
|
| 86 |
+
set w .$dataName
|
| 87 |
+
} else {
|
| 88 |
+
set w $data(-parent).$dataName
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
# (re)create the dialog box if necessary
|
| 92 |
+
#
|
| 93 |
+
if {![winfo exists $w]} {
|
| 94 |
+
MotifFDialog_BuildUI $w
|
| 95 |
+
} elseif {[winfo class $w] ne "TkMotifFDialog"} {
|
| 96 |
+
destroy $w
|
| 97 |
+
MotifFDialog_BuildUI $w
|
| 98 |
+
} else {
|
| 99 |
+
set data(fEnt) $w.top.f1.ent
|
| 100 |
+
set data(dList) $w.top.f2.a.l
|
| 101 |
+
set data(fList) $w.top.f2.b.l
|
| 102 |
+
set data(sEnt) $w.top.f3.ent
|
| 103 |
+
set data(okBtn) $w.bot.ok
|
| 104 |
+
set data(filterBtn) $w.bot.filter
|
| 105 |
+
set data(cancelBtn) $w.bot.cancel
|
| 106 |
+
}
|
| 107 |
+
MotifFDialog_SetListMode $w
|
| 108 |
+
|
| 109 |
+
# Dialog boxes should be transient with respect to their parent,
|
| 110 |
+
# so that they will always stay on top of their parent window. However,
|
| 111 |
+
# some window managers will create the window as withdrawn if the parent
|
| 112 |
+
# window is withdrawn or iconified. Combined with the grab we put on the
|
| 113 |
+
# window, this can hang the entire application. Therefore we only make
|
| 114 |
+
# the dialog transient if the parent is viewable.
|
| 115 |
+
|
| 116 |
+
if {[winfo viewable [winfo toplevel $data(-parent)]] } {
|
| 117 |
+
wm transient $w $data(-parent)
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
MotifFDialog_FileTypes $w
|
| 121 |
+
MotifFDialog_Update $w
|
| 122 |
+
|
| 123 |
+
# Withdraw the window, then update all the geometry information
|
| 124 |
+
# so we know how big it wants to be, then center the window in the
|
| 125 |
+
# display (Motif style) and de-iconify it.
|
| 126 |
+
|
| 127 |
+
::tk::PlaceWindow $w
|
| 128 |
+
wm title $w $data(-title)
|
| 129 |
+
|
| 130 |
+
return $w
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
# ::tk::MotifFDialog_FileTypes --
|
| 134 |
+
#
|
| 135 |
+
# Checks the -filetypes option. If present this adds a list of radio-
|
| 136 |
+
# buttons to pick the file types from.
|
| 137 |
+
#
|
| 138 |
+
# Arguments:
|
| 139 |
+
# w Pathname of the tk_get*File dialogue.
|
| 140 |
+
#
|
| 141 |
+
# Results:
|
| 142 |
+
# none
|
| 143 |
+
|
| 144 |
+
proc ::tk::MotifFDialog_FileTypes {w} {
|
| 145 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 146 |
+
|
| 147 |
+
set f $w.top.f3.types
|
| 148 |
+
destroy $f
|
| 149 |
+
|
| 150 |
+
# No file types: use "*" as the filter and display no radio-buttons
|
| 151 |
+
if {$data(-filetypes) eq ""} {
|
| 152 |
+
set data(filter) *
|
| 153 |
+
return
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
# The filetypes radiobuttons
|
| 157 |
+
# set data(fileType) $data(-defaulttype)
|
| 158 |
+
# Default type to first entry
|
| 159 |
+
set initialTypeName [lindex $data(origfiletypes) 0 0]
|
| 160 |
+
if {$data(-typevariable) ne ""} {
|
| 161 |
+
upvar #0 $data(-typevariable) typeVariable
|
| 162 |
+
if {[info exists typeVariable]} {
|
| 163 |
+
set initialTypeName $typeVariable
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
set ix 0
|
| 167 |
+
set data(fileType) 0
|
| 168 |
+
foreach fltr $data(origfiletypes) {
|
| 169 |
+
set fname [lindex $fltr 0]
|
| 170 |
+
if {[string first $initialTypeName $fname] == 0} {
|
| 171 |
+
set data(fileType) $ix
|
| 172 |
+
break
|
| 173 |
+
}
|
| 174 |
+
incr ix
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
MotifFDialog_SetFilter $w [lindex $data(-filetypes) $data(fileType)]
|
| 178 |
+
|
| 179 |
+
#don't produce radiobuttons for only one filetype
|
| 180 |
+
if {[llength $data(-filetypes)] == 1} {
|
| 181 |
+
return
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
frame $f
|
| 185 |
+
set cnt 0
|
| 186 |
+
if {$data(-filetypes) ne {}} {
|
| 187 |
+
foreach type $data(-filetypes) {
|
| 188 |
+
set title [lindex $type 0]
|
| 189 |
+
set filter [lindex $type 1]
|
| 190 |
+
radiobutton $f.b$cnt \
|
| 191 |
+
-text $title \
|
| 192 |
+
-variable ::tk::dialog::file::[winfo name $w](fileType) \
|
| 193 |
+
-value $cnt \
|
| 194 |
+
-command [list tk::MotifFDialog_SetFilter $w $type]
|
| 195 |
+
pack $f.b$cnt -side left
|
| 196 |
+
incr cnt
|
| 197 |
+
}
|
| 198 |
+
}
|
| 199 |
+
$f.b$data(fileType) invoke
|
| 200 |
+
|
| 201 |
+
pack $f -side bottom -fill both
|
| 202 |
+
|
| 203 |
+
return
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
# This proc gets called whenever data(filter) is set
|
| 207 |
+
#
|
| 208 |
+
proc ::tk::MotifFDialog_SetFilter {w type} {
|
| 209 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 210 |
+
variable ::tk::Priv
|
| 211 |
+
|
| 212 |
+
set data(filter) [lindex $type 1]
|
| 213 |
+
set Priv(selectFileType) [lindex [lindex $type 0] 0]
|
| 214 |
+
|
| 215 |
+
MotifFDialog_Update $w
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
# ::tk::MotifFDialog_Config --
|
| 219 |
+
#
|
| 220 |
+
# Iterates over the optional arguments to determine the option
|
| 221 |
+
# values for the Motif file dialog; gives default values to
|
| 222 |
+
# unspecified options.
|
| 223 |
+
#
|
| 224 |
+
# Arguments:
|
| 225 |
+
# dataName The name of the global variable in which
|
| 226 |
+
# data for the file dialog is stored.
|
| 227 |
+
# type "Save" or "Open"
|
| 228 |
+
# argList Options parsed by the procedure.
|
| 229 |
+
|
| 230 |
+
proc ::tk::MotifFDialog_Config {dataName type argList} {
|
| 231 |
+
upvar ::tk::dialog::file::$dataName data
|
| 232 |
+
|
| 233 |
+
set data(type) $type
|
| 234 |
+
|
| 235 |
+
# 1: the configuration specs
|
| 236 |
+
#
|
| 237 |
+
set specs {
|
| 238 |
+
{-defaultextension "" "" ""}
|
| 239 |
+
{-filetypes "" "" ""}
|
| 240 |
+
{-initialdir "" "" ""}
|
| 241 |
+
{-initialfile "" "" ""}
|
| 242 |
+
{-parent "" "" "."}
|
| 243 |
+
{-title "" "" ""}
|
| 244 |
+
{-typevariable "" "" ""}
|
| 245 |
+
}
|
| 246 |
+
if {$type eq "open"} {
|
| 247 |
+
lappend specs {-multiple "" "" "0"}
|
| 248 |
+
}
|
| 249 |
+
if {$type eq "save"} {
|
| 250 |
+
lappend specs {-confirmoverwrite "" "" "1"}
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
set data(-multiple) 0
|
| 254 |
+
set data(-confirmoverwrite) 1
|
| 255 |
+
# 2: default values depending on the type of the dialog
|
| 256 |
+
#
|
| 257 |
+
if {![info exists data(selectPath)]} {
|
| 258 |
+
# first time the dialog has been popped up
|
| 259 |
+
set data(selectPath) [pwd]
|
| 260 |
+
set data(selectFile) ""
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
# 3: parse the arguments
|
| 264 |
+
#
|
| 265 |
+
tclParseConfigSpec ::tk::dialog::file::$dataName $specs "" $argList
|
| 266 |
+
|
| 267 |
+
if {$data(-title) eq ""} {
|
| 268 |
+
if {$type eq "open"} {
|
| 269 |
+
if {$data(-multiple) != 0} {
|
| 270 |
+
set data(-title) "[mc {Open Multiple Files}]"
|
| 271 |
+
} else {
|
| 272 |
+
set data(-title) [mc "Open"]
|
| 273 |
+
}
|
| 274 |
+
} else {
|
| 275 |
+
set data(-title) [mc "Save As"]
|
| 276 |
+
}
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
# 4: set the default directory and selection according to the -initial
|
| 280 |
+
# settings
|
| 281 |
+
#
|
| 282 |
+
if {$data(-initialdir) ne ""} {
|
| 283 |
+
if {[file isdirectory $data(-initialdir)]} {
|
| 284 |
+
set data(selectPath) [lindex [glob $data(-initialdir)] 0]
|
| 285 |
+
} else {
|
| 286 |
+
set data(selectPath) [pwd]
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
# Convert the initialdir to an absolute path name.
|
| 290 |
+
|
| 291 |
+
set old [pwd]
|
| 292 |
+
cd $data(selectPath)
|
| 293 |
+
set data(selectPath) [pwd]
|
| 294 |
+
cd $old
|
| 295 |
+
}
|
| 296 |
+
set data(selectFile) $data(-initialfile)
|
| 297 |
+
|
| 298 |
+
# 5. Parse the -filetypes option. It is not used by the motif
|
| 299 |
+
# file dialog, but we check for validity of the value to make sure
|
| 300 |
+
# the application code also runs fine with the TK file dialog.
|
| 301 |
+
#
|
| 302 |
+
set data(origfiletypes) $data(-filetypes)
|
| 303 |
+
set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)]
|
| 304 |
+
|
| 305 |
+
if {![info exists data(filter)]} {
|
| 306 |
+
set data(filter) *
|
| 307 |
+
}
|
| 308 |
+
if {![winfo exists $data(-parent)]} {
|
| 309 |
+
return -code error -errorcode [list TK LOOKUP WINDOW $data(-parent)] \
|
| 310 |
+
"bad window path name \"$data(-parent)\""
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
# ::tk::MotifFDialog_BuildUI --
|
| 315 |
+
#
|
| 316 |
+
# Builds the UI components of the Motif file dialog.
|
| 317 |
+
#
|
| 318 |
+
# Arguments:
|
| 319 |
+
# w Pathname of the dialog to build.
|
| 320 |
+
#
|
| 321 |
+
# Results:
|
| 322 |
+
# None.
|
| 323 |
+
|
| 324 |
+
proc ::tk::MotifFDialog_BuildUI {w} {
|
| 325 |
+
set dataName [lindex [split $w .] end]
|
| 326 |
+
upvar ::tk::dialog::file::$dataName data
|
| 327 |
+
|
| 328 |
+
# Create the dialog toplevel and internal frames.
|
| 329 |
+
#
|
| 330 |
+
toplevel $w -class TkMotifFDialog
|
| 331 |
+
set top [frame $w.top -relief raised -bd 1]
|
| 332 |
+
set bot [frame $w.bot -relief raised -bd 1]
|
| 333 |
+
|
| 334 |
+
pack $w.bot -side bottom -fill x
|
| 335 |
+
pack $w.top -side top -expand yes -fill both
|
| 336 |
+
|
| 337 |
+
set f1 [frame $top.f1]
|
| 338 |
+
set f2 [frame $top.f2]
|
| 339 |
+
set f3 [frame $top.f3]
|
| 340 |
+
|
| 341 |
+
pack $f1 -side top -fill x
|
| 342 |
+
pack $f3 -side bottom -fill x
|
| 343 |
+
pack $f2 -expand yes -fill both
|
| 344 |
+
|
| 345 |
+
set f2a [frame $f2.a]
|
| 346 |
+
set f2b [frame $f2.b]
|
| 347 |
+
|
| 348 |
+
grid $f2a -row 0 -column 0 -rowspan 1 -columnspan 1 -padx 4 -pady 4 \
|
| 349 |
+
-sticky news
|
| 350 |
+
grid $f2b -row 0 -column 1 -rowspan 1 -columnspan 1 -padx 4 -pady 4 \
|
| 351 |
+
-sticky news
|
| 352 |
+
grid rowconfigure $f2 0 -minsize 0 -weight 1
|
| 353 |
+
grid columnconfigure $f2 0 -minsize 0 -weight 1
|
| 354 |
+
grid columnconfigure $f2 1 -minsize 150 -weight 2
|
| 355 |
+
|
| 356 |
+
# The Filter box
|
| 357 |
+
#
|
| 358 |
+
bind [::tk::AmpWidget label $f1.lab -text [mc "Fil&ter:"] -anchor w] \
|
| 359 |
+
<<AltUnderlined>> [list focus $f1.ent]
|
| 360 |
+
entry $f1.ent
|
| 361 |
+
pack $f1.lab -side top -fill x -padx 6 -pady 4
|
| 362 |
+
pack $f1.ent -side top -fill x -padx 4 -pady 0
|
| 363 |
+
set data(fEnt) $f1.ent
|
| 364 |
+
|
| 365 |
+
# The file and directory lists
|
| 366 |
+
#
|
| 367 |
+
set data(dList) [MotifFDialog_MakeSList $w $f2a \
|
| 368 |
+
[mc "&Directory:"] DList]
|
| 369 |
+
set data(fList) [MotifFDialog_MakeSList $w $f2b \
|
| 370 |
+
[mc "Fi&les:"] FList]
|
| 371 |
+
|
| 372 |
+
# The Selection box
|
| 373 |
+
#
|
| 374 |
+
bind [::tk::AmpWidget label $f3.lab -text [mc "&Selection:"] -anchor w] \
|
| 375 |
+
<<AltUnderlined>> [list focus $f3.ent]
|
| 376 |
+
entry $f3.ent
|
| 377 |
+
pack $f3.lab -side top -fill x -padx 6 -pady 0
|
| 378 |
+
pack $f3.ent -side top -fill x -padx 4 -pady 4
|
| 379 |
+
set data(sEnt) $f3.ent
|
| 380 |
+
|
| 381 |
+
# The buttons
|
| 382 |
+
#
|
| 383 |
+
set maxWidth [::tk::mcmaxamp &OK &Filter &Cancel]
|
| 384 |
+
set maxWidth [expr {$maxWidth<6?6:$maxWidth}]
|
| 385 |
+
set data(okBtn) [::tk::AmpWidget button $bot.ok -text [mc "&OK"] \
|
| 386 |
+
-width $maxWidth \
|
| 387 |
+
-command [list tk::MotifFDialog_OkCmd $w]]
|
| 388 |
+
set data(filterBtn) [::tk::AmpWidget button $bot.filter -text [mc "&Filter"] \
|
| 389 |
+
-width $maxWidth \
|
| 390 |
+
-command [list tk::MotifFDialog_FilterCmd $w]]
|
| 391 |
+
set data(cancelBtn) [::tk::AmpWidget button $bot.cancel -text [mc "&Cancel"] \
|
| 392 |
+
-width $maxWidth \
|
| 393 |
+
-command [list tk::MotifFDialog_CancelCmd $w]]
|
| 394 |
+
|
| 395 |
+
pack $bot.ok $bot.filter $bot.cancel -padx 10 -pady 10 -expand yes \
|
| 396 |
+
-side left
|
| 397 |
+
|
| 398 |
+
# Create the bindings:
|
| 399 |
+
#
|
| 400 |
+
bind $w <Alt-Key> [list ::tk::AltKeyInDialog $w %A]
|
| 401 |
+
|
| 402 |
+
bind $data(fEnt) <Return> [list tk::MotifFDialog_ActivateFEnt $w]
|
| 403 |
+
bind $data(sEnt) <Return> [list tk::MotifFDialog_ActivateSEnt $w]
|
| 404 |
+
bind $w <Escape> [list tk::MotifFDialog_CancelCmd $w]
|
| 405 |
+
bind $w.bot <Destroy> {set ::tk::Priv(selectFilePath) {}}
|
| 406 |
+
|
| 407 |
+
wm protocol $w WM_DELETE_WINDOW [list tk::MotifFDialog_CancelCmd $w]
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
proc ::tk::MotifFDialog_SetListMode {w} {
|
| 411 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 412 |
+
|
| 413 |
+
if {$data(-multiple) != 0} {
|
| 414 |
+
set selectmode extended
|
| 415 |
+
} else {
|
| 416 |
+
set selectmode browse
|
| 417 |
+
}
|
| 418 |
+
set f $w.top.f2.b
|
| 419 |
+
$f.l configure -selectmode $selectmode
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
# ::tk::MotifFDialog_MakeSList --
|
| 423 |
+
#
|
| 424 |
+
# Create a scrolled-listbox and set the keyboard accelerator
|
| 425 |
+
# bindings so that the list selection follows what the user
|
| 426 |
+
# types.
|
| 427 |
+
#
|
| 428 |
+
# Arguments:
|
| 429 |
+
# w Pathname of the dialog box.
|
| 430 |
+
# f Frame widget inside which to create the scrolled
|
| 431 |
+
# listbox. This frame widget already exists.
|
| 432 |
+
# label The string to display on top of the listbox.
|
| 433 |
+
# under Sets the -under option of the label.
|
| 434 |
+
# cmdPrefix Specifies procedures to call when the listbox is
|
| 435 |
+
# browsed or activated.
|
| 436 |
+
|
| 437 |
+
proc ::tk::MotifFDialog_MakeSList {w f label cmdPrefix} {
|
| 438 |
+
bind [::tk::AmpWidget label $f.lab -text $label -anchor w] \
|
| 439 |
+
<<AltUnderlined>> [list focus $f.l]
|
| 440 |
+
listbox $f.l -width 12 -height 5 -exportselection 0\
|
| 441 |
+
-xscrollcommand [list $f.h set] -yscrollcommand [list $f.v set]
|
| 442 |
+
scrollbar $f.v -orient vertical -takefocus 0 -command [list $f.l yview]
|
| 443 |
+
scrollbar $f.h -orient horizontal -takefocus 0 -command [list $f.l xview]
|
| 444 |
+
grid $f.lab -row 0 -column 0 -sticky news -rowspan 1 -columnspan 2 \
|
| 445 |
+
-padx 2 -pady 2
|
| 446 |
+
grid $f.l -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
|
| 447 |
+
grid $f.v -row 1 -column 1 -rowspan 1 -columnspan 1 -sticky news
|
| 448 |
+
grid $f.h -row 2 -column 0 -rowspan 1 -columnspan 1 -sticky news
|
| 449 |
+
|
| 450 |
+
grid rowconfigure $f 0 -weight 0 -minsize 0
|
| 451 |
+
grid rowconfigure $f 1 -weight 1 -minsize 0
|
| 452 |
+
grid columnconfigure $f 0 -weight 1 -minsize 0
|
| 453 |
+
|
| 454 |
+
# bindings for the listboxes
|
| 455 |
+
#
|
| 456 |
+
set list $f.l
|
| 457 |
+
bind $list <<ListboxSelect>> [list tk::MotifFDialog_Browse$cmdPrefix $w]
|
| 458 |
+
bind $list <Double-ButtonRelease-1> \
|
| 459 |
+
[list tk::MotifFDialog_Activate$cmdPrefix $w]
|
| 460 |
+
bind $list <Return> "tk::MotifFDialog_Browse$cmdPrefix [list $w]; \
|
| 461 |
+
tk::MotifFDialog_Activate$cmdPrefix [list $w]"
|
| 462 |
+
|
| 463 |
+
bindtags $list [list Listbox $list [winfo toplevel $list] all]
|
| 464 |
+
ListBoxKeyAccel_Set $list
|
| 465 |
+
|
| 466 |
+
return $f.l
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
# ::tk::MotifFDialog_InterpFilter --
|
| 470 |
+
#
|
| 471 |
+
# Interpret the string in the filter entry into two components:
|
| 472 |
+
# the directory and the pattern. If the string is a relative
|
| 473 |
+
# pathname, give a warning to the user and restore the pattern
|
| 474 |
+
# to original.
|
| 475 |
+
#
|
| 476 |
+
# Arguments:
|
| 477 |
+
# w pathname of the dialog box.
|
| 478 |
+
#
|
| 479 |
+
# Results:
|
| 480 |
+
# A list of two elements. The first element is the directory
|
| 481 |
+
# specified # by the filter. The second element is the filter
|
| 482 |
+
# pattern itself.
|
| 483 |
+
|
| 484 |
+
proc ::tk::MotifFDialog_InterpFilter {w} {
|
| 485 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 486 |
+
|
| 487 |
+
set text [string trim [$data(fEnt) get]]
|
| 488 |
+
|
| 489 |
+
# Perform tilde substitution
|
| 490 |
+
#
|
| 491 |
+
set badTilde 0
|
| 492 |
+
if {[string index $text 0] eq "~"} {
|
| 493 |
+
set list [file split $text]
|
| 494 |
+
set tilde [lindex $list 0]
|
| 495 |
+
if {[catch {set tilde [glob $tilde]}]} {
|
| 496 |
+
set badTilde 1
|
| 497 |
+
} else {
|
| 498 |
+
set text [eval file join [concat $tilde [lrange $list 1 end]]]
|
| 499 |
+
}
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
# If the string is a relative pathname, combine it
|
| 503 |
+
# with the current selectPath.
|
| 504 |
+
|
| 505 |
+
set relative 0
|
| 506 |
+
if {[file pathtype $text] eq "relative"} {
|
| 507 |
+
set relative 1
|
| 508 |
+
} elseif {$badTilde} {
|
| 509 |
+
set relative 1
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
if {$relative} {
|
| 513 |
+
tk_messageBox -icon warning -type ok \
|
| 514 |
+
-message "\"$text\" must be an absolute pathname"
|
| 515 |
+
|
| 516 |
+
$data(fEnt) delete 0 end
|
| 517 |
+
$data(fEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \
|
| 518 |
+
$data(filter)]
|
| 519 |
+
|
| 520 |
+
return [list $data(selectPath) $data(filter)]
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
set resolved [::tk::dialog::file::JoinFile [file dirname $text] [file tail $text]]
|
| 524 |
+
|
| 525 |
+
if {[file isdirectory $resolved]} {
|
| 526 |
+
set dir $resolved
|
| 527 |
+
set fil $data(filter)
|
| 528 |
+
} else {
|
| 529 |
+
set dir [file dirname $resolved]
|
| 530 |
+
set fil [file tail $resolved]
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
return [list $dir $fil]
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
# ::tk::MotifFDialog_Update
|
| 537 |
+
#
|
| 538 |
+
# Load the files and synchronize the "filter" and "selection" fields
|
| 539 |
+
# boxes.
|
| 540 |
+
#
|
| 541 |
+
# Arguments:
|
| 542 |
+
# w pathname of the dialog box.
|
| 543 |
+
#
|
| 544 |
+
# Results:
|
| 545 |
+
# None.
|
| 546 |
+
|
| 547 |
+
proc ::tk::MotifFDialog_Update {w} {
|
| 548 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 549 |
+
|
| 550 |
+
$data(fEnt) delete 0 end
|
| 551 |
+
$data(fEnt) insert 0 \
|
| 552 |
+
[::tk::dialog::file::JoinFile $data(selectPath) $data(filter)]
|
| 553 |
+
$data(sEnt) delete 0 end
|
| 554 |
+
$data(sEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \
|
| 555 |
+
$data(selectFile)]
|
| 556 |
+
|
| 557 |
+
MotifFDialog_LoadFiles $w
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
# ::tk::MotifFDialog_LoadFiles --
|
| 561 |
+
#
|
| 562 |
+
# Loads the files and directories into the two listboxes according
|
| 563 |
+
# to the filter setting.
|
| 564 |
+
#
|
| 565 |
+
# Arguments:
|
| 566 |
+
# w pathname of the dialog box.
|
| 567 |
+
#
|
| 568 |
+
# Results:
|
| 569 |
+
# None.
|
| 570 |
+
|
| 571 |
+
proc ::tk::MotifFDialog_LoadFiles {w} {
|
| 572 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 573 |
+
|
| 574 |
+
$data(dList) delete 0 end
|
| 575 |
+
$data(fList) delete 0 end
|
| 576 |
+
|
| 577 |
+
set appPWD [pwd]
|
| 578 |
+
if {[catch {cd $data(selectPath)}]} {
|
| 579 |
+
cd $appPWD
|
| 580 |
+
|
| 581 |
+
$data(dList) insert end ".."
|
| 582 |
+
return
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
# Make the dir and file lists
|
| 586 |
+
#
|
| 587 |
+
# For speed we only have one glob, which reduces the file system
|
| 588 |
+
# calls (good for slow NFS networks).
|
| 589 |
+
#
|
| 590 |
+
# We also do two smaller sorts (files + dirs) instead of one large sort,
|
| 591 |
+
# which gives a small speed increase.
|
| 592 |
+
#
|
| 593 |
+
set top 0
|
| 594 |
+
set dlist ""
|
| 595 |
+
set flist ""
|
| 596 |
+
foreach f [glob -nocomplain .* *] {
|
| 597 |
+
if {[file isdir ./$f]} {
|
| 598 |
+
lappend dlist $f
|
| 599 |
+
} else {
|
| 600 |
+
foreach pat $data(filter) {
|
| 601 |
+
if {[string match $pat $f]} {
|
| 602 |
+
if {[string match .* $f]} {
|
| 603 |
+
incr top
|
| 604 |
+
}
|
| 605 |
+
lappend flist $f
|
| 606 |
+
break
|
| 607 |
+
}
|
| 608 |
+
}
|
| 609 |
+
}
|
| 610 |
+
}
|
| 611 |
+
eval [list $data(dList) insert end] [lsort -dictionary $dlist]
|
| 612 |
+
eval [list $data(fList) insert end] [lsort -dictionary $flist]
|
| 613 |
+
|
| 614 |
+
# The user probably doesn't want to see the . files. We adjust the view
|
| 615 |
+
# so that the listbox displays all the non-dot files
|
| 616 |
+
$data(fList) yview $top
|
| 617 |
+
|
| 618 |
+
cd $appPWD
|
| 619 |
+
}
|
| 620 |
+
|
| 621 |
+
# ::tk::MotifFDialog_BrowseDList --
|
| 622 |
+
#
|
| 623 |
+
# This procedure is called when the directory list is browsed
|
| 624 |
+
# (clicked-over) by the user.
|
| 625 |
+
#
|
| 626 |
+
# Arguments:
|
| 627 |
+
# w The pathname of the dialog box.
|
| 628 |
+
#
|
| 629 |
+
# Results:
|
| 630 |
+
# None.
|
| 631 |
+
|
| 632 |
+
proc ::tk::MotifFDialog_BrowseDList {w} {
|
| 633 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 634 |
+
|
| 635 |
+
focus $data(dList)
|
| 636 |
+
if {[$data(dList) curselection] eq ""} {
|
| 637 |
+
return
|
| 638 |
+
}
|
| 639 |
+
set subdir [$data(dList) get [$data(dList) curselection]]
|
| 640 |
+
if {$subdir eq ""} {
|
| 641 |
+
return
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
$data(fList) selection clear 0 end
|
| 645 |
+
|
| 646 |
+
set list [MotifFDialog_InterpFilter $w]
|
| 647 |
+
set data(filter) [lindex $list 1]
|
| 648 |
+
|
| 649 |
+
switch -- $subdir {
|
| 650 |
+
. {
|
| 651 |
+
set newSpec [::tk::dialog::file::JoinFile $data(selectPath) $data(filter)]
|
| 652 |
+
}
|
| 653 |
+
.. {
|
| 654 |
+
set newSpec [::tk::dialog::file::JoinFile [file dirname $data(selectPath)] \
|
| 655 |
+
$data(filter)]
|
| 656 |
+
}
|
| 657 |
+
default {
|
| 658 |
+
set newSpec [::tk::dialog::file::JoinFile [::tk::dialog::file::JoinFile \
|
| 659 |
+
$data(selectPath) $subdir] $data(filter)]
|
| 660 |
+
}
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
$data(fEnt) delete 0 end
|
| 664 |
+
$data(fEnt) insert 0 $newSpec
|
| 665 |
+
}
|
| 666 |
+
|
| 667 |
+
# ::tk::MotifFDialog_ActivateDList --
|
| 668 |
+
#
|
| 669 |
+
# This procedure is called when the directory list is activated
|
| 670 |
+
# (double-clicked) by the user.
|
| 671 |
+
#
|
| 672 |
+
# Arguments:
|
| 673 |
+
# w The pathname of the dialog box.
|
| 674 |
+
#
|
| 675 |
+
# Results:
|
| 676 |
+
# None.
|
| 677 |
+
|
| 678 |
+
proc ::tk::MotifFDialog_ActivateDList {w} {
|
| 679 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 680 |
+
|
| 681 |
+
if {[$data(dList) curselection] eq ""} {
|
| 682 |
+
return
|
| 683 |
+
}
|
| 684 |
+
set subdir [$data(dList) get [$data(dList) curselection]]
|
| 685 |
+
if {$subdir eq ""} {
|
| 686 |
+
return
|
| 687 |
+
}
|
| 688 |
+
|
| 689 |
+
$data(fList) selection clear 0 end
|
| 690 |
+
|
| 691 |
+
switch -- $subdir {
|
| 692 |
+
. {
|
| 693 |
+
set newDir $data(selectPath)
|
| 694 |
+
}
|
| 695 |
+
.. {
|
| 696 |
+
set newDir [file dirname $data(selectPath)]
|
| 697 |
+
}
|
| 698 |
+
default {
|
| 699 |
+
set newDir [::tk::dialog::file::JoinFile $data(selectPath) $subdir]
|
| 700 |
+
}
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
set data(selectPath) $newDir
|
| 704 |
+
MotifFDialog_Update $w
|
| 705 |
+
|
| 706 |
+
if {$subdir ne ".."} {
|
| 707 |
+
$data(dList) selection set 0
|
| 708 |
+
$data(dList) activate 0
|
| 709 |
+
} else {
|
| 710 |
+
$data(dList) selection set 1
|
| 711 |
+
$data(dList) activate 1
|
| 712 |
+
}
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
# ::tk::MotifFDialog_BrowseFList --
|
| 716 |
+
#
|
| 717 |
+
# This procedure is called when the file list is browsed
|
| 718 |
+
# (clicked-over) by the user.
|
| 719 |
+
#
|
| 720 |
+
# Arguments:
|
| 721 |
+
# w The pathname of the dialog box.
|
| 722 |
+
#
|
| 723 |
+
# Results:
|
| 724 |
+
# None.
|
| 725 |
+
|
| 726 |
+
proc ::tk::MotifFDialog_BrowseFList {w} {
|
| 727 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 728 |
+
|
| 729 |
+
focus $data(fList)
|
| 730 |
+
set data(selectFile) ""
|
| 731 |
+
foreach item [$data(fList) curselection] {
|
| 732 |
+
lappend data(selectFile) [$data(fList) get $item]
|
| 733 |
+
}
|
| 734 |
+
if {[llength $data(selectFile)] == 0} {
|
| 735 |
+
return
|
| 736 |
+
}
|
| 737 |
+
|
| 738 |
+
$data(dList) selection clear 0 end
|
| 739 |
+
|
| 740 |
+
$data(fEnt) delete 0 end
|
| 741 |
+
$data(fEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \
|
| 742 |
+
$data(filter)]
|
| 743 |
+
$data(fEnt) xview end
|
| 744 |
+
|
| 745 |
+
# if it's a multiple selection box, just put in the filenames
|
| 746 |
+
# otherwise put in the full path as usual
|
| 747 |
+
$data(sEnt) delete 0 end
|
| 748 |
+
if {$data(-multiple) != 0} {
|
| 749 |
+
$data(sEnt) insert 0 $data(selectFile)
|
| 750 |
+
} else {
|
| 751 |
+
$data(sEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \
|
| 752 |
+
[lindex $data(selectFile) 0]]
|
| 753 |
+
}
|
| 754 |
+
$data(sEnt) xview end
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
# ::tk::MotifFDialog_ActivateFList --
|
| 758 |
+
#
|
| 759 |
+
# This procedure is called when the file list is activated
|
| 760 |
+
# (double-clicked) by the user.
|
| 761 |
+
#
|
| 762 |
+
# Arguments:
|
| 763 |
+
# w The pathname of the dialog box.
|
| 764 |
+
#
|
| 765 |
+
# Results:
|
| 766 |
+
# None.
|
| 767 |
+
|
| 768 |
+
proc ::tk::MotifFDialog_ActivateFList {w} {
|
| 769 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 770 |
+
|
| 771 |
+
if {[$data(fList) curselection] eq ""} {
|
| 772 |
+
return
|
| 773 |
+
}
|
| 774 |
+
set data(selectFile) [$data(fList) get [$data(fList) curselection]]
|
| 775 |
+
if {$data(selectFile) eq ""} {
|
| 776 |
+
return
|
| 777 |
+
} else {
|
| 778 |
+
MotifFDialog_ActivateSEnt $w
|
| 779 |
+
}
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
# ::tk::MotifFDialog_ActivateFEnt --
|
| 783 |
+
#
|
| 784 |
+
# This procedure is called when the user presses Return inside
|
| 785 |
+
# the "filter" entry. It updates the dialog according to the
|
| 786 |
+
# text inside the filter entry.
|
| 787 |
+
#
|
| 788 |
+
# Arguments:
|
| 789 |
+
# w The pathname of the dialog box.
|
| 790 |
+
#
|
| 791 |
+
# Results:
|
| 792 |
+
# None.
|
| 793 |
+
|
| 794 |
+
proc ::tk::MotifFDialog_ActivateFEnt {w} {
|
| 795 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 796 |
+
|
| 797 |
+
set list [MotifFDialog_InterpFilter $w]
|
| 798 |
+
set data(selectPath) [lindex $list 0]
|
| 799 |
+
set data(filter) [lindex $list 1]
|
| 800 |
+
|
| 801 |
+
MotifFDialog_Update $w
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
# ::tk::MotifFDialog_ActivateSEnt --
|
| 805 |
+
#
|
| 806 |
+
# This procedure is called when the user presses Return inside
|
| 807 |
+
# the "selection" entry. It sets the ::tk::Priv(selectFilePath)
|
| 808 |
+
# variable so that the vwait loop in tk::MotifFDialog will be
|
| 809 |
+
# terminated.
|
| 810 |
+
#
|
| 811 |
+
# Arguments:
|
| 812 |
+
# w The pathname of the dialog box.
|
| 813 |
+
#
|
| 814 |
+
# Results:
|
| 815 |
+
# None.
|
| 816 |
+
|
| 817 |
+
proc ::tk::MotifFDialog_ActivateSEnt {w} {
|
| 818 |
+
variable ::tk::Priv
|
| 819 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 820 |
+
|
| 821 |
+
set selectFilePath [string trim [$data(sEnt) get]]
|
| 822 |
+
|
| 823 |
+
if {$selectFilePath eq ""} {
|
| 824 |
+
MotifFDialog_FilterCmd $w
|
| 825 |
+
return
|
| 826 |
+
}
|
| 827 |
+
|
| 828 |
+
if {$data(-multiple) == 0} {
|
| 829 |
+
set selectFilePath [list $selectFilePath]
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
if {[file isdirectory [lindex $selectFilePath 0]]} {
|
| 833 |
+
set data(selectPath) [lindex [glob $selectFilePath] 0]
|
| 834 |
+
set data(selectFile) ""
|
| 835 |
+
MotifFDialog_Update $w
|
| 836 |
+
return
|
| 837 |
+
}
|
| 838 |
+
|
| 839 |
+
set newFileList ""
|
| 840 |
+
foreach item $selectFilePath {
|
| 841 |
+
if {[file pathtype $item] ne "absolute"} {
|
| 842 |
+
set item [file join $data(selectPath) $item]
|
| 843 |
+
} elseif {![file exists [file dirname $item]]} {
|
| 844 |
+
tk_messageBox -icon warning -type ok \
|
| 845 |
+
-message [mc {Directory "%1$s" does not exist.} \
|
| 846 |
+
[file dirname $item]]
|
| 847 |
+
return
|
| 848 |
+
}
|
| 849 |
+
|
| 850 |
+
if {![file exists $item]} {
|
| 851 |
+
if {$data(type) eq "open"} {
|
| 852 |
+
tk_messageBox -icon warning -type ok \
|
| 853 |
+
-message [mc {File "%1$s" does not exist.} $item]
|
| 854 |
+
return
|
| 855 |
+
}
|
| 856 |
+
} elseif {$data(type) eq "save" && $data(-confirmoverwrite)} {
|
| 857 |
+
set message [format %s%s \
|
| 858 |
+
[mc "File \"%1\$s\" already exists.\n\n" $selectFilePath] \
|
| 859 |
+
[mc {Replace existing file?}]]
|
| 860 |
+
set answer [tk_messageBox -icon warning -type yesno \
|
| 861 |
+
-message $message]
|
| 862 |
+
if {$answer eq "no"} {
|
| 863 |
+
return
|
| 864 |
+
}
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
lappend newFileList $item
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
# Return selected filter
|
| 871 |
+
if {[info exists data(-typevariable)] && $data(-typevariable) ne ""
|
| 872 |
+
&& [info exists data(-filetypes)] && $data(-filetypes) ne ""} {
|
| 873 |
+
upvar #0 $data(-typevariable) typeVariable
|
| 874 |
+
set typeVariable [lindex $data(origfiletypes) $data(fileType) 0]
|
| 875 |
+
}
|
| 876 |
+
|
| 877 |
+
if {$data(-multiple) != 0} {
|
| 878 |
+
set Priv(selectFilePath) $newFileList
|
| 879 |
+
} else {
|
| 880 |
+
set Priv(selectFilePath) [lindex $newFileList 0]
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
# Set selectFile and selectPath to first item in list
|
| 884 |
+
set Priv(selectFile) [file tail [lindex $newFileList 0]]
|
| 885 |
+
set Priv(selectPath) [file dirname [lindex $newFileList 0]]
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
|
| 889 |
+
proc ::tk::MotifFDialog_OkCmd {w} {
|
| 890 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 891 |
+
|
| 892 |
+
MotifFDialog_ActivateSEnt $w
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
proc ::tk::MotifFDialog_FilterCmd {w} {
|
| 896 |
+
upvar ::tk::dialog::file::[winfo name $w] data
|
| 897 |
+
|
| 898 |
+
MotifFDialog_ActivateFEnt $w
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
proc ::tk::MotifFDialog_CancelCmd {w} {
|
| 902 |
+
variable ::tk::Priv
|
| 903 |
+
|
| 904 |
+
set Priv(selectFilePath) ""
|
| 905 |
+
set Priv(selectFile) ""
|
| 906 |
+
set Priv(selectPath) ""
|
| 907 |
+
}
|
| 908 |
+
|
| 909 |
+
proc ::tk::ListBoxKeyAccel_Set {w} {
|
| 910 |
+
bind Listbox <Any-Key> ""
|
| 911 |
+
bind $w <Destroy> [list tk::ListBoxKeyAccel_Unset $w]
|
| 912 |
+
bind $w <Any-Key> [list tk::ListBoxKeyAccel_Key $w %A]
|
| 913 |
+
}
|
| 914 |
+
|
| 915 |
+
proc ::tk::ListBoxKeyAccel_Unset {w} {
|
| 916 |
+
variable ::tk::Priv
|
| 917 |
+
|
| 918 |
+
catch {after cancel $Priv(lbAccel,$w,afterId)}
|
| 919 |
+
unset -nocomplain Priv(lbAccel,$w) Priv(lbAccel,$w,afterId)
|
| 920 |
+
}
|
| 921 |
+
|
| 922 |
+
# ::tk::ListBoxKeyAccel_Key--
|
| 923 |
+
#
|
| 924 |
+
# This procedure maintains a list of recently entered keystrokes
|
| 925 |
+
# over a listbox widget. It arranges an idle event to move the
|
| 926 |
+
# selection of the listbox to the entry that begins with the
|
| 927 |
+
# keystrokes.
|
| 928 |
+
#
|
| 929 |
+
# Arguments:
|
| 930 |
+
# w The pathname of the listbox.
|
| 931 |
+
# key The key which the user just pressed.
|
| 932 |
+
#
|
| 933 |
+
# Results:
|
| 934 |
+
# None.
|
| 935 |
+
|
| 936 |
+
proc ::tk::ListBoxKeyAccel_Key {w key} {
|
| 937 |
+
variable ::tk::Priv
|
| 938 |
+
|
| 939 |
+
if { $key eq "" } {
|
| 940 |
+
return
|
| 941 |
+
}
|
| 942 |
+
append Priv(lbAccel,$w) $key
|
| 943 |
+
ListBoxKeyAccel_Goto $w $Priv(lbAccel,$w)
|
| 944 |
+
catch {
|
| 945 |
+
after cancel $Priv(lbAccel,$w,afterId)
|
| 946 |
+
}
|
| 947 |
+
set Priv(lbAccel,$w,afterId) [after 500 \
|
| 948 |
+
[list tk::ListBoxKeyAccel_Reset $w]]
|
| 949 |
+
}
|
| 950 |
+
|
| 951 |
+
proc ::tk::ListBoxKeyAccel_Goto {w string} {
|
| 952 |
+
variable ::tk::Priv
|
| 953 |
+
|
| 954 |
+
set string [string tolower $string]
|
| 955 |
+
set end [$w index end]
|
| 956 |
+
set theIndex -1
|
| 957 |
+
|
| 958 |
+
for {set i 0} {$i < $end} {incr i} {
|
| 959 |
+
set item [string tolower [$w get $i]]
|
| 960 |
+
if {[string compare $string $item] >= 0} {
|
| 961 |
+
set theIndex $i
|
| 962 |
+
}
|
| 963 |
+
if {[string compare $string $item] <= 0} {
|
| 964 |
+
set theIndex $i
|
| 965 |
+
break
|
| 966 |
+
}
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
if {$theIndex >= 0} {
|
| 970 |
+
$w selection clear 0 end
|
| 971 |
+
$w selection set $theIndex $theIndex
|
| 972 |
+
$w activate $theIndex
|
| 973 |
+
$w see $theIndex
|
| 974 |
+
event generate $w <<ListboxSelect>>
|
| 975 |
+
}
|
| 976 |
+
}
|
| 977 |
+
|
| 978 |
+
proc ::tk::ListBoxKeyAccel_Reset {w} {
|
| 979 |
+
variable ::tk::Priv
|
| 980 |
+
|
| 981 |
+
unset -nocomplain Priv(lbAccel,$w)
|
| 982 |
+
}
|
| 983 |
+
|
| 984 |
+
proc ::tk_getFileType {} {
|
| 985 |
+
variable ::tk::Priv
|
| 986 |
+
|
| 987 |
+
return $Priv(selectFileType)
|
| 988 |
+
}
|
| 989 |
+
|
vllm/lib/python3.10/site-packages/setuptools/_vendor/__pycache__/typing_extensions.cpython-310.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ef7293e3161b02b6a9d33e9d530289db2a607d302026483b6efb88af81cfd29e
|
| 3 |
+
size 100328
|
vllm/lib/python3.10/site-packages/smmap/__pycache__/buf.cpython-310.pyc
ADDED
|
Binary file (5.08 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/smmap/test/__init__.py
ADDED
|
File without changes
|
vllm/lib/python3.10/site-packages/smmap/test/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (160 Bytes). View file
|
|
|
vllm/lib/python3.10/site-packages/smmap/test/__pycache__/lib.cpython-310.pyc
ADDED
|
Binary file (2.18 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/smmap/test/__pycache__/test_mman.cpython-310.pyc
ADDED
|
Binary file (4.79 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/smmap/test/__pycache__/test_tutorial.cpython-310.pyc
ADDED
|
Binary file (1.33 kB). View file
|
|
|
vllm/lib/python3.10/site-packages/smmap/test/lib.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Provide base classes for the test system"""
|
| 2 |
+
from unittest import TestCase
|
| 3 |
+
import os
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
__all__ = ['TestBase', 'FileCreator']
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
#{ Utilities
|
| 10 |
+
|
| 11 |
+
class FileCreator:
|
| 12 |
+
|
| 13 |
+
"""A instance which creates a temporary file with a prefix and a given size
|
| 14 |
+
and provides this info to the user.
|
| 15 |
+
Once it gets deleted, it will remove the temporary file as well."""
|
| 16 |
+
__slots__ = ("_size", "_path")
|
| 17 |
+
|
| 18 |
+
def __init__(self, size, prefix=''):
|
| 19 |
+
assert size, "Require size to be larger 0"
|
| 20 |
+
|
| 21 |
+
self._size = size
|
| 22 |
+
|
| 23 |
+
with tempfile.NamedTemporaryFile("wb", prefix=prefix, delete=False) as file:
|
| 24 |
+
self._path = file.name
|
| 25 |
+
file.seek(size - 1)
|
| 26 |
+
file.write(b'1')
|
| 27 |
+
|
| 28 |
+
assert os.path.getsize(self.path) == size
|
| 29 |
+
|
| 30 |
+
def __del__(self):
|
| 31 |
+
try:
|
| 32 |
+
os.remove(self.path)
|
| 33 |
+
except OSError:
|
| 34 |
+
pass
|
| 35 |
+
# END exception handling
|
| 36 |
+
|
| 37 |
+
def __enter__(self):
|
| 38 |
+
return self
|
| 39 |
+
|
| 40 |
+
def __exit__(self, exc_type, exc_value, traceback):
|
| 41 |
+
self.__del__()
|
| 42 |
+
|
| 43 |
+
@property
|
| 44 |
+
def path(self):
|
| 45 |
+
return self._path
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def size(self):
|
| 49 |
+
return self._size
|
| 50 |
+
|
| 51 |
+
#} END utilities
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class TestBase(TestCase):
|
| 55 |
+
|
| 56 |
+
"""Foundation used by all tests"""
|
| 57 |
+
|
| 58 |
+
#{ Configuration
|
| 59 |
+
k_window_test_size = 1000 * 1000 * 8 + 5195
|
| 60 |
+
#} END configuration
|
| 61 |
+
|
| 62 |
+
#{ Overrides
|
| 63 |
+
@classmethod
|
| 64 |
+
def setUpAll(cls):
|
| 65 |
+
# nothing for now
|
| 66 |
+
pass
|
| 67 |
+
|
| 68 |
+
# END overrides
|
| 69 |
+
|
| 70 |
+
#{ Interface
|
| 71 |
+
|
| 72 |
+
#} END interface
|
vllm/lib/python3.10/site-packages/smmap/test/test_buf.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .lib import TestBase, FileCreator
|
| 2 |
+
|
| 3 |
+
from smmap.mman import (
|
| 4 |
+
SlidingWindowMapManager,
|
| 5 |
+
StaticWindowMapManager
|
| 6 |
+
)
|
| 7 |
+
from smmap.buf import SlidingWindowMapBuffer
|
| 8 |
+
|
| 9 |
+
from random import randint
|
| 10 |
+
from time import time
|
| 11 |
+
import sys
|
| 12 |
+
import os
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
man_optimal = SlidingWindowMapManager()
|
| 16 |
+
man_worst_case = SlidingWindowMapManager(
|
| 17 |
+
window_size=TestBase.k_window_test_size // 100,
|
| 18 |
+
max_memory_size=TestBase.k_window_test_size // 3,
|
| 19 |
+
max_open_handles=15)
|
| 20 |
+
static_man = StaticWindowMapManager()
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class TestBuf(TestBase):
|
| 24 |
+
|
| 25 |
+
def test_basics(self):
|
| 26 |
+
with FileCreator(self.k_window_test_size, "buffer_test") as fc:
|
| 27 |
+
|
| 28 |
+
# invalid paths fail upon construction
|
| 29 |
+
c = man_optimal.make_cursor(fc.path)
|
| 30 |
+
self.assertRaises(ValueError, SlidingWindowMapBuffer, type(c)()) # invalid cursor
|
| 31 |
+
self.assertRaises(ValueError, SlidingWindowMapBuffer, c, fc.size) # offset too large
|
| 32 |
+
|
| 33 |
+
buf = SlidingWindowMapBuffer() # can create uninitialized buffers
|
| 34 |
+
assert buf.cursor() is None
|
| 35 |
+
|
| 36 |
+
# can call end access any time
|
| 37 |
+
buf.end_access()
|
| 38 |
+
buf.end_access()
|
| 39 |
+
assert len(buf) == 0
|
| 40 |
+
|
| 41 |
+
# begin access can revive it, if the offset is suitable
|
| 42 |
+
offset = 100
|
| 43 |
+
assert buf.begin_access(c, fc.size) == False
|
| 44 |
+
assert buf.begin_access(c, offset) == True
|
| 45 |
+
assert len(buf) == fc.size - offset
|
| 46 |
+
assert buf.cursor().is_valid()
|
| 47 |
+
|
| 48 |
+
# empty begin access keeps it valid on the same path, but alters the offset
|
| 49 |
+
assert buf.begin_access() == True
|
| 50 |
+
assert len(buf) == fc.size
|
| 51 |
+
assert buf.cursor().is_valid()
|
| 52 |
+
|
| 53 |
+
# simple access
|
| 54 |
+
with open(fc.path, 'rb') as fp:
|
| 55 |
+
data = fp.read()
|
| 56 |
+
assert data[offset] == buf[0]
|
| 57 |
+
assert data[offset:offset * 2] == buf[0:offset]
|
| 58 |
+
|
| 59 |
+
# negative indices, partial slices
|
| 60 |
+
assert buf[-1] == buf[len(buf) - 1]
|
| 61 |
+
assert buf[-10:] == buf[len(buf) - 10:len(buf)]
|
| 62 |
+
|
| 63 |
+
# end access makes its cursor invalid
|
| 64 |
+
buf.end_access()
|
| 65 |
+
assert not buf.cursor().is_valid()
|
| 66 |
+
assert buf.cursor().is_associated() # but it remains associated
|
| 67 |
+
|
| 68 |
+
# an empty begin access fixes it up again
|
| 69 |
+
assert buf.begin_access() == True and buf.cursor().is_valid()
|
| 70 |
+
del(buf) # ends access automatically
|
| 71 |
+
del(c)
|
| 72 |
+
|
| 73 |
+
assert man_optimal.num_file_handles() == 1
|
| 74 |
+
|
| 75 |
+
# PERFORMANCE
|
| 76 |
+
# blast away with random access and a full mapping - we don't want to
|
| 77 |
+
# exaggerate the manager's overhead, but measure the buffer overhead
|
| 78 |
+
# We do it once with an optimal setting, and with a worse manager which
|
| 79 |
+
# will produce small mappings only !
|
| 80 |
+
max_num_accesses = 100
|
| 81 |
+
fd = os.open(fc.path, os.O_RDONLY)
|
| 82 |
+
for item in (fc.path, fd):
|
| 83 |
+
for manager, man_id in ((man_optimal, 'optimal'),
|
| 84 |
+
(man_worst_case, 'worst case'),
|
| 85 |
+
(static_man, 'static optimal')):
|
| 86 |
+
buf = SlidingWindowMapBuffer(manager.make_cursor(item))
|
| 87 |
+
assert manager.num_file_handles() == 1
|
| 88 |
+
for access_mode in range(2): # single, multi
|
| 89 |
+
num_accesses_left = max_num_accesses
|
| 90 |
+
num_bytes = 0
|
| 91 |
+
fsize = fc.size
|
| 92 |
+
|
| 93 |
+
st = time()
|
| 94 |
+
buf.begin_access()
|
| 95 |
+
while num_accesses_left:
|
| 96 |
+
num_accesses_left -= 1
|
| 97 |
+
if access_mode: # multi
|
| 98 |
+
ofs_start = randint(0, fsize)
|
| 99 |
+
ofs_end = randint(ofs_start, fsize)
|
| 100 |
+
d = buf[ofs_start:ofs_end]
|
| 101 |
+
assert len(d) == ofs_end - ofs_start
|
| 102 |
+
assert d == data[ofs_start:ofs_end]
|
| 103 |
+
num_bytes += len(d)
|
| 104 |
+
del d
|
| 105 |
+
else:
|
| 106 |
+
pos = randint(0, fsize)
|
| 107 |
+
assert buf[pos] == data[pos]
|
| 108 |
+
num_bytes += 1
|
| 109 |
+
# END handle mode
|
| 110 |
+
# END handle num accesses
|
| 111 |
+
|
| 112 |
+
buf.end_access()
|
| 113 |
+
assert manager.num_file_handles()
|
| 114 |
+
assert manager.collect()
|
| 115 |
+
assert manager.num_file_handles() == 0
|
| 116 |
+
elapsed = max(time() - st, 0.001) # prevent zero division errors on windows
|
| 117 |
+
mb = float(1000 * 1000)
|
| 118 |
+
mode_str = (access_mode and "slice") or "single byte"
|
| 119 |
+
print("%s: Made %i random %s accesses to buffer created from %s reading a total of %f mb in %f s (%f mb/s)"
|
| 120 |
+
% (man_id, max_num_accesses, mode_str, type(item), num_bytes / mb, elapsed, (num_bytes / mb) / elapsed),
|
| 121 |
+
file=sys.stderr)
|
| 122 |
+
# END handle access mode
|
| 123 |
+
del buf
|
| 124 |
+
# END for each manager
|
| 125 |
+
# END for each input
|
| 126 |
+
os.close(fd)
|
vllm/lib/python3.10/site-packages/smmap/test/test_mman.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .lib import TestBase, FileCreator
|
| 2 |
+
|
| 3 |
+
from smmap.mman import (
|
| 4 |
+
WindowCursor,
|
| 5 |
+
SlidingWindowMapManager,
|
| 6 |
+
StaticWindowMapManager
|
| 7 |
+
)
|
| 8 |
+
from smmap.util import align_to_mmap
|
| 9 |
+
|
| 10 |
+
from random import randint
|
| 11 |
+
from time import time
|
| 12 |
+
import os
|
| 13 |
+
import sys
|
| 14 |
+
from copy import copy
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class TestMMan(TestBase):
|
| 18 |
+
|
| 19 |
+
def test_cursor(self):
|
| 20 |
+
with FileCreator(self.k_window_test_size, "cursor_test") as fc:
|
| 21 |
+
man = SlidingWindowMapManager()
|
| 22 |
+
ci = WindowCursor(man) # invalid cursor
|
| 23 |
+
assert not ci.is_valid()
|
| 24 |
+
assert not ci.is_associated()
|
| 25 |
+
assert ci.size() == 0 # this is cached, so we can query it in invalid state
|
| 26 |
+
|
| 27 |
+
cv = man.make_cursor(fc.path)
|
| 28 |
+
assert not cv.is_valid() # no region mapped yet
|
| 29 |
+
assert cv.is_associated() # but it know where to map it from
|
| 30 |
+
assert cv.file_size() == fc.size
|
| 31 |
+
assert cv.path() == fc.path
|
| 32 |
+
|
| 33 |
+
# copy module
|
| 34 |
+
cio = copy(cv)
|
| 35 |
+
assert not cio.is_valid() and cio.is_associated()
|
| 36 |
+
|
| 37 |
+
# assign method
|
| 38 |
+
assert not ci.is_associated()
|
| 39 |
+
ci.assign(cv)
|
| 40 |
+
assert not ci.is_valid() and ci.is_associated()
|
| 41 |
+
|
| 42 |
+
# unuse non-existing region is fine
|
| 43 |
+
cv.unuse_region()
|
| 44 |
+
cv.unuse_region()
|
| 45 |
+
|
| 46 |
+
# destruction is fine (even multiple times)
|
| 47 |
+
cv._destroy()
|
| 48 |
+
WindowCursor(man)._destroy()
|
| 49 |
+
|
| 50 |
+
def test_memory_manager(self):
|
| 51 |
+
slide_man = SlidingWindowMapManager()
|
| 52 |
+
static_man = StaticWindowMapManager()
|
| 53 |
+
|
| 54 |
+
for man in (static_man, slide_man):
|
| 55 |
+
assert man.num_file_handles() == 0
|
| 56 |
+
assert man.num_open_files() == 0
|
| 57 |
+
winsize_cmp_val = 0
|
| 58 |
+
if isinstance(man, StaticWindowMapManager):
|
| 59 |
+
winsize_cmp_val = -1
|
| 60 |
+
# END handle window size
|
| 61 |
+
assert man.window_size() > winsize_cmp_val
|
| 62 |
+
assert man.mapped_memory_size() == 0
|
| 63 |
+
assert man.max_mapped_memory_size() > 0
|
| 64 |
+
|
| 65 |
+
# collection doesn't raise in 'any' mode
|
| 66 |
+
man._collect_lru_region(0)
|
| 67 |
+
# doesn't raise if we are within the limit
|
| 68 |
+
man._collect_lru_region(10)
|
| 69 |
+
|
| 70 |
+
# doesn't fail if we over-allocate
|
| 71 |
+
assert man._collect_lru_region(sys.maxsize) == 0
|
| 72 |
+
|
| 73 |
+
# use a region, verify most basic functionality
|
| 74 |
+
with FileCreator(self.k_window_test_size, "manager_test") as fc:
|
| 75 |
+
fd = os.open(fc.path, os.O_RDONLY)
|
| 76 |
+
try:
|
| 77 |
+
for item in (fc.path, fd):
|
| 78 |
+
c = man.make_cursor(item)
|
| 79 |
+
assert c.path_or_fd() is item
|
| 80 |
+
assert c.use_region(10, 10).is_valid()
|
| 81 |
+
assert c.ofs_begin() == 10
|
| 82 |
+
assert c.size() == 10
|
| 83 |
+
with open(fc.path, 'rb') as fp:
|
| 84 |
+
assert c.buffer()[:] == fp.read(20)[10:]
|
| 85 |
+
|
| 86 |
+
if isinstance(item, int):
|
| 87 |
+
self.assertRaises(ValueError, c.path)
|
| 88 |
+
else:
|
| 89 |
+
self.assertRaises(ValueError, c.fd)
|
| 90 |
+
# END handle value error
|
| 91 |
+
# END for each input
|
| 92 |
+
finally:
|
| 93 |
+
os.close(fd)
|
| 94 |
+
# END for each manasger type
|
| 95 |
+
|
| 96 |
+
def test_memman_operation(self):
|
| 97 |
+
# test more access, force it to actually unmap regions
|
| 98 |
+
with FileCreator(self.k_window_test_size, "manager_operation_test") as fc:
|
| 99 |
+
with open(fc.path, 'rb') as fp:
|
| 100 |
+
data = fp.read()
|
| 101 |
+
fd = os.open(fc.path, os.O_RDONLY)
|
| 102 |
+
try:
|
| 103 |
+
max_num_handles = 15
|
| 104 |
+
# small_size =
|
| 105 |
+
for mtype, args in ((StaticWindowMapManager, (0, fc.size // 3, max_num_handles)),
|
| 106 |
+
(SlidingWindowMapManager, (fc.size // 100, fc.size // 3, max_num_handles)),):
|
| 107 |
+
for item in (fc.path, fd):
|
| 108 |
+
assert len(data) == fc.size
|
| 109 |
+
|
| 110 |
+
# small windows, a reasonable max memory. Not too many regions at once
|
| 111 |
+
man = mtype(window_size=args[0], max_memory_size=args[1], max_open_handles=args[2])
|
| 112 |
+
c = man.make_cursor(item)
|
| 113 |
+
|
| 114 |
+
# still empty (more about that is tested in test_memory_manager()
|
| 115 |
+
assert man.num_open_files() == 0
|
| 116 |
+
assert man.mapped_memory_size() == 0
|
| 117 |
+
|
| 118 |
+
base_offset = 5000
|
| 119 |
+
# window size is 0 for static managers, hence size will be 0. We take that into consideration
|
| 120 |
+
size = man.window_size() // 2
|
| 121 |
+
assert c.use_region(base_offset, size).is_valid()
|
| 122 |
+
rr = c.region()
|
| 123 |
+
assert rr.client_count() == 2 # the manager and the cursor and us
|
| 124 |
+
|
| 125 |
+
assert man.num_open_files() == 1
|
| 126 |
+
assert man.num_file_handles() == 1
|
| 127 |
+
assert man.mapped_memory_size() == rr.size()
|
| 128 |
+
|
| 129 |
+
# assert c.size() == size # the cursor may overallocate in its static version
|
| 130 |
+
assert c.ofs_begin() == base_offset
|
| 131 |
+
assert rr.ofs_begin() == 0 # it was aligned and expanded
|
| 132 |
+
if man.window_size():
|
| 133 |
+
# but isn't larger than the max window (aligned)
|
| 134 |
+
assert rr.size() == align_to_mmap(man.window_size(), True)
|
| 135 |
+
else:
|
| 136 |
+
assert rr.size() == fc.size
|
| 137 |
+
# END ignore static managers which dont use windows and are aligned to file boundaries
|
| 138 |
+
|
| 139 |
+
assert c.buffer()[:] == data[base_offset:base_offset + (size or c.size())]
|
| 140 |
+
|
| 141 |
+
# obtain second window, which spans the first part of the file - it is a still the same window
|
| 142 |
+
nsize = (size or fc.size) - 10
|
| 143 |
+
assert c.use_region(0, nsize).is_valid()
|
| 144 |
+
assert c.region() == rr
|
| 145 |
+
assert man.num_file_handles() == 1
|
| 146 |
+
assert c.size() == nsize
|
| 147 |
+
assert c.ofs_begin() == 0
|
| 148 |
+
assert c.buffer()[:] == data[:nsize]
|
| 149 |
+
|
| 150 |
+
# map some part at the end, our requested size cannot be kept
|
| 151 |
+
overshoot = 4000
|
| 152 |
+
base_offset = fc.size - (size or c.size()) + overshoot
|
| 153 |
+
assert c.use_region(base_offset, size).is_valid()
|
| 154 |
+
if man.window_size():
|
| 155 |
+
assert man.num_file_handles() == 2
|
| 156 |
+
assert c.size() < size
|
| 157 |
+
assert c.region() is not rr # old region is still available, but has not cursor ref anymore
|
| 158 |
+
assert rr.client_count() == 1 # only held by manager
|
| 159 |
+
else:
|
| 160 |
+
assert c.size() < fc.size
|
| 161 |
+
# END ignore static managers which only have one handle per file
|
| 162 |
+
rr = c.region()
|
| 163 |
+
assert rr.client_count() == 2 # manager + cursor
|
| 164 |
+
assert rr.ofs_begin() < c.ofs_begin() # it should have extended itself to the left
|
| 165 |
+
assert rr.ofs_end() <= fc.size # it cannot be larger than the file
|
| 166 |
+
assert c.buffer()[:] == data[base_offset:base_offset + (size or c.size())]
|
| 167 |
+
|
| 168 |
+
# unising a region makes the cursor invalid
|
| 169 |
+
c.unuse_region()
|
| 170 |
+
assert not c.is_valid()
|
| 171 |
+
if man.window_size():
|
| 172 |
+
# but doesn't change anything regarding the handle count - we cache it and only
|
| 173 |
+
# remove mapped regions if we have to
|
| 174 |
+
assert man.num_file_handles() == 2
|
| 175 |
+
# END ignore this for static managers
|
| 176 |
+
|
| 177 |
+
# iterate through the windows, verify data contents
|
| 178 |
+
# this will trigger map collection after a while
|
| 179 |
+
max_random_accesses = 5000
|
| 180 |
+
num_random_accesses = max_random_accesses
|
| 181 |
+
memory_read = 0
|
| 182 |
+
st = time()
|
| 183 |
+
|
| 184 |
+
# cache everything to get some more performance
|
| 185 |
+
includes_ofs = c.includes_ofs
|
| 186 |
+
max_mapped_memory_size = man.max_mapped_memory_size()
|
| 187 |
+
max_file_handles = man.max_file_handles()
|
| 188 |
+
mapped_memory_size = man.mapped_memory_size
|
| 189 |
+
num_file_handles = man.num_file_handles
|
| 190 |
+
while num_random_accesses:
|
| 191 |
+
num_random_accesses -= 1
|
| 192 |
+
base_offset = randint(0, fc.size - 1)
|
| 193 |
+
|
| 194 |
+
# precondition
|
| 195 |
+
if man.window_size():
|
| 196 |
+
assert max_mapped_memory_size >= mapped_memory_size()
|
| 197 |
+
# END statistics will overshoot, which is fine
|
| 198 |
+
assert max_file_handles >= num_file_handles()
|
| 199 |
+
assert c.use_region(base_offset, (size or c.size())).is_valid()
|
| 200 |
+
csize = c.size()
|
| 201 |
+
assert c.buffer()[:] == data[base_offset:base_offset + csize]
|
| 202 |
+
memory_read += csize
|
| 203 |
+
|
| 204 |
+
assert includes_ofs(base_offset)
|
| 205 |
+
assert includes_ofs(base_offset + csize - 1)
|
| 206 |
+
assert not includes_ofs(base_offset + csize)
|
| 207 |
+
# END while we should do an access
|
| 208 |
+
elapsed = max(time() - st, 0.001) # prevent zero division errors on windows
|
| 209 |
+
mb = float(1000 * 1000)
|
| 210 |
+
print("%s: Read %i mb of memory with %i random on cursor initialized with %s accesses in %fs (%f mb/s)\n"
|
| 211 |
+
% (mtype, memory_read / mb, max_random_accesses, type(item), elapsed, (memory_read / mb) / elapsed),
|
| 212 |
+
file=sys.stderr)
|
| 213 |
+
|
| 214 |
+
# an offset as large as the size doesn't work !
|
| 215 |
+
assert not c.use_region(fc.size, size).is_valid()
|
| 216 |
+
|
| 217 |
+
# collection - it should be able to collect all
|
| 218 |
+
assert man.num_file_handles()
|
| 219 |
+
assert man.collect()
|
| 220 |
+
assert man.num_file_handles() == 0
|
| 221 |
+
# END for each item
|
| 222 |
+
# END for each manager type
|
| 223 |
+
finally:
|
| 224 |
+
os.close(fd)
|
vllm/lib/python3.10/site-packages/smmap/test/test_util.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .lib import TestBase, FileCreator
|
| 2 |
+
|
| 3 |
+
from smmap.util import (
|
| 4 |
+
MapWindow,
|
| 5 |
+
MapRegion,
|
| 6 |
+
MapRegionList,
|
| 7 |
+
ALLOCATIONGRANULARITY,
|
| 8 |
+
is_64_bit,
|
| 9 |
+
align_to_mmap
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
import os
|
| 13 |
+
import sys
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class TestMMan(TestBase):
|
| 17 |
+
|
| 18 |
+
def test_window(self):
|
| 19 |
+
wl = MapWindow(0, 1) # left
|
| 20 |
+
wc = MapWindow(1, 1) # center
|
| 21 |
+
wc2 = MapWindow(10, 5) # another center
|
| 22 |
+
wr = MapWindow(8000, 50) # right
|
| 23 |
+
|
| 24 |
+
assert wl.ofs_end() == 1
|
| 25 |
+
assert wc.ofs_end() == 2
|
| 26 |
+
assert wr.ofs_end() == 8050
|
| 27 |
+
|
| 28 |
+
# extension does nothing if already in place
|
| 29 |
+
maxsize = 100
|
| 30 |
+
wc.extend_left_to(wl, maxsize)
|
| 31 |
+
assert wc.ofs == 1 and wc.size == 1
|
| 32 |
+
wl.extend_right_to(wc, maxsize)
|
| 33 |
+
wl.extend_right_to(wc, maxsize)
|
| 34 |
+
assert wl.ofs == 0 and wl.size == 1
|
| 35 |
+
|
| 36 |
+
# an actual left extension
|
| 37 |
+
pofs_end = wc2.ofs_end()
|
| 38 |
+
wc2.extend_left_to(wc, maxsize)
|
| 39 |
+
assert wc2.ofs == wc.ofs_end() and pofs_end == wc2.ofs_end()
|
| 40 |
+
|
| 41 |
+
# respects maxsize
|
| 42 |
+
wc.extend_right_to(wr, maxsize)
|
| 43 |
+
assert wc.ofs == 1 and wc.size == maxsize
|
| 44 |
+
wc.extend_right_to(wr, maxsize)
|
| 45 |
+
assert wc.ofs == 1 and wc.size == maxsize
|
| 46 |
+
|
| 47 |
+
# without maxsize
|
| 48 |
+
wc.extend_right_to(wr, sys.maxsize)
|
| 49 |
+
assert wc.ofs_end() == wr.ofs and wc.ofs == 1
|
| 50 |
+
|
| 51 |
+
# extend left
|
| 52 |
+
wr.extend_left_to(wc2, maxsize)
|
| 53 |
+
wr.extend_left_to(wc2, maxsize)
|
| 54 |
+
assert wr.size == maxsize
|
| 55 |
+
|
| 56 |
+
wr.extend_left_to(wc2, sys.maxsize)
|
| 57 |
+
assert wr.ofs == wc2.ofs_end()
|
| 58 |
+
|
| 59 |
+
wc.align()
|
| 60 |
+
assert wc.ofs == 0 and wc.size == align_to_mmap(wc.size, True)
|
| 61 |
+
|
| 62 |
+
def test_region(self):
|
| 63 |
+
with FileCreator(self.k_window_test_size, "window_test") as fc:
|
| 64 |
+
half_size = fc.size // 2
|
| 65 |
+
rofs = align_to_mmap(4200, False)
|
| 66 |
+
rfull = MapRegion(fc.path, 0, fc.size)
|
| 67 |
+
rhalfofs = MapRegion(fc.path, rofs, fc.size)
|
| 68 |
+
rhalfsize = MapRegion(fc.path, 0, half_size)
|
| 69 |
+
|
| 70 |
+
# offsets
|
| 71 |
+
assert rfull.ofs_begin() == 0 and rfull.size() == fc.size
|
| 72 |
+
assert rfull.ofs_end() == fc.size # if this method works, it works always
|
| 73 |
+
|
| 74 |
+
assert rhalfofs.ofs_begin() == rofs and rhalfofs.size() == fc.size - rofs
|
| 75 |
+
assert rhalfsize.ofs_begin() == 0 and rhalfsize.size() == half_size
|
| 76 |
+
|
| 77 |
+
assert rfull.includes_ofs(0) and rfull.includes_ofs(fc.size - 1) and rfull.includes_ofs(half_size)
|
| 78 |
+
assert not rfull.includes_ofs(-1) and not rfull.includes_ofs(sys.maxsize)
|
| 79 |
+
|
| 80 |
+
# auto-refcount
|
| 81 |
+
assert rfull.client_count() == 1
|
| 82 |
+
rfull2 = rfull
|
| 83 |
+
assert rfull.client_count() == 1, "no auto-counting"
|
| 84 |
+
|
| 85 |
+
# window constructor
|
| 86 |
+
w = MapWindow.from_region(rfull)
|
| 87 |
+
assert w.ofs == rfull.ofs_begin() and w.ofs_end() == rfull.ofs_end()
|
| 88 |
+
|
| 89 |
+
def test_region_list(self):
|
| 90 |
+
with FileCreator(100, "sample_file") as fc:
|
| 91 |
+
fd = os.open(fc.path, os.O_RDONLY)
|
| 92 |
+
try:
|
| 93 |
+
for item in (fc.path, fd):
|
| 94 |
+
ml = MapRegionList(item)
|
| 95 |
+
|
| 96 |
+
assert len(ml) == 0
|
| 97 |
+
assert ml.path_or_fd() == item
|
| 98 |
+
assert ml.file_size() == fc.size
|
| 99 |
+
finally:
|
| 100 |
+
os.close(fd)
|
| 101 |
+
|
| 102 |
+
def test_util(self):
|
| 103 |
+
assert isinstance(is_64_bit(), bool) # just call it
|
| 104 |
+
assert align_to_mmap(1, False) == 0
|
| 105 |
+
assert align_to_mmap(1, True) == ALLOCATIONGRANULARITY
|
vllm/lib/python3.10/site-packages/smmap/util.py
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Module containing a memory memory manager which provides a sliding window on a number of memory mapped files"""
|
| 2 |
+
import os
|
| 3 |
+
import sys
|
| 4 |
+
|
| 5 |
+
from mmap import mmap, ACCESS_READ
|
| 6 |
+
from mmap import ALLOCATIONGRANULARITY
|
| 7 |
+
|
| 8 |
+
__all__ = ["align_to_mmap", "is_64_bit",
|
| 9 |
+
"MapWindow", "MapRegion", "MapRegionList", "ALLOCATIONGRANULARITY"]
|
| 10 |
+
|
| 11 |
+
#{ Utilities
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def align_to_mmap(num, round_up):
|
| 15 |
+
"""
|
| 16 |
+
Align the given integer number to the closest page offset, which usually is 4096 bytes.
|
| 17 |
+
|
| 18 |
+
:param round_up: if True, the next higher multiple of page size is used, otherwise
|
| 19 |
+
the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0)
|
| 20 |
+
:return: num rounded to closest page"""
|
| 21 |
+
res = (num // ALLOCATIONGRANULARITY) * ALLOCATIONGRANULARITY
|
| 22 |
+
if round_up and (res != num):
|
| 23 |
+
res += ALLOCATIONGRANULARITY
|
| 24 |
+
# END handle size
|
| 25 |
+
return res
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def is_64_bit():
|
| 29 |
+
""":return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bit"""
|
| 30 |
+
return sys.maxsize > (1 << 32) - 1
|
| 31 |
+
|
| 32 |
+
#}END utilities
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
#{ Utility Classes
|
| 36 |
+
|
| 37 |
+
class MapWindow:
|
| 38 |
+
|
| 39 |
+
"""Utility type which is used to snap windows towards each other, and to adjust their size"""
|
| 40 |
+
__slots__ = (
|
| 41 |
+
'ofs', # offset into the file in bytes
|
| 42 |
+
'size' # size of the window in bytes
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
def __init__(self, offset, size):
|
| 46 |
+
self.ofs = offset
|
| 47 |
+
self.size = size
|
| 48 |
+
|
| 49 |
+
def __repr__(self):
|
| 50 |
+
return "MapWindow(%i, %i)" % (self.ofs, self.size)
|
| 51 |
+
|
| 52 |
+
@classmethod
|
| 53 |
+
def from_region(cls, region):
|
| 54 |
+
""":return: new window from a region"""
|
| 55 |
+
return cls(region._b, region.size())
|
| 56 |
+
|
| 57 |
+
def ofs_end(self):
|
| 58 |
+
return self.ofs + self.size
|
| 59 |
+
|
| 60 |
+
def align(self):
|
| 61 |
+
"""Assures the previous window area is contained in the new one"""
|
| 62 |
+
nofs = align_to_mmap(self.ofs, 0)
|
| 63 |
+
self.size += self.ofs - nofs # keep size constant
|
| 64 |
+
self.ofs = nofs
|
| 65 |
+
self.size = align_to_mmap(self.size, 1)
|
| 66 |
+
|
| 67 |
+
def extend_left_to(self, window, max_size):
|
| 68 |
+
"""Adjust the offset to start where the given window on our left ends if possible,
|
| 69 |
+
but don't make yourself larger than max_size.
|
| 70 |
+
The resize will assure that the new window still contains the old window area"""
|
| 71 |
+
rofs = self.ofs - window.ofs_end()
|
| 72 |
+
nsize = rofs + self.size
|
| 73 |
+
rofs -= nsize - min(nsize, max_size)
|
| 74 |
+
self.ofs -= rofs
|
| 75 |
+
self.size += rofs
|
| 76 |
+
|
| 77 |
+
def extend_right_to(self, window, max_size):
|
| 78 |
+
"""Adjust the size to make our window end where the right window begins, but don't
|
| 79 |
+
get larger than max_size"""
|
| 80 |
+
self.size = min(self.size + (window.ofs - self.ofs_end()), max_size)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class MapRegion:
|
| 84 |
+
|
| 85 |
+
"""Defines a mapped region of memory, aligned to pagesizes
|
| 86 |
+
|
| 87 |
+
**Note:** deallocates used region automatically on destruction"""
|
| 88 |
+
__slots__ = [
|
| 89 |
+
'_b', # beginning of mapping
|
| 90 |
+
'_mf', # mapped memory chunk (as returned by mmap)
|
| 91 |
+
'_uc', # total amount of usages
|
| 92 |
+
'_size', # cached size of our memory map
|
| 93 |
+
'__weakref__'
|
| 94 |
+
]
|
| 95 |
+
|
| 96 |
+
#{ Configuration
|
| 97 |
+
#} END configuration
|
| 98 |
+
|
| 99 |
+
def __init__(self, path_or_fd, ofs, size, flags=0):
|
| 100 |
+
"""Initialize a region, allocate the memory map
|
| 101 |
+
:param path_or_fd: path to the file to map, or the opened file descriptor
|
| 102 |
+
:param ofs: **aligned** offset into the file to be mapped
|
| 103 |
+
:param size: if size is larger then the file on disk, the whole file will be
|
| 104 |
+
allocated the the size automatically adjusted
|
| 105 |
+
:param flags: additional flags to be given when opening the file.
|
| 106 |
+
:raise Exception: if no memory can be allocated"""
|
| 107 |
+
self._b = ofs
|
| 108 |
+
self._size = 0
|
| 109 |
+
self._uc = 0
|
| 110 |
+
|
| 111 |
+
if isinstance(path_or_fd, int):
|
| 112 |
+
fd = path_or_fd
|
| 113 |
+
else:
|
| 114 |
+
fd = os.open(path_or_fd, os.O_RDONLY | getattr(os, 'O_BINARY', 0) | flags)
|
| 115 |
+
# END handle fd
|
| 116 |
+
|
| 117 |
+
try:
|
| 118 |
+
kwargs = dict(access=ACCESS_READ, offset=ofs)
|
| 119 |
+
corrected_size = size
|
| 120 |
+
sizeofs = ofs
|
| 121 |
+
|
| 122 |
+
# have to correct size, otherwise (instead of the c version) it will
|
| 123 |
+
# bark that the size is too large ... many extra file accesses because
|
| 124 |
+
# if this ... argh !
|
| 125 |
+
actual_size = min(os.fstat(fd).st_size - sizeofs, corrected_size)
|
| 126 |
+
self._mf = mmap(fd, actual_size, **kwargs)
|
| 127 |
+
# END handle memory mode
|
| 128 |
+
|
| 129 |
+
self._size = len(self._mf)
|
| 130 |
+
finally:
|
| 131 |
+
if isinstance(path_or_fd, str):
|
| 132 |
+
os.close(fd)
|
| 133 |
+
# END only close it if we opened it
|
| 134 |
+
# END close file handle
|
| 135 |
+
# We assume the first one to use us keeps us around
|
| 136 |
+
self.increment_client_count()
|
| 137 |
+
|
| 138 |
+
def __repr__(self):
|
| 139 |
+
return "MapRegion<%i, %i>" % (self._b, self.size())
|
| 140 |
+
|
| 141 |
+
#{ Interface
|
| 142 |
+
|
| 143 |
+
def buffer(self):
|
| 144 |
+
""":return: a buffer containing the memory"""
|
| 145 |
+
return self._mf
|
| 146 |
+
|
| 147 |
+
def map(self):
|
| 148 |
+
""":return: a memory map containing the memory"""
|
| 149 |
+
return self._mf
|
| 150 |
+
|
| 151 |
+
def ofs_begin(self):
|
| 152 |
+
""":return: absolute byte offset to the first byte of the mapping"""
|
| 153 |
+
return self._b
|
| 154 |
+
|
| 155 |
+
def size(self):
|
| 156 |
+
""":return: total size of the mapped region in bytes"""
|
| 157 |
+
return self._size
|
| 158 |
+
|
| 159 |
+
def ofs_end(self):
|
| 160 |
+
""":return: Absolute offset to one byte beyond the mapping into the file"""
|
| 161 |
+
return self._b + self._size
|
| 162 |
+
|
| 163 |
+
def includes_ofs(self, ofs):
|
| 164 |
+
""":return: True if the given offset can be read in our mapped region"""
|
| 165 |
+
return self._b <= ofs < self._b + self._size
|
| 166 |
+
|
| 167 |
+
def client_count(self):
|
| 168 |
+
""":return: number of clients currently using this region"""
|
| 169 |
+
return self._uc
|
| 170 |
+
|
| 171 |
+
def increment_client_count(self, ofs = 1):
|
| 172 |
+
"""Adjust the usage count by the given positive or negative offset.
|
| 173 |
+
If usage count equals 0, we will auto-release our resources
|
| 174 |
+
:return: True if we released resources, False otherwise. In the latter case, we can still be used"""
|
| 175 |
+
self._uc += ofs
|
| 176 |
+
assert self._uc > -1, "Increments must match decrements, usage counter negative: %i" % self._uc
|
| 177 |
+
|
| 178 |
+
if self.client_count() == 0:
|
| 179 |
+
self.release()
|
| 180 |
+
return True
|
| 181 |
+
else:
|
| 182 |
+
return False
|
| 183 |
+
# end handle release
|
| 184 |
+
|
| 185 |
+
def release(self):
|
| 186 |
+
"""Release all resources this instance might hold. Must only be called if there usage_count() is zero"""
|
| 187 |
+
self._mf.close()
|
| 188 |
+
|
| 189 |
+
#} END interface
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class MapRegionList(list):
|
| 193 |
+
|
| 194 |
+
"""List of MapRegion instances associating a path with a list of regions."""
|
| 195 |
+
__slots__ = (
|
| 196 |
+
'_path_or_fd', # path or file descriptor which is mapped by all our regions
|
| 197 |
+
'_file_size' # total size of the file we map
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
def __new__(cls, path):
|
| 201 |
+
return super().__new__(cls)
|
| 202 |
+
|
| 203 |
+
def __init__(self, path_or_fd):
|
| 204 |
+
self._path_or_fd = path_or_fd
|
| 205 |
+
self._file_size = None
|
| 206 |
+
|
| 207 |
+
def path_or_fd(self):
|
| 208 |
+
""":return: path or file descriptor we are attached to"""
|
| 209 |
+
return self._path_or_fd
|
| 210 |
+
|
| 211 |
+
def file_size(self):
|
| 212 |
+
""":return: size of file we manager"""
|
| 213 |
+
if self._file_size is None:
|
| 214 |
+
if isinstance(self._path_or_fd, str):
|
| 215 |
+
self._file_size = os.stat(self._path_or_fd).st_size
|
| 216 |
+
else:
|
| 217 |
+
self._file_size = os.fstat(self._path_or_fd).st_size
|
| 218 |
+
# END handle path type
|
| 219 |
+
# END update file size
|
| 220 |
+
return self._file_size
|
| 221 |
+
|
| 222 |
+
#} END utility classes
|
vllm/lib/python3.10/site-packages/zmq/__init__.pxd
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from zmq.backend.cython cimport Context, Frame, Socket, libzmq
|
vllm/lib/python3.10/site-packages/zmq/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Python bindings for 0MQ"""
|
| 2 |
+
|
| 3 |
+
# Copyright (C) PyZMQ Developers
|
| 4 |
+
# Distributed under the terms of the Modified BSD License.
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
import sys
|
| 10 |
+
from contextlib import contextmanager
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@contextmanager
|
| 14 |
+
def _libs_on_path():
|
| 15 |
+
"""context manager for libs directory on $PATH
|
| 16 |
+
|
| 17 |
+
Works around mysterious issue where os.add_dll_directory
|
| 18 |
+
does not resolve imports (conda-forge Python >= 3.8)
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
if not sys.platform.startswith("win"):
|
| 22 |
+
yield
|
| 23 |
+
return
|
| 24 |
+
|
| 25 |
+
libs_dir = os.path.abspath(
|
| 26 |
+
os.path.join(
|
| 27 |
+
os.path.dirname(__file__),
|
| 28 |
+
os.pardir,
|
| 29 |
+
"pyzmq.libs",
|
| 30 |
+
)
|
| 31 |
+
)
|
| 32 |
+
if not os.path.exists(libs_dir):
|
| 33 |
+
# no bundled libs
|
| 34 |
+
yield
|
| 35 |
+
return
|
| 36 |
+
|
| 37 |
+
path_before = os.environ.get("PATH")
|
| 38 |
+
try:
|
| 39 |
+
os.environ["PATH"] = os.pathsep.join([path_before or "", libs_dir])
|
| 40 |
+
yield
|
| 41 |
+
finally:
|
| 42 |
+
if path_before is None:
|
| 43 |
+
os.environ.pop("PATH")
|
| 44 |
+
else:
|
| 45 |
+
os.environ["PATH"] = path_before
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
# zmq top-level imports
|
| 49 |
+
|
| 50 |
+
# workaround for Windows
|
| 51 |
+
with _libs_on_path():
|
| 52 |
+
from zmq import backend
|
| 53 |
+
|
| 54 |
+
from . import constants # noqa
|
| 55 |
+
from .constants import * # noqa
|
| 56 |
+
from zmq.backend import * # noqa
|
| 57 |
+
from zmq import sugar
|
| 58 |
+
from zmq.sugar import * # noqa
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def get_includes():
|
| 62 |
+
"""Return a list of directories to include for linking against pyzmq with cython."""
|
| 63 |
+
from os.path import abspath, dirname, exists, join, pardir
|
| 64 |
+
|
| 65 |
+
base = dirname(__file__)
|
| 66 |
+
parent = abspath(join(base, pardir))
|
| 67 |
+
includes = [parent] + [join(parent, base, subdir) for subdir in ('utils',)]
|
| 68 |
+
if exists(join(parent, base, 'include')):
|
| 69 |
+
includes.append(join(parent, base, 'include'))
|
| 70 |
+
return includes
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def get_library_dirs():
|
| 74 |
+
"""Return a list of directories used to link against pyzmq's bundled libzmq."""
|
| 75 |
+
from os.path import abspath, dirname, join, pardir
|
| 76 |
+
|
| 77 |
+
base = dirname(__file__)
|
| 78 |
+
parent = abspath(join(base, pardir))
|
| 79 |
+
return [join(parent, base)]
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
COPY_THRESHOLD = 65536
|
| 83 |
+
DRAFT_API = backend.has("draft")
|
| 84 |
+
|
| 85 |
+
__all__ = (
|
| 86 |
+
[
|
| 87 |
+
'get_includes',
|
| 88 |
+
'COPY_THRESHOLD',
|
| 89 |
+
'DRAFT_API',
|
| 90 |
+
]
|
| 91 |
+
+ constants.__all__
|
| 92 |
+
+ sugar.__all__
|
| 93 |
+
+ backend.__all__
|
| 94 |
+
)
|
vllm/lib/python3.10/site-packages/zmq/__init__.pyi
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List
|
| 2 |
+
|
| 3 |
+
from . import backend, sugar
|
| 4 |
+
|
| 5 |
+
COPY_THRESHOLD: int
|
| 6 |
+
DRAFT_API: bool
|
| 7 |
+
__version__: str
|
| 8 |
+
|
| 9 |
+
# mypy doesn't like overwriting symbols with * so be explicit
|
| 10 |
+
# about what comes from backend, not from sugar
|
| 11 |
+
# see tools/backend_imports.py to generate this list
|
| 12 |
+
# note: `x as x` is required for re-export
|
| 13 |
+
# see https://github.com/python/mypy/issues/2190
|
| 14 |
+
from .backend import IPC_PATH_MAX_LEN as IPC_PATH_MAX_LEN
|
| 15 |
+
from .backend import curve_keypair as curve_keypair
|
| 16 |
+
from .backend import curve_public as curve_public
|
| 17 |
+
from .backend import device as device
|
| 18 |
+
from .backend import has as has
|
| 19 |
+
from .backend import proxy as proxy
|
| 20 |
+
from .backend import proxy_steerable as proxy_steerable
|
| 21 |
+
from .backend import strerror as strerror
|
| 22 |
+
from .backend import zmq_errno as zmq_errno
|
| 23 |
+
from .backend import zmq_poll as zmq_poll
|
| 24 |
+
from .constants import *
|
| 25 |
+
from .error import *
|
| 26 |
+
from .sugar import *
|
| 27 |
+
|
| 28 |
+
def get_includes() -> list[str]: ...
|
| 29 |
+
def get_library_dirs() -> list[str]: ...
|