--- a/DSVColumnView.st Fri Jan 02 19:22:28 1998 +0100
+++ b/DSVColumnView.st Sat Jan 03 18:02:59 1998 +0100
@@ -21,7 +21,7 @@
beDependentOfRows bgColor hgLgFgColor hgLgBgColor actionBlock
doubleClickActionBlock separatorLightColor separatorDarkColor
verticalSpacing horizontalSpacing toggleOnButton toggleOffButton
- rowSelectorButton comboViewButton'
+ rowSelectorButton comboViewButton clickPosition'
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
DefaultHilightForegroundColor DefaultHilightBackgroundColor
DefaultSeparatorDarkColor DefaultSeparatorLightColor
@@ -299,8 +299,8 @@
self contentsChanged.
]
].
+ sizeOfListChanged := false.
self changed:#sizeOfColumns.
- sizeOfListChanged := false.
!
@@ -461,14 +461,15 @@
]
].
- beDependentOfRows ifTrue:[
- self beDependentOfRows:false.
- list := aList.
- self beDependentOfRows:true.
+ beDependentOfRows ifTrue:[ self beDependentOfRows:false ].
+
+ aList size ~~ 0 ifTrue:[
+ list := OrderedCollection new:(aList size).
+ list replaceFrom:1 to:(list size) with:aList startingAt:1.
+ beDependentOfRows ifTrue:[self beDependentOfRows:true].
] ifFalse:[
- list := aList
+ list := nil
].
- aList size == 0 ifTrue:[list := nil].
shown ifTrue:[
self recomputeHeightOfContents.
@@ -508,8 +509,7 @@
self invalidate
] ifFalse:[
bgColor := aColor
- ].
- self changed:#style.
+ ]
]
!
@@ -524,8 +524,7 @@
realized ifTrue:[
self invalidate.
self contentsChanged
- ].
- self changed:#style.
+ ]
]
!
@@ -546,8 +545,7 @@
self invalidate
] ifFalse:[
fgColor := aColor
- ].
- self changed:#style.
+ ]
]
!
@@ -663,14 +661,18 @@
list isNil ifTrue:[
list := OrderedCollection new.
preferredExtent := nil. "/ force a recomputation
- ] ifFalse:[
- list := list asOrderedCollection
].
+
beDependentOfRows ifTrue:[
aRow notNil ifTrue:[aRow addDependent:self].
].
list add:aRow beforeIndex:aRowNr.
+
+ list size == 1 ifTrue:[
+ self invalidate.
+ ^ aRow
+ ].
self recomputeHeightOfContents.
(y0 := self numberOfSelections) ~~ 0 ifTrue:[
@@ -698,8 +700,8 @@
y0 := self yVisibleOfRowNr:aRowNr.
y1 := y0 + rowHeight.
- (y1 > margin and:[y0 < (height - margin)]) ifTrue:[
- h := height - margin - y1.
+ (y1 > margin and:[y0 < (h := height - margin)]) ifTrue:[
+ h := h - y1.
y0 := y0 max:margin.
dH := y1 - y0.
self catchExpose.
@@ -707,8 +709,9 @@
self copyFrom:self x:0 y:y0
toX:0 y:y1
width:width height:h async:true.
+
+ self redrawX:margin y:y0 width:width - margin - margin height:dH.
self waitForExpose.
- self redrawX:margin y:y0 width:width height:dH.
]
].
sizeOfListChanged := true.
@@ -753,8 +756,6 @@
row removeDependent:self
].
- list isArray ifTrue:[list := list asOrderedCollection].
-
(y0 := self numberOfSelections) ~~ 0 ifTrue:[
y0 == 1 ifTrue:[
(y0 := self firstIndexSelected) > aRowNr ifTrue:[
@@ -806,7 +807,7 @@
self waitForExpose.
].
y0 := y0 + h.
- self redrawX:margin y:y0 width:width height:(height - y0).
+ self redrawX:margin y:y0 width:width - margin - margin height:(height - y0).
].
sizeOfListChanged := true.
self contentsChanged.
@@ -951,14 +952,13 @@
redrawX:x y:y width:w height:h
"redraw part of myself immediately, given logical coordinates
"
- |c0 c1 aCol prevClipArea
- size "{ Class:SmallInteger }"
- idx "{ Class:SmallInteger }"
+ |c0 prevClipArea
start "{ Class:SmallInteger }"
stop "{ Class:SmallInteger }"
x0 "{ Class:SmallInteger }"
x1 "{ Class:SmallInteger }"
maxX "{ Class:SmallInteger }"
+ minX "{ Class:SmallInteger }"
yTop "{ Class:SmallInteger }"
yBot "{ Class:SmallInteger }"
times "{ Class:SmallInteger }"
@@ -969,32 +969,29 @@
self paint:bgColor.
self fillRectangleX:x y:y width:w height:h.
- (size := columnDescriptors size) ~~ 0 ifTrue:[
+ columnDescriptors size ~~ 0 ifTrue:[
yTop := margin - viewOrigin y.
c0 := y - yTop.
start := (c0 // rowHeight) + 1.
- stop := (c0 + h - 1 // rowHeight + 1) min:(self size).
+ stop := (c0 + h - 1 // rowHeight + 1) min:(list size).
(times := stop - start + 1) > 0 ifTrue:[
- prevClipArea := clipRect.
- clipRect := nil.
-
- maxX := (x + w) max:(width - margin).
+ prevClipArea := clipRect.
+ clipRect := nil.
+
+ maxX := (x + w) min:(width - margin).
x0 := margin - viewOrigin x.
yTop := yTop + ((start - 1) * rowHeight).
yBot := yTop + (times * rowHeight).
- idx := 1.
yMax := height - margin - margin.
-
- size timesRepeat:[
- aCol := columnDescriptors at:idx.
- idx := idx + 1.
- x1 := x0 + aCol width.
+ minX := x max:margin.
+
+ columnDescriptors do:[:aCol|
+ x1 := x0 + aCol width.
(x1 > x and:[x0 < maxX]) ifTrue:[
- c0 := x0 max:margin.
- c1 := (x1 max:maxX) - c0.
- device setClipX:c0 y:margin width:c1 height:yMax in:drawableId gc:gcId.
+ c0 := (x1 min:maxX) - minX.
+ device setClipX:minX y:margin width:c0 height:yMax in:drawableId gc:gcId.
aCol drawFrom:start times:times x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor.
].
x0 := x1
@@ -1045,7 +1042,6 @@
^ self
].
].
-
scr := 0.
y > height ifTrue:[
@@ -1059,22 +1055,35 @@
idx := self yVisibleToRowNr:y.
]
].
-
- (idx isNil or:[idx < 1]) ifTrue:[^ self].
-
- (self isInSelection:idx) ifTrue:[
+ (idx isNil or:[idx < 1 or:[self isInSelection:idx]]) ifTrue:[
^ self
].
-
selectedRowIndex := selectedRowIndex asOrderedCollection.
- selectedRowIndex add:idx.
+
+ clickPosition notNil ifTrue:[
+ (clickPosition - idx) abs > 1 ifTrue:[|s e|
+ clickPosition < idx ifTrue:[
+ s := clickPosition + 1.
+ e := idx - 1.
+ ] ifFalse:[
+ s := idx + 1.
+ e := clickPosition - 1.
+ ].
+ s to:e do:[:i|
+ (self isInSelection:i) ifFalse:[
+ selectedRowIndex add:i.
+ self redrawRowAt:i colAt:0.
+ ]
+ ]
+ ]
+ ].
+ selectedRowIndex add:(clickPosition := idx).
scr == 0 ifTrue:[
- self redrawRowAt:idx
+ self redrawX:margin y:y width:width - margin - margin height:1
] ifFalse:[
self scrollTo:(viewOrigin + (0 @ scr)) redraw:true
].
- self selectionChanged.
!
buttonMultiPress:button x:x y:y
@@ -1168,6 +1177,17 @@
!
+buttonRelease:button x:x y:y
+
+ clickPosition notNil ifTrue:[
+ clickPosition := nil.
+ self selectionChanged.
+ ].
+ super buttonRelease:button x:x y:y
+
+
+!
+
contentsChanged
"contents changed - move origin up if possible
"
@@ -1841,9 +1861,9 @@
ifFalse:[y1 := margin. y := y1 + h].
self catchExpose.
- self copyFrom:self x:0 y:y0 toX:0 y:y1 width:width height:h async:true.
+ self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true.
self waitForExpose.
- self redrawX:0 y:y width:width height:(innerHG - h).
+ self redrawX:margin y:y width:innerWT height:(innerHG - h).
]
] ifFalse:[ "/ SCROLL HORIZONTAL
dX := dX abs.
@@ -1853,16 +1873,16 @@
] ifFalse:[ "/ COPY HORIZONTAL
|x0 x1 w|
- x0 := x1 := dX.
+ x0 := x1 := dX + margin.
w := width - dX - margin.
- dltOrg x < 0 ifTrue:[x0 := 0. x := x0]
- ifFalse:[x1 := 0. x := w].
+ dltOrg x < 0 ifTrue:[x0 := x := margin ]
+ ifFalse:[x1 := margin. x := w].
self catchExpose.
- self copyFrom:self x:x0 y:0 toX:x1 y:0 width:w height:height async:true.
+ self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true.
self waitForExpose.
- self redrawX:x y:0 width:(width - w) height:height.
+ self redrawX:x y:margin width:(width - w) height:innerHG.
]
].
self originChanged:dltOrg.
@@ -2113,7 +2133,7 @@
].
(rowNr = selectedRowIndex and:[colNr == selectedColIndex]) ifTrue:[
- ^ self "/ nothing changed
+ ^ self
].
"/ release old selection
@@ -2219,5 +2239,5 @@
!DSVColumnView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.17 1998-01-02 18:22:28 tz Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.18 1998-01-03 17:02:59 ca Exp $'
! !