ListModelView.st
changeset 2852 c5651fcf9770
parent 2745 5986c83276b1
child 2866 01d609cfb3d9
equal deleted inserted replaced
2851:fa192ee81bb5 2852:c5651fcf9770
    12 
    12 
    13 
    13 
    14 "{ Package: 'stx:libwidg2' }"
    14 "{ Package: 'stx:libwidg2' }"
    15 
    15 
    16 View subclass:#ListModelView
    16 View subclass:#ListModelView
    17 	instanceVariableNames:'list listHolder textStartLeft viewOrigin enabled fgColor bgColor
    17 	instanceVariableNames:'list listHolder textStartLeft textStartTop viewOrigin enabled
    18 		lineSpacing widthOfContents computeWidthInRange startOfLinesY
    18 		fgColor bgColor lineSpacing widthOfContents computeWidthInRange
    19 		autoScroll autoScrollBlock scrollWhenUpdating hasConstantHeight
    19 		startOfLinesY autoScroll autoScrollBlock scrollWhenUpdating
    20 		constantHeight previousExtent renderer'
    20 		hasConstantHeight constantHeight previousExtent renderer'
    21 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor
    21 	classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor
    22 		DefaultLightColor StopRedrawSignal'
    22 		DefaultLightColor StopRedrawSignal'
    23 	poolDictionaries:''
    23 	poolDictionaries:''
    24 	category:'Views-Lists'
    24 	category:'Views-Lists'
    25 !
    25 !
   199         list addDependent:self
   199         list addDependent:self
   200     ].
   200     ].
   201     preferredExtent := nil.
   201     preferredExtent := nil.
   202     widthOfContents := nil.
   202     widthOfContents := nil.
   203 
   203 
   204     self realized ifFalse:[^ self].
   204     realized ifTrue:[
   205 
   205         self recomputeHeightOfContents.
   206     self recomputeHeightOfContents.
   206         scrollWhenUpdating == #beginOfText ifTrue:[
   207 
   207             viewOrigin = (0@0) ifFalse:[
   208 
   208                 self originWillChange.
   209     scrollWhenUpdating == #beginOfText ifTrue:[
   209                 negatedOrg := viewOrigin negated.
   210         viewOrigin = (0@0) ifFalse:[
   210                 viewOrigin := (0@0).
   211             self originWillChange.
   211                 self originChanged:negatedOrg.
   212             negatedOrg := viewOrigin negated.
   212             ].
   213             viewOrigin := (0@0).
   213         ] ifFalse:[
   214             self originChanged:negatedOrg.
   214             scrollWhenUpdating == #endOfText ifTrue:[
   215         ].
   215                 self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false
   216     ] ifFalse:[
   216             ]
   217         scrollWhenUpdating == #endOfText ifTrue:[
   217         ].
   218             self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false
   218         self invalidate.
   219         ]
   219     ].
   220     ].
       
   221 
       
   222     self invalidate.
       
   223     self contentsChanged
   220     self contentsChanged
   224 !
   221 !
   225 
   222 
   226 renderer
   223 renderer
   227     "returns the used renderer
   224     "returns the used renderer
   273 
   270 
   274 
   271 
   275 !
   272 !
   276 
   273 
   277 hasConstantHeight
   274 hasConstantHeight
   278     "user configured; true if each line has the same lineHeight
   275     "user configured; true if each line has the same lineHeight.
   279      optimize for scroller update
   276      Optimizes scroll and redraw operations
   280     "
   277     "
       
   278 
   281     ^ hasConstantHeight
   279     ^ hasConstantHeight
   282 !
   280 !
   283 
   281 
   284 hasConstantHeight:aBool
   282 hasConstantHeight:aBool
   285     "user configured; true if each line has the same lineHeight
   283     "user configured; true if each line has the same lineHeight.
   286      optimize for scroller update
   284      Optimizes scrolling and redraw.
   287     "
   285     "
       
   286 
   288     aBool == hasConstantHeight ifTrue:[
   287     aBool == hasConstantHeight ifTrue:[
   289 	^ self
   288         ^ self
   290     ].
   289     ].
   291     constantHeight    := nil.
   290     constantHeight    := nil.
   292     hasConstantHeight := aBool.
   291     hasConstantHeight := aBool.
   293 
   292 
   294     self lostSynchronisation.
   293     self lostSynchronisation.
   369 
   368 
   370         (font widthOn:device) ~~ oldWidth ifTrue:[       "/ force a recomputation
   369         (font widthOn:device) ~~ oldWidth ifTrue:[       "/ force a recomputation
   371             preferredExtent := nil.
   370             preferredExtent := nil.
   372             widthOfContents := nil.
   371             widthOfContents := nil.
   373         ].
   372         ].
   374         oldHeight ~~ (font heightOn:device) ifTrue:[
   373         realized ifTrue:[
   375             self recomputeHeightOfContents.
   374             oldHeight ~~ (font heightOn:device) ifTrue:[
   376         ].
   375                 self recomputeHeightOfContents.
   377         self invalidate
   376             ].
       
   377             self invalidate
       
   378         ].
   378     ].
   379     ].
   379 !
   380 !
   380 
   381 
   381 foregroundColor
   382 foregroundColor
   382     "get the foreground color
   383     "get the foreground color
   410      by which lines are vertically separated.
   411      by which lines are vertically separated.
   411     "
   412     "
   412     lineSpacing ~= aNumber ifTrue:[
   413     lineSpacing ~= aNumber ifTrue:[
   413         lineSpacing := aNumber.
   414         lineSpacing := aNumber.
   414 
   415 
   415         self recomputeHeightOfContents.
   416         realized ifTrue:[
   416         self invalidate
   417             self recomputeHeightOfContents.
       
   418             self invalidate
       
   419         ]
   417     ]
   420     ]
   418 !
   421 !
   419 
   422 
   420 viewBackground:aColor
   423 viewBackground:aColor
   421     "set the background color
   424     "set the background color
   455 lineChangedAt:aLnNr with:arg
   458 lineChangedAt:aLnNr with:arg
   456     "line changed at position; check whether line height changed"
   459     "line changed at position; check whether line height changed"
   457 
   460 
   458     |cache
   461     |cache
   459      oldHeight "{ Class:SmallInteger }"
   462      oldHeight "{ Class:SmallInteger }"
   460      dltHeight "{ Class:SmallInteger }" |
   463      deltaHeight "{ Class:SmallInteger }" |
   461 
   464 
   462     (arg == #icon or:[arg == #hierarchy]) ifTrue:[
   465     (arg == #icon or:[arg == #hierarchy]) ifTrue:[
   463         ^ self
   466         ^ self
   464     ].
   467     ].
   465     hasConstantHeight ifTrue:[
   468     hasConstantHeight ifTrue:[
   466         self invalidateLineAt:aLnNr.
   469         self invalidateLineAt:aLnNr.
   467         ^ self
   470         ^ self
   468     ].
   471     ].
   469 
   472 
   470     oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr).
   473     oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr).
   471     dltHeight := (self heightOfLineAt:aLnNr) - oldHeight.
   474     deltaHeight := (self heightOfLineAt:aLnNr) - oldHeight.
   472 
   475 
   473     dltHeight == 0 ifTrue:[
   476     deltaHeight == 0 ifTrue:[
   474         self invalidateLineAt:aLnNr.
   477         self invalidateLineAt:aLnNr.
   475         ^ self
   478         ^ self
   476     ].
   479     ].
   477     cache := self startOfLinesY.
   480     cache := self startOfLinesY.
   478 
   481 
   479     aLnNr + 1 to:cache size do:[:i|
   482     aLnNr + 1 to:cache size do:[:i|
   480         cache at:i put:((cache at:i) + dltHeight)
   483         cache at:i put:((cache at:i) + deltaHeight)
   481     ].
   484     ].
   482     self invalidate.
   485     self invalidate.
   483 !
   486 !
   484 
   487 
   485 listChangedInsert:start nItems:nLines
   488 listChangedInsert:start nItems:nLines
   504 
   507 
   505     newSz := startOfLinesY size + nLines.
   508     newSz := startOfLinesY size + nLines.
   506 
   509 
   507     (newSz - 1) ~~ self size ifTrue:[
   510     (newSz - 1) ~~ self size ifTrue:[
   508         "/
   511         "/
   509         "/ no longer synchrounous
   512         "/ no longer synchronized
   510         "/
   513         "/
   511         ^ self lostSynchronisation
   514         ^ self lostSynchronisation
   512     ].
   515     ].
   513     newLines := startOfLinesY copy.
   516     newLines := startOfLinesY copy.
   514     newLines addAll:(Array new:nLines) beforeIndex:start + 1.
   517     newLines addAll:(Array new:nLines) beforeIndex:start + 1.
   701     ].
   704     ].
   702 
   705 
   703     super update:what with:aPara from:chgObj
   706     super update:what with:aPara from:chgObj
   704 !
   707 !
   705 
   708 
   706 updateFromList:what with:aPara
   709 updateFromList:what with:aParameter
   707     "called if the list changed
   710     "called if the list changed"
   708     "
   711 
   709     |arg1 arg2|
   712     |arg1 arg2|
   710 
   713 
   711     aPara isCollection ifFalse:[
   714     aParameter isCollection ifFalse:[
   712         what == #at:     ifTrue:[self lineChangedAt:aPara        with:nil.   ^ self].
   715         what == #at:     ifTrue:[self lineChangedAt:aParameter        with:nil.   ^ self].
   713         what == #insert: ifTrue:[self listChangedInsert:aPara  nItems:1.     ^ self].
   716         what == #insert: ifTrue:[self listChangedInsert:aParameter  nItems:1.     ^ self].
   714         what == #remove: ifTrue:[self listChangedRemove:aPara toIndex:aPara. ^ self].
   717         what == #remove: ifTrue:[self listChangedRemove:aParameter toIndex:aParameter. ^ self].
   715       ^ self.
   718         self halt.
   716     ].
   719         self list:(self list).  "/ reload list
   717 
   720         ^ self.
   718     arg1 := aPara at:1.
   721     ].
   719     arg2 := aPara at:2.
   722 
       
   723     arg1 := aParameter at:1.
       
   724     arg2 := aParameter at:2.
   720 
   725 
   721     (arg1 == 1 and:[arg2 == self size]) ifTrue:[
   726     (arg1 == 1 and:[arg2 == self size]) ifTrue:[
   722         self list:(self list).  "/ reload list
   727         self list:(self list).  "/ reload list
   723       ^ self
   728         ^ self
   724     ].
   729     ].
   725 
   730 
   726     what == #at:               ifTrue:[self lineChangedAt:arg1        with:arg2. ^ self].
   731     what == #at:               ifTrue:[self lineChangedAt:arg1        with:arg2. ^ self].
   727     what == #insertCollection: ifTrue:[self listChangedInsert:arg1  nItems:arg2. ^ self].
   732     what == #insertCollection: ifTrue:[self listChangedInsert:arg1  nItems:arg2. ^ self].
   728     what == #removeFrom:       ifTrue:[self listChangedRemove:arg1 toIndex:arg2. ^ self].
   733     what == #removeFrom:       ifTrue:[self listChangedRemove:arg1 toIndex:arg2. ^ self].
   729 
   734 
   730     what == #replace: ifTrue:[
   735     what == #replace: ifTrue:[
   731         arg1 to:arg2 do:[:i|self lineChangedAt:i with:nil].
   736         arg1 to:arg2 do:[:i|self lineChangedAt:i with:nil].
   732       ^ self
   737         ^ self
   733     ].
   738     ].
       
   739     self halt.
       
   740     self list:(self list).  "/ reload list
   734 ! !
   741 ! !
   735 
   742 
   736 !ListModelView methodsFor:'drawing'!
   743 !ListModelView methodsFor:'drawing'!
   737 
   744 
   738 drawElementsFrom:start to:stop x:x y:y w:w
   745 drawElementsFrom:start to:stop x:x y:y w:w
   838     "
   845     "
   839     |start stop yAbs yStart|
   846     |start stop yAbs yStart|
   840 
   847 
   841     shown ifFalse:[^ self].
   848     shown ifFalse:[^ self].
   842 
   849 
   843     (self startOfLinesY size == 1 and:[self size > 1]) ifTrue:[
   850     (self startOfLinesY size) == (self size + 1) ifFalse:[
   844         "oops, recompute the height of the contents (the first time after creation).
   851         "oops, recompute the height of the contents (the first time after creation).
   845         "
   852         "
   846         self recomputeHeightOfContents.
   853         self recomputeHeightOfContents.
   847 
   854 
   848         self startOfLinesY size > 1 ifTrue:[
   855         self startOfLinesY size > 1 ifTrue:[
  1018     DefaultBackgroundColor notNil ifTrue:[
  1025     DefaultBackgroundColor notNil ifTrue:[
  1019         viewBackground := DefaultBackgroundColor
  1026         viewBackground := DefaultBackgroundColor
  1020     ].
  1027     ].
  1021     lineSpacing   := 0.
  1028     lineSpacing   := 0.
  1022     textStartLeft := 2.
  1029     textStartLeft := 2.
       
  1030     textStartTop  := 2.
  1023     fgColor       := DefaultForegroundColor.
  1031     fgColor       := DefaultForegroundColor.
  1024     bgColor       := viewBackground.
  1032     bgColor       := viewBackground.
  1025     startOfLinesY := OrderedCollection new.
  1033     startOfLinesY := OrderedCollection new.
  1026 
  1034 
  1027     startOfLinesY add:(2 + margin). "/ top inset of first line
  1035     startOfLinesY add:(textStartTop + margin). "/ top inset of first line
  1028 
  1036 
  1029     DefaultShadowColor notNil ifTrue:[
  1037     DefaultShadowColor notNil ifTrue:[
  1030         shadowColor := DefaultShadowColor
  1038         shadowColor := DefaultShadowColor
  1031     ].
  1039     ].
  1032 
  1040 
  1054 !
  1062 !
  1055 
  1063 
  1056 mapped
  1064 mapped
  1057     "recompute list
  1065     "recompute list
  1058     "
  1066     "
  1059     shown ifFalse:[
  1067     "/ shown ifFalse:[
  1060         self recomputeHeightOfContents.
  1068         self recomputeHeightOfContents.
  1061         self contentsChanged.
  1069         self contentsChanged.
  1062     ].
  1070     "/ ].
  1063     renderer mapped.
  1071     renderer mapped.
  1064     super mapped
  1072     super mapped
  1065 !
  1073 !
  1066 
  1074 
  1067 recreate
  1075 recreate
  1098 
  1106 
  1099     ^ self sensor hasDamageFor:self
  1107     ^ self sensor hasDamageFor:self
  1100 !
  1108 !
  1101 
  1109 
  1102 startOfLinesY
  1110 startOfLinesY
  1103     "returns a sequencable list which keeps all the absolute Y-start positions
  1111     "returns a collection of absolute Y-positions per line. 
  1104      for each line into the list. The first entry is the top Y inset.
  1112      The first entry is the top Y inset.
  1105     "
  1113      The size of the list is one more than the lists size,
       
  1114      providing the Y-position of the line below the contents as its last entry."
       
  1115 
  1106     ^ startOfLinesY
  1116     ^ startOfLinesY
  1107 !
  1117 !
  1108 
  1118 
  1109 xAbsoluteOfItem:anItem
  1119 xAbsoluteOfItem:anItem
  1110     "returns the absolute x of the labeled text
  1120     "returns the absolute x of the labeled text
  1128     (y := cash at:aLineNr ifAbsent:nil) notNil ifTrue:[
  1138     (y := cash at:aLineNr ifAbsent:nil) notNil ifTrue:[
  1129         ^ y
  1139         ^ y
  1130     ].
  1140     ].
  1131 
  1141 
  1132     "/ recompute a y position
  1142     "/ recompute a y position
  1133     y1 := cash at:1 ifAbsent:2.
  1143     y1 := cash at:1 ifAbsent:textStartTop.
  1134     y2 := cash at:2 ifAbsent:10.
  1144     y2 := cash at:2 ifAbsent:(textStartTop + 16).
  1135   ^ aLineNr * (y2 - y1) + y1
  1145     ^ aLineNr * (y2 - y1) + y1
  1136 !
  1146 !
  1137 
  1147 
  1138 yVisibleOfLine:aLineNr
  1148 yVisibleOfLine:aLineNr
  1139     "given a lineNr, return y-coordinate in view
  1149     "given a lineNr, return y-coordinate in view
  1140     "
  1150     "
  1142 
  1152 
  1143 
  1153 
  1144 !
  1154 !
  1145 
  1155 
  1146 yVisibleToLineNr:yVisible
  1156 yVisibleToLineNr:yVisible
  1147     "returns the line number assigned to a physical y or nil if out of list
  1157     "returns the line number for a given physical y coordinate
  1148     "
  1158      or nil if beyond of list.
  1149     |cash
  1159     "
       
  1160 
       
  1161     |cache
  1150      yAbs       "{ Class: SmallInteger}"
  1162      yAbs       "{ Class: SmallInteger}"
  1151      size       "{ Class: SmallInteger}"
  1163      size       "{ Class: SmallInteger}"
  1152      ictr       "{ Class: SmallInteger}"
  1164      ictr       "{ Class: SmallInteger}"
  1153      yRun       "{ Class: SmallInteger}"
  1165      yRun       "{ Class: SmallInteger}"
  1154     |
  1166     |
  1155     cash := self startOfLinesY.
       
  1156 
       
  1157     (size := cash size) < 2 ifTrue:[^ nil].   "/ empty list
       
  1158 
  1167 
  1159     yAbs := yVisible + viewOrigin y.
  1168     yAbs := yVisible + viewOrigin y.
  1160     yRun := cash at:size.
  1169     cache := self startOfLinesY.
       
  1170 
       
  1171     (size := cache size) < 2 ifTrue:[
       
  1172         "/ empty list
       
  1173         (yAbs between:textStartTop and:textStartTop+16) ifTrue:[^ 1].
       
  1174         ^ nil
       
  1175     ].   
       
  1176 
       
  1177     yRun := cache at:size.
  1161 
  1178 
  1162     yAbs >= yRun ifTrue:[
  1179     yAbs >= yRun ifTrue:[
  1163         yAbs == yRun ifTrue:[ ^ size - 1].
  1180         yAbs == yRun ifTrue:[ ^ size - 1].
  1164       ^ nil   "/ out of list
  1181         ^ nil   "/ out of list
  1165     ].
  1182     ].
  1166 
  1183 
  1167     constantHeight notNil ifTrue:[
  1184     constantHeight notNil ifTrue:[
  1168         yAbs := yAbs - (cash at:1).
  1185         yAbs := yAbs - (cache at:1).
  1169         yAbs < constantHeight ifTrue:[ ^ 1 ].
  1186         yAbs < constantHeight ifTrue:[ ^ 1 ].
  1170       ^ yAbs // constantHeight + 1
  1187         ^ yAbs // constantHeight + 1
  1171     ].
  1188     ].
  1172 
  1189 
  1173     ictr := yAbs // (cash at:2).
  1190     ictr := yAbs // (cache at:2).
  1174     ictr < 1 ifTrue:[ ictr := 1 ]
  1191     ictr < 1 ifTrue:[ ictr := 1 ]
  1175             ifFalse:[ ictr := ictr min:size ].
  1192             ifFalse:[ ictr := ictr min:size ].
  1176 
  1193 
  1177     yRun := cash at:ictr.
  1194     yRun := cache at:ictr.
  1178 
  1195 
  1179     yRun > yAbs ifTrue:[
  1196     yRun > yAbs ifTrue:[
  1180         [(ictr := ictr - 1) > 0 ] whileTrue:[
  1197         [(ictr := ictr - 1) > 0 ] whileTrue:[
  1181             yRun := cash at:ictr.
  1198             yRun := cache at:ictr.
  1182             yRun <= yAbs ifTrue:[ ^ ictr ].
  1199             yRun <= yAbs ifTrue:[ ^ ictr ].
  1183         ].
  1200         ].
  1184         ^ 1
  1201         ^ 1
  1185     ].
  1202     ].
  1186 
  1203 
  1187     [ yRun ~~ yAbs ] whileTrue:[
  1204     [ yRun ~~ yAbs ] whileTrue:[
  1188         ictr := ictr + 1.
  1205         ictr := ictr + 1.
  1189         yRun := cash at:ictr.
  1206         yRun := cache at:ictr.
  1190         yRun > yAbs ifTrue:[ ^ ictr - 1 ].
  1207         yRun > yAbs ifTrue:[ ^ ictr - 1 ].
  1191     ].
  1208     ].
  1192     ^ ictr
  1209     ^ ictr
  1193 !
  1210 !
  1194 
  1211 
  1325 
  1342 
  1326 recomputeHeightOfContents
  1343 recomputeHeightOfContents
  1327     "recompute all the y positions
  1344     "recompute all the y positions
  1328     "
  1345     "
  1329     |newList
  1346     |newList
  1330      yAbs "{ Class: SmallInteger }"
  1347      yAbs "{ Class: SmallInteger }" 
  1331      lnHg "{ Class: SmallInteger }"
  1348      size "{ Class: SmallInteger }"|
  1332      size "{ Class: SmallInteger }"
  1349 
  1333     |
  1350     yAbs    := (textStartTop + margin).   "/ top inset of first line
  1334 
       
  1335     yAbs    := startOfLinesY at:1.   "/ top inset of first line
       
  1336     size    := self size.
  1351     size    := self size.
  1337     newList := OrderedCollection new:(size + 1).
  1352     newList := OrderedCollection new:(size + 1).
  1338 
       
  1339     newList add:yAbs.
  1353     newList add:yAbs.
  1340 
  1354 
  1341     size == 0 ifTrue:[
  1355     size ~~ 0 ifTrue:[
  1342         startOfLinesY := newList.
  1356         hasConstantHeight ifTrue:[
  1343         ^ self
  1357             constantHeight isNil ifTrue:[ constantHeight := self heightOfAnyNonNilItem ].
  1344     ].
  1358         ].
  1345 
  1359         
  1346     hasConstantHeight ifTrue:[
       
  1347         constantHeight notNil ifTrue:[ lnHg := constantHeight ]
       
  1348                              ifFalse:[ lnHg := self heightOfLineAt:1 ].
       
  1349 
       
  1350         1 to:size do:[:anIndex|
  1360         1 to:size do:[:anIndex|
  1351             newList add:(yAbs := yAbs + lnHg)
  1361             yAbs := yAbs + (constantHeight notNil 
  1352         ].
  1362                                 ifTrue:[constantHeight] 
  1353         startOfLinesY := newList.
  1363                                 ifFalse:[self realHeightOfLineAt:anIndex]).
  1354         ^ self
  1364             newList add:yAbs
  1355     ].
  1365         ].
  1356 
       
  1357     1 to:size do:[:anIndex|
       
  1358         lnHg := self heightOfLineAt:anIndex.
       
  1359         newList add:(yAbs := yAbs + lnHg)
       
  1360     ].
  1366     ].
  1361     startOfLinesY := newList.
  1367     startOfLinesY := newList.
  1362 ! !
  1368 ! !
  1363 
  1369 
  1364 !ListModelView methodsFor:'scroller interface'!
  1370 !ListModelView methodsFor:'scroller interface'!
  1365 
  1371 
  1366 getWidthOfContents
  1372 getWidthOfContents
  1367     ^ widthOfContents
  1373     ^ widthOfContents
  1368 !
  1374 !
  1369 
  1375 
       
  1376 heightOfAnyNonNilItem
       
  1377     "returns the height of a line at an index (including lineSpacing...)"
       
  1378 
       
  1379     |item|
       
  1380 
       
  1381     item := list detect:[:i | i notNil] ifNone:nil.
       
  1382     item isNil ifTrue:[ ^ 16 "arbitrary" ].
       
  1383     ^ self lineHeightFor:item.
       
  1384 !
       
  1385 
  1370 heightOfContents
  1386 heightOfContents
  1371     "return the height of the contents in pixels
  1387     "return the height of the contents in pixels"
  1372     "
  1388 
  1373     ^ self startOfLinesY last ? 0
  1389     ^ self startOfLinesY last ? 0
  1374 !
  1390 !
  1375 
  1391 
  1376 heightOfLineAt:aLineNr
  1392 heightOfLineAt:aLineNr
  1377     "returns the total height for a line at an index( including lineSpacing ... )
  1393     "returns the height of a line at an index (including lineSpacing...)"
  1378     "
       
  1379     |item|
       
  1380 
  1394 
  1381     hasConstantHeight ifTrue:[
  1395     hasConstantHeight ifTrue:[
  1382         constantHeight notNil ifTrue:[ ^ constantHeight ].
  1396         constantHeight isNil ifTrue:[ 
  1383         item := self at:1 ifAbsent:nil.
  1397             constantHeight := self heightOfAnyNonNilItem.
  1384 
  1398         ].
  1385         item notNil ifTrue:[
  1399         ^ constantHeight
  1386             constantHeight := self lineHeightFor:item.
  1400     ].
  1387             ^ constantHeight
  1401     ^ self realHeightOfLineAt:aLineNr
  1388         ]
       
  1389     ] ifFalse:[
       
  1390         item := self at:aLineNr ifAbsent:nil.
       
  1391 
       
  1392         item notNil ifTrue:[
       
  1393             ^ self lineHeightFor:item
       
  1394         ]
       
  1395     ].
       
  1396     ^ 4
       
  1397 !
  1402 !
  1398 
  1403 
  1399 innerHeight
  1404 innerHeight
  1400     "returns the inner height of the contents shown
  1405     "returns the inner height of the contents shown
  1401     "
  1406     "
  1414     "returns the maximum possible y of the view origin
  1419     "returns the maximum possible y of the view origin
  1415     "
  1420     "
  1416     ^ (self heightOfContents - self innerHeight) max:0
  1421     ^ (self heightOfContents - self innerHeight) max:0
  1417 
  1422 
  1418 
  1423 
       
  1424 !
       
  1425 
       
  1426 realHeightOfLineAt:aLineNr
       
  1427     "returns the real (uncached) height of a line at an index"
       
  1428 
       
  1429     |item|
       
  1430 
       
  1431     item := self at:aLineNr ifAbsent:nil.
       
  1432     item notNil ifTrue:[
       
  1433         ^ self lineHeightFor:item
       
  1434     ].
       
  1435     ^ font height "arbitrary"
  1419 !
  1436 !
  1420 
  1437 
  1421 setWidthOfContents: aWidth
  1438 setWidthOfContents: aWidth
  1422     widthOfContents := aWidth.
  1439     widthOfContents := aWidth.
  1423 !
  1440 !
  1722 ! !
  1739 ! !
  1723 
  1740 
  1724 !ListModelView::Renderer methodsFor:'change & update'!
  1741 !ListModelView::Renderer methodsFor:'change & update'!
  1725 
  1742 
  1726 listWillChange
  1743 listWillChange
  1727     "called before the list changed, clear cashes ect.
  1744     "called before the list changed, clear caches etc.
  1728      here nothing is done
  1745      here nothing is done
  1729     "
  1746     "
  1730 !
  1747 !
  1731 
  1748 
  1732 withinUpdateFromListDo:aBlock
  1749 withinUpdateFromListDo:aBlock
  1832 ! !
  1849 ! !
  1833 
  1850 
  1834 !ListModelView class methodsFor:'documentation'!
  1851 !ListModelView class methodsFor:'documentation'!
  1835 
  1852 
  1836 version
  1853 version
  1837     ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.96 2004-09-20 10:33:52 stefan Exp $'
  1854     ^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.97 2005-10-06 10:58:18 cg Exp $'
  1838 ! !
  1855 ! !
  1839 
  1856 
  1840 ListModelView initialize!
  1857 ListModelView initialize!