ListView.st
changeset 1656 1202fbc95970
parent 1637 f40b75c349d7
child 1693 e76979454c2f
equal deleted inserted replaced
1655:2928bb99f774 1656:1202fbc95970
  1332                     characterString := lineString species new:endCol.
  1332                     characterString := lineString species new:endCol.
  1333                     characterString replaceFrom:1 to:len with:lineString startingAt:1.
  1333                     characterString replaceFrom:1 to:len with:lineString startingAt:1.
  1334                     lineString := characterString
  1334                     lineString := characterString
  1335                 ].
  1335                 ].
  1336                 self paint:bg.
  1336                 self paint:bg.
  1337                 fontIsFixedWidth ifTrue:[
  1337                 (lineString isMemberOf:String) ifTrue:[
  1338                     w := (endCol - sCol + 1) * fontWidth
  1338                     fontIsFixedWidth ifTrue:[
       
  1339                         w := (endCol - sCol + 1) * fontWidth
       
  1340                     ] ifFalse:[
       
  1341                         w := font widthOf:lineString from:sCol to:endCol
       
  1342                     ]
  1339                 ] ifFalse:[
  1343                 ] ifFalse:[
  1340                     (lineString isMemberOf:String) ifTrue:[
  1344                     w := (lineString copyFrom:sCol to:endCol) widthOn:self
  1341                         w := font widthOf:lineString from:sCol to:endCol
       
  1342                     ] ifFalse:[
       
  1343                         w := (lineString copyFrom:sCol to:endCol) widthOn:self
       
  1344                     ]
       
  1345                 ].
  1345                 ].
  1346                 self fillRectangleX:x y:yf 
  1346                 self fillRectangleX:x y:yf 
  1347                               width:w
  1347                               width:w
  1348                               height:fontHeight.
  1348                               height:fontHeight.
  1349                 self paint:fg on:bg.
  1349                 self paint:fg on:bg.
  1350                 self displayOpaqueString:lineString from:sCol to:endCol x:x y:(y + fontAscent)
  1350                 self displayOpaqueString:lineString from:sCol to:endCol x:x y:(y + fontAscent)
  1351             ]
  1351             ]
  1352         ]
  1352         ]
  1353     ]
  1353     ]
  1354 
  1354 
  1355     "Modified: / 16.6.1998 / 13:19:11 / cg"
  1355     "Modified: / 3.9.1998 / 21:54:01 / cg"
  1356 !
  1356 !
  1357 
  1357 
  1358 drawVisibleLine:visLineNr from:startCol with:fg and:bg
  1358 drawVisibleLine:visLineNr from:startCol with:fg and:bg
  1359     "draw right part of a visible line from startCol to end of line in fg/bg"
  1359     "draw right part of a visible line from startCol to end of line in fg/bg"
  1360 
  1360 
  1767      hasEmphasis oPosRight oPosLeft|
  1767      hasEmphasis oPosRight oPosLeft|
  1768 
  1768 
  1769     xRel := x - textStartLeft + leftOffset.
  1769     xRel := x - textStartLeft + leftOffset.
  1770     (xRel <= 0) ifTrue:[^ 1].
  1770     (xRel <= 0) ifTrue:[^ 1].
  1771 
  1771 
       
  1772     lineString := self visibleAt:visLineNr.
       
  1773 
  1772     "
  1774     "
  1773      for fix fonts, this is easy ...
  1775      for fix fonts, this is easy ...
  1774     "
  1776     "
  1775     fontIsFixedWidth ifTrue:[
  1777     (fontIsFixedWidth 
       
  1778     and:[lineString isNil
       
  1779          or:[lineString isMemberOf:String]]) ifTrue:[
  1776         ^ (xRel // fontWidth) + 1
  1780         ^ (xRel // fontWidth) + 1
  1777     ].
  1781     ].
  1778 
  1782 
  1779     "
  1783     "
  1780      for variable fonts, more work is required ...
  1784      for variable fonts, more work is required ...
  1781     "
  1785     "
  1782     lineString := self visibleAt:visLineNr.
       
  1783     lineString notNil ifTrue:[
  1786     lineString notNil ifTrue:[
  1784         lineString := lineString asString.
  1787         lineString := lineString asString.
  1785         (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[
  1788         (hasEmphasis := lineString hasChangeOfEmphasis) ifTrue:[
  1786             linePixelWidth := lineString widthOn:self
  1789             linePixelWidth := lineString widthOn:self
  1787         ] ifFalse:[
  1790         ] ifFalse:[
  1852          ]
  1855          ]
  1853     ].
  1856     ].
  1854 
  1857 
  1855     ^ runCol
  1858     ^ runCol
  1856 
  1859 
  1857     "Modified: / 28.7.1998 / 12:17:40 / cg"
  1860     "Modified: / 3.9.1998 / 21:55:41 / cg"
  1858 !
  1861 !
  1859 
  1862 
  1860 computeNumberOfLinesShown
  1863 computeNumberOfLinesShown
  1861     "recompute the number of visible lines"
  1864     "recompute the number of visible lines"
  1862 
  1865 
  2266     "given a visible line- and colNr, return x-coordinate in view"
  2269     "given a visible line- and colNr, return x-coordinate in view"
  2267 
  2270 
  2268     |line lineSize tcol|
  2271     |line lineSize tcol|
  2269 
  2272 
  2270     tcol := col - 1.
  2273     tcol := col - 1.
  2271     fontIsFixedWidth ifTrue:[
       
  2272 	^ (tcol * fontWidth) + textStartLeft
       
  2273     ].
       
  2274     line := self visibleAt:visLineNr.
  2274     line := self visibleAt:visLineNr.
       
  2275     (fontIsFixedWidth 
       
  2276     and:[line isNil
       
  2277          or:[line isMemberOf:String]]) ifTrue:[
       
  2278         ^ (tcol * fontWidth) + textStartLeft
       
  2279     ].
  2275     line notNil ifTrue:[
  2280     line notNil ifTrue:[
  2276 	lineSize := line size
  2281         lineSize := line size
  2277     ] ifFalse:[
  2282     ] ifFalse:[
  2278 	lineSize := 0
  2283         lineSize := 0
  2279     ].
  2284     ].
  2280     (lineSize == 0) ifTrue:[
  2285     (lineSize == 0) ifTrue:[
  2281 	^ (tcol * fontWidth) + textStartLeft
  2286         ^ (tcol * fontWidth) + textStartLeft
  2282     ].
  2287     ].
  2283 
  2288 
  2284     (lineSize < col) ifTrue:[
  2289     (lineSize < col) ifTrue:[
  2285 	^ (line widthOn:self) 
  2290         ^ (line widthOn:self) 
  2286 	  + (fontWidth * (tcol - lineSize)) 
  2291           + (fontWidth * (tcol - lineSize)) 
  2287 	  + textStartLeft
  2292           + textStartLeft
  2288     ].
  2293     ].
  2289     (line isMemberOf:String) ifTrue:[
  2294     (line isMemberOf:String) ifTrue:[
  2290 	^ (font widthOf:line from:1 to:tcol) + textStartLeft
  2295         ^ (font widthOf:line from:1 to:tcol) + textStartLeft
  2291     ].
  2296     ].
  2292     ^ ((line copyTo:tcol) widthOn:self) + textStartLeft
  2297     ^ ((line copyTo:tcol) widthOn:self) + textStartLeft
  2293 
  2298 
  2294     "Modified: 19.7.1996 / 20:38:54 / cg"
  2299     "Modified: / 3.9.1998 / 21:56:33 / cg"
  2295 !
  2300 !
  2296 
  2301 
  2297 yOfLine:lineNr
  2302 yOfLine:lineNr
  2298     "given a physical lineNr, return y-coordinate in view
  2303     "given a physical lineNr, return y-coordinate in view
  2299      - works for fix-height fonts only"
  2304      - works for fix-height fonts only"
  3783 ! !
  3788 ! !
  3784 
  3789 
  3785 !ListView class methodsFor:'documentation'!
  3790 !ListView class methodsFor:'documentation'!
  3786 
  3791 
  3787 version
  3792 version
  3788     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.172 1998-08-07 17:56:43 cg Exp $'
  3793     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.173 1998-09-04 16:27:18 cg Exp $'
  3789 ! !
  3794 ! !