support #hasConstantHeight for optimization
authorca
Wed, 09 Oct 2002 16:30:06 +0200
changeset 2262 30a159efe4b1
parent 2261 dd8a6eb74790
child 2263 e7648d72264f
support #hasConstantHeight for optimization
HierarchicalListView.st
--- a/HierarchicalListView.st	Wed Oct 09 16:29:33 2002 +0200
+++ b/HierarchicalListView.st	Wed Oct 09 16:30:06 2002 +0200
@@ -1159,23 +1159,26 @@
   ^ image
 !
 
-heightOfLineAt:aLineNr
-    "returns the total height for a line at an index, including
-     lineSpacing, the figure and the label
+heightOfItem:anItem
+    "returns the height of an item excluding lineSpacing ...
     "
-    |item icon height|
+    |image height|
 
-    item := list at:aLineNr ifAbsent:nil.
-    item isNil ifTrue:[^ 4].
+    height := anItem heightOn:self.
+    image := self figureFor:anItem.
 
-    height := item heightOn:self.
+    image ifNotNil:[
+        height := image height max:height.
+    ].
 
-    (icon := self figureFor:item) notNil ifTrue:[
-        height := (icon heightOn:self) max:height.
-    ].
-  ^ lineSpacing + height
-
-
+    hasConstantHeight ifTrue:[
+        icons size ~~ 0 ifTrue:[
+            icons do:[:anIcon| height := anIcon height max:height ]
+        ] ifFalse:[
+            image ifNil:[ height := height max:16 ]
+        ]
+    ].    
+    ^ height
 !
 
 indicatorLineAtX:x y:y
@@ -1413,5 +1416,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.51 2002-10-01 07:40:23 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.52 2002-10-09 14:30:06 ca Exp $'
 ! !