ListView.st
changeset 5111 6d3c864f0a03
parent 5096 2c222bef8f8e
child 5128 787b617a99e5
child 5198 8aeb2f4089c9
equal deleted inserted replaced
5110:5fb77774d29c 5111:6d3c864f0a03
   699 
   699 
   700     list isNil ifTrue:[list := OrderedCollection new].
   700     list isNil ifTrue:[list := OrderedCollection new].
   701     list add:aString.
   701     list add:aString.
   702 
   702 
   703     includesNonStrings ifFalse:[
   703     includesNonStrings ifFalse:[
   704         includesNonStrings := (aString notNil and:[(aString isMemberOf:String) not]).
   704         includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
   705         includesNonStrings ifTrue:[
   705         includesNonStrings ifTrue:[
   706             fontHeightBefore := fontHeight.
   706             fontHeightBefore := fontHeight.
   707             self getFontParameters.
   707             self getFontParameters.
   708             fontHeightBefore ~~ fontHeight ifTrue:[
   708             fontHeightBefore ~~ fontHeight ifTrue:[
   709                 self invalidate
   709                 self invalidate
   734     widthOfWidestLine notNil ifTrue:[
   734     widthOfWidestLine notNil ifTrue:[
   735         self recomputeWidthOfWidestLineFor:aString old:nil.
   735         self recomputeWidthOfWidestLineFor:aString old:nil.
   736     ].
   736     ].
   737 
   737 
   738     includesNonStrings ifFalse:[
   738     includesNonStrings ifFalse:[
   739         includesNonStrings := (aString notNil and:[(aString isMemberOf:String) not]).
   739         includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
   740 "/        includesNonStrings ifTrue:[self getFontParameters].
   740 "/        includesNonStrings ifTrue:[self getFontParameters].
   741     ].
   741     ].
   742     shown ifTrue:[
   742     shown ifTrue:[
   743         lastShown := self lastLineShown.
   743         lastShown := self lastLineShown.
   744         index <= 2 ifTrue:[
   744         index <= 2 ifTrue:[
   771     ].
   771     ].
   772     includesNonStrings ifFalse:[
   772     includesNonStrings ifFalse:[
   773         includesNonStrings := 
   773         includesNonStrings := 
   774             aCollectionOfLines 
   774             aCollectionOfLines 
   775                 contains:[:someLine |
   775                 contains:[:someLine |
   776                     someLine notNil and:[(someLine isMemberOf:String) not].
   776                     someLine notNil and:[(someLine isSingleByteString) not].
   777                 ]
   777                 ]
   778     ].
   778     ].
   779 
   779 
   780     widthOfWidestLine notNil ifTrue:[
   780     widthOfWidestLine notNil ifTrue:[
   781         aCollectionOfLines do:[:eachLine |
   781         aCollectionOfLines do:[:eachLine |
  1553         self textChanged
  1553         self textChanged
  1554     ].
  1554     ].
  1555 
  1555 
  1556     didIncludeNonStrings := includesNonStrings.
  1556     didIncludeNonStrings := includesNonStrings.
  1557     includesNonStrings ifFalse:[
  1557     includesNonStrings ifFalse:[
  1558         includesNonStrings := (aString notNil and:[(aString isMemberOf:String) not]).
  1558         includesNonStrings := (aString notNil and:[(aString isSingleByteString) not]).
  1559     ] ifTrue:[
  1559     ] ifTrue:[
  1560         (aString isNil or:[(aString isMemberOf:String)]) ifTrue:[
  1560         (aString isNil or:[(aString isSingleByteString)]) ifTrue:[
  1561             includesNonStrings := list contains:[:l | l notNil and:[(l isMemberOf:String) not]].
  1561             includesNonStrings := list contains:[:l | l notNil and:[(l isSingleByteString) not]].
  1562         ]
  1562         ]
  1563     ].
  1563     ].
  1564 
  1564 
  1565     includesNonStrings ~~ didIncludeNonStrings ifTrue:[
  1565     includesNonStrings ~~ didIncludeNonStrings ifTrue:[
  1566         self getFontParameters.
  1566         self getFontParameters.
  2063         x := (self xOfCol:sCol inVisibleLine:visLineNr) - viewOrigin x.
  2063         x := (self xOfCol:sCol inVisibleLine:visLineNr) - viewOrigin x.
  2064         y := (self yOfVisibleLine:visLineNr).
  2064         y := (self yOfVisibleLine:visLineNr).
  2065         yf := y - (lineSpacing // 2).
  2065         yf := y - (lineSpacing // 2).
  2066 
  2066 
  2067         len := lineString size.
  2067         len := lineString size.
  2068         (lineString notNil and:[(lineString isMemberOf:String) not ])
  2068         (lineString notNil and:[lineString isString not ])
  2069         ifTrue:[
  2069         ifTrue:[
  2070             w := lineString widthFrom:sCol to:(endCol min:len) on:self.
  2070             w := lineString widthFrom:sCol to:(endCol min:len) on:self.
  2071             endCol > len ifTrue:[
  2071             endCol > len ifTrue:[
  2072                 sCol > len ifTrue:[
  2072                 sCol > len ifTrue:[
  2073                     numExtraCols := (endCol - sCol + 1).
  2073                     numExtraCols := (endCol - sCol + 1).
  2108             "/ remove any color emphasis, to enforce drawing in fg/bg
  2108             "/ remove any color emphasis, to enforce drawing in fg/bg
  2109 
  2109 
  2110             lineString := self withoutColorEmphasis:lineString ifFg:fg andBg:bg.
  2110             lineString := self withoutColorEmphasis:lineString ifFg:fg andBg:bg.
  2111 
  2111 
  2112             backgroundAlreadyClearedColor == bg ifFalse:[
  2112             backgroundAlreadyClearedColor == bg ifFalse:[
  2113                 (lineString isMemberOf:String) ifTrue:[
  2113                 (lineString isSingleByteString) ifTrue:[
  2114                     fontIsFixedWidth ifTrue:[
  2114                     fontIsFixedWidth ifTrue:[
  2115                         w := (eCol - sCol + 1) * fontWidth
  2115                         w := (eCol - sCol + 1) * fontWidth
  2116                     ] ifFalse:[
  2116                     ] ifFalse:[
  2117                         w := font widthOf:lineString from:sCol to:eCol
  2117                         w := font widthOf:lineString from:sCol to:eCol
  2118                     ]
  2118                     ]
  2375         "includes non strings or area is big enough: redraw whole lines"
  2375         "includes non strings or area is big enough: redraw whole lines"
  2376         self redrawFromVisibleLine:startLine to:stopLine
  2376         self redrawFromVisibleLine:startLine to:stopLine
  2377     ] ifFalse:[
  2377     ] ifFalse:[
  2378         line := self visibleAt:startLine.
  2378         line := self visibleAt:startLine.
  2379 
  2379 
  2380         (fontIsFixedWidth and:[line isMemberOf:String]) ifFalse:[
  2380         (fontIsFixedWidth and:[line isSingleByteString]) ifFalse:[
  2381             "start/end col has to be computed for each line"
  2381             "start/end col has to be computed for each line"
  2382 
  2382 
  2383             startLine to:stopLine do:[:i |
  2383             startLine to:stopLine do:[:i |
  2384                 startCol := self colOfX:x inVisibleLine:i.
  2384                 startCol := self colOfX:x inVisibleLine:i.
  2385                 endCol := self colOfX:(x + w) inVisibleLine:i.
  2385                 endCol := self colOfX:(x + w) inVisibleLine:i.
  2395             endCol := self colOfX:(x + w) inVisibleLine:startLine.
  2395             endCol := self colOfX:(x + w) inVisibleLine:startLine.
  2396             startCol > 0 ifTrue:[
  2396             startCol > 0 ifTrue:[
  2397                 endCol > 0 ifTrue:[
  2397                 endCol > 0 ifTrue:[
  2398                     startLine to:stopLine do:[:i |
  2398                     startLine to:stopLine do:[:i |
  2399                         line := self visibleAt:i.
  2399                         line := self visibleAt:i.
  2400                         (line isMemberOf:String) ifTrue:[
  2400                         (line isSingleByteString) ifTrue:[
  2401                             self redrawVisibleLine:i from:startCol to:endCol
  2401                             self redrawVisibleLine:i from:startCol to:endCol
  2402                         ] ifFalse:[
  2402                         ] ifFalse:[
  2403                             self redrawVisibleLine:i
  2403                             self redrawVisibleLine:i
  2404                         ]
  2404                         ]
  2405                     ]
  2405                     ]
  2846         "/
  2846         "/
  2847         hMax := list inject:hMax into:[:maxSoFar :thisLine |
  2847         hMax := list inject:hMax into:[:maxSoFar :thisLine |
  2848                                         thisLine isNil ifTrue:[
  2848                                         thisLine isNil ifTrue:[
  2849                                             maxSoFar
  2849                                             maxSoFar
  2850                                         ] ifFalse:[
  2850                                         ] ifFalse:[
  2851                                             (thisLine isMemberOf:String) ifTrue:[
  2851                                             (thisLine isSingleByteString) ifTrue:[
  2852                                                 maxSoFar
  2852                                                 maxSoFar
  2853                                             ] ifFalse:[
  2853                                             ] ifFalse:[
  2854                                                 maxSoFar max:(thisLine heightOn:self)
  2854                                                 maxSoFar max:(thisLine heightOn:self)
  2855                                             ]
  2855                                             ]
  2856                                         ]
  2856                                         ]
  3049 
  3049 
  3050     widthOfWidestLine notNil ifTrue:[
  3050     widthOfWidestLine notNil ifTrue:[
  3051         newEntry isNil ifTrue:[
  3051         newEntry isNil ifTrue:[
  3052             newW := 0
  3052             newW := 0
  3053         ] ifFalse:[
  3053         ] ifFalse:[
  3054             (newEntry isMemberOf:String) ifTrue:[
  3054             (newEntry isSingleByteString) ifTrue:[
  3055                 newW := font widthOf:newEntry
  3055                 newW := font widthOf:newEntry
  3056             ] ifFalse:[
  3056             ] ifFalse:[
  3057                 newW := newEntry widthOn:self
  3057                 newW := newEntry widthOn:self
  3058             ].
  3058             ].
  3059         ].
  3059         ].
  3062             widthOfWidestLine := newW.
  3062             widthOfWidestLine := newW.
  3063         ] ifFalse:[
  3063         ] ifFalse:[
  3064             oldEntry isNil ifTrue:[
  3064             oldEntry isNil ifTrue:[
  3065                 oldW := 0
  3065                 oldW := 0
  3066             ] ifFalse:[
  3066             ] ifFalse:[
  3067                 (oldEntry isMemberOf:String) ifTrue:[
  3067                 (oldEntry isSingleByteString) ifTrue:[
  3068                     oldW := font widthOf:oldEntry
  3068                     oldW := font widthOf:oldEntry
  3069                 ] ifFalse:[
  3069                 ] ifFalse:[
  3070                     oldW := oldEntry widthOn:self
  3070                     oldW := oldEntry widthOn:self
  3071                 ].
  3071                 ].
  3072             ].
  3072             ].
  3185 
  3185 
  3186 widthOfLineString:entry
  3186 widthOfLineString:entry
  3187     "return the width of an entry"
  3187     "return the width of an entry"
  3188 
  3188 
  3189     entry isNil ifTrue:[^ 0].
  3189     entry isNil ifTrue:[^ 0].
  3190     (entry isMemberOf:String) ifTrue:[
  3190     (entry isSingleByteString) ifTrue:[
  3191         ^ font widthOf:entry
  3191         ^ font widthOf:entry
  3192     ].
  3192     ].
  3193     ^ entry widthOn:self
  3193     ^ entry widthOn:self
  3194 
  3194 
  3195     "Modified: 12.5.1996 / 20:09:53 / cg"
  3195     "Modified: 12.5.1996 / 20:09:53 / cg"
  3222         last := listSize
  3222         last := listSize
  3223     ].
  3223     ].
  3224 
  3224 
  3225     self from:first to:last do:[:line |
  3225     self from:first to:last do:[:line |
  3226         line notNil ifTrue:[
  3226         line notNil ifTrue:[
  3227             (line isMemberOf:String) ifTrue:[
  3227             (line isSingleByteString) ifTrue:[
  3228                 thisLen := font widthOf:line
  3228                 thisLen := font widthOf:line
  3229             ] ifFalse:[
  3229             ] ifFalse:[
  3230                 thisLen := line widthOn:self
  3230                 thisLen := line widthOn:self
  3231             ].
  3231             ].
  3232             (thisLen > max) ifTrue:[
  3232             (thisLen > max) ifTrue:[
  3290     ] ifFalse:[
  3290     ] ifFalse:[
  3291         tcol := col - 1.
  3291         tcol := col - 1.
  3292 
  3292 
  3293         line := self visibleAt:visLineNr.
  3293         line := self visibleAt:visLineNr.
  3294         (fontIsFixedWidth
  3294         (fontIsFixedWidth
  3295         and:[line isNil or:[line isMemberOf:String]])
  3295         and:[line isNil or:[line isSingleByteString]])
  3296         ifTrue:[
  3296         ifTrue:[
  3297             lText := (tcol * fontWidth)
  3297             lText := (tcol * fontWidth)
  3298         ] ifFalse:[
  3298         ] ifFalse:[
  3299             line notNil ifTrue:[
  3299             line notNil ifTrue:[
  3300                 lineSize := line string size
  3300                 lineSize := line string size
  3305                 lText := (tcol * fontWidth)
  3305                 lText := (tcol * fontWidth)
  3306             ] ifFalse:[
  3306             ] ifFalse:[
  3307                 (lineSize < col) ifTrue:[
  3307                 (lineSize < col) ifTrue:[
  3308                     lText := (line widthOn:self) + (fontWidth * (tcol - lineSize))
  3308                     lText := (line widthOn:self) + (fontWidth * (tcol - lineSize))
  3309                 ] ifFalse:[
  3309                 ] ifFalse:[
  3310                     (line isMemberOf:String) ifTrue:[
  3310                     (line isSingleByteString) ifTrue:[
  3311                         lText := (font widthOf:line from:1 to:tcol)
  3311                         lText := (font widthOf:line from:1 to:tcol)
  3312                     ] ifFalse:[
  3312                     ] ifFalse:[
  3313                         lText := line widthFrom:1 to:tcol on:self.
  3313                         lText := line widthFrom:1 to:tcol on:self.
  3314                     ]
  3314                     ]
  3315                 ]
  3315                 ]
  3629         start to:stop do:[:lineNr |
  3629         start to:stop do:[:lineNr |
  3630             |entry w|
  3630             |entry w|
  3631 
  3631 
  3632             entry := list at:lineNr.
  3632             entry := list at:lineNr.
  3633             entry notNil ifTrue:[
  3633             entry notNil ifTrue:[
  3634                 (entry isMemberOf:String) ifTrue:[
  3634                 (entry isSingleByteString) ifTrue:[
  3635                     w := f widthOf:entry
  3635                     w := f widthOf:entry
  3636                 ] ifFalse:[
  3636                 ] ifFalse:[
  3637                     w := entry widthOn:self
  3637                     w := entry widthOn:self
  3638                 ].
  3638                 ].
  3639                 max := max max:w.
  3639                 max := max max:w.
  3646                 start to:stop do:[:lineNr |
  3646                 start to:stop do:[:lineNr |
  3647                     |line|
  3647                     |line|
  3648 
  3648 
  3649                     line := list at:lineNr.
  3649                     line := list at:lineNr.
  3650                     line notNil ifTrue:[
  3650                     line notNil ifTrue:[
  3651                         (line isMemberOf:String) ifTrue:[
  3651                         (line isSingleByteString) ifTrue:[
  3652                             line size > lengthOfLongestString ifTrue:[
  3652                             line size > lengthOfLongestString ifTrue:[
  3653                                 lengthOfLongestString := line size
  3653                                 lengthOfLongestString := line size
  3654                             ].
  3654                             ].
  3655                         ] ifFalse:[
  3655                         ] ifFalse:[
  3656                             max := max max:(line widthOn:self)
  3656                             max := max max:(line widthOn:self)
  3698         "/ mhmh - really dont know yet
  3698         "/ mhmh - really dont know yet
  3699         d := Screen current
  3699         d := Screen current
  3700     ].
  3700     ].
  3701     f := font := font onDevice:d.
  3701     f := font := font onDevice:d.
  3702 
  3702 
  3703     (line isMemberOf:String) ifTrue:[
  3703     (line isSingleByteString) ifTrue:[
  3704         ^ f widthOf:line
  3704         ^ f widthOf:line
  3705     ].
  3705     ].
  3706     ^ line widthOn:self
  3706     ^ line widthOn:self
  3707 
  3707 
  3708     "Created: / 10.11.1998 / 23:59:20 / cg"
  3708     "Created: / 10.11.1998 / 23:59:20 / cg"
  5305 ! !
  5305 ! !
  5306 
  5306 
  5307 !ListView class methodsFor:'documentation'!
  5307 !ListView class methodsFor:'documentation'!
  5308 
  5308 
  5309 version
  5309 version
  5310     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.398 2014-07-06 12:43:22 cg Exp $'
  5310     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.399 2014-07-12 05:39:50 cg Exp $'
  5311 !
  5311 !
  5312 
  5312 
  5313 version_CVS
  5313 version_CVS
  5314     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.398 2014-07-06 12:43:22 cg Exp $'
  5314     ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.399 2014-07-12 05:39:50 cg Exp $'
  5315 ! !
  5315 ! !
  5316 
  5316