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 / Tree.tcl < prev    next >
Text File  |  2001-12-08  |  4KB  |  192 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: Tree.tcl,v 1.2.2.2 2001/12/09 02:54:02 idiscovery Exp $
  4. #
  5. # Tree.tcl --
  6. #
  7. #    This file implements the TixTree widget.
  8. #
  9. # Copyright (c) 1993-1999 Ioi Kim Lam.
  10. # Copyright (c) 2000-2001 Tix Project Group.
  11. #
  12. # See the file "license.terms" for information on usage and redistribution
  13. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. #
  15.  
  16.  
  17. tixWidgetClass tixTree {
  18.     -classname TixTree
  19.     -superclass tixVTree
  20.     -method {
  21.     autosetmode close getmode open setmode
  22.     }
  23.     -flag {
  24.     -browsecmd -command -opencmd -closecmd
  25.     }
  26.     -configspec {
  27.     {-browsecmd browseCmd BrowseCmd ""}
  28.     {-command command Command ""}
  29.     {-closecmd closeCmd CloseCmd ""}
  30.     {-opencmd openCmd OpenCmd ""}
  31.     }
  32.     -default {
  33.     {.scrollbar            auto}
  34.     {*Scrollbar.takeFocus           0}
  35.     {*borderWidth                   1}
  36.     {*hlist.background              #c3c3c3}
  37.     {*hlist.drawBranch              1}
  38.     {*hlist.height                  10}
  39.     {*hlist.highlightBackground      #d9d9d9}
  40.     {*hlist.indicator               1}
  41.     {*hlist.indent                  20}
  42.     {*hlist.itemType                imagetext}
  43.     {*hlist.padX                    2}
  44.     {*hlist.padY                    2}
  45.     {*hlist.relief                  sunken}
  46.     {*hlist.takeFocus               1}
  47.     {*hlist.wideSelection           0}
  48.     {*hlist.width                   20}
  49.     }
  50. }
  51.  
  52. proc tixTree:InitWidgetRec {w} {
  53.     upvar #0 $w data
  54.  
  55.     tixChainMethod $w InitWidgetRec
  56. }
  57.  
  58. proc tixTree:ConstructWidget {w} {
  59.     upvar #0 $w data
  60.  
  61.     tixChainMethod $w ConstructWidget
  62. }
  63.  
  64. proc tixTree:SetBindings {w} {
  65.     upvar #0 $w data
  66.  
  67.     tixChainMethod $w SetBindings
  68. }
  69.  
  70. #----------------------------------------------------------------------
  71. #
  72. #            Widget commands
  73. #
  74. #----------------------------------------------------------------------
  75. proc tixTree:autosetmode {w} {
  76.     tixTree:SetModes $w ""
  77. }
  78.  
  79. proc tixTree:close {w ent} {
  80.     upvar #0 $w data
  81.  
  82.     set type [tixVTree:GetType $w $ent]
  83.     if {$type == "close"} {
  84.     tixCallMethod $w Activate $ent $type
  85.     }
  86. }
  87.  
  88. proc tixTree:open {w ent} {
  89.     upvar #0 $w data
  90.  
  91.     set type [tixVTree:GetType $w $ent]
  92.     if {$type == "open"} {
  93.     tixCallMethod $w Activate $ent $type
  94.     }
  95. }
  96.  
  97. proc tixTree:getmode {w ent} {
  98.     tixVTree:GetType $w $ent
  99. }
  100.  
  101. proc tixTree:setmode {w ent mode} {
  102.     tixVTree:SetMode $w $ent $mode
  103. }
  104. #----------------------------------------------------------------------
  105. #
  106. #            Private Methods
  107. #
  108. #----------------------------------------------------------------------
  109. proc tixTree:SetModes {w ent} {
  110.     upvar #0 $w data
  111.    
  112.     set mode none
  113.  
  114.     if {$ent == ""} {
  115.     set children [$data(w:hlist) info children]
  116.     } else {
  117.     set children [$data(w:hlist) info children $ent]
  118.     }
  119.  
  120.     if {$children != ""} {
  121.     set mode close
  122.  
  123.     foreach c $children {
  124.         if {[$data(w:hlist) info hidden $c]} {
  125.         set mode open
  126.         }
  127.         tixTree:SetModes $w $c
  128.     }
  129.     }
  130.     
  131.     if {$ent != ""} {
  132.     tixVTree:SetMode $w $ent $mode
  133.     }
  134. }
  135. #----------------------------------------------------------------------
  136. #
  137. #            Virtual Methods
  138. #
  139. #----------------------------------------------------------------------
  140. proc tixTree:OpenCmd {w ent} {
  141.     upvar #0 $w data
  142.  
  143.     if {$data(-opencmd) != ""} {
  144.     tixTree:CallSwitchCmd $w $data(-opencmd) $ent
  145.     } else {
  146.     tixChainMethod $w OpenCmd $ent
  147.  
  148.     }
  149. }
  150.  
  151. proc tixTree:CloseCmd {w ent} {
  152.     upvar #0 $w data
  153.  
  154.     if {$data(-closecmd) != ""} {
  155.     tixTree:CallSwitchCmd $w $data(-closecmd) $ent
  156.     } else {
  157.     tixChainMethod $w CloseCmd $ent
  158.     }
  159. }
  160.  
  161. # Call the opencmd or closecmd, depending on the mode ($cmd argument)
  162. #
  163. proc tixTree:CallSwitchCmd {w cmd ent} {
  164.     upvar #0 $w data
  165.  
  166.     set bind(specs) {%V}
  167.     set bind(%V)    $ent
  168.  
  169.     tixEvalCmdBinding $w $cmd bind $ent
  170. }
  171.  
  172. proc tixTree:Command {w B} {
  173.     upvar #0 $w data
  174.     upvar $B bind
  175.  
  176.     tixChainMethod $w Command $B
  177.  
  178.     set ent [tixEvent flag V]
  179.     if {$data(-command) != ""} {
  180.     tixEvalCmdBinding $w $data(-command) bind $ent
  181.     }
  182. }
  183.  
  184. proc tixTree:BrowseCmd {w B} {
  185.     upvar #0 $w data
  186.  
  187.     set ent [tixEvent flag V]
  188.     if {$data(-browsecmd) != ""} {
  189.     tixEvalCmdBinding $w $data(-browsecmd) "" $ent
  190.     }
  191. }
  192.