HListDD.tcl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: HListDD.tcl,v 1.3 2001/12/09 05:04:02 idiscovery Exp $
  4. #
  5. # HListDD.tcl --
  6. #
  7. # !!! PRE-ALPHA CODE, NOT USED, DON'T USE !!!
  8. #
  9. # This file implements drag+drop for HList.
  10. #
  11. # Copyright (c) 1993-1999 Ioi Kim Lam.
  12. # Copyright (c) 2000-2001 Tix Project Group.
  13. #
  14. # See the file "license.terms" for information on usage and redistribution
  15. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  16. #
  17. #
  18. # events
  19. #
  20. #
  21. proc tixHListSingle:DragTimer {w ent} {
  22. case [tixHListSingle:GetState $w] {
  23. {1} {
  24. # fire up
  25. }
  26. }
  27. }
  28. #----------------------------------------------------------------------
  29. #
  30. # Drag + Drop Bindings
  31. #
  32. #----------------------------------------------------------------------
  33. #----------------------------------------#
  34. # Sending Actions #
  35. #----------------------------------------#
  36. #----------------------------------------------------------------------
  37. # tixHListSingle:Send:WaitDrag --
  38. #
  39. # Sender wait for dragging action
  40. #----------------------------------------------------------------------
  41. proc tixHListSingle:Send:WaitDrag {w x y} {
  42. global tixPriv
  43. set ent [tixHListSingle:GetNearest $w $y]
  44. if {$ent != ""} {
  45. $w anchor set $ent
  46. $w select clear
  47. $w select set $ent
  48. set tixPriv(dd,$w:moved) 0
  49. set tixPriv(dd,$w:entry) $ent
  50. # set browsecmd [$w cget -browsecmd]
  51. # if {$browsecmd != "" && $ent != ""} {
  52. # eval $browsecmd $ent
  53. # }
  54. }
  55. }
  56. proc tixHListSingle:Send:StartDrag {w x y} {
  57. global tixPriv
  58. set dd [tixGetDragDropContext $w]
  59. if {![info exists tixPriv(dd,$w:entry)]} {
  60. return
  61. }
  62. if {$tixPriv(dd,$w:entry) == ""} {
  63. return
  64. }
  65. if {$tixPriv(dd,$w:moved) == 0} {
  66. $w dragsite set $tixPriv(dd,$w:entry)
  67. set tixPriv(dd,$w:moved) 1
  68. $dd config -source $w -command [list tixHListSingle:Send:Cmd $w]
  69. $dd startdrag $X $Y
  70. } else {
  71. $dd drag $X $Y
  72. }
  73. }
  74. proc tixHListSingle:Send:DoneDrag {w x y} {
  75. global tixPriv
  76. global moved
  77. if {![info exists tixPriv(dd,$w:entry)]} {
  78. return
  79. }
  80. if {$tixPriv(dd,$w:entry) == ""} {
  81. return
  82. }
  83. if {$tixPriv(dd,$w:moved) == 1} {
  84. set dd [tixGetDragDropContext $w]
  85. $dd drop $X $Y
  86. }
  87. $w dragsite clear
  88. catch {unset tixPriv(dd,$w:moved)}
  89. catch {unset tixPriv(dd,$w:entry)}
  90. }
  91. proc tixHListSingle:Send:Cmd {w option args} {
  92. set dragCmd [$w cget -dragcmd]
  93. if {$dragCmd != ""} {
  94. return [eval $dragCmd $option $args]
  95. }
  96. # Perform the default action
  97. #
  98. case "$option" {
  99. who {
  100. return $w
  101. }
  102. types {
  103. return {data text}
  104. }
  105. get {
  106. global tixPriv
  107. if {[lindex $args 0] == "text"} {
  108. if {$tixPriv(dd,$w:entry) != ""} {
  109. return [$w entrycget $tixPriv(dd,$w:entry) -text]
  110. }
  111. }
  112. if {[lindex $args 0] == "data"} {
  113. if {$tixPriv(dd,$w:entry) != ""} {
  114. return [$w entrycget $tixPriv(dd,$w:entry) -data]
  115. }
  116. }
  117. }
  118. }
  119. }
  120. #----------------------------------------#
  121. # Receiving Actions #
  122. #----------------------------------------#
  123. proc tixHListSingle:Rec:DragOver {w sender x y} {
  124. if {[$w cget -selectmode] != "dragdrop"} {
  125. return
  126. }
  127. set ent [tixHListSingle:GetNearest $w $y]
  128. if {$ent != ""} {
  129. $w dropsite set $ent
  130. } else {
  131. $w dropsite clear
  132. }
  133. }
  134. proc tixHListSingle:Rec:DragIn {w sender x y} {
  135. if {[$w cget -selectmode] != "dragdrop"} {
  136. return
  137. }
  138. set ent [tixHListSingle:GetNearest $w $y]
  139. if {$ent != ""} {
  140. $w dropsite set $ent
  141. } else {
  142. $w dropsite clear
  143. }
  144. }
  145. proc tixHListSingle:Rec:DragOut {w sender x y} {
  146. if {[$w cget -selectmode] != "dragdrop"} {
  147. return
  148. }
  149. $w dropsite clear
  150. }
  151. proc tixHListSingle:Rec:Drop {w sender x y} {
  152. if {[$w cget -selectmode] != "dragdrop"} {
  153. return
  154. }
  155. $w dropsite clear
  156. set ent [tixHListSingle:GetNearest $w $y]
  157. if {$ent != ""} {
  158. $w anchor set $ent
  159. $w select clear
  160. $w select set $ent
  161. }
  162. set dropCmd [$w cget -dropcmd]
  163. if {$dropCmd != ""} {
  164. eval $dropCmd $sender $x $y
  165. return
  166. }
  167. # set browsecmd [$w cget -browsecmd]
  168. # if {$browsecmd != "" && $ent != ""} {
  169. # eval $browsecmd [list $ent]
  170. # }
  171. }
  172. tixDropBind TixHListSingle <In> "tixHListSingle:Rec:DragIn %W %S %x %y"
  173. tixDropBind TixHListSingle <Over> "tixHListSingle:Rec:DragOver %W %S %x %y"
  174. tixDropBind TixHListSingle <Out> "tixHListSingle:Rec:DragOut %W %S %x %y"
  175. tixDropBind TixHListSingle <Drop> "tixHListSingle:Rec:Drop %W %S %x %y"