/usr/share/blt2.5/demos/dragdrop1.tcl is in blt-demo 2.5.3+dfsg-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #!/usr/bin/wish8.6
if {[lindex $argv end] != "spawn"} {
exec [info nameofexecutable] [info script] spawn &
}
package require BLT
# --------------------------------------------------------------------------
# Starting with Tcl 8.x, the BLT commands are stored in their own
# namespace called "blt". The idea is to prevent name clashes with
# Tcl commands and variables from other packages, such as a "table"
# command in two different packages.
#
# You can access the BLT commands in a couple of ways. You can prefix
# all the BLT commands with the namespace qualifier "blt::"
#
# blt::graph .g
# blt::table . .g -resize both
#
# or you can import all the command into the global namespace.
#
# namespace import blt::*
# graph .g
# table . .g -resize both
#
# --------------------------------------------------------------------------
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
source scripts/demo.tcl
if { ([info exists tcl_platform]) && ($tcl_platform(platform) == "windows") } {
source scripts/send.tcl
SendInit
SendVerify
}
# ----------------------------------------------------------------------
# This procedure is invoked each time a token is grabbed from the
# sample window. It configures the token to display the current
# color, and returns the color value that is later passed to the
# target handler.
# ----------------------------------------------------------------------
proc package_color {token} {
set bg [.sample cget -background]
set fg [.sample cget -foreground]
$token.label configure -background $bg -foreground $fg
return $bg
}
# ----------------------------------------------------------------------
# Main application window...
# ----------------------------------------------------------------------
label .sample -text "Color" -height 2 -bd 10 -relief sunken
#
# Set up the color sample as a drag&drop source for "color" values:
#
drag&drop source .sample \
-packagecmd {package_color %t} \
-sitecmd { puts "%s %t" }
drag&drop source .sample handler color
#
# Set up the color sample as a drag&drop target for "color" values:
#
drag&drop target .sample handler color {set_color %v}
#
# Establish the appearance of the token window:
#
set token [drag&drop token .sample]
label $token.label -text "Color"
pack $token.label
scale .redScale -label "Red" -orient horizontal \
-from 0 -to 255 -command adjust_color
frame .redSample -width 20 -height 20 -borderwidth 3 -relief sunken
scale .greenScale -label "Green" -orient horizontal \
-from 0 -to 255 -command adjust_color
frame .greenSample -width 20 -height 20 -borderwidth 3 -relief sunken
scale .blueScale -label "Blue" -orient horizontal \
-from 0 -to 255 -command adjust_color
frame .blueSample -width 20 -height 20 -borderwidth 3 -relief sunken
# ----------------------------------------------------------------------
# This procedure loads a new color value into this editor.
# ----------------------------------------------------------------------
proc set_color {cval} {
set rgb [winfo rgb . $cval]
set rval [expr round([lindex $rgb 0]/65535.0*255)]
.redScale set $rval
set gval [expr round([lindex $rgb 1]/65535.0*255)]
.greenScale set $gval
set bval [expr round([lindex $rgb 2]/65535.0*255)]
.blueScale set $bval
}
# ----------------------------------------------------------------------
# This procedure is invoked whenever an RGB slider changes to
# update the color samples in this display.
# ----------------------------------------------------------------------
proc adjust_color {args} {
set rval [.redScale get]
.redSample configure -background [format "#%.2x0000" $rval]
set gval [.greenScale get]
.greenSample configure -background [format "#00%.2x00" $gval]
set bval [.blueScale get]
.blueSample configure -background [format "#0000%.2x" $bval]
.sample configure -background \
[format "#%.2x%.2x%.2x" $rval $gval $bval]
if {$rval+$gval+$bval < 1.5*255} {
.sample configure -foreground white
} else {
.sample configure -foreground black
}
}
table . .sample 0,0 -columnspan 2 -fill both -pady {0 4}
table . .redScale 1,0 -fill both
table . .redSample 1,1 -fill both
table . .greenScale 2,0 -fill both
table . .greenSample 2,1 -fill both
table . .blueScale 3,0 -fill both
table . .blueSample 3,1 -fill both
|