TList.tcl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: TList.tcl,v 1.6 2002/01/24 09:13:58 idiscovery Exp $
  4. #
  5. # TList.tcl --
  6. #
  7. # This file defines the default bindings for Tix Tabular Listbox
  8. # widgets.
  9. #
  10. # Copyright (c) 1993-1999 Ioi Kim Lam.
  11. # Copyright (c) 2000-2001 Tix Project Group.
  12. #
  13. # See the file "license.terms" for information on usage and redistribution
  14. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  15. #
  16. global tkPriv
  17. if {![llength [info globals tkPriv]]} {
  18. tk::unsupported::ExposePrivateVariable tkPriv
  19. }
  20. #--------------------------------------------------------------------------
  21. # tkPriv elements used in this file:
  22. #
  23. # afterId - Token returned by "after" for autoscanning.
  24. # fakeRelease - Cancel the ButtonRelease-1 after the user double click
  25. #--------------------------------------------------------------------------
  26. #
  27. proc tixTListBind {} {
  28. tixBind TixTList <ButtonPress-1> {
  29. tixTList:Button-1 %W %x %y
  30. }
  31. tixBind TixTList <Shift-ButtonPress-1> {
  32. tixTList:Shift-Button-1 %W %x %y
  33. }
  34. tixBind TixTList <Control-ButtonPress-1> {
  35. tixTList:Control-Button-1 %W %x %y
  36. }
  37. tixBind TixTList <ButtonRelease-1> {
  38. tixTList:ButtonRelease-1 %W %x %y
  39. }
  40. tixBind TixTList <Double-ButtonPress-1> {
  41. tixTList:Double-1 %W %x %y
  42. }
  43. tixBind TixTList <B1-Motion> {
  44. set tkPriv(x) %x
  45. set tkPriv(y) %y
  46. set tkPriv(X) %X
  47. set tkPriv(Y) %Y
  48. tixTList:B1-Motion %W %x %y
  49. }
  50. tixBind TixTList <Control-B1-Motion> {
  51. set tkPriv(x) %x
  52. set tkPriv(y) %y
  53. set tkPriv(X) %X
  54. set tkPriv(Y) %Y
  55. tixTList:Control-B1-Motion %W %x %y
  56. }
  57. tixBind TixTList <B1-Leave> {
  58. set tkPriv(x) %x
  59. set tkPriv(y) %y
  60. set tkPriv(X) %X
  61. set tkPriv(Y) %Y
  62. tixTList:B1-Leave %W
  63. }
  64. tixBind TixTList <B1-Enter> {
  65. tixTList:B1-Enter %W %x %y
  66. }
  67. tixBind TixTList <Control-B1-Leave> {
  68. set tkPriv(x) %x
  69. set tkPriv(y) %y
  70. set tkPriv(X) %X
  71. set tkPriv(Y) %Y
  72. tixTList:Control-B1-Leave %W
  73. }
  74. tixBind TixTList <Control-B1-Enter> {
  75. tixTList:Control-B1-Enter %W %x %y
  76. }
  77. # Keyboard bindings
  78. #
  79. tixBind TixTList <Up> {
  80. tixTList:DirKey %W up
  81. }
  82. tixBind TixTList <Down> {
  83. tixTList:DirKey %W down
  84. }
  85. tixBind TixTList <Left> {
  86. tixTList:DirKey %W left
  87. }
  88. tixBind TixTList <Right> {
  89. tixTList:DirKey %W right
  90. }
  91. tixBind TixTList <Prior> {
  92. %W yview scroll -1 pages
  93. }
  94. tixBind TixTList <Next> {
  95. %W yview scroll 1 pages
  96. }
  97. tixBind TixTList <Return> {
  98. tixTList:Return %W
  99. }
  100. tixBind TixTList <space> {
  101. tixTList:Space %W
  102. }
  103. #
  104. # Don't use tixBind because %A causes Tk 8.3.2 to crash
  105. #
  106. bind TixTList <MouseWheel> {
  107. if {"[%W cget -orient]" == "vertical"} {
  108. %W xview scroll [expr {- (%D / 120) * 4}] units
  109. } else {
  110. %W yview scroll [expr {- (%D / 120) * 2}] units
  111. }
  112. }
  113. }
  114. #----------------------------------------------------------------------
  115. #
  116. #
  117. # Mouse bindings
  118. #
  119. #
  120. #----------------------------------------------------------------------
  121. proc tixTList:Button-1 {w x y} {
  122. if {[$w cget -state] == "disabled"} {
  123. return
  124. }
  125. if {[$w cget -takefocus]} {
  126. focus $w
  127. }
  128. case [tixTList:GetState $w] {
  129. {s0} {
  130. tixTList:GoState s1 $w $x $y
  131. }
  132. {b0} {
  133. tixTList:GoState b1 $w $x $y
  134. }
  135. {m0} {
  136. tixTList:GoState m1 $w $x $y
  137. }
  138. {e0} {
  139. tixTList:GoState e1 $w $x $y
  140. }
  141. }
  142. }
  143. proc tixTList:Shift-Button-1 {w x y} {
  144. if {[$w cget -state] == "disabled"} {
  145. return
  146. }
  147. if {[$w cget -takefocus]} {
  148. focus $w
  149. }
  150. case [tixTList:GetState $w] {
  151. {s0} {
  152. tixTList:GoState s1 $w $x $y
  153. }
  154. {b0} {
  155. tixTList:GoState b1 $w $x $y
  156. }
  157. {m0} {
  158. tixTList:GoState m7 $w $x $y
  159. }
  160. {e0} {
  161. tixTList:GoState e7 $w $x $y
  162. }
  163. }
  164. }
  165. proc tixTList:Control-Button-1 {w x y} {
  166. if {[$w cget -state] == "disabled"} {
  167. return
  168. }
  169. if {[$w cget -takefocus]} {
  170. focus $w
  171. }
  172. case [tixTList:GetState $w] {
  173. {s0} {
  174. tixTList:GoState s1 $w $x $y
  175. }
  176. {b0} {
  177. tixTList:GoState b1 $w $x $y
  178. }
  179. {m0} {
  180. tixTList:GoState m1 $w $x $y
  181. }
  182. {e0} {
  183. tixTList:GoState e10 $w $x $y
  184. }
  185. }
  186. }
  187. proc tixTList:ButtonRelease-1 {w x y} {
  188. case [tixTList:GetState $w] {
  189. {s2 s4 s5 s6} {
  190. tixTList:GoState s3 $w
  191. }
  192. {b2 b4 b5 b6} {
  193. tixTList:GoState b3 $w
  194. }
  195. {m2} {
  196. tixTList:GoState m3 $w
  197. }
  198. {m5} {
  199. tixTList:GoState m6 $w $x $y
  200. }
  201. {m9} {
  202. tixTList:GoState m0 $w
  203. }
  204. {e2} {
  205. tixTList:GoState e3 $w
  206. }
  207. {e5} {
  208. tixTList:GoState e6 $w $x $y
  209. }
  210. {e9} {
  211. tixTList:GoState e0 $w
  212. }
  213. }
  214. }
  215. proc tixTList:B1-Motion {w x y} {
  216. case [tixTList:GetState $w] {
  217. {s2 s4} {
  218. tixTList:GoState s4 $w $x $y
  219. }
  220. {b2 b4} {
  221. tixTList:GoState b4 $w $x $y
  222. }
  223. {m2 m5} {
  224. tixTList:GoState m4 $w $x $y
  225. }
  226. {e2 e5} {
  227. tixTList:GoState e4 $w $x $y
  228. }
  229. }
  230. }
  231. proc tixTList:Control-B1-Motion {w x y} {
  232. case [tixTList:GetState $w] {
  233. {s2 s4} {
  234. tixTList:GoState s4 $w $x $y
  235. }
  236. {b2 b4} {
  237. tixTList:GoState b4 $w $x $y
  238. }
  239. {m2 m5} {
  240. tixTList:GoState m4 $w $x $y
  241. }
  242. }
  243. }
  244. proc tixTList:Double-1 {w x y} {
  245. case [tixTList:GetState $w] {
  246. {s0} {
  247. tixTList:GoState s7 $w $x $y
  248. }
  249. {b0} {
  250. tixTList:GoState b7 $w $x $y
  251. }
  252. }
  253. }
  254. proc tixTList:B1-Leave {w} {
  255. case [tixTList:GetState $w] {
  256. {s2 s4} {
  257. tixTList:GoState s5 $w
  258. }
  259. {b2 b4} {
  260. tixTList:GoState b5 $w
  261. }
  262. {m2 m5} {
  263. tixTList:GoState m8 $w
  264. }
  265. {e2 e5} {
  266. tixTList:GoState e8 $w
  267. }
  268. }
  269. }
  270. proc tixTList:B1-Enter {w x y} {
  271. case [tixTList:GetState $w] {
  272. {s5 s6} {
  273. tixTList:GoState s4 $w $x $y
  274. }
  275. {b5 b6} {
  276. tixTList:GoState b4 $w $x $y
  277. }
  278. {m8 m9} {
  279. tixTList:GoState m4 $w $x $y
  280. }
  281. {e8 e9} {
  282. tixTList:GoState e4 $w $x $y
  283. }
  284. }
  285. }
  286. proc tixTList:Control-B1-Leave {w} {
  287. case [tixTList:GetState $w] {
  288. {s2 s4} {
  289. tixTList:GoState s5 $w
  290. }
  291. {b2 b4} {
  292. tixTList:GoState b5 $w
  293. }
  294. {m2 m5} {
  295. tixTList:GoState m8 $w
  296. }
  297. }
  298. }
  299. proc tixTList:Control-B1-Enter {w x y} {
  300. case [tixTList:GetState $w] {
  301. {s5 s6} {
  302. tixTList:GoState s4 $w $x $y
  303. }
  304. {b5 b6} {
  305. tixTList:GoState b4 $w $x $y
  306. }
  307. {m8 m9} {
  308. tixTList:GoState m4 $w $x $y
  309. }
  310. }
  311. }
  312. proc tixTList:AutoScan {w} {
  313. case [tixTList:GetState $w] {
  314. {s5 s6} {
  315. tixTList:GoState s6 $w
  316. }
  317. {b5 b6} {
  318. tixTList:GoState b6 $w
  319. }
  320. {m8 m9} {
  321. tixTList:GoState m9 $w
  322. }
  323. {e8 e9} {
  324. tixTList:GoState e9 $w
  325. }
  326. }
  327. }
  328. #----------------------------------------------------------------------
  329. #
  330. #
  331. # Key bindings
  332. #
  333. #
  334. #----------------------------------------------------------------------
  335. proc tixTList:DirKey {w key} {
  336. if {[$w cget -state] == "disabled"} {
  337. return
  338. }
  339. case [tixTList:GetState $w] {
  340. {s0} {
  341. tixTList:GoState s8 $w $key
  342. }
  343. {b0} {
  344. tixTList:GoState b8 $w $key
  345. }
  346. }
  347. }
  348. proc tixTList:Return {w} {
  349. if {[$w cget -state] == "disabled"} {
  350. return
  351. }
  352. case [tixTList:GetState $w] {
  353. {s0} {
  354. tixTList:GoState s9 $w
  355. }
  356. {b0} {
  357. tixTList:GoState b9 $w
  358. }
  359. }
  360. }
  361. proc tixTList:Space {w} {
  362. if {[$w cget -state] == "disabled"} {
  363. return
  364. }
  365. case [tixTList:GetState $w] {
  366. {s0} {
  367. tixTList:GoState s10 $w
  368. }
  369. {b0} {
  370. tixTList:GoState b10 $w
  371. }
  372. }
  373. }
  374. #----------------------------------------------------------------------
  375. #
  376. # STATE MANIPULATION
  377. #
  378. #
  379. #----------------------------------------------------------------------
  380. proc tixTList:GetState {w} {
  381. global $w:priv:state
  382. if {[info exists $w:priv:state]} {
  383. #
  384. # If the app has changed the selectmode, reset the state to the
  385. # original state.
  386. #
  387. set type [string index [$w cget -selectmode] 0]
  388. if {"[string index [set $w:priv:state] 0]" != "$type"} {
  389. unset $w:priv:state
  390. }
  391. }
  392. if {![info exists $w:priv:state]} {
  393. case [$w cget -selectmode] {
  394. single {
  395. set $w:priv:state s0
  396. }
  397. browse {
  398. set $w:priv:state b0
  399. }
  400. multiple {
  401. set $w:priv:state m0
  402. }
  403. extended {
  404. set $w:priv:state e0
  405. }
  406. default {
  407. set $w:priv:state unknown
  408. }
  409. }
  410. }
  411. return [set $w:priv:state]
  412. }
  413. proc tixTList:SetState {w n} {
  414. global $w:priv:state
  415. set $w:priv:state $n
  416. }
  417. proc tixTList:GoState {n w args} {
  418. # puts "going from [tixTList:GetState $w] --> $n"
  419. tixTList:SetState $w $n
  420. eval tixTList:GoState-$n $w $args
  421. }
  422. #----------------------------------------------------------------------
  423. # States
  424. #----------------------------------------------------------------------
  425. #----------------------------------------------------------------------
  426. # SINGLE SELECTION
  427. #----------------------------------------------------------------------
  428. proc tixTList:GoState-s0 {w} {
  429. }
  430. proc tixTList:GoState-s1 {w x y} {
  431. set ent [$w nearest $x $y]
  432. if {$ent != ""} {
  433. $w anchor set $ent
  434. $w see $ent
  435. }
  436. tixTList:GoState s2 $w
  437. }
  438. proc tixTList:GoState-s2 {w} {
  439. }
  440. proc tixTList:GoState-s3 {w} {
  441. set ent [$w info anchor]
  442. if {$ent != ""} {
  443. $w selection clear
  444. $w selection set $ent
  445. tixTList:CallBrowseCmd $w $ent
  446. }
  447. tixTList:GoState s0 $w
  448. }
  449. proc tixTList:GoState-s4 {w x y} {
  450. set ent [$w nearest $x $y]
  451. if {$ent != ""} {
  452. $w anchor set $ent
  453. $w see $ent
  454. }
  455. }
  456. proc tixTList:GoState-s5 {w} {
  457. tixTList:StartScan $w
  458. }
  459. proc tixTList:GoState-s6 {w} {
  460. global tkPriv
  461. tixTList:DoScan $w
  462. }
  463. proc tixTList:GoState-s7 {w x y} {
  464. set ent [$w nearest $x $y]
  465. if {$ent != ""} {
  466. $w selection clear
  467. $w selection set $ent
  468. tixTList:CallCommand $w $ent
  469. }
  470. tixTList:GoState s0 $w
  471. }
  472. proc tixTList:GoState-s8 {w key} {
  473. set anchor [$w info anchor]
  474. if {$anchor == ""} {
  475. set anchor 0
  476. } else {
  477. set anchor [$w info $key $anchor]
  478. }
  479. $w anchor set $anchor
  480. $w see $anchor
  481. tixTList:GoState s0 $w
  482. }
  483. proc tixTList:GoState-s9 {w} {
  484. set anchor [$w info anchor]
  485. if {$anchor == ""} {
  486. set anchor 0
  487. $w anchor set $anchor
  488. $w see $anchor
  489. }
  490. if {[$w info anchor] != ""} {
  491. # ! may not have any elements
  492. #
  493. tixTList:CallCommand $w [$w info anchor]
  494. $w selection clear
  495. $w selection set $anchor
  496. }
  497. tixTList:GoState s0 $w
  498. }
  499. proc tixTList:GoState-s10 {w} {
  500. set anchor [$w info anchor]
  501. if {$anchor == ""} {
  502. set anchor 0
  503. $w anchor set $anchor
  504. $w see $anchor
  505. }
  506. if {[$w info anchor] != ""} {
  507. # ! may not have any elements
  508. #
  509. tixTList:CallBrowseCmd $w [$w info anchor]
  510. $w selection clear
  511. $w selection set $anchor
  512. }
  513. tixTList:GoState s0 $w
  514. }
  515. #----------------------------------------------------------------------
  516. # BROWSE SELECTION
  517. #----------------------------------------------------------------------
  518. proc tixTList:GoState-b0 {w} {
  519. }
  520. proc tixTList:GoState-b1 {w x y} {
  521. set ent [$w nearest $x $y]
  522. if {$ent != ""} {
  523. $w anchor set $ent
  524. $w see $ent
  525. $w selection clear
  526. $w selection set $ent
  527. tixTList:CallBrowseCmd $w $ent
  528. }
  529. tixTList:GoState b2 $w
  530. }
  531. proc tixTList:GoState-b2 {w} {
  532. }
  533. proc tixTList:GoState-b3 {w} {
  534. set ent [$w info anchor]
  535. if {$ent != ""} {
  536. $w selection clear
  537. $w selection set $ent
  538. tixTList:CallBrowseCmd $w $ent
  539. }
  540. tixTList:GoState b0 $w
  541. }
  542. proc tixTList:GoState-b4 {w x y} {
  543. set ent [$w nearest $x $y]
  544. if {$ent != ""} {
  545. $w anchor set $ent
  546. $w see $ent
  547. $w selection clear
  548. $w selection set $ent
  549. tixTList:CallBrowseCmd $w $ent
  550. }
  551. }
  552. proc tixTList:GoState-b5 {w} {
  553. tixTList:StartScan $w
  554. }
  555. proc tixTList:GoState-b6 {w} {
  556. global tkPriv
  557. tixTList:DoScan $w
  558. }
  559. proc tixTList:GoState-b7 {w x y} {
  560. set ent [$w nearest $x $y]
  561. if {$ent != ""} {
  562. $w selection clear
  563. $w selection set $ent
  564. tixTList:CallCommand $w $ent
  565. }
  566. tixTList:GoState b0 $w
  567. }
  568. proc tixTList:GoState-b8 {w key} {
  569. set anchor [$w info anchor]
  570. if {$anchor == ""} {
  571. set anchor 0
  572. } else {
  573. set anchor [$w info $key $anchor]
  574. }
  575. $w anchor set $anchor
  576. $w selection clear
  577. $w selection set $anchor
  578. $w see $anchor
  579. tixTList:CallBrowseCmd $w $anchor
  580. tixTList:GoState b0 $w
  581. }
  582. proc tixTList:GoState-b9 {w} {
  583. set anchor [$w info anchor]
  584. if {$anchor == ""} {
  585. set anchor 0
  586. $w anchor set $anchor
  587. $w see $anchor
  588. }
  589. if {[$w info anchor] != ""} {
  590. # ! may not have any elements
  591. #
  592. tixTList:CallCommand $w [$w info anchor]
  593. $w selection clear
  594. $w selection set $anchor
  595. }
  596. tixTList:GoState b0 $w
  597. }
  598. proc tixTList:GoState-b10 {w} {
  599. set anchor [$w info anchor]
  600. if {$anchor == ""} {
  601. set anchor 0
  602. $w anchor set $anchor
  603. $w see $anchor
  604. }
  605. if {[$w info anchor] != ""} {
  606. # ! may not have any elements
  607. #
  608. tixTList:CallBrowseCmd $w [$w info anchor]
  609. $w selection clear
  610. $w selection set $anchor
  611. }
  612. tixTList:GoState b0 $w
  613. }
  614. #----------------------------------------------------------------------
  615. # MULTIPLE SELECTION
  616. #----------------------------------------------------------------------
  617. proc tixTList:GoState-m0 {w} {
  618. }
  619. proc tixTList:GoState-m1 {w x y} {
  620. set ent [$w nearest $x $y]
  621. if {$ent != ""} {
  622. $w anchor set $ent
  623. $w see $ent
  624. $w selection clear
  625. $w selection set $ent
  626. tixTList:CallBrowseCmd $w $ent
  627. }
  628. tixTList:GoState m2 $w
  629. }
  630. proc tixTList:GoState-m2 {w} {
  631. }
  632. proc tixTList:GoState-m3 {w} {
  633. set ent [$w info anchor]
  634. if {$ent != ""} {
  635. tixTList:CallBrowseCmd $w $ent
  636. }
  637. tixTList:GoState m0 $w
  638. }
  639. proc tixTList:GoState-m4 {w x y} {
  640. set from [$w info anchor]
  641. set to [$w nearest $x $y]
  642. if {$to != ""} {
  643. $w selection clear
  644. $w selection set $from $to
  645. tixTList:CallBrowseCmd $w $to
  646. }
  647. tixTList:GoState m5 $w
  648. }
  649. proc tixTList:GoState-m5 {w} {
  650. }
  651. proc tixTList:GoState-m6 {w x y} {
  652. set ent [$w nearest $x $y]
  653. if {$ent != ""} {
  654. tixTList:CallBrowseCmd $w $ent
  655. }
  656. tixTList:GoState m0 $w
  657. }
  658. proc tixTList:GoState-m7 {w x y} {
  659. set from [$w info anchor]
  660. set to [$w nearest $x $y]
  661. if {$from == ""} {
  662. set from $to
  663. $w anchor set $from
  664. $w see $from
  665. }
  666. if {$to != ""} {
  667. $w selection clear
  668. $w selection set $from $to
  669. tixTList:CallBrowseCmd $w $to
  670. }
  671. tixTList:GoState m5 $w
  672. }
  673. proc tixTList:GoState-m8 {w} {
  674. tixTList:StartScan $w
  675. }
  676. proc tixTList:GoState-m9 {w} {
  677. tixTList:DoScan $w
  678. }
  679. proc tixTList:GoState-xm7 {w x y} {
  680. set ent [$w nearest $x $y]
  681. if {$ent != ""} {
  682. $w selection clear
  683. $w selection set $ent
  684. tixTList:CallCommand $w $ent
  685. }
  686. tixTList:GoState m0 $w
  687. }
  688. #----------------------------------------------------------------------
  689. # EXTENDED SELECTION
  690. #----------------------------------------------------------------------
  691. proc tixTList:GoState-e0 {w} {
  692. }
  693. proc tixTList:GoState-e1 {w x y} {
  694. set ent [$w nearest $x $y]
  695. if {$ent != ""} {
  696. $w anchor set $ent
  697. $w see $ent
  698. $w selection clear
  699. $w selection set $ent
  700. tixTList:CallBrowseCmd $w $ent
  701. }
  702. tixTList:GoState e2 $w
  703. }
  704. proc tixTList:GoState-e2 {w} {
  705. }
  706. proc tixTList:GoState-e3 {w} {
  707. set ent [$w info anchor]
  708. if {$ent != ""} {
  709. tixTList:CallBrowseCmd $w $ent
  710. }
  711. tixTList:GoState e0 $w
  712. }
  713. proc tixTList:GoState-e4 {w x y} {
  714. set from [$w info anchor]
  715. set to [$w nearest $x $y]
  716. if {$to != ""} {
  717. $w selection clear
  718. $w selection set $from $to
  719. tixTList:CallBrowseCmd $w $to
  720. }
  721. tixTList:GoState e5 $w
  722. }
  723. proc tixTList:GoState-e5 {w} {
  724. }
  725. proc tixTList:GoState-e6 {w x y} {
  726. set ent [$w nearest $x $y]
  727. if {$ent != ""} {
  728. tixTList:CallBrowseCmd $w $ent
  729. }
  730. tixTList:GoState e0 $w
  731. }
  732. proc tixTList:GoState-e7 {w x y} {
  733. set from [$w info anchor]
  734. set to [$w nearest $x $y]
  735. if {$from == ""} {
  736. set from $to
  737. $w anchor set $from
  738. $w see $from
  739. }
  740. if {$to != ""} {
  741. $w selection clear
  742. $w selection set $from $to
  743. tixTList:CallBrowseCmd $w $to
  744. }
  745. tixTList:GoState e5 $w
  746. }
  747. proc tixTList:GoState-e8 {w} {
  748. tixTList:StartScan $w
  749. }
  750. proc tixTList:GoState-e9 {w} {
  751. tixTList:DoScan $w
  752. }
  753. proc tixTList:GoState-e10 {w x y} {
  754. set ent [$w nearest $x $y]
  755. if {$ent != ""} {
  756. if {[$w info anchor] == ""} {
  757. $w anchor set $ent
  758. $w see $ent
  759. }
  760. if {[$w selection includes $ent]} {
  761. $w selection clear $ent
  762. } else {
  763. $w selection set $ent
  764. }
  765. tixTList:CallBrowseCmd $w $ent
  766. }
  767. tixTList:GoState e2 $w
  768. }
  769. proc tixTList:GoState-xm7 {w x y} {
  770. set ent [$w nearest $x $y]
  771. if {$ent != ""} {
  772. $w selection clear
  773. $w selection set $ent
  774. tixTList:CallCommand $w $ent
  775. }
  776. tixTList:GoState e0 $w
  777. }
  778. #----------------------------------------------------------------------
  779. # callback actions
  780. #----------------------------------------------------------------------
  781. proc tixTList:SetAnchor {w x y} {
  782. set ent [$w nearest $x $y]
  783. if {$ent != "" && [$w entrycget $ent -state] != "disabled"} {
  784. $w anchor set $ent
  785. $w see $ent
  786. return $ent
  787. }
  788. return ""
  789. }
  790. proc tixTList:Select {w ent} {
  791. $w selection clear
  792. $w select set $ent
  793. }
  794. proc tixTList:StartScan {w} {
  795. global tkPriv
  796. set tkPriv(afterId) [after 50 tixTList:AutoScan $w]
  797. }
  798. proc tixTList:DoScan {w} {
  799. global tkPriv
  800. set x $tkPriv(x)
  801. set y $tkPriv(y)
  802. set X $tkPriv(X)
  803. set Y $tkPriv(Y)
  804. set out 0
  805. if {$y >= [winfo height $w]} {
  806. $w yview scroll 1 units
  807. set out 1
  808. }
  809. if {$y < 0} {
  810. $w yview scroll -1 units
  811. set out 1
  812. }
  813. if {$x >= [winfo width $w]} {
  814. $w xview scroll 2 units
  815. set out 1
  816. }
  817. if {$x < 0} {
  818. $w xview scroll -2 units
  819. set out 1
  820. }
  821. if {$out} {
  822. set tkPriv(afterId) [after 50 tixTList:AutoScan $w]
  823. }
  824. }
  825. proc tixTList:CallBrowseCmd {w ent} {
  826. set browsecmd [$w cget -browsecmd]
  827. if {$browsecmd != ""} {
  828. set bind(specs) {%V}
  829. set bind(%V) $ent
  830. tixEvalCmdBinding $w $browsecmd bind $ent
  831. }
  832. }
  833. proc tixTList:CallCommand {w ent} {
  834. set command [$w cget -command]
  835. if {$command != ""} {
  836. set bind(specs) {%V}
  837. set bind(%V) $ent
  838. tixEvalCmdBinding $w $command bind $ent
  839. }
  840. }