f767df4e |
1 | ########################### |
2 | # # |
3 | # Version 1.4 # |
4 | # by SZV # |
5 | # # |
6 | ########################### |
7 | # |
8 | # Open : double-clic or + |
9 | # Close : double-clic or - |
10 | # Refresh tree : close top level and re-open |
11 | # |
12 | # Attributes: |
13 | # white : interoperable |
14 | # white + c : non interoperable |
15 | # X : X Reference |
16 | # Red : not yet commited in transaction #0 |
17 | # |
18 | # |
19 | |
20 | proc __update { args } { |
21 | } |
22 | |
23 | proc dftree { DDF_Browser } { |
24 | |
25 | global env |
26 | global DFTREE_WINDOWS |
27 | global DFTREE_GLOBALS |
28 | global $DDF_Browser |
29 | |
30 | puts $DDF_Browser |
31 | |
32 | package require Tk |
33 | |
34 | ## Create images |
35 | set DFTREE_GLOBALS(ImageLabel) [DFOpenImage dfb_folder.gif] |
36 | set DFTREE_GLOBALS(ImageAttrOther) [DFOpenImage dfb_attribute.gif] |
37 | set DFTREE_GLOBALS(ImageAttrNS) [DFOpenImage dfb_attribns.gif] |
38 | |
39 | ## set DFTREE_LabelStyle [tixDisplayStyle imagetext \ |
40 | ## -font 9x15bold \ |
41 | ## -background Bisque3 \ |
42 | ## ] |
43 | |
44 | ## set DFTREE_LabelStyle1 [tixDisplayStyle imagetext \ |
45 | ## -font 9x15bold \ |
46 | ## -background Bisque3 \ |
47 | ## -foreground SeaGreen2 \ |
48 | ## ] |
49 | |
50 | ## set DFTREE_AttributeStyle [tixDisplayStyle imagetext \ |
51 | ## -font 9x15 \ |
52 | ## -background Bisque3 \ |
53 | ## ] |
54 | |
55 | ## set DFTREE_AttributeStyle1 [tixDisplayStyle imagetext \ |
56 | ## -font 9x15 \ |
57 | ## -background Bisque3 \ |
58 | ## -foreground DarkGreen \ |
59 | ## ] |
60 | |
61 | ## set DFTREE_AttributeStyle2 [tixDisplayStyle imagetext \ |
62 | ## -font 9x15 \ |
63 | ## -background Bisque3 \ |
64 | ## -foreground Red \ |
65 | ## ] |
66 | |
67 | set w .$DDF_Browser |
68 | toplevel $w -height 400 -width 700 -background bisque3 |
69 | |
70 | ######## |
71 | # Tree # |
72 | ######## |
73 | |
74 | set tree1 [ttk::treeview $w.tree -show tree] |
75 | $tree1 tag bind Label <<TreeviewOpen>> [list DFTREE:Tree:Open $DDF_Browser $w] |
76 | $tree1 tag configure Label -font 9x15bold -foreground DarkGreen |
77 | #$tree1 tag configure Attribute -font 9x15 -background bisque3 |
78 | #$tree1 tag configure AttributeList -font 9x15 -background bisque3 |
79 | pack $tree1 -expand yes -fill both -padx 4 -pady 4 |
80 | |
81 | # to see different fonts: /usr/openwin/lib/X11/fonts/misc or xlsfonts? |
82 | # 8x13 8x13bold 9x15 9x15bold |
83 | # hlist.font 8x13bold |
84 | # hlist.gap "15" |
85 | # hlist.indent "30" |
86 | |
87 | set DFTREE_WINDOWS($w,tree) $tree1 |
88 | set DFTREE_WINDOWS($w,root) [$tree1 insert {} end \ |
89 | -text $DDF_Browser \ |
90 | -values "" \ |
91 | -tags Label] |
92 | |
93 | # Here we need to open first node! |
94 | |
95 | return |
96 | } |
97 | |
98 | ############################################################################### |
99 | # |
100 | # |
101 | proc DFTREE:Tree:Open { DDF_Browser w } { |
102 | |
103 | global DFTREE_WINDOWS |
104 | global DFTREE_GLOBALS |
105 | global $DDF_Browser |
106 | |
107 | set df_tree $DFTREE_WINDOWS($w,tree) |
108 | set df_node [$df_tree focus] |
109 | |
110 | #if {$df_node == $DFTREE_WINDOWS($w,root)} { |
111 | # This is root |
112 | set chdlist [$df_tree children $df_node] |
113 | if {$chdlist != {}} { |
114 | # The root branch already exists in hlist. |
115 | # Clear all its children to force the tree to be updated. |
116 | $df_tree delete $chdlist |
117 | } |
118 | #} |
119 | |
120 | #update |
121 | DFTREE:Tree:Fill $DDF_Browser $df_tree $df_node |
122 | return |
123 | } |
124 | |
125 | ############################################################################### |
126 | # |
127 | # |
128 | proc DFTREE:Tree:Fill { DDF_Browser df_tree df_node } { |
129 | |
130 | global DFTREE_GLOBALS |
131 | global $DDF_Browser |
132 | |
133 | set loc [lindex [$df_tree item $df_node -values] 0] |
134 | set type [lindex [$df_tree item $df_node -tags] 0] |
135 | |
136 | switch -glob $type { |
137 | |
138 | Label { |
139 | DFTREE:Tree:UpdateLabel $DDF_Browser $df_tree $df_node $loc |
140 | } |
141 | |
142 | #AttributeList { |
143 | # DFTREE:Tree:UpdateAttributeList $DDF_Browser $df_tree $df_node $loc |
144 | #} |
145 | |
146 | default { |
147 | } |
148 | } |
149 | return |
150 | } |
151 | |
152 | ############################################################################### |
153 | # $df_entry is a label entry, "1:3:2" for example, or "" for root. |
154 | # |
155 | proc DFTREE:Tree:UpdateLabel { DDF_Browser df_tree df_node df_entry } { |
156 | |
157 | global DFTREE_GLOBALS |
158 | global $DDF_Browser |
159 | |
160 | foreach fullname [split [DFOpenLabel $DDF_Browser $df_entry] "\\" ] { |
161 | FCTREE:Tree:DecodeLabelItem $DDF_Browser $df_tree $df_node $df_entry $fullname |
162 | } |
163 | return |
164 | } |
165 | |
166 | ############################################################################### |
167 | # |
168 | # |
169 | proc DFTREE:Tree:UpdateAttributeList { DDF_Browser df_tree df_node df_entry} { |
170 | |
171 | global DFTREE_GLOBALS |
172 | global $DDF_Browser |
173 | |
174 | set image_other $DFTREE_GLOBALS(ImageAttrOther) |
175 | set image_ns $DFTREE_GLOBALS(ImageAttrNS) |
176 | #set xrefimage $DFTREE_GLOBALS(ImageAttrOther) |
177 | |
178 | # abv: index attributes |
179 | set num 0 |
180 | set attributes [split [DFOpenAttributeList $DDF_Browser $df_entry ] "\\" ] |
181 | set iattributes {} |
182 | foreach fullname $attributes { |
183 | set num [expr $num + 1] |
184 | lappend fullname $num |
185 | lappend iattributes $fullname |
186 | } |
187 | |
188 | foreach fullname [lsort $iattributes] { |
189 | |
190 | # Information first split |
191 | set tmplist [split $fullname " "] |
192 | set name [lindex $tmplist 0] |
193 | set transaction [lindex $tmplist 1] |
194 | set valid [lindex $tmplist 2] |
195 | set forgotten [lindex $tmplist 3] |
196 | set backuped [lindex $tmplist 4] |
197 | set maybeopen [lindex $tmplist 5] |
198 | |
199 | # Name analysis to suppress the map address. |
200 | set shortlist [split $name "#"] |
201 | set shortname [lindex $shortlist 0] |
202 | set index [lindex $shortlist 1] |
203 | |
204 | # Package analysis to determine the icon type. |
205 | #set pk [lindex [split $name _] 0] |
206 | set node_img $image_other |
207 | #if {$pk == "TDataStd" || $pk == "TNaming"} {set node_img $standardimage} |
208 | #if {$pk == "TXRef"} {set node_img $xrefimage} |
209 | if {$shortname == "TNaming_NamedShape"} {set node_img $image_ns} |
210 | |
211 | set textname "$shortname" |
212 | |
213 | # if { [llength $tmplist] >5 } { set textname [lindex $tmplist 5] } |
214 | set textname "$textname [DFGetAttributeValue $DDF_Browser $df_entry [lindex $tmplist 6]]" |
215 | |
216 | # Transaction analysis |
217 | if {$transaction == "0"} { |
218 | # set locstyle $DFTREE_AttributeStyle |
219 | } else { |
220 | # set textname "$textname T=$transaction" |
221 | # set locstyle $DFTREE_AttributeStyle1 |
222 | } |
223 | |
224 | # Valid? |
225 | if {$valid == "NotValid"} {set textname "$textname $valid"} |
226 | |
227 | # Forgotten? |
228 | if {$forgotten == "Forgotten"} {set textname "$textname $forgotten"} |
229 | |
230 | # Backuped? |
231 | if {$backuped == "Backuped"} {set textname "$textname $backuped"} |
232 | |
233 | set df_new [$df_tree insert $df_node end \ |
234 | -text $textname -image $node_img -tags Attribute] |
235 | |
236 | if {$maybeopen == "1"} { |
237 | $df_tree item $df_new -open true |
238 | DFTREE:Tree:UpdateAttribute $DDF_Browser $df_tree $df_new $index |
239 | } |
240 | } |
241 | } |
242 | |
243 | ############################################################################### |
244 | # $loc is always the attribute index |
245 | # |
246 | proc DFTREE:Tree:UpdateAttribute { DDF_Browser df_tree df_node a_index } { |
247 | |
248 | global DFTREE_GLOBALS |
249 | global $DDF_Browser |
250 | |
251 | set tmplist [split [DFOpenAttribute $DDF_Browser $a_index ] "\\"] |
252 | |
253 | # Failed or not? |
254 | if {[lindex $tmplist 0] == "Failed"} { |
255 | ## set locstyle $DFTREE_AttributeStyle2 |
256 | } else { |
257 | ## set locstyle $DFTREE_AttributeStyle |
258 | } |
259 | |
260 | foreach name $tmplist { |
261 | $df_tree insert $df_node end -text $name -tags Terminal |
262 | } |
263 | return |
264 | } |
265 | |
266 | ############################################################################### |
267 | # item: |
268 | # "Entry Name=TheNameIfExists Modified|NotModified 0|1" |
269 | proc FCTREE:Tree:DecodeLabelItem { DDF_Browser df_tree df_node df_entry labelItem} { |
270 | |
271 | global DFTREE_GLOBALS |
272 | global $DDF_Browser |
273 | |
274 | set tmplist [split $labelItem " " ] |
275 | set labname [lindex $tmplist 0] |
276 | |
277 | set textname "$labname" |
278 | |
279 | if {$labname == "AttributeList"} { |
280 | |
281 | # Attribute List |
282 | # -------------- |
283 | |
284 | #set modified [lindex $tmplist 1] |
285 | |
286 | # Modified or not? |
287 | #if {$modified == "Modified"} { |
288 | # set textname "$textname $modified" |
289 | ## set locstyle $DFTREE_AttributeStyle1 |
290 | #} else { |
291 | ## set locstyle $DFTREE_AttributeStyle |
292 | #} |
293 | |
294 | #set df_new [$df_tree insert $df_node end \ |
295 | # -text $textname \ |
296 | # -image $DFTREE_GLOBALS(ImageAttrList) \ |
297 | # -tags AttributeList] |
298 | |
299 | #$df_tree item $df_new -open true |
300 | |
301 | DFTREE:Tree:UpdateAttributeList $DDF_Browser $df_tree $df_node $df_entry |
302 | |
303 | } else { |
304 | |
305 | # Sub-label(s) |
306 | # ------------ |
307 | |
308 | set name [lindex $tmplist 1] |
309 | set modified [lindex $tmplist 2] |
310 | set maybeopen [lindex $tmplist 3] |
311 | |
312 | # Name? |
313 | set ll [expr [string length $name] -2] |
314 | if {$ll > 0} { |
315 | set textname "$textname [string range $name 1 $ll]" |
316 | } |
317 | |
318 | # Modified or not? |
319 | if {$modified == "Modified"} { |
320 | set textname "$textname $modified" |
321 | } |
322 | |
323 | set df_new [$df_tree insert $df_node end \ |
324 | -text $textname \ |
325 | -image $DFTREE_GLOBALS(ImageLabel) \ |
326 | -values $labname \ |
327 | -tags Label] |
328 | |
329 | if {$maybeopen == "1"} { |
330 | $df_tree item $df_new -open true |
331 | } |
332 | |
333 | DFTREE:Tree:UpdateLabel $DDF_Browser $df_tree $df_new $labname |
334 | } |
335 | } |
336 | |
337 | ############################################################################### |
338 | # |
339 | # |
340 | proc DFGetAttributeValue { DDF_Browser lab index } { |
341 | |
342 | global $DDF_Browser; # necessary for DRAW command to see the browser |
343 | |
344 | if {[catch "XAttributeValue $DDF_Browser $lab $index" ret]} { |
345 | return "" |
346 | } |
347 | if {"$ret" == ""} { return "" } |
348 | return "\[$ret\]" |
349 | } |
350 | |
351 | ############################################################################### |
352 | # |
353 | # |
354 | proc DFOpenImage { img } { |
355 | |
356 | global env |
357 | |
358 | if {[catch "image create photo -file $env(DRAWHOME)/$img" ret]} { |
359 | return "" |
360 | } |
361 | return $ret |
362 | } |