📄 dropsite.tcl
字号:
# ------------------------------------------------------------------------------# dropsite.tcl# This file is part of Unifix BWidget Toolkit# $Id: dropsite.tcl,v 1.7 1999/07/09 08:10:30 eric Exp $# ------------------------------------------------------------------------------# Index of commands:# - DropSite::include# - DropSite::setdrop# - DropSite::register# - DropSite::setcursor# - DropSite::setoperation# - DropSite::_update_operation# - DropSite::_compute_operation# - DropSite::_draw_operation# - DropSite::_init_drag# - DropSite::_motion# - DropSite::_release# ------------------------------------------------------------------------------namespace eval DropSite { Widget::declare DropSite { {-dropovercmd String "" 0} {-dropcmd String "" 0} {-droptypes String "" 0} } proc use { } {} variable _top ".drag" variable _opw ".drag.\#op" variable _target "" variable _status 0 variable _tabops variable _defops variable _source variable _type variable _data variable _evt # key win unix # shift 1 | 1 -> 1 # control 4 | 4 -> 4 # alt 8 | 16 -> 24 # meta | 64 -> 88 array set _tabops { mod,none 0 mod,shift 1 mod,control 4 mod,alt 24 ops,copy 1 ops,move 1 ops,link 1 } if { $tcl_platform(platform) == "unix" } { set _tabops(mod,alt) 8 } else { set _tabops(mod,alt) 16 } array set _defops \ [list \ copy,mod shift \ move,mod control \ link,mod alt \ copy,img @[file join $env(BWIDGET_LIBRARY) "images" "opcopy.xbm"] \ move,img @[file join $env(BWIDGET_LIBRARY) "images" "opmove.xbm"] \ link,img @[file join $env(BWIDGET_LIBRARY) "images" "oplink.xbm"]] bind DragTop <KeyPress-Shift_L> {DropSite::_update_operation [expr %s | 1]} bind DragTop <KeyPress-Shift_R> {DropSite::_update_operation [expr %s | 1]} bind DragTop <KeyPress-Control_L> {DropSite::_update_operation [expr %s | 4]} bind DragTop <KeyPress-Control_R> {DropSite::_update_operation [expr %s | 4]} if { $tcl_platform(platform) == "unix" } { bind DragTop <KeyPress-Alt_L> {DropSite::_update_operation [expr %s | 8]} bind DragTop <KeyPress-Alt_R> {DropSite::_update_operation [expr %s | 8]} } else { bind DragTop <KeyPress-Alt_L> {DropSite::_update_operation [expr %s | 16]} bind DragTop <KeyPress-Alt_R> {DropSite::_update_operation [expr %s | 16]} } bind DragTop <KeyRelease-Shift_L> {DropSite::_update_operation [expr %s & ~1]} bind DragTop <KeyRelease-Shift_R> {DropSite::_update_operation [expr %s & ~1]} bind DragTop <KeyRelease-Control_L> {DropSite::_update_operation [expr %s & ~4]} bind DragTop <KeyRelease-Control_R> {DropSite::_update_operation [expr %s & ~4]} if { $tcl_platform(platform) == "unix" } { bind DragTop <KeyRelease-Alt_L> {DropSite::_update_operation [expr %s & ~8]} bind DragTop <KeyRelease-Alt_R> {DropSite::_update_operation [expr %s & ~8]} } else { bind DragTop <KeyRelease-Alt_L> {DropSite::_update_operation [expr %s & ~16]} bind DragTop <KeyRelease-Alt_R> {DropSite::_update_operation [expr %s & ~16]} }}# ------------------------------------------------------------------------------# Command DropSite::include# ------------------------------------------------------------------------------proc DropSite::include { class types } { set dropoptions { {-dropenabled Boolean 0 0} {-dropovercmd String "" 0} {-dropcmd String "" 0} } lappend dropoptions [list -droptypes String $types 0] Widget::declare $class $dropoptions}# ------------------------------------------------------------------------------# Command DropSite::setdrop# Widget interface to register# ------------------------------------------------------------------------------proc DropSite::setdrop { path subpath dropover drop {force 0}} { set cen [Widget::hasChanged $path -dropenabled en] set ctypes [Widget::hasChanged $path -droptypes types] if { $en } { if { $force || $cen || $ctypes } { register $subpath \ -droptypes $types \ -dropcmd $drop \ -dropovercmd $dropover } } else { register $subpath }}# ------------------------------------------------------------------------------# Command DropSite::register# ------------------------------------------------------------------------------proc DropSite::register { path args } { variable _tabops variable _defops upvar \#0 DropSite::$path drop Widget::init DropSite .drop$path $args if { [info exists drop] } { unset drop } set dropcmd [Widget::getoption .drop$path -dropcmd] set types [Widget::getoption .drop$path -droptypes] set overcmd [Widget::getoption .drop$path -dropovercmd] Widget::destroy .drop$path if { $dropcmd != "" && $types != "" } { set drop(dropcmd) $dropcmd set drop(overcmd) $overcmd foreach {type ops} $types { set drop($type,ops) {} foreach {descop lmod} $ops { if { ![llength $descop] || [llength $descop] > 3 } { return -code error "invalid operation description \"$descop\"" } foreach {subop baseop imgop} $descop { set subop [string trim $subop] if { ![string length $subop] } { return -code error "sub operation is empty" } if { ![string length $baseop] } { set baseop $subop } if { [info exists drop($type,ops,$subop)] } { return -code error "operation \"$subop\" already defined" } if { ![info exists _tabops(ops,$baseop)] } { return -code error "invalid base operation \"$baseop\"" } if { [string compare $subop $baseop] && [info exists _tabops(ops,$subop)] } { return -code error "sub operation \"$subop\" is a base operation" } if { ![string length $imgop] } { set imgop $_defops($baseop,img) } } if { ![string compare $lmod "program"] } { set drop($type,ops,$subop) $baseop set drop($type,img,$subop) $imgop } else { if { ![string length $lmod] } { set lmod $_defops($baseop,mod) } set mask 0 foreach mod $lmod { if { ![info exists _tabops(mod,$mod)] } { return -code error "invalid modifier \"$mod\"" } set mask [expr {$mask | $_tabops(mod,$mod)}] } if { ($mask == 0) != ([string compare $subop "default"] == 0) } { return -code error "sub operation default can only be used with modifier \"none\"" } set drop($type,mod,$mask) $subop set drop($type,ops,$subop) $baseop set drop($type,img,$subop) $imgop lappend masklist $mask } } if { ![info exists drop($type,mod,0)] } { set drop($type,mod,0) default set drop($type,ops,default) copy set drop($type,img,default) $_defops(copy,img) lappend masklist 0 } set drop($type,ops,force) copy set drop($type,img,force) $_defops(copy,img) foreach mask [lsort -integer -decreasing $masklist] { lappend drop($type,ops) $mask $drop($type,mod,$mask) } } }}# ------------------------------------------------------------------------------# Command DropSite::setcursor# ------------------------------------------------------------------------------proc DropSite::setcursor { cursor } { catch {.drag configure -cursor $cursor}}# ------------------------------------------------------------------------------# Command DropSite::setoperation# ------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -