DataSetColumn.st
changeset 1490 9c418c3aaf49
parent 1487 fd003e2156cc
child 1492 eefe55529016
equal deleted inserted replaced
1489:d4c9639f7786 1490:9c418c3aaf49
    16 Object subclass:#DataSetColumn
    16 Object subclass:#DataSetColumn
    17 	instanceVariableNames:'columnNumber dataSet width description buttonExtent shownValue
    17 	instanceVariableNames:'columnNumber dataSet width description buttonExtent shownValue
    18 		rendererType backgroundColor rowSeparatorSelector
    18 		rendererType backgroundColor rowSeparatorSelector
    19 		showColSeparator showRowSeparator foregroundColor fgSelector
    19 		showColSeparator showRowSeparator foregroundColor fgSelector
    20 		bgSelector columnAlignment label readSelector
    20 		bgSelector columnAlignment label readSelector
    21 		numArgsToReadSelector columnAdaptor'
    21 		numArgsToReadSelector columnAdaptor descWidth descMinWidth'
    22 	classVariableNames:''
    22 	classVariableNames:''
    23 	poolDictionaries:''
    23 	poolDictionaries:''
    24 	category:'Views-DataSet'
    24 	category:'Views-DataSet'
    25 !
    25 !
    26 
    26 
   183 ! !
   183 ! !
   184 
   184 
   185 !DataSetColumn methodsFor:'accessing dimension'!
   185 !DataSetColumn methodsFor:'accessing dimension'!
   186 
   186 
   187 minWidth
   187 minWidth
   188     "get my minimum width required by the column
   188     "get the minimum width required by the column
   189     "
   189     "
   190     |width|
   190     descMinWidth notNil ifTrue:[
   191 
   191         ^ descMinWidth
   192     width := description minWidth.
   192     ].
   193   ^ width == 0 ifTrue:[self width] ifFalse:[width]
   193     width := nil.
       
   194   ^ self width
       
   195 
       
   196 !
       
   197 
       
   198 setDescWidth:aWidth
       
   199     "set a fixed width
       
   200     "
       
   201     descWidth    := aWidth max:(4 + label preferredWidth).
       
   202     descMinWidth := width := descWidth.
   194 
   203 
   195 
   204 
   196 !
   205 !
   197 
   206 
   198 width
   207 width
   200     "
   209     "
   201     |max  "{ Class:SmallInteger }"|
   210     |max  "{ Class:SmallInteger }"|
   202 
   211 
   203     width notNil ifTrue:[^ width].              "/ already computed
   212     width notNil ifTrue:[^ width].              "/ already computed
   204 
   213 
   205     (width := description width) isReal ifTrue:[
   214     descMinWidth notNil ifTrue:[
   206         width := (width * dataSet width) rounded.
   215         width := descMinWidth.
   207     ].
   216       ^ width
   208 
   217     ].
   209     (width := width max:(description minWidth)) ~~ 0 ifTrue:[
   218 
   210         ^ width
   219     width := description minWidth max:(label preferredWidth).
       
   220 
       
   221     descWidth isReal ifTrue:[
       
   222         width := width max:(descWidth * dataSet width) rounded.
       
   223       ^ width
   211     ].
   224     ].
   212 
   225 
   213     self containsText ifTrue:[
   226     self containsText ifTrue:[
   214         "/ take maximum 5 entries to calculate the width;
   227         "/ take maximum 5 entries to calculate the width;
   215         "/ can be resized later if neccessary
   228         "/ can be resized later if neccessary
   221         ].
   234         ].
   222         description editorType ~~ #None ifTrue:[
   235         description editorType ~~ #None ifTrue:[
   223             width := width + (dataSet font widthOn:dataSet device)
   236             width := width + (dataSet font widthOn:dataSet device)
   224         ].
   237         ].
   225     ].
   238     ].
   226     width := width + buttonExtent x.
   239     width := width + buttonExtent x + dataSet separatorSize + (2 * dataSet horizontalSpacing).
   227 
   240     descMinWidth := width.
   228     label notNil ifTrue:[
   241   ^ width
   229         width := width max:(4 + label preferredWidth)
   242 
   230     ].
       
   231     ^ width := width + dataSet separatorSize + (2 * dataSet horizontalSpacing).
       
   232 
       
   233 
       
   234 !
       
   235 
       
   236 width:aWidth
       
   237     "set the width
       
   238     "
       
   239     width := aWidth max:(description minWidth)
       
   240 
   243 
   241 ! !
   244 ! !
   242 
   245 
   243 !DataSetColumn methodsFor:'drawing'!
   246 !DataSetColumn methodsFor:'drawing'!
   244 
   247 
   566     dataSet          := aDSVColumnView.
   569     dataSet          := aDSVColumnView.
   567     label            := aLabel.
   570     label            := aLabel.
   568 
   571 
   569     description      := aDescription.
   572     description      := aDescription.
   570     rendererType     := description rendererType.
   573     rendererType     := description rendererType.
       
   574     descWidth        := description width.
   571     width            := nil.
   575     width            := nil.
   572     device           := dataSet device.
   576     device           := dataSet device.
   573     shownValue       := [:aRow| nil ].
   577     shownValue       := [:aRow| nil ].
   574     rowSeparatorSelector := description rowSeparatorSelector.
   578     rowSeparatorSelector := description rowSeparatorSelector.
   575     fgSelector       := description foregroundSelector.
   579     fgSelector       := description foregroundSelector.
   861 ! !
   865 ! !
   862 
   866 
   863 !DataSetColumn class methodsFor:'documentation'!
   867 !DataSetColumn class methodsFor:'documentation'!
   864 
   868 
   865 version
   869 version
   866     ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.46 1999-08-24 15:29:07 cg Exp $'
   870     ^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.47 1999-08-28 14:09:39 cg Exp $'
   867 ! !
   871 ! !