home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / beeld / teken / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / TList.tcl < prev    next >
Text File  |  2002-01-24  |  19KB  |  954 lines

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