⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dropsite.tcl

📁 Linux下的MSN聊天程序源码
💻 TCL
📖 第 1 页 / 共 2 页
字号:
# ------------------------------------------------------------------------------#  dropsite.tcl#  This file is part of Unifix BWidget Toolkit#  $Id: dropsite.tcl 3417 2004-12-03 00:31:24Z tjikkun $# ------------------------------------------------------------------------------#  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::define DropSite dropsite -classonly    Widget::declare DropSite [list \	    [list -dropovercmd String "" 0] \	    [list -dropcmd     String "" 0] \	    [list -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 $::BWIDGET::LIBRARY "images" "opcopy.xbm"] \             move,img  @[file join $::BWIDGET::LIBRARY "images" "opmove.xbm"] \             link,img  @[file join $::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 [list \	    [list	-dropenabled	Boolean	0	0] \	    [list	-dropovercmd	String	""	0] \	    [list	-dropcmd	String	""	0] \	    [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::getMegawidgetOption .drop$path -dropcmd]    set types   [Widget::getMegawidgetOption .drop$path -droptypes]    set overcmd [Widget::getMegawidgetOption .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 equal $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 equal $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 equal $subop "default"]) } {                        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 + -