HierarchicalListView.st
changeset 1897 5609f92e6d4a
parent 1843 61595a6b2e37
child 1898 4239a343dbe6
--- a/HierarchicalListView.st	Fri Dec 01 16:35:16 2000 +0100
+++ b/HierarchicalListView.st	Wed Dec 06 18:45:52 2000 +0100
@@ -190,6 +190,12 @@
         showRoot := aList showRoot
     ].
     super list:aList
+!
+
+parentToChildInset
+    "returns the computed inset between parent / child
+    "
+    ^ imageInset + imageWidth
 ! !
 
 !HierarchicalListView methodsFor:'accessing-colors'!
@@ -559,15 +565,16 @@
      begHLnX  "{ Class:SmallInteger }"
      endHLnX  "{ Class:SmallInteger }"
 
-     widthLvl "{ Class:SmallInteger }"
-     offsHLnX "{ Class:SmallInteger }"
+     widthLvl  "{ Class:SmallInteger }"
+     offsHLnX  "{ Class:SmallInteger }"
 
-     level    "{ Class:SmallInteger }"
-     startLvI "{ Class:SmallInteger }"
-     startLvX "{ Class:SmallInteger }"
-     limitLvI "{ Class:SmallInteger }"
-     limitLvX "{ Class:SmallInteger }"
-     imgHWdt  "{ Class:SmallInteger }"
+     level     "{ Class:SmallInteger }"
+     startLvI  "{ Class:SmallInteger }"
+     startLvX  "{ Class:SmallInteger }"
+     limitLvI  "{ Class:SmallInteger }"
+     limitLvX  "{ Class:SmallInteger }"
+     imgHWdt   "{ Class:SmallInteger }"
+     minXVLine "{ Class:SmallInteger }"
     |
     imgHWdt  := imageWidth // 2.
     widthLvl := imageInset + imageWidth.
@@ -584,6 +591,12 @@
     limitLvI := 2.
     limitLvX := limitLvI * widthLvl + offsHLnX.
 
+    showRoot ifFalse:[
+        minXVLine := (self xOfFigureLevel:2) - 2.       "/ tolerance
+    ] ifTrue:[
+        minXVLine := 0
+    ].
+
     showRootNot  := showRoot not.
     yBot         := yT.
     begHLnY      := runHLnY := yT.
@@ -635,7 +648,11 @@
                 item hasChildren ifTrue:[
                     p1 := endHLnX.
                 ] ifFalse:[
-                    p1 := begHLnX + imgHWdt
+                    (showRoot not and:[item parent isRootItem]) ifTrue:[
+                        p1 := xL - 1    "/ do not draw the horizontal line
+                    ] ifFalse:[
+                        p1 := begHLnX + imgHWdt
+                    ]
                 ]
             ].
             xL < p1 ifTrue:[
@@ -648,12 +665,17 @@
             x  := begHLnX.
             p2 := parent.
             lv := level - 1.
-            self displayLineFromX:x y:runHLnY toX:x y:y.
+
+            x >= minXVLine ifTrue:[
+                self displayLineFromX:x y:runHLnY toX:x y:y.
+            ].
 
             [((p1 := p2 parent) notNil and:[(x := x - widthLvl) >= limitLvX])] whileTrue:[
                 (p1 last ~~ p2 and:[x <= xR]) ifTrue:[
                     x >= startLvX ifTrue:[
-                        self displayLineFromX:x y:(yTop - 1) toX:x y:yBot
+                        x >= minXVLine ifTrue:[
+                            self displayLineFromX:x y:(yTop - 1) toX:x y:yBot
+                        ]
                     ] ifFalse:[
                         buildInArray isNil ifTrue:[buildInArray := Array new:startLvI].
                         buildInArray at:lv put:yBot
@@ -670,8 +692,10 @@
     "/
     "/ draw outstanding verical lines to left
     "/
+    x := minXVLine max:xL.
+
     (item isExpanded and:[item hasChildren]) ifTrue:[
-        (endHLnX >= xL and:[endHLnX <= xR]) ifTrue:[
+        (endHLnX >= x and:[endHLnX <= xR]) ifTrue:[
             self displayLineFromX:endHLnX y:yCtr toX:endHLnX y:yBot.
         ]
     ].
@@ -684,13 +708,14 @@
             |yB|
 
             (yB := buildInArray at:i) notNil ifTrue:[
-                self displayLineFromX:x y:y toX:x y:yB
+                x >= minXVLine ifTrue:[
+                    self displayLineFromX:x y:y toX:x y:yB
+                ]
             ].
             x := x + widthLvl.
         ]
     ].
     self mask:nil.
-
 ! !
 
 !HierarchicalListView methodsFor:'event handling'!
@@ -1040,5 +1065,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.32 2000-09-19 08:45:49 martin Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.33 2000-12-06 17:45:52 ca Exp $'
 ! !