diff options
Diffstat (limited to 'library')
-rw-r--r-- | library/tkdnd.tcl | 11 | ||||
-rw-r--r-- | library/tkdnd_macosx.tcl | 87 | ||||
-rw-r--r-- | library/tkdnd_unix.tcl | 41 | ||||
-rw-r--r-- | library/tkdnd_windows.tcl | 11 |
4 files changed, 103 insertions, 47 deletions
diff --git a/library/tkdnd.tcl b/library/tkdnd.tcl index 0fbf3db..d15f622 100644 --- a/library/tkdnd.tcl +++ b/library/tkdnd.tcl @@ -157,6 +157,7 @@ namespace eval tkdnd { } load $dir/$PKG_LIB_FILE $PACKAGE_NAME source $dir/tkdnd_compat.tcl + ${_platform_namespace}::initialise };# initialise proc GetDropFileTempDirectory { } { @@ -325,7 +326,7 @@ proc tkdnd::_init_drag { button source state rootX rootY } { set action [_DoDragDrop $source $actions $types $data $button] } aqua { - set action [macdnd::dodragdrop $source $actions $types $data] + set action [macdnd::dodragdrop $source $actions $types $data $button] } default { error "unknown Tk windowing system" @@ -381,7 +382,7 @@ proc tkdnd::_end_drag { button source target action type data result # ---------------------------------------------------------------------------- proc tkdnd::platform_specific_types { types } { variable _platform_namespace - return [${_platform_namespace}::_platform_specific_types $types] + ${_platform_namespace}::_platform_specific_types $types }; # tkdnd::platform_specific_types # ---------------------------------------------------------------------------- @@ -389,7 +390,7 @@ proc tkdnd::platform_specific_types { types } { # ---------------------------------------------------------------------------- proc tkdnd::platform_independent_types { types } { variable _platform_namespace - return [${_platform_namespace}::_platform_independent_types $types] + ${_platform_namespace}::_platform_independent_types $types }; # tkdnd::platform_independent_types # ---------------------------------------------------------------------------- @@ -397,7 +398,7 @@ proc tkdnd::platform_independent_types { types } { # ---------------------------------------------------------------------------- proc tkdnd::platform_specific_type { type } { variable _platform_namespace - return [${_platform_namespace}::_platform_specific_type $type] + ${_platform_namespace}::_platform_specific_type $type }; # tkdnd::platform_specific_type # ---------------------------------------------------------------------------- @@ -405,7 +406,7 @@ proc tkdnd::platform_specific_type { type } { # ---------------------------------------------------------------------------- proc tkdnd::platform_independent_type { type } { variable _platform_namespace - return [${_platform_namespace}::_platform_independent_type $type] + ${_platform_namespace}::_platform_independent_type $type }; # tkdnd::platform_independent_type # ---------------------------------------------------------------------------- diff --git a/library/tkdnd_macosx.tcl b/library/tkdnd_macosx.tcl index a610d05..ce1b224 100644 --- a/library/tkdnd_macosx.tcl +++ b/library/tkdnd_macosx.tcl @@ -1,6 +1,6 @@ # # tkdnd_macosx.tcl -- -# +# # This file implements some utility procedures that are used by the TkDND # package. @@ -24,13 +24,13 @@ # and need not follow the licensing terms described here, provided that # the new terms are clearly indicated on the first page of each file where # they apply. -# +# # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -# +# # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE @@ -53,27 +53,42 @@ if {[tk windowingsystem] eq "aqua" && "AppKit" ni [winfo server .]} { namespace eval macdnd { variable _dropped_data + + + proc initialise {} { + variable _tkdnd2platform + variable _platform2tkdnd + + ## Initialize the tkdnd 2 platform & platform 2 tkdnd arrays for type conversion... + array set _platform2tkdnd [list \ + NSPasteboardTypeString DND_Text \ + NSFilenamesPboardType DND_Files \ + ] + foreach type [array names _platform2tkdnd] { + lappend _tkdnd2platform($_platform2tkdnd($type)) $type + } + };# initialise };# namespace macdnd # ---------------------------------------------------------------------------- # Command macdnd::_HandleEnter # ---------------------------------------------------------------------------- proc macdnd::_HandleEnter { path drag_source typelist } { - return [::tkdnd::xdnd::_HandleXdndEnter $path $drag_source $typelist] + ::tkdnd::xdnd::_HandleXdndEnter $path $drag_source $typelist };# macdnd::_HandleEnter # ---------------------------------------------------------------------------- -# Command macdnd::_HandlePosition +# Command macdnd::_HandlePosition # ---------------------------------------------------------------------------- proc macdnd::_HandlePosition { drop_target rootX rootY } { - return [::tkdnd::xdnd::_HandleXdndPosition $drop_target $rootX $rootY] + ::tkdnd::xdnd::_HandleXdndPosition $drop_target $rootX $rootY };# macdnd::_HandlePosition # ---------------------------------------------------------------------------- # Command macdnd::_HandleLeave # ---------------------------------------------------------------------------- proc macdnd::_HandleLeave { args } { - return [::tkdnd::xdnd::_HandleXdndLeave] + ::tkdnd::xdnd::_HandleXdndLeave };# macdnd::_HandleLeave # ---------------------------------------------------------------------------- @@ -82,7 +97,7 @@ proc macdnd::_HandleLeave { args } { proc macdnd::_HandleDrop { drop_target data args } { variable _dropped_data set _dropped_data $data - return [::tkdnd::xdnd::_HandleXdndDrop 0] + ::tkdnd::xdnd::_HandleXdndDrop 0 };# macdnd::_HandleDrop # ---------------------------------------------------------------------------- @@ -90,81 +105,99 @@ proc macdnd::_HandleDrop { drop_target data args } { # ---------------------------------------------------------------------------- proc macdnd::_GetDroppedData { time } { variable _dropped_data - return $_dropped_data + return $_dropped_data };# macdnd::_GetDroppedData proc xdnd::_GetDroppedData { time } { - return [::tkdnd::macdnd::_GetDroppedData $time] + ::tkdnd::macdnd::_GetDroppedData $time };# xdnd::_GetDroppedData # ---------------------------------------------------------------------------- # Command macdnd::_GetDragSource # ---------------------------------------------------------------------------- proc macdnd::_GetDragSource { } { - return [::tkdnd::xdnd::_GetDragSource] + ::tkdnd::xdnd::_GetDragSource };# macdnd::_GetDragSource # ---------------------------------------------------------------------------- # Command macdnd::_GetDropTarget # ---------------------------------------------------------------------------- proc macdnd::_GetDropTarget { } { - return [::tkdnd::xdnd::_GetDropTarget] + ::tkdnd::xdnd::_GetDropTarget };# macdnd::_GetDropTarget # ---------------------------------------------------------------------------- +# Command macdnd::_GetDragSourceCommonTypes +# ---------------------------------------------------------------------------- +proc macdnd::_GetDragSourceCommonTypes { } { + ::tkdnd::xdnd::_GetDragSourceCommonTypes +};# macdnd::_GetDragSourceCommonTypes + +# ---------------------------------------------------------------------------- +# Command macdnd::_GetDropTargetCommonTypes +# ---------------------------------------------------------------------------- +proc macdnd::_GetDropTargetCommonTypes { } { + ::tkdnd::xdnd::_GetDropTargetCommonTypes +};# macdnd::_GetDropTargetCommonTypes + +# ---------------------------------------------------------------------------- # Command macdnd::_supported_types # ---------------------------------------------------------------------------- proc macdnd::_supported_types { types } { - return [::tkdnd::xdnd::_supported_types $types] + ::tkdnd::xdnd::_supported_types $types }; # macdnd::_supported_types # ---------------------------------------------------------------------------- # Command macdnd::_platform_specific_types # ---------------------------------------------------------------------------- proc macdnd::_platform_specific_types { types } { - return [::tkdnd::xdnd::_platform_specific_types $types] + ::tkdnd::xdnd::_platform_specific_types $types }; # macdnd::_platform_specific_types # ---------------------------------------------------------------------------- # Command macdnd::_normalise_data # ---------------------------------------------------------------------------- proc macdnd::_normalise_data { type data } { - return [::tkdnd::xdnd::_normalise_data $type $data] + ::tkdnd::xdnd::_normalise_data $type $data }; # macdnd::_normalise_data # ---------------------------------------------------------------------------- # Command macdnd::_platform_specific_type # ---------------------------------------------------------------------------- proc macdnd::_platform_specific_type { type } { - switch $type { - DND_Text {return [list NSStringPboardType]} - DND_Files {return [list NSFilenamesPboardType]} - default {return [list $type]} + variable _tkdnd2platform + if {[info exists _tkdnd2platform($type)]} { + return $_tkdnd2platform($type) } + list $type }; # macdnd::_platform_specific_type proc xdnd::_platform_specific_type { type } { - return [::tkdnd::macdnd::_platform_specific_type $type] + ::tkdnd::macdnd::_platform_specific_type $type }; # xdnd::_platform_specific_type # ---------------------------------------------------------------------------- # Command macdnd::_platform_independent_type # ---------------------------------------------------------------------------- proc macdnd::_platform_independent_type { type } { - switch $type { - NSStringPboardType {return DND_Text} - NSFilenamesPboardType {return DND_Files} - default {return [list $type]} + variable _platform2tkdnd + if {[info exists _platform2tkdnd($type)]} { + return $_platform2tkdnd($type) } + return $type }; # macdnd::_platform_independent_type proc xdnd::_platform_independent_type { type } { - return [::tkdnd::macdnd::_platform_independent_type $type] + ::tkdnd::macdnd::_platform_independent_type $type }; # xdnd::_platform_independent_type # ---------------------------------------------------------------------------- # Command macdnd::_supported_type # ---------------------------------------------------------------------------- proc macdnd::_supported_type { type } { - return 1 + variable _platform2tkdnd + if {[info exists _platform2tkdnd($type)]} { + return 1 + } + return 0 }; # macdnd::_supported_type proc xdnd::_supported_type { type } { - return [::tkdnd::macdnd::_supported_type $type] + ::tkdnd::macdnd::_supported_type $type }; # xdnd::_supported_type diff --git a/library/tkdnd_unix.tcl b/library/tkdnd_unix.tcl index 4d70eb0..38cb4bf 100644 --- a/library/tkdnd_unix.tcl +++ b/library/tkdnd_unix.tcl @@ -1,6 +1,6 @@ # # tkdnd_unix.tcl -- -# +# # This file implements some utility procedures that are used by the TkDND # package. # @@ -21,13 +21,13 @@ # and need not follow the licensing terms described here, provided that # the new terms are clearly indicated on the first page of each file where # they apply. -# +# # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -# +# # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE @@ -56,6 +56,9 @@ namespace eval xdnd { proc debug {msg} { puts $msg };# debug + + proc initialise { } { + };# initialise };# namespace xdnd # ---------------------------------------------------------------------------- @@ -114,7 +117,7 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } { return refuse_drop } - ## Does the new drop target support any of our new types? + ## Does the new drop target support any of our new types? set _types [bind $drop_target <<DropTargetTypes>>] # debug ">> Accepted types: $drop_target $_types" if {[llength $_types]} { @@ -129,7 +132,7 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } { } } } - + # debug "\t($_drop_target) -> ($drop_target)" if {$drop_target != $_drop_target} { if {[string length $_drop_target]} { @@ -183,7 +186,7 @@ proc xdnd::_HandleXdndPosition { drop_target rootX rootY {drag_source {}} } { } set _drop_target $drop_target } - + set _action refuse_drop set _drop_target {} if {[info exists common_drag_source_types]} { @@ -380,7 +383,7 @@ proc xdnd::_GetDroppedData { time } { # ---------------------------------------------------------------------------- proc xdnd::_GetDragSource { } { variable _drag_source - return $_drag_source + return $_drag_source };# xdnd::_GetDragSource # ---------------------------------------------------------------------------- @@ -395,6 +398,22 @@ proc xdnd::_GetDropTarget { } { };# xdnd::_GetDropTarget # ---------------------------------------------------------------------------- +# Command xdnd::_GetDragSourceCommonTypes +# ---------------------------------------------------------------------------- +proc xdnd::_GetDragSourceCommonTypes { } { + variable _common_drag_source_types + return $_common_drag_source_types +};# xdnd::_GetDragSourceCommonTypes + +# ---------------------------------------------------------------------------- +# Command xdnd::_GetDropTargetCommonTypes +# ---------------------------------------------------------------------------- +proc xdnd::_GetDropTargetCommonTypes { } { + variable _common_drag_source_types + return $_common_drag_source_types +};# xdnd::_GetDropTargetCommonTypes + +# ---------------------------------------------------------------------------- # Command xdnd::_supported_types # ---------------------------------------------------------------------------- proc xdnd::_supported_types { types } { @@ -423,7 +442,7 @@ proc xdnd::_normalise_data { type data } { # Tk knows how to interpret the following types: # STRING, TEXT, COMPOUND_TEXT # UTF8_STRING - # Else, it returns a list of 8 or 32 bit numbers... + # Else, it returns a list of 8 or 32 bit numbers... switch -glob $type { STRING - UTF8_STRING - TEXT - COMPOUND_TEXT {return $data} text/html - @@ -459,7 +478,7 @@ proc xdnd::_normalise_data { type data } { application/x-color { return $data } - text/x-moz-url - + text/x-moz-url - application/q-iconlist - default {return $data} } @@ -636,7 +655,7 @@ proc xdnd::_process_drag_events {event} { ## Examine the modifiers to suggest an action... set _dodragdrop_default_action [_default_action $event] ## Is it a Tk widget? - # set path [winfo containing $rootx $rooty] + # set path [winfo containing $rootx $rooty] # puts "Window under mouse: $window ($path)" if {$_dodragdrop_drop_target != $window} { ## Send XdndLeave to $_dodragdrop_drop_target @@ -867,7 +886,7 @@ proc xdnd::_default_action {event} { variable _dodragdrop_actions variable _dodragdrop_actions_len if {$_dodragdrop_actions_len == 1} {return [lindex $_dodragdrop_actions 0]} - + set alt [dict get $event Alt] set shift [dict get $event Shift] set control [dict get $event Control] diff --git a/library/tkdnd_windows.tcl b/library/tkdnd_windows.tcl index 9533f0f..b1a8268 100644 --- a/library/tkdnd_windows.tcl +++ b/library/tkdnd_windows.tcl @@ -1,6 +1,6 @@ # # tkdnd_windows.tcl -- -# +# # This file implements some utility procedures that are used by the TkDND # package. # @@ -21,13 +21,13 @@ # and need not follow the licensing terms described here, provided that # the new terms are clearly indicated on the first page of each file where # they apply. -# +# # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -# +# # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE @@ -49,6 +49,9 @@ namespace eval olednd { variable _last_mouse_root_x 0 variable _last_mouse_root_y 0 + + proc initialise { } { + };# initialise };# namespace olednd # ---------------------------------------------------------------------------- @@ -72,7 +75,7 @@ proc olednd::_HandleDragEnter { drop_target typelist actionlist pressedkeys # pressedkeys=$pressedkeys, rootX=$rootX, rootY=$rootY" focus $drop_target - ## Does the new drop target support any of our new types? + ## Does the new drop target support any of our new types? variable _types; set _types [bind $drop_target <<DropTargetTypes>>] if {[llength $_types]} { ## Examine the drop target types, to find at least one match with the drag |