# HG changeset patch # User Claus Gittinger # Date 830526981 -7200 # Node ID 19deffec383dcd2a82d70e965eb0b2accaefee8b # Parent 032b3245e53a619bee3b8ab22e86baecde9ec960 if there is no listMessage, try aspect to get models text diff -r 032b3245e53a -r 19deffec383d ListView.st --- a/ListView.st Thu Apr 25 19:34:16 1996 +0200 +++ b/ListView.st Fri Apr 26 15:56:21 1996 +0200 @@ -194,6 +194,7 @@ top open + globally set the fg/bg colors: |top l| @@ -209,6 +210,7 @@ top open + non-string entries: |top list l| @@ -223,6 +225,65 @@ l list:list. top open + + + + using a model (default listMessage is aspectMessage): + + |top model l theModelsText| + + model := Plug new. + model respondTo:#modelsAspect + with:[ theModelsText ]. + + top := StandardSystemView new. + top extent:100@200. + + l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top. + l model:model. + l aspect:#modelsAspect. + + top open. + + Delay waitForSeconds:3. + theModelsText := #('foo' 'bar' 'baz'). + model changed:#modelsAspect. + + + + using a model with different aspects + for two listViews: + + |top model l1 l2 plainText| + + plainText := #(''). + + model := Plug new. + model respondTo:#modelsUppercaseText + with:[ plainText asStringCollection + collect:[:l | l asUppercase]]. + model respondTo:#modelsLowercaseText + with:[ plainText asStringCollection + collect:[:l | l asLowercase]]. + + top := StandardSystemView extent:200@200. + + l1 := ListView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top. + l1 model:model. + l1 aspect:#modelsAspect. + l1 listMessage:#modelsUppercaseText. + + l2 := ListView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top. + l2 model:model. + l2 aspect:#modelsAspect. + l2 listMessage:#modelsLowercaseText. + + top open. + + Delay waitForSeconds:3. + plainText := #('foo' 'bar' 'baz'). + model changed:#modelsAspect. + " ! ! @@ -552,33 +613,36 @@ ! removeIndex:lineNr - "delete line, update view" + "delete a line, redraw the view" |visLine w srcY "{ Class: SmallInteger }" | (self removeIndexWithoutRedraw:lineNr) ifFalse:[^ self]. + " is there a need to redraw ? " shown ifFalse:[^ self]. visLine := self listLineToVisibleLine:lineNr. visLine notNil ifTrue:[ - w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown). - srcY := topMargin + (visLine * fontHeight). - self catchExpose. - self copyFrom:self x:textStartLeft y:srcY - toX:textStartLeft y:(srcY - fontHeight) - width:w height:((nLinesShown - visLine) * fontHeight). - self redrawVisibleLine:nFullLinesShown. - " - redraw last partial line - if any - " - (nFullLinesShown ~~ nLinesShown) ifTrue:[ - self redrawVisibleLine:nLinesShown - ]. - self waitForExpose + w := self widthForScrollBetween:lineNr and:(firstLineShown + nLinesShown). + srcY := topMargin + (visLine * fontHeight). + self catchExpose. + self copyFrom:self x:textStartLeft y:srcY + toX:textStartLeft y:(srcY - fontHeight) + width:w height:((nLinesShown - visLine) * fontHeight). + self redrawVisibleLine:nFullLinesShown. + " + redraw last partial line - if any + " + (nFullLinesShown ~~ nLinesShown) ifTrue:[ + self redrawVisibleLine:nLinesShown + ]. + self waitForExpose ] + + "Modified: 26.4.1996 / 13:44:47 / cg" ! removeIndexWithoutRedraw:lineNr @@ -1443,18 +1507,28 @@ ! getListFromModel - "ask my model (if any) for the text via the listMsg." - - |text| - - (model notNil - and:[listMsg notNil]) ifTrue:[ - text := model perform:listMsg. - text notNil ifTrue:[ - text := text asStringCollection. - ]. - self list:text + "ask my model (if any) for the text via the listMsg. + If there is no listMessage, try aspect for backward compatibility." + + |text msg| + + model notNil ifTrue:[ + msg := listMsg. + msg isNil ifTrue:[ + msg := aspectMsg + ]. + + + msg notNil ifTrue:[ + text := model perform:msg. + text notNil ifTrue:[ + text := text asStringCollection. + ]. + self list:text + ] ]. + + "Modified: 26.4.1996 / 14:09:42 / cg" ! lineOfCharacterPosition:charPos @@ -1814,6 +1888,16 @@ ! +lineIsFullyVisible:line + "is line fully visible?" + + (line >= firstLineShown + and:[ line < (firstLineShown + nFullLinesShown) ]) ifTrue:[ ^ true ]. + ^ false. + + "Created: 26.4.1996 / 14:36:45 / cg" +! + lineIsVisible:line "is line visible?" @@ -2970,5 +3054,5 @@ !ListView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.77 1996-04-25 17:32:39 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.78 1996-04-26 13:55:45 cg Exp $' ! ! diff -r 032b3245e53a -r 19deffec383d SelListV.st --- a/SelListV.st Thu Apr 25 19:34:16 1996 +0200 +++ b/SelListV.st Fri Apr 26 15:56:21 1996 +0200 @@ -2089,26 +2089,34 @@ ! getListFromModel - "if I have a model and a listMsg, get my list from it" - - |text| + "if I have a model, get my list from it using the listMessage. + If listMessage is nil, try aspectMessage for backward compatibilty." + + |text msg| model notNil ifTrue:[ - listMsg notNil ifTrue:[ - items := model perform:listMsg. - items notNil ifTrue:[ - printItems ifTrue:[ - text := items collect:[:element | element printString] - ] ifFalse:[ - text := items - ]. + msg := listMsg. + msg isNil ifTrue:[ + msg := aspectMsg + ]. + + listMsg notNil ifTrue:[ + items := model perform:msg. + items notNil ifTrue:[ + printItems ifTrue:[ + text := items collect:[:element | element printString] + ] ifFalse:[ + text := items + ]. "/ text notNil ifTrue:[ "/ text := text asStringCollection. "/ ] - ]. - self list:text keepSelection:true. "/ expandTabs:false - ]. + ]. + self list:text keepSelection:true. "/ expandTabs:false + ]. ]. + + "Modified: 26.4.1996 / 14:09:04 / cg" ! getSelectionFromModel @@ -2723,5 +2731,5 @@ !SelectionInListView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.65 1996-04-25 17:33:40 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/Attic/SelListV.st,v 1.66 1996-04-26 13:56:21 cg Exp $' ! ! diff -r 032b3245e53a -r 19deffec383d SelectionInListView.st --- a/SelectionInListView.st Thu Apr 25 19:34:16 1996 +0200 +++ b/SelectionInListView.st Fri Apr 26 15:56:21 1996 +0200 @@ -2089,26 +2089,34 @@ ! getListFromModel - "if I have a model and a listMsg, get my list from it" - - |text| + "if I have a model, get my list from it using the listMessage. + If listMessage is nil, try aspectMessage for backward compatibilty." + + |text msg| model notNil ifTrue:[ - listMsg notNil ifTrue:[ - items := model perform:listMsg. - items notNil ifTrue:[ - printItems ifTrue:[ - text := items collect:[:element | element printString] - ] ifFalse:[ - text := items - ]. + msg := listMsg. + msg isNil ifTrue:[ + msg := aspectMsg + ]. + + listMsg notNil ifTrue:[ + items := model perform:msg. + items notNil ifTrue:[ + printItems ifTrue:[ + text := items collect:[:element | element printString] + ] ifFalse:[ + text := items + ]. "/ text notNil ifTrue:[ "/ text := text asStringCollection. "/ ] - ]. - self list:text keepSelection:true. "/ expandTabs:false - ]. + ]. + self list:text keepSelection:true. "/ expandTabs:false + ]. ]. + + "Modified: 26.4.1996 / 14:09:04 / cg" ! getSelectionFromModel @@ -2723,5 +2731,5 @@ !SelectionInListView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.65 1996-04-25 17:33:40 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg/SelectionInListView.st,v 1.66 1996-04-26 13:56:21 cg Exp $' ! !