--- a/DSVColumnView.st Thu Apr 16 12:59:40 1998 +0200
+++ b/DSVColumnView.st Thu Apr 16 13:00:21 1998 +0200
@@ -695,79 +695,80 @@
"add a new row before slot aRowNr and redisplay; returns nil in case
of an invalid index or the row
"
- |y0 y1 h dH|
-
- list isNil ifTrue:[
- list := OrderedCollection new.
- preferredExtent := nil. "/ force a recomputation
+ self addAll:(Array with:aRow) beforeIndex:aRowNr.
+ ^ aRow.
+!
+
+addAll:aList beforeIndex:start
+ "add a collection of rows before slot start and redisplay
+ "
+ |y0 y1 yD h dH size noSel|
+
+ (size := aList size) == 0 ifTrue:[
+ ^ self
+ ].
+
+ self size == 0 ifTrue:[
+ ^ self list:aList
].
beDependentOfRows ifTrue:[
- aRow notNil ifTrue:[aRow addDependent:self].
+ aList do:[:aRow| aRow notNil ifTrue:[aRow addDependent:self]]
].
- list add:aRow beforeIndex:aRowNr.
-
- self recomputeHeightOfContents.
-
- (y0 := self numberOfSelections) ~~ 0 ifTrue:[
- y0 == 1 ifTrue:[
- (y0 := self firstIndexSelected) >= aRowNr ifTrue:[
- y0 := y0 + 1.
- multipleSelectOk ifFalse:[
- selectedRowIndex := y0
- ] ifTrue:[
- selectedRowIndex at:1 put:y0
+ noSel := self numberOfSelections.
+
+ noSel ~~ 0 ifTrue:[
+ multipleSelectOk ifFalse:[
+ selectedRowIndex >= start ifTrue:[
+ selectedRowIndex := selectedRowIndex + size
+ ]
+ ] ifTrue:[
+ 1 to:noSel do:[:i||v|
+ (v := selectedRowIndex at:i) >= start ifTrue:[
+ selectedRowIndex at:i put:(v + size)
]
]
- ] ifFalse:[
- self deselect
]
].
-
- y0 := (aRowNr - 1) * rowHeight.
+ list addAll:aList beforeIndex:start.
+ self recomputeHeightOfContents.
+
+ y0 := (start - 1) * rowHeight.
+ yD := size * rowHeight.
+ y1 := y0 + yD.
y0 < viewOrigin y ifTrue:[
self originWillChange.
- viewOrigin y:(rowHeight + viewOrigin y).
- self originChanged:(0 @ rowHeight).
+ viewOrigin y:(yD + viewOrigin y).
+ self originChanged:(0 @ yD).
+ ].
+
+ (shown not or:[self sensor hasDamageFor:self]) ifTrue:[
+ ^ self contentsChanged.
].
- (shown not or:[self sensor hasDamageFor:self]) ifFalse:[
- y0 := self yVisibleOfRowNr:aRowNr.
- y1 := y0 + rowHeight.
-
- (y1 > margin and:[y0 < (h := height - margin)]) ifTrue:[
- h := h - y1.
- y0 := y0 max:margin.
- dH := y1 - y0.
- aRowNr == list size ifFalse:[
- self catchExpose.
-
- self copyFrom:self x:0 y:y0
- toX:0 y:y1
- width:width height:h async:true.
-
- self waitForExpose
- ].
- self redrawX:margin y:y0 width:width - margin - margin height:dH.
- ]
+ y0 := self yVisibleOfRowNr:start.
+ y1 := y0 + yD.
+
+ (y1 > margin and:[y0 < (h := height - margin)]) ifTrue:[
+ h := h - y1.
+ y0 := y0 max:margin.
+ dH := y1 - y0.
+
+ start == list size ifFalse:[
+ self catchExpose.
+
+ self copyFrom:self x:0 y:y0
+ toX:0 y:y1
+ width:width height:h async:true.
+
+ self waitForExpose
+ ].
+ self redrawX:margin y:y0 width:width - margin - margin height:dH.
].
self contentsChanged.
- ^ aRow
-!
-
-addAll:aCollection beforeIndex:aRowNr
- "add a collection of rows before slot aRowNr and redisplay
- "
- aCollection size ~~ 0 ifTrue:[
- self size == 0 ifTrue:[
- ^ self list:aCollection
- ].
- aCollection reverseDo:[:aRow|
- self add:aRow beforeIndex:aRowNr
- ]
- ].
+
!
addFirst:aRow
@@ -782,49 +783,82 @@
self removeIndex:1
!
-removeIndex:aRowNr
- "remove row at an index; returns the removed row
+removeFrom:startIndex to:stopIndex
+ "remove rows from start to stop
"
- |y0 y1 h dY oY yB noRedraw row|
-
- row := list at:aRowNr ifAbsent:[^ self subscriptBoundsError:aRowNr].
-
- (beDependentOfRows and:[row notNil]) ifTrue:[
- row removeDependent:self
+ |coll noRedraw
+ noSel "{ Class: SmallInteger }"
+ size "{ Class: SmallInteger }"
+ start "{ Class: SmallInteger }"
+ stop "{ Class: SmallInteger }"
+ y0 "{ Class: SmallInteger }"
+ y1 "{ Class: SmallInteger }"
+ oY "{ Class: SmallInteger }"
+ dY "{ Class: SmallInteger }"
+ yB "{ Class: SmallInteger }"
+ h "{ Class: SmallInteger }"
+ |
+
+ ( (start := startIndex) < 1
+ or:[(stop := stopIndex) > list size]
+ ) ifTrue:[
+ ^ self subscriptBoundsError:start
].
-
- (y0 := self numberOfSelections) ~~ 0 ifTrue:[
- y0 == 1 ifTrue:[
- (y0 := self firstIndexSelected) > aRowNr ifTrue:[
- y0 := y0 - 1.
- multipleSelectOk ifFalse:[
- selectedRowIndex := y0
- ] ifTrue:[
- selectedRowIndex at:1 put:y0
- ]
- ] ifFalse:[
- y0 == aRowNr ifTrue:[
+ size := stop - start + 1.
+
+ beDependentOfRows ifTrue:[
+ list from:start to:stop do:[:r| r notNil ifTrue:[r removeDependent:self]].
+ ].
+ noSel := self numberOfSelections.
+
+ noSel ~~ 0 ifTrue:[
+ noSel == 1 ifTrue:[
+ noSel := self firstIndexSelected.
+
+ noSel < start ifFalse:[
+ noSel > stop ifTrue:[
+ noSel := noSel - size.
+
+ multipleSelectOk ifFalse:[selectedRowIndex := noSel]
+ ifTrue:[selectedRowIndex at:1 put:noSel]
+ ] ifFalse:[
editValue notNil ifTrue:[
editValue removeDependent:self.
editValue := nil.
].
- self deselect
+ self deselect.
]
]
] ifFalse:[
- self deselect
+ coll := OrderedCollection new:noSel.
+
+ selectedRowIndex do:[:i|
+ i < start ifTrue:[
+ coll add:i
+ ] ifFalse:[
+ i > stop ifTrue:[
+ coll add:(i - size)
+ ]
+ ]
+ ].
+ coll size == 0 ifTrue:[
+ self deselect
+ ] ifFalse:[
+ selectedRowIndex := coll
+ ]
]
].
- y1 := aRowNr * rowHeight.
- y0 := y1 - rowHeight.
+ list removeFrom:start to:stop.
+
+ y0 := start - 1 * rowHeight.
+ dY := size * rowHeight.
+ y1 := dY + y0.
yB := y1 + margin - viewOrigin y.
-
- list removeIndex:aRowNr.
self recomputeHeightOfContents.
y0 < (oY := viewOrigin y) ifTrue:[
(noRedraw := y1 <= oY) ifFalse:[dY := y0 - oY]
- ifTrue:[dY := rowHeight negated].
+ ifTrue:[dY := dY negated].
self originWillChange.
viewOrigin y:(dY + oY).
self originChanged:(0 @ dY).
@@ -834,7 +868,7 @@
(noRedraw or:[shown not]) ifFalse:[
y1 := yB.
- y0 := self yVisibleOfRowNr:aRowNr.
+ y0 := self yVisibleOfRowNr:start.
h := height - margin - yB.
y0 := y0 max:margin.
@@ -847,7 +881,17 @@
self redrawX:margin y:y0 width:width - margin - margin height:(height - y0).
].
self contentsChanged.
- ^ row.
+
+!
+
+removeIndex:aRowNr
+ "remove row at an index; returns the removed row
+ "
+ |row|
+
+ row := list at:aRowNr ifAbsent:nil.
+ self removeFrom:aRowNr to:aRowNr.
+ ^ row
!
removeLast
@@ -1265,7 +1309,7 @@
selectedRowIndex add:(clickPosition := idx).
scr == 0 ifTrue:[
- self redrawX:margin y:y width:width - margin - margin height:1
+ self redrawRowAt:idx colAt:0.
] ifFalse:[
self scrollTo:(viewOrigin + (0 @ scr)) redraw:true
].
@@ -1330,7 +1374,6 @@
]
]
].
-
(self canDrag and:[self isSelected:rowNr inColumn:colNr]) ifTrue:[
clickPosition := x @ y.
dragAccessPoint := (colNr @ rowNr).
@@ -2582,5 +2625,5 @@
!DSVColumnView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.33 1998-04-14 13:36:18 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.34 1998-04-16 11:00:21 ca Exp $'
! !