bug fix when adding new elements; must draw vertical lines above
authorca
Wed, 04 Jul 2001 10:35:29 +0200
changeset 1976 1788b0045176
parent 1975 bad9d0302b03
child 1977 e658f77f88b2
bug fix when adding new elements; must draw vertical lines above
HierarchicalListView.st
--- a/HierarchicalListView.st	Mon Jul 02 14:41:27 2001 +0200
+++ b/HierarchicalListView.st	Wed Jul 04 10:35:29 2001 +0200
@@ -462,11 +462,47 @@
         self invalidate:(Rectangle left:x0 top:y0 width:(x1 - x0) height:h) 
               repairNow:true.
     ]
+!
 
+listChangedInsert:firstAddedIndex nItems:nLines
+    "must draw vertical lines above the added items
+    "
+    |item prnt idx level yTop yBot xLft rec start maxY|
 
+    super listChangedInsert:firstAddedIndex nItems:nLines.
+
+    (     shown
+     and:[showLines
+     and:[firstAddedIndex > 1
+     and:[nLines ~~ 0
+     and:[(item := list at:firstAddedIndex ifAbsent:nil) notNil
+     and:[(level := item level) > 1]]]]]
+    ) ifFalse:[
+         ^ self.
+    ].
+    xLft := (self xOfFigureLevel:(level - 1)) + (imageWidth // 2) - 1.
 
+    (xLft > margin and:[xLft < (width - margin)]) ifFalse:[
+        ^ self
+    ].
+    start := firstAddedIndex - 1.
 
+    start to:1 by:-1 do:[:i| |el|
+        el := list at:i.
 
+        el level <= level ifTrue:[
+            i == start ifTrue:[^ self].
+
+            yTop := (self yVisibleOfLine:i + 1) max:margin.
+            maxY := height - margin.
+
+            yTop < maxY ifTrue:[
+                yBot := (self yVisibleOfLine:firstAddedIndex) - 1 min:maxY.
+                self invalidate:(Rectangle left:xLft top:yTop width:3 height:(yBot - yTop))
+            ].
+            ^ self
+        ]
+    ].
 !
 
 update:what with:aPara from:chgObj
@@ -1139,5 +1175,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.36 2001-01-09 17:36:48 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.37 2001-07-04 08:35:29 ca Exp $'
 ! !