# HG changeset patch # User ca # Date 1036426372 -3600 # Node ID adc6843fbaa66cb15fdf729908064578ac569e98 # Parent c4610dae596e09bb155a93e1ec0ca5faba19fd30 prepared for ListItemRenderer diff -r c4610dae596e -r adc6843fbaa6 HierarchicalListView.st --- a/HierarchicalListView.st Mon Nov 04 17:10:50 2002 +0100 +++ b/HierarchicalListView.st Mon Nov 04 17:12:52 2002 +0100 @@ -14,14 +14,14 @@ "{ Package: 'stx:libwidg2' }" SelectionInListModelView subclass:#HierarchicalListView - instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines - showLeftIndicators indicatorAction useDefaultIcons icons - openIndicator closeIndicator alignTextRight alignTextRightX - maxWidthOfText minLineHeight levelOfLastItem expandOnSelect - autoScrollHorizontal' - classVariableNames:'' - poolDictionaries:'' - category:'Views-Trees' + instanceVariableNames:'imageInset imageWidth lineMask lineColor showRoot showLines + showLeftIndicators indicatorAction useDefaultIcons icons + openIndicator closeIndicator alignTextRight alignTextRightX + maxWidthOfText minLineHeight levelOfLastItem expandOnSelect + autoScrollHorizontal' + classVariableNames:'' + poolDictionaries:'' + category:'Views-Trees' ! !HierarchicalListView class methodsFor:'documentation'! @@ -601,7 +601,7 @@ (arg ~~ #redraw and:[widthOfContents notNil]) ifTrue:[ x0 := (self xVisibleOfTextAtLevel:(item level)) - + (item widthOn:self) + + (renderer widthFor:item) + (viewOrigin x). x0 > widthOfContents ifTrue:[ @@ -734,13 +734,6 @@ !HierarchicalListView methodsFor:'drawing basics'! -displayElement:anItem x:x y:y h:h - "draw a label at x/y; fg/bg colors are already set - " - anItem displayOn:self x:x y:y h:h - -! - drawElementsFrom:start to:stop x:xLeft y:yT w:w "draw the items between start to stop without clearing the background " @@ -1056,7 +1049,7 @@ list showRoot ifFalse:[ maxLevel := maxLevel - 1 ]. widthOfContents := widthOfContents + (maxLevel * needMore) ]. - width := anItem widthOn:self. + width := renderer widthFor:anItem. startOfText := self xVisibleOfTextAtLevel:(anItem level). widthOfContents := widthOfContents max:(startOfText + width). @@ -1066,7 +1059,7 @@ ]. self contentsChanged. StopRedrawSignal raise. - ^ icon + ^ icon ! ! !HierarchicalListView methodsFor:'event handling'! @@ -1241,28 +1234,6 @@ !HierarchicalListView methodsFor:'private'! -heightOfItem:anItem - "returns the height of an item excluding lineSpacing ... - " - |image height| - - height := anItem heightOn:self. - image := self iconFor:anItem. - - image notNil ifTrue:[ - height := image height max:height. - ]. - - hasConstantHeight ifTrue:[ - icons size ~~ 0 ifTrue:[ - icons do:[:anIcon| height := anIcon height max:height ] - ] ifFalse:[ - image isNil ifTrue:[ height := height max:16 ] - ] - ]. - ^ height max:minLineHeight -! - iconFor:anItem "returns an icon or image for the item or nil if the item provides no image and #useDefaultIcons is switched off. @@ -1301,6 +1272,29 @@ ^ icons at:#collapsed ifAbsentPut:[ self imageOnDevice:(self class collapsedIcon) ]. ! +lineHeightFor:anItem + "returns the computed line height for an item + " + |image height| + + height := renderer heightFor:anItem. + image := self iconFor:anItem. + + image notNil ifTrue:[ + height := image height max:height. + ]. + + hasConstantHeight ifTrue:[ + icons size ~~ 0 ifTrue:[ + icons do:[:anIcon| height := anIcon height max:height ] + ] ifFalse:[ + image isNil ifTrue:[ height := height max:16 ] + ] + ]. + height := height + lineSpacing. + ^ height max:minLineHeight +! + smallestLevelBetween:start and:stop "returns the smallest level of all items in a range " @@ -1360,7 +1354,7 @@ item := list at:idx ifAbsent:nil. item notNil ifTrue:[ - width := (item widthOn:self) max:width. + width := (renderer widthFor:item) max:width. nprnt := item parent. nprnt ~~ pprnt ifTrue:[ @@ -1398,7 +1392,7 @@ ] ]. pitem := item. - itemW := item widthOn:self. + itemW := renderer widthFor:item. maxWidthOfText := maxWidthOfText max:itemW. width := (itemW + textX) max:width ]. @@ -1459,7 +1453,7 @@ xLft := self xVisibleOfIconAtLevel:(level - 1). lvWidth := self parentToChildInset. - xRgt := (self xVisibleOfTextAtLevel:level) + (item widthOn:self). + xRgt := (self xVisibleOfTextAtLevel:level) + (renderer widthFor:item). xLft > lvWidth negated ifTrue:[ xRgt < width ifTrue:[^ vwOrgX] @@ -1468,7 +1462,7 @@ xInset := ((width - (xRgt - xLft) // 2) // lvWidth * lvWidth) max:0. vwOrgX := xLft + vwOrgX - xInset - margin. vwOrgX < lvWidth ifTrue:[^ 0 ]. - ^ vwOrgX + ^ vwOrgX ! makeLineVisible:aLnrNr @@ -1482,7 +1476,7 @@ aLnrNr <= 1 ifTrue:[ aLnrNr == 1 ifTrue:[ self scrollTo:(0 @ 0) ]. - ^ self + ^ self ]. item := list at:aLnrNr ifAbsent:nil. @@ -1491,7 +1485,7 @@ y0 := self yVisibleOfLine:aLnrNr. ( y0 < margin - or:[(y0 + (item heightOn:self)) > (height - margin)] + or:[(y0 + (renderer heightFor:item)) > (height - margin)] ) ifTrue:[ newY := ((self yAbsoluteOfLine:aLnrNr) - (height // 2)) max:0. ] ifFalse:[ @@ -1517,5 +1511,5 @@ !HierarchicalListView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.69 2002-11-04 14:37:13 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.70 2002-11-04 16:12:52 ca Exp $' ! !