--- a/DataSetView.st Tue Mar 24 01:32:48 1998 +0100
+++ b/DataSetView.st Mon Mar 30 14:05:40 1998 +0200
@@ -14,7 +14,7 @@
View subclass:#DataSetView
- instanceVariableNames:'labelView columnView listHolder useIndex labels scrolledView'
+ instanceVariableNames:'labelView columnView listHolder useIndex scrolledView'
classVariableNames:''
poolDictionaries:''
category:'Views-DataSet'
@@ -369,6 +369,59 @@
"
! !
+!DataSetView class methodsFor:'test'!
+
+test
+ |top scr clDc rows slct list bool spc img|
+
+ top := StandardSystemView new label:'select'; extent:600@500.
+ scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
+
+ clDc := OrderedCollection new.
+ rows := OrderedCollection new.
+ list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ).
+ slct := #( #text #field #cbox #clist #toggle #choices ).
+ bool := true.
+
+ 10 to:30 do:[:i| |values|
+ values := list collect:[:n|
+ n isString ifTrue:[n, i printString]
+ ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
+ ].
+ rows add:(Structure newWith:slct values:values).
+ bool := bool not.
+ ].
+ clDc add:( spc := DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
+ spc labelAlignment:#left.
+
+ img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).
+ clDc add:( spc := DataSetColumnSpec label:img editorType:#None selector:#text ).
+ spc labelAlignment:#right.
+
+ img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).
+ clDc add:( spc := DataSetColumnSpec label:img editorType:#InputField selector:#field ).
+ spc labelAlignment:#left.
+
+ img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).
+ clDc add:( spc := DataSetColumnSpec label:(LabelAndIcon icon:img string:'Combo') editorType:#ComboBox selector:#cbox ).
+ spc labelAlignment:#center.
+ spc choices:#choices.
+
+ clDc add:( spc := DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
+ spc choices:#choices.
+ clDc add:( spc := DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
+ clDc do:[:el|
+ el minWidth:80.
+ el labelActionSelector:#dummy.
+ ].
+ scr has3Dseparators:true.
+ scr columnDescriptors:clDc.
+ scr list:rows.
+ top open.
+
+
+! !
+
!DataSetView methodsFor:'accessing'!
add:aRow
@@ -404,7 +457,7 @@
or a full scrollBar.
"
scrolledView horizontalMini:aBool.
- self recomputeLabelView.
+ self columnsSizeChanged.
!
horizontalScrollable:aBool
@@ -412,7 +465,7 @@
If disabled, the horizontal scrollBar is made invisible.
"
scrolledView horizontalScrollable:aBool.
- self recomputeLabelView.
+ self columnsSizeChanged.
!
isHorizontalScrollable
@@ -432,7 +485,7 @@
or a full scrollBar.
"
scrolledView verticalMini:aBool.
- self recomputeLabelView.
+ self columnsSizeChanged.
!
@@ -441,7 +494,7 @@
If disabled, the horizontal scrollBar is made invisible.
"
scrolledView verticalScrollable:aBool.
- self recomputeLabelView
+ self columnsSizeChanged
!
viewBackground
@@ -523,6 +576,26 @@
!DataSetView methodsFor:'change & update'!
+columnsSizeChanged
+ "recompute label view
+ "
+ |pL pR|
+
+ realized ifFalse:[
+ ^ self
+ ].
+
+ pL := device translatePoint:(0@0) from:(columnView id) to:(self id).
+ pR := device translatePoint:((columnView width) @ 0) from:(columnView id) to:(self id).
+
+ labelView leftInset:pL x - 1.
+ labelView rightInset:(self width - pR x).
+
+ labelView columnsSizeChanged.
+ scrolledView topInset:(labelView height).
+
+!
+
update:what with:aPara from:chgObj
"one of my models changed
"
@@ -542,11 +615,11 @@
].
^ self
].
-
- what == #sizeOfColumns ifTrue:[ ^ self recomputeLabels ].
- what == #columnsLayout ifTrue:[ ^ self updateLabels ].
- what == #originOfContents ifTrue:[ ^ self lablesOriginXChanged:(aPara x) ].
-
+ realized ifTrue:[
+ what == #sizeOfColumns ifTrue:[ ^ self columnsSizeChanged ].
+ what == #columnsLayout ifTrue:[ ^ labelView columnsLayoutChanged ].
+ what == #originOfContents ifTrue:[ ^ labelView columnsOriginChanged:aPara ].
+ ].
^ self
].
@@ -579,124 +652,6 @@
].
! !
-!DataSetView methodsFor:'change & update labels'!
-
-hasVisibleLabel:aColumn
- "returns true if label of the column is visible
- "
- |l|
-
- (aColumn showColSeparator or:[aColumn == columnView lastColumn]) ifTrue:[
- ^ true
- ].
- ^ ((l := aColumn label) isImage or:[l size ~~ 0])
-
-
-!
-
-lablesOriginXChanged:aDeltaX
- "the origin of all labels changed; (scrolling left or right)
- "
- |point|
-
- (shown and:[aDeltaX ~~ 0]) ifTrue:[
- point := aDeltaX @ 0.
-
- aDeltaX > 0 ifTrue:[
- labels do:[:aLabel| aLabel origin:((aLabel origin) - point) ]
- ] ifFalse:[
- labels reverseDo:[:aLabel| aLabel origin:((aLabel origin) - point) ]
- ]
- ].
-
-!
-
-recomputeLabelView
- "recompute label view
- "
- |p|
-
- p := device translatePoint:(0@0) from:(columnView id) to:(self id).
- labelView leftInset:p x.
- p := device translatePoint:((columnView width) @ 0) from:(columnView id) to:(self id).
- labelView rightInset:(self width - p x).
-!
-
-recomputeLabels
- "labels changed; recompute labels
- "
- |hgt lbl|
-
- labels size ~~ 0 ifTrue:[ labels do:[:b| b destroy] ].
- labels := OrderedCollection new.
-
- columnView numberOfColumns == 0 ifTrue:[
- ^ self
- ].
- hgt := 0.
-
- columnView columnsDo:[:aCol||l|
- (self hasVisibleLabel:aCol) ifTrue:[
- lbl := DSVLabelView column:aCol in:labelView.
- hgt := (lbl preferredExtent y) max:hgt.
- labels add:lbl.
- ]
- ].
- hgt := hgt + (hgt // 5).
-
- scrolledView topInset:hgt.
- labelView bottomInset:(hgt negated).
-
- realized ifTrue:[
- self updateLabels.
- labels do:[:l| l realize ].
- ]
-
-
-!
-
-updateLabels
- "layout of labels changed; recompute layout
- "
- |x0 x1 dX id noCols size|
-
- size := labels size.
- noCols := columnView numberOfColumns.
-
- size ~~ noCols ifTrue:[
- noCols == 0 ifTrue:[
- ^ self recomputeLabels
- ].
- id := 0.
-
- columnView columnsDo:[:aCol|
- (self hasVisibleLabel:aCol) ifTrue:[id := id + 1]
- ].
- size ~~ id ifTrue:[
- ^ self recomputeLabels
- ].
- ].
- size == 0 ifTrue:[ ^ self ].
-
- x0 := columnView margin - columnView xOriginOfContents.
- dX := columnView separatorSize - 1.
- id := 1.
- x1 := 0.
-
- columnView columnsDo:[:aCol|
- x1 := x1 + aCol width.
-
- (self hasVisibleLabel:aCol) ifTrue:[
- (labels at:id) origin:(x0 @ 0.0) extent:(x1 - dX @ 1.0).
- x0 := x0 + x1.
- x1 := 0.
- id := id + 1.
- ]
- ].
-
-
-! !
-
!DataSetView methodsFor:'change & update list'!
insert:anIndex
@@ -797,7 +752,7 @@
"
super initialize.
- labelView := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.0) in:self.
+ labelView := DSVLabelView origin:(0.0 @ 0.0) corner:(1.0 @ 0.0) in:self.
scrolledView := HVScrollableView for:DSVColumnView
miniScrollerH:true
@@ -807,11 +762,11 @@
in:self.
useIndex := true.
- labels := OrderedCollection new.
columnView := scrolledView scrolledView.
columnView borderWidth:0.
columnView addDependent:self.
+ labelView for:columnView.
!
@@ -832,10 +787,8 @@
]
].
columnView selectRowIndex:selection.
-
super realize.
- self recomputeLabelView.
- self updateLabels.
+ self columnsSizeChanged.
! !
!DataSetView methodsFor:'queries'!
@@ -849,5 +802,5 @@
!DataSetView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.17 1998-03-09 16:04:25 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.18 1998-03-30 12:05:40 ca Exp $'
! !