diff -r 9c418c3aaf49 -r d6133cb2f3c9 DSVLabelView.st --- a/DSVLabelView.st Sat Aug 28 16:10:08 1999 +0200 +++ b/DSVLabelView.st Sat Aug 28 18:50:27 1999 +0200 @@ -15,12 +15,20 @@ SimpleView subclass:#DSVLabelView - instanceVariableNames:'isVisible dataSet columns selection enabled preferredHeight' + instanceVariableNames:'isVisible dataSet tabulator columns selection enabled + preferredHeight' classVariableNames:'' poolDictionaries:'' category:'Views-DataSet' ! +SimpleView subclass:#Tabulator + instanceVariableNames:'column colRight startX transX minRqX' + classVariableNames:'' + poolDictionaries:'' + privateIn:DSVLabelView +! + !DSVLabelView class methodsFor:'documentation'! copyright @@ -200,26 +208,69 @@ !DSVLabelView methodsFor:'event handling'! +buttonMotion:state x:x y:y + "mouse-button was moved while pressed; + redraw thumb at its new position and, if scroll-mode is asynchronous, + the scroll action is performed + " + tabulator notNil ifTrue:[tabulator moveToX:x] + + +! + buttonPress:button x:x y:y "handle a button press event; checks whether the item under the mouse is selectable. If true, the selection is set to the item. " - (selection := self xVisibleToSelectionIndex:x) notNil ifTrue:[ - self invalidateItemAt:selection - ] + |x0 x1| + + (isVisible and:[enabled and:[shown]]) ifFalse:[ + ^ self + ]. + x1 := dataSet xVisibleOfColNr:1. + + columns keysAndValuesDo:[:index :aCol| + x0 := x1. + x1 := x0 + aCol width. + + (x1 > x and:[x0 < x]) ifTrue:[ + x + 6 > x1 ifFalse:[ + aCol label isSelectable ifTrue:[ + self invalidateItemAt:(selection := index) + ] + ] ifTrue:[ + tabulator := Tabulator new. + tabulator column:aCol colRight:x1. + tabulator openFor:self x:x y:0 h:(self superView height) + ]. + ^ self + ]. + ]. + ! buttonRelease:button x:x y:y "handle a button press event; checks whether the item under the mouse is the selected item. If true, the application is informed. " - |selected index| + |selected index column deltaX| selection isNil ifTrue:[ + tabulator notNil ifTrue:[ + column := tabulator column. + deltaX := tabulator deltaX. + tabulator destroy. + tabulator := nil. + + deltaX abs > 2 ifTrue:[ + dataSet changeWidthOfColumn:column deltaX:deltaX + ] + ]. ^ self ]. index := self xVisibleToSelectionIndex:x. selected := index == selection. + index := selection. selection := nil. self invalidateItemAt:index. @@ -234,12 +285,21 @@ for:aColumnView "initialization " + dataSet := aColumnView. + self level:(dataSet level). + self borderWidth:(dataSet borderWidth). +! + +initialize + super initialize. + enabled := true. isVisible := true. - dataSet := aColumnView. columns := #(). - self level:(dataSet level). - self borderWidth:(dataSet borderWidth). + + self enableMotionEvents. + + ! realize @@ -308,8 +368,68 @@ ] ! ! +!DSVLabelView::Tabulator methodsFor:'accessing'! + +column + "return the value of the instance variable 'column' (automatically generated)" + + ^ column! + +deltaX + "returns the distance x between the start and end action + " + ^ self origin x - startX +! ! + +!DSVLabelView::Tabulator methodsFor:'dimension'! + +moveToX:x + |ogX org| + + ogX := (minRqX max:x) + transX. + org := self origin. + + org x ~~ ogX ifTrue:[ + org x:ogX. + self origin:org. + ] + +! + +openFor:aView x:x y:y h:h + |pnt dev w| + + dev := aView device. + pnt := dev translatePoint:(x@y) + from:(aView id) + to:(dev rootView id). + + minRqX := colRight - column width + column minimumRequiredWidth. + transX := pnt x - x. + startX := pnt x. + + self origin:pnt extent:(2 @ h). + self backgroundColor:(Color black). + self openAndWait. +! ! + +!DSVLabelView::Tabulator methodsFor:'initialization'! + +column:aColumn colRight:x + colRight := x. + column := aColumn. +! + +isPopUpView + "return true if view is a popup view; without decoration + and popUp to top immediately + " + ^ true + +! ! + !DSVLabelView class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.25 1999-08-24 15:29:02 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/DSVLabelView.st,v 1.26 1999-08-28 16:50:27 cg Exp $' ! !