OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tix/] [library/] [Tree.tcl] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.