ListView.st
changeset 2429 eed79a96e43b
parent 2427 43cc7ea39bac
child 2430 d8f21cf216fb
equal deleted inserted replaced
2428:f800d9ec09a8 2429:eed79a96e43b
   925      If scan is true, scan the passed list for nonStrings; 
   925      If scan is true, scan the passed list for nonStrings; 
   926      otherwise, take the information from the nonStrings arg.
   926      otherwise, take the information from the nonStrings arg.
   927      (the nonStrings information is remembered to optimize later redraws & height computations)."
   927      (the nonStrings information is remembered to optimize later redraws & height computations)."
   928 
   928 
   929     |oldFirst oldLeft nonStringsBefore fontHeightBefore
   929     |oldFirst oldLeft nonStringsBefore fontHeightBefore
   930      scrollToEnd scrollToTop|
   930      scrollToEnd scrollToTop newLeftOffset|
   931 
   931 
   932     scrollToTop := scrollWhenUpdating == #begin or:[scrollWhenUpdating == #beginOfText].
   932     scrollToTop := scrollWhenUpdating == #begin or:[scrollWhenUpdating == #beginOfText].
   933     scrollToEnd := scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText].
   933     scrollToEnd := scrollWhenUpdating == #end or:[scrollWhenUpdating == #endOfText].
   934 
   934 
   935     (aCollection isNil and:[list isNil]) ifTrue:[
   935     (aCollection isNil and:[list isNil]) ifTrue:[
   936         "no contents change"
   936         "no contents change"
   937         scrollToTop ifTrue:[
   937         scrollToTop ifTrue:[
   938             self scrollToTop.
   938             self scrollToTop.
   939             self scrollToLeft.
       
   940         ] ifFalse:[
   939         ] ifFalse:[
   941             scrollToEnd ifTrue:[
   940             scrollToEnd ifTrue:[
   942                 self scrollToBottom.
   941                 self scrollToBottom.
   943             ]
   942             ]
   944         ].
   943         ].
       
   944         self scrollToLeft.
   945         ^ self
   945         ^ self
   946     ].
   946     ].
   947     list := aCollection.
   947     list := aCollection.
   948 
   948 
   949     nonStringsBefore := includesNonStrings.
   949     nonStringsBefore := includesNonStrings.
   965         self getFontParameters.
   965         self getFontParameters.
   966     ].
   966     ].
   967 
   967 
   968     widthOfWidestLine := nil.   "/ i.e. unknown
   968     widthOfWidestLine := nil.   "/ i.e. unknown
   969     oldFirst := firstLineShown.
   969     oldFirst := firstLineShown.
   970     oldLeft := leftOffset.
   970     oldLeft := viewOrigin x.
   971 
   971 
   972     (includesNonStrings ~~ nonStringsBefore) ifTrue:[
   972     (includesNonStrings ~~ nonStringsBefore) ifTrue:[
   973         self computeNumberOfLinesShown.
   973         self computeNumberOfLinesShown.
   974     ].
   974     ].
       
   975 
       
   976     newLeftOffset := viewOrigin x.
   975     scrollToTop ifTrue:[
   977     scrollToTop ifTrue:[
   976         firstLineShown := 1.
   978         firstLineShown := 1.
   977         leftOffset := 0.
   979         newLeftOffset := 0.
   978     ] ifFalse:[
   980     ] ifFalse:[
   979         scrollToEnd ifTrue:[
   981         scrollToEnd ifTrue:[
   980             firstLineShown := (list size - nFullLinesShown + 1) max:1.
   982             firstLineShown := (list size - nFullLinesShown + 1) max:1.
   981             leftOffset := 0.
   983             newLeftOffset := 0.
   982         ]
   984         ]
       
   985     ].
       
   986     newLeftOffset > 0 ifTrue:[
       
   987         self widthOfContents <= self innerWidth ifTrue:[
       
   988             newLeftOffset := 0.
       
   989         ].
       
   990     ].
       
   991     newLeftOffset ~= oldLeft ifTrue:[ 
       
   992         viewOrigin := newLeftOffset @ viewOrigin y.
   983     ].
   993     ].
   984 
   994 
   985     realized ifTrue:[
   995     realized ifTrue:[
   986         self contentsChanged.
   996         self contentsChanged.
   987         "
   997         "
  1162      (for example: a file list being shown, without disturbing the user too much)"
  1172      (for example: a file list being shown, without disturbing the user too much)"
  1163 
  1173 
  1164     |oldFirst nonStringsBefore linesShownBefore|
  1174     |oldFirst nonStringsBefore linesShownBefore|
  1165 
  1175 
  1166     (aCollection isNil and:[list isNil]) ifTrue:[
  1176     (aCollection isNil and:[list isNil]) ifTrue:[
  1167 	"no change"
  1177         "no change"
  1168 	^ self
  1178         ^ self
  1169     ].
  1179     ].
  1170 
  1180 
  1171 "/    list isNil ifTrue:[
  1181 "/    list isNil ifTrue:[
  1172 "/        linesShownBefore := (1 to:nLinesShown) collect:[:i | ''].
  1182 "/        linesShownBefore := (1 to:nLinesShown) collect:[:i | ''].
  1173 "/    ] ifFalse:[
  1183 "/    ] ifFalse:[
  1179 
  1189 
  1180     nonStringsBefore := includesNonStrings.
  1190     nonStringsBefore := includesNonStrings.
  1181     includesNonStrings := false.
  1191     includesNonStrings := false.
  1182 
  1192 
  1183     list notNil ifTrue:[
  1193     list notNil ifTrue:[
  1184 	expandTabs ifTrue:[
  1194         expandTabs ifTrue:[
  1185 	    self expandTabs
  1195             self expandTabs
  1186 	] ifFalse:[
  1196         ] ifFalse:[
  1187 	    includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0.
  1197             includesNonStrings := (list findFirst:[:e | e isString not]) ~~ 0.
  1188 	].
  1198         ].
  1189     ].
  1199     ].
  1190     (includesNonStrings ~~ nonStringsBefore) ifTrue:[
  1200     (includesNonStrings ~~ nonStringsBefore) ifTrue:[
  1191 	self getFontParameters.
  1201         self getFontParameters.
  1192 	self computeNumberOfLinesShown.
  1202         self computeNumberOfLinesShown.
  1193     ].
  1203     ].
  1194 
  1204 
  1195 "/ new - reposition horizontally if too big
  1205 "/ new - reposition horizontally if too big
  1196     widthOfWidestLine := nil.   "/ i.e. unknown
  1206     widthOfWidestLine := nil.   "/ i.e. unknown
  1197     innerWidth >= self widthOfContents ifTrue:[
  1207     innerWidth >= self widthOfContents ifTrue:[
  1198 	viewOrigin x:0.
  1208         viewOrigin := 0 @ viewOrigin y.
  1199 	leftOffset := 0.
       
  1200     ].
  1209     ].
  1201     self contentsChanged.
  1210     self contentsChanged.
  1202 
  1211 
  1203 "/ new - reposition vertically if too big
  1212 "/ new - reposition vertically if too big
  1204     (firstLineShown + nFullLinesShown) > self size ifTrue:[
  1213     (firstLineShown + nFullLinesShown) > self size ifTrue:[
  1205 	oldFirst := firstLineShown.
  1214         oldFirst := firstLineShown.
  1206 	firstLineShown := self size - nFullLinesShown + 1.
  1215         firstLineShown := self size - nFullLinesShown + 1.
  1207 	firstLineShown < 1 ifTrue:[firstLineShown := 1].
  1216         firstLineShown < 1 ifTrue:[firstLineShown := 1].
  1208 
  1217 
  1209 	viewOrigin y:(firstLineShown - 1 * fontHeight).
  1218         viewOrigin y:(firstLineShown - 1 * fontHeight).
  1210 	self originChanged:0 @ ((oldFirst - 1) negated * fontHeight).
  1219         self originChanged:0 @ ((oldFirst - 1) negated * fontHeight).
  1211 	linesShownBefore := nil.
  1220         linesShownBefore := nil.
  1212 	shown ifTrue:[
  1221         shown ifTrue:[
  1213 	    self clear.
  1222             self clear.
  1214 	]
  1223         ]
  1215     ].
  1224     ].
  1216 "/ end new
  1225 "/ end new
  1217 
  1226 
  1218     (shown and:[doRedraw]) ifTrue:[
  1227     (shown and:[doRedraw]) ifTrue:[
  1219 	  self redrawFromVisibleLine:1 to:nLinesShown
  1228           self redrawFromVisibleLine:1 to:nLinesShown
  1220 
  1229 
  1221 "/        linesShownBefore isNil ifTrue:[
  1230 "/        linesShownBefore isNil ifTrue:[
  1222 "/            self redrawFromVisibleLine:1 to:nLinesShown
  1231 "/            self redrawFromVisibleLine:1 to:nLinesShown
  1223 "/        ] ifFalse:[
  1232 "/        ] ifFalse:[
  1224 "/            1 to:nLinesShown do:[:l |
  1233 "/            1 to:nLinesShown do:[:l |
  1541     ] ifFalse:[
  1550     ] ifFalse:[
  1542         e := endLine
  1551         e := endLine
  1543     ].
  1552     ].
  1544 
  1553 
  1545     (startLine <= e) ifTrue:[
  1554     (startLine <= e) ifTrue:[
  1546         x := textStartLeft - leftOffset.
  1555         x := textStartLeft - viewOrigin x.
  1547         self paint:fg on:bg.
  1556         self paint:fg on:bg.
  1548         self from:startLine to:e do:[:line |
  1557         self from:startLine to:e do:[:line |
  1549             line notNil ifTrue:[
  1558             line notNil ifTrue:[
  1550                 "/ remove lines color emphasis, to enforce color.
  1559                 "/ remove lines color emphasis, to enforce color.
  1551                 "/ otherwise blue text is not visible if selection-bg is blue
  1560                 "/ otherwise blue text is not visible if selection-bg is blue
  1611 !
  1620 !
  1612 
  1621 
  1613 drawLine:line inVisible:visLineNr with:fg and:bg
  1622 drawLine:line inVisible:visLineNr with:fg and:bg
  1614     "draw a given string at visible lines position in fg/bg"
  1623     "draw a given string at visible lines position in fg/bg"
  1615 
  1624 
  1616     self drawLine:line atX:(textStartLeft - leftOffset) inVisible:visLineNr with:fg and:bg
  1625     self drawLine:line atX:(textStartLeft - viewOrigin x) inVisible:visLineNr with:fg and:bg
  1617 !
  1626 !
  1618 
  1627 
  1619 drawVisibleLine:visLineNr col:col with:fg and:bg
  1628 drawVisibleLine:visLineNr col:col with:fg and:bg
  1620     "draw single character at col index of visible line in fg/bg"
  1629     "draw single character at col index of visible line in fg/bg"
  1621 
  1630 
  1624     lineString := self visibleAt:visLineNr.
  1633     lineString := self visibleAt:visLineNr.
  1625     (lineString notNil and:[lineString isString not]) ifTrue:[
  1634     (lineString notNil and:[lineString isString not]) ifTrue:[
  1626         ^ self drawVisibleLine:visLineNr with:fg and:bg
  1635         ^ self drawVisibleLine:visLineNr with:fg and:bg
  1627     ].
  1636     ].
  1628 
  1637 
  1629     x := (self xOfCol:col inVisibleLine:visLineNr) - leftOffset.
  1638     x := (self xOfCol:col inVisibleLine:visLineNr) - viewOrigin x.
  1630     y := self yOfVisibleLine:visLineNr.
  1639     y := self yOfVisibleLine:visLineNr.
  1631     self paint:bg.
  1640     self paint:bg.
  1632 
  1641 
  1633     yf := y - (lineSpacing // 2).
  1642     yf := y - (lineSpacing // 2).
  1634     col > lineString size ifTrue:[
  1643     col > lineString size ifTrue:[
  1664 
  1673 
  1665         (lineString notNil and:[lineString isString not])
  1674         (lineString notNil and:[lineString isString not])
  1666         ifTrue:[
  1675         ifTrue:[
  1667             self drawVisibleLine:visLineNr with:fg and:bg.
  1676             self drawVisibleLine:visLineNr with:fg and:bg.
  1668         ] ifFalse:[
  1677         ] ifFalse:[
  1669             x := (self xOfCol:sCol inVisibleLine:visLineNr) - leftOffset.
  1678             x := (self xOfCol:sCol inVisibleLine:visLineNr) - viewOrigin x.
  1670             y := (self yOfVisibleLine:visLineNr).
  1679             y := (self yOfVisibleLine:visLineNr).
  1671             yf := y - (lineSpacing // 2).
  1680             yf := y - (lineSpacing // 2).
  1672             len := lineString size.
  1681             len := lineString size.
  1673 
  1682 
  1674             (sCol > len) ifTrue:[
  1683             (sCol > len) ifTrue:[
  1727         index1 := 1
  1736         index1 := 1
  1728     ] ifFalse:[
  1737     ] ifFalse:[
  1729         index1 := startCol
  1738         index1 := startCol
  1730     ].
  1739     ].
  1731     y := self yOfVisibleLine:visLineNr.
  1740     y := self yOfVisibleLine:visLineNr.
  1732     x := (self xOfCol:index1 inVisibleLine:visLineNr) - leftOffset.
  1741     x := (self xOfCol:index1 inVisibleLine:visLineNr) - viewOrigin x.
  1733     backgroundAlreadyClearedColor == bg ifFalse:[
  1742     backgroundAlreadyClearedColor == bg ifFalse:[
  1734         self paint:bg.
  1743         self paint:bg.
  1735         self fillRectangleX:x y:y - (lineSpacing // 2)
  1744         self fillRectangleX:x y:y - (lineSpacing // 2)
  1736                       width:(width + leftOffset - x)
  1745                       width:(width + viewOrigin x - x)
  1737                      height:fontHeight.
  1746                      height:fontHeight.
  1738     ].
  1747     ].
  1739     lineString := self visibleAt:visLineNr.
  1748     lineString := self visibleAt:visLineNr.
  1740     lineString notNil ifTrue:[
  1749     lineString notNil ifTrue:[
  1741         lineString isString ifFalse:[
  1750         lineString isString ifFalse:[
  1756 
  1765 
  1757 drawVisibleLine:visLineNr with:fg and:bg
  1766 drawVisibleLine:visLineNr with:fg and:bg
  1758     "draw a visible line in fg/bg"
  1767     "draw a visible line in fg/bg"
  1759 
  1768 
  1760     self 
  1769     self 
  1761 	drawLine:(self visibleAt:visLineNr) 
  1770         drawLine:(self visibleAt:visLineNr) 
  1762 	atX:(textStartLeft - leftOffset) 
  1771         atX:(textStartLeft - viewOrigin x) 
  1763 	inVisible:visLineNr 
  1772         inVisible:visLineNr 
  1764 	with:fg 
  1773         with:fg 
  1765 	and:bg
  1774         and:bg
  1766 
  1775 
  1767     "Modified: 28.2.1996 / 19:30:23 / cg"
  1776     "Modified: 28.2.1996 / 19:30:23 / cg"
  1768 !
  1777 !
  1769 
  1778 
  1770 fillRectangleX:x y:y width:w height:h
  1779 fillRectangleX:x y:y width:w height:h
  2037     bitGravity := #NorthWest.
  2046     bitGravity := #NorthWest.
  2038     list := nil.
  2047     list := nil.
  2039     firstLineShown := 1.
  2048     firstLineShown := 1.
  2040     nFullLinesShown := 1. "just any value ..."
  2049     nFullLinesShown := 1. "just any value ..."
  2041     nLinesShown := 1.     "just any value"
  2050     nLinesShown := 1.     "just any value"
  2042     leftOffset := 0.
       
  2043     partialLines := true.
  2051     partialLines := true.
  2044     tabPositions := UserDefaultTabPositions ? DefaultTabPositions.
  2052     tabPositions := UserDefaultTabPositions ? DefaultTabPositions.
  2045     includesNonStrings := false.
  2053     includesNonStrings := false.
  2046     self getFontParameters.
  2054     self getFontParameters.
  2047     wordCheck := [:char | char isNationalAlphaNumeric].
  2055     wordCheck := [:char | char isNationalAlphaNumeric].
  2173     "given a visible lineNr and x-coordinate, return colNr"
  2181     "given a visible lineNr and x-coordinate, return colNr"
  2174 
  2182 
  2175     |lineString linePixelWidth xRel runCol posLeft posRight done
  2183     |lineString linePixelWidth xRel runCol posLeft posRight done
  2176      hasEmphasis oPosRight oPosLeft|
  2184      hasEmphasis oPosRight oPosLeft|
  2177 
  2185 
  2178     xRel := x - textStartLeft + leftOffset.
  2186     xRel := x - textStartLeft + viewOrigin x.
  2179     (xRel <= 0) ifTrue:[^ 1].
  2187     (xRel <= 0) ifTrue:[^ 1].
  2180 
  2188 
  2181     lineString := self visibleAt:visLineNr.
  2189     lineString := self visibleAt:visLineNr.
  2182 
  2190 
  2183     "
  2191     "
  2262             "/ (avoid endless loop if the binary search does not make progress)
  2270             "/ (avoid endless loop if the binary search does not make progress)
  2263             done := true.
  2271             done := true.
  2264         ]
  2272         ]
  2265     ].
  2273     ].
  2266 "/self paint:Color red.
  2274 "/self paint:Color red.
  2267 "/self displayRectangleX:posLeft+textStartLeft-leftOffset y:(self yOfVisibleLine:visLineNr)
  2275 "/self displayRectangleX:posLeft+textStartLeft-viewOrigin x y:(self yOfVisibleLine:visLineNr)
  2268 "/                       width:(posRight-posLeft) height:fontHeight.
  2276 "/                       width:(posRight-posLeft) height:fontHeight.
  2269 "/self paint:Color black.
  2277 "/self paint:Color black.
  2270     ^ runCol
  2278     ^ runCol
  2271 
  2279 
  2272     "Modified: / 8.9.1998 / 21:18:42 / cg"
  2280     "Modified: / 8.9.1998 / 21:18:42 / cg"
  3077 
  3085 
  3078 xOriginOfContents
  3086 xOriginOfContents
  3079     "return the horizontal origin of the contents in pixels
  3087     "return the horizontal origin of the contents in pixels
  3080      - used for scrollbar interface"
  3088      - used for scrollbar interface"
  3081 
  3089 
  3082     ^ leftOffset 
  3090     ^ viewOrigin x 
  3083 !
  3091 !
  3084 
  3092 
  3085 yOriginOfContents
  3093 yOriginOfContents
  3086     "return the vertical origin of the contents in pixels
  3094     "return the vertical origin of the contents in pixels
  3087      - used for scrollbar interface"
  3095      - used for scrollbar interface"
  3301 
  3309 
  3302     visLnr := self listLineToVisibleLine:aLineNr.
  3310     visLnr := self listLineToVisibleLine:aLineNr.
  3303     visLnr isNil ifTrue:[^ self].
  3311     visLnr isNil ifTrue:[^ self].
  3304 
  3312 
  3305     xWant := self xOfCol:aCol inVisibleLine:visLnr.
  3313     xWant := self xOfCol:aCol inVisibleLine:visLnr.
  3306     xVis := xWant - leftOffset.
  3314     xVis := xWant - viewOrigin x.
  3307 
  3315 
  3308     "
  3316     "
  3309      dont scroll, if already visible
  3317      dont scroll, if already visible
  3310      (but scroll, if not in inner 20%..80% of visible area)
  3318      (but scroll, if not in inner 20%..80% of visible area)
  3311     "
  3319     "
  3464 scrollHorizontalTo:aPixelOffset
  3472 scrollHorizontalTo:aPixelOffset
  3465     "change origin to make aPixelOffset be the left col"
  3473     "change origin to make aPixelOffset be the left col"
  3466 
  3474 
  3467     |nPixel|
  3475     |nPixel|
  3468 
  3476 
  3469     nPixel := aPixelOffset - leftOffset.
  3477     nPixel := aPixelOffset - viewOrigin x.
  3470     nPixel ~~ 0 ifTrue:[
  3478     nPixel ~~ 0 ifTrue:[
  3471         self scrollTo:(viewOrigin + (nPixel @ 0)) redraw:true
  3479         self scrollTo:(viewOrigin + (nPixel @ 0)) redraw:true
  3472     ]
  3480     ]
  3473 
  3481 
  3474     "Modified: / 3.3.1999 / 22:55:20 / cg"
  3482     "Modified: / 3.3.1999 / 22:55:20 / cg"
  3516 !
  3524 !
  3517 
  3525 
  3518 scrollToCol:aColNr
  3526 scrollToCol:aColNr
  3519     "change origin to make aColNr be the left col"
  3527     "change origin to make aColNr be the left col"
  3520 
  3528 
  3521     |pxlOffset|
  3529     |pxlOffset leftOffset|
       
  3530 
       
  3531     leftOffset := viewOrigin x.
  3522 
  3532 
  3523     aColNr == 1 ifTrue:[
  3533     aColNr == 1 ifTrue:[
  3524 	leftOffset ~~ 0 ifTrue:[
  3534         leftOffset ~~ 0 ifTrue:[
  3525 	    self scrollLeft:leftOffset.
  3535             self scrollLeft:leftOffset.
  3526 	].
  3536         ].
  3527 	^ self
  3537         ^ self
  3528     ].
  3538     ].
  3529 
  3539 
  3530     pxlOffset := font width * (aColNr - 1).
  3540     pxlOffset := font width * (aColNr - 1).
  3531 
  3541 
  3532     pxlOffset < leftOffset ifTrue:[
  3542     pxlOffset < leftOffset ifTrue:[
  3533 	self scrollLeft:(leftOffset - pxlOffset)
  3543         self scrollLeft:(leftOffset - pxlOffset)
  3534     ] ifFalse:[
  3544     ] ifFalse:[
  3535 	pxlOffset > leftOffset ifTrue:[
  3545         pxlOffset > leftOffset ifTrue:[
  3536 	    self scrollRight:(pxlOffset - leftOffset)
  3546             self scrollRight:(pxlOffset - leftOffset)
  3537 	]
  3547         ]
  3538     ]
  3548     ]
  3539 !
  3549 !
  3540 
  3550 
  3541 scrollToLeft
  3551 scrollToLeft
  3542     "change origin to start (left) of text"
  3552     "change origin to start (left) of text"
  3543 
  3553 
  3544     leftOffset ~~ 0 ifTrue:[
  3554     viewOrigin x ~~ 0 ifTrue:[
  3545 	self scrollToCol:1
  3555         self scrollToCol:1
  3546     ]
  3556     ]
  3547 !
  3557 !
  3548 
  3558 
  3549 scrollToLine:aLineNr
  3559 scrollToLine:aLineNr
  3550     "change origin to make aLineNr be the top line"
  3560     "change origin to make aLineNr be the top line"
  3745      w    "{ Class:SmallInteger }"
  3755      w    "{ Class:SmallInteger }"
  3746      y0   "{ Class:SmallInteger }"
  3756      y0   "{ Class:SmallInteger }"
  3747      y1   "{ Class:SmallInteger }"
  3757      y1   "{ Class:SmallInteger }"
  3748      y    "{ Class:SmallInteger }"
  3758      y    "{ Class:SmallInteger }"
  3749      x    "{ Class:SmallInteger }"
  3759      x    "{ Class:SmallInteger }"
  3750      delta newFirstLine newViewOrigin newLeftOffset
  3760      delta newFirstLine newViewOrigin 
  3751      hBefore wBefore inv wg|
  3761      hBefore wBefore inv wg|
  3752 
  3762 
  3753     hBefore := height.
  3763     hBefore := height.
  3754     wBefore := width.
  3764     wBefore := width.
  3755 
  3765 
  3756     dltOrg := anOrigin - viewOrigin.
  3766     dltOrg := anOrigin - viewOrigin.
  3757 
  3767 
  3758 "/  compute valid horizontal offset x
  3768 "/  compute valid horizontal offset x
  3759 
  3769 
  3760     (x := dltOrg x) ~~ 0 ifTrue:[
  3770     (x := dltOrg x) ~~ 0 ifTrue:[
  3761         tmp := leftOffset + x.
  3771         tmp := viewOrigin x + x.
  3762 
  3772 
  3763         x < 0 ifTrue:[                                          "/ scrolling left
  3773         x < 0 ifTrue:[                                          "/ scrolling left
  3764             tmp < 0 ifTrue:[x := 0 - leftOffset]
  3774             tmp < 0 ifTrue:[x := 0 - viewOrigin x]
  3765         ] ifFalse:[                                             "/ scrolling right
  3775         ] ifFalse:[                                             "/ scrolling right
  3766          "/ allows scrolling to the right of widest line
  3776          "/ allows scrolling to the right of widest line
  3767             max := self widthOfContents + (self additionalMarginForHorizontalScroll).
  3777             max := self widthOfContents + (self additionalMarginForHorizontalScroll).
  3768 
  3778 
  3769             tmp + width > max ifTrue:[
  3779             tmp + width > max ifTrue:[
  3770                 x := (max - leftOffset - width) max:0
  3780                 x := (max - viewOrigin x - width) max:0
  3771             ]
  3781             ]
  3772         ]
  3782         ]
  3773     ].
  3783     ].
  3774 
  3784 
  3775 "/  compute valid vertical offset measured in lines
  3785 "/  compute valid vertical offset measured in lines
  3798     ].
  3808     ].
  3799     delta := (x @ y).
  3809     delta := (x @ y).
  3800 
  3810 
  3801     newFirstLine := firstLineShown + noLn.
  3811     newFirstLine := firstLineShown + noLn.
  3802     newViewOrigin := viewOrigin + delta.
  3812     newViewOrigin := viewOrigin + delta.
  3803     newLeftOffset := newViewOrigin x max:0.
       
  3804 
  3813 
  3805     (shown and:[doRedraw]) ifFalse:[
  3814     (shown and:[doRedraw]) ifFalse:[
  3806         self originWillChange.
  3815         self originWillChange.
  3807         firstLineShown := newFirstLine.
  3816         firstLineShown := newFirstLine.
  3808         viewOrigin := newViewOrigin.
  3817         viewOrigin := newViewOrigin.
  3809         leftOffset := newLeftOffset.
       
  3810         ^ self originChanged:delta
  3818         ^ self originChanged:delta
  3811     ].
  3819     ].
  3812 
  3820 
  3813 "/    (self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[               "/ outstanding expose events
  3821 "/    (self sensor notNil and: [self sensor hasExposeEventFor:self]) ifTrue:[               "/ outstanding expose events
  3814 "/        self invalidate.                                        "/ redraw all
  3822 "/        self invalidate.                                        "/ redraw all
  3821       or:[(x abs) > (width // 4 * 3)]]  "/ big enough to redraw all
  3829       or:[(x abs) > (width // 4 * 3)]]  "/ big enough to redraw all
  3822     ) ifTrue:[
  3830     ) ifTrue:[
  3823         self originWillChange.
  3831         self originWillChange.
  3824         firstLineShown := newFirstLine.
  3832         firstLineShown := newFirstLine.
  3825         viewOrigin := newViewOrigin.
  3833         viewOrigin := newViewOrigin.
  3826         leftOffset := newLeftOffset.
       
  3827         self invalidate.
  3834         self invalidate.
  3828         ^ self originChanged:delta
  3835         ^ self originChanged:delta
  3829     ].
  3836     ].
  3830 
  3837 
  3831     "/ OLD:
  3838     "/ OLD:
  3895         inv := (y1@margin) extent:(y0@h).      
  3902         inv := (y1@margin) extent:(y0@h).      
  3896     ].
  3903     ].
  3897 
  3904 
  3898     firstLineShown := newFirstLine.
  3905     firstLineShown := newFirstLine.
  3899     viewOrigin := newViewOrigin.
  3906     viewOrigin := newViewOrigin.
  3900     leftOffset := newLeftOffset.
       
  3901 
  3907 
  3902     self invalidateDeviceRectangle:inv repairNow:false.
  3908     self invalidateDeviceRectangle:inv repairNow:false.
  3903 
  3909 
  3904     self originChanged:delta.
  3910     self originChanged:delta.
  3905     self waitForExpose.
  3911     self waitForExpose.
  4386 ! !
  4392 ! !
  4387 
  4393 
  4388 !ListView class methodsFor:'documentation'!
  4394 !ListView class methodsFor:'documentation'!
  4389 
  4395 
  4390 version
  4396 version
  4391     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.256 2001-10-04 16:53:32 cg Exp $'
  4397     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.257 2001-10-05 08:55:19 cg Exp $'
  4392 ! !
  4398 ! !