home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 31 / FreelogHS31.iso / Texte / scribus / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / HList.tcl < prev    next >
Text File  |  2002-07-12  |  19KB  |  925 lines

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