--- a/DSVColumnView.st Tue Mar 27 14:01:53 2001 +0200
+++ b/DSVColumnView.st Thu Mar 29 12:57:49 2001 +0200
@@ -876,31 +876,14 @@
at:aRowNr put:aRow
"change the row at an index. The added row is returned
"
- |row|
-
- lockRowIndex == aRowNr ifTrue:[
- ^ self
- ].
- row := list at:aRowNr.
- row == aRow ifTrue:[
- ^ self invalidateRowAt:aRowNr
- ].
-
- beDependentOfRows ifTrue:[
- (row := list at:aRowNr) notNil ifTrue:[
- row removeDependent:self
+ lockRowIndex ~~ aRowNr ifTrue:[
+ (aRowNr <= list size and:[(list at:aRowNr) == aRow]) ifTrue:[
+ self invalidateRowAt:aRowNr
+ ] ifFalse:[
+ self replaceFrom:aRowNr to:aRowNr with:(Array with:aRow) startingAt:1.
]
].
-
- list at:aRowNr put:aRow.
-
- aRow notNil ifTrue:[ "/ free list
- beDependentOfRows ifTrue:[
- aRow addDependent:self
- ].
- self invalidateRowAt:aRowNr
- ].
- ^ aRow.
+ ^ aRow
!
first
@@ -1326,6 +1309,59 @@
"remove last row; the row is returned
"
^ self removeIndex:(list size)
+!
+
+replaceFrom:start to:stop with:aCollection startingAt:repStart
+ "replace elements in the receiver between index start and stop,
+ with elements taken from replacementCollection starting at repStart.
+ Return the receiver.
+ "
+ |row inSelList listSize repStop run|
+
+ inSelList := OrderedCollection new.
+ listSize := list size.
+ repStop := repStart + (stop - start).
+
+ list isNil ifTrue:[
+ list := OrderedCollection new
+ ].
+
+ [listSize < stop] whileTrue:[ list add:nil. listSize := listSize + 1 ].
+
+ start to:stop do:[:i| |aRow|
+ aRow := list at:i ifAbsent:nil.
+
+ aRow notNil ifTrue:[
+ beDependentOfRows ifTrue:[aRow removeDependent:self].
+
+ (self isInSelection:i) ifTrue:[
+ inSelList add:i
+ ].
+ list at:i put:nil.
+ ]
+ ].
+
+ beDependentOfRows ifTrue:[
+ aCollection from:repStart to:repStop do:[:aRow|
+ aRow notNil ifTrue:[aRow addDependent:self]
+ ]
+ ].
+
+ run := start.
+ aCollection from:repStart to:repStop do:[:aRow|
+ list at:run put:aRow.
+ run := run + 1.
+ ].
+ self invalidateRowsFrom:start to:stop.
+
+ inSelList size ~~ 0 ifTrue:[
+ self numberOfSelections == inSelList size ifTrue:[
+ self deselect
+ ] ifFalse:[
+ selectedRowIndex := selectedRowIndex select:[:i| (inSelList identityIndexOf:i) == 0 ].
+ self selectionChanged.
+ ]
+ ].
! !
!DSVColumnView methodsFor:'change & update'!
@@ -1449,8 +1485,7 @@
^ self.
].
what == #replace: ifTrue:[
- list notNil ifTrue:[list from:arg1 to:arg2 put:nil].
- arg1 to:arg2 do:[:i| self at:i put:(listHoldersList at:i) ].
+ self replaceFrom:arg1 to:arg2 with:listHoldersList startingAt:arg1.
^ self
].
^ self
@@ -1594,6 +1629,27 @@
]
!
+invalidateRowsFrom:aStart to:aStop
+ "redraw visible row from start to stop
+ "
+ |size start stop y0 y1|
+
+ shown ifTrue:[
+ size := list size.
+ start := aStart notNil ifTrue:[aStart max:1] ifFalse:[1].
+ stop := aStop notNil ifTrue:[aStop min:size] ifFalse:[size].
+
+ start <= stop ifTrue:[
+ y0 := (self yVisibleOfRowNr:start) max:margin.
+ y1 := ((self yVisibleOfRowNr:stop) + rowHeight) min:height.
+
+ y0 < y1 ifTrue:[
+ self invalidateX:margin y:y0 width:width height:(y1 - y0)
+ ]
+ ]
+ ]
+!
+
invalidateX:x y:y width:w height:h
"invalidate a rectangle
"
@@ -3506,5 +3562,5 @@
!DSVColumnView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.126 2001-03-19 09:42:41 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.127 2001-03-29 10:57:49 ca Exp $'
! !