12 |
12 |
13 |
13 |
14 |
14 |
15 |
15 |
16 Object subclass:#DataSetColumn |
16 Object subclass:#DataSetColumn |
17 instanceVariableNames:'columnNumber dataSet minWidth width description buttonExtent |
17 instanceVariableNames:'columnNumber dataSet width description buttonExtent shownValue |
18 drawableAction shownValue rendererType backgroundColor |
18 rendererType backgroundColor rowSeparatorSelector |
19 rowSeparatorSelector showColSeparator showRowSeparator |
19 showColSeparator showRowSeparator foregroundColor fgSelector |
20 foregroundColor fgSelector bgSelector columnAlignment label |
20 bgSelector columnAlignment label readSelector |
21 readSelector numArgsToReadSelector columnAdaptor' |
21 numArgsToReadSelector columnAdaptor' |
22 classVariableNames:'' |
22 classVariableNames:'' |
23 poolDictionaries:'' |
23 poolDictionaries:'' |
24 category:'Views-DataSet' |
24 category:'Views-DataSet' |
25 ! |
25 ! |
26 |
26 |
51 |
51 |
52 columnNumber <Integer> sequence number (into list of columns) |
52 columnNumber <Integer> sequence number (into list of columns) |
53 |
53 |
54 dataSet <DSVColumnView> the view it belongs to |
54 dataSet <DSVColumnView> the view it belongs to |
55 |
55 |
56 minWidth <Integer> minimum required width by the column |
|
57 |
|
58 width <Integer> width of column |
56 width <Integer> width of column |
59 |
57 |
60 description <DataSetColumnSpec> the column description |
58 description <DataSetColumnSpec> the column description |
61 |
59 |
62 buttonExtent <Point> extent of drawable form |
60 buttonExtent <Point> extent of drawable form |
63 |
|
64 drawableAction <Action> action to access the printable |
|
65 label of a cell |
|
66 |
61 |
67 rendererType <Type> renderer type (cached value from |
62 rendererType <Type> renderer type (cached value from |
68 the column specification). |
63 the column specification). |
69 |
64 |
70 backgroundColor <Color or nil> background color of all cells or nil |
65 backgroundColor <Color or nil> background color of all cells or nil |
179 ^ label |
174 ^ label |
180 |
175 |
181 |
176 |
182 ! |
177 ! |
183 |
178 |
|
179 minWidth |
|
180 "get my minimum width required by the column |
|
181 " |
|
182 |width| |
|
183 |
|
184 width := description minWidth. |
|
185 ^ width == 0 ifTrue:[self width] ifFalse:[width] |
|
186 |
|
187 |
|
188 ! |
|
189 |
184 rendererType |
190 rendererType |
185 "returns my renderer type |
191 "returns my renderer type |
186 " |
192 " |
187 ^ rendererType |
193 ^ rendererType |
188 ! |
194 ! |
189 |
195 |
190 width |
196 width |
191 "returns the width in pixels |
197 "returns the width in pixels |
192 " |
198 " |
193 |max w| |
199 |max "{ Class:SmallInteger }"| |
194 |
200 |
195 width notNil ifTrue:[ ^ width ]. "/ already computed |
201 width notNil ifTrue:[^ width]. "/ already computed |
196 |
202 |
197 width := description width. |
203 (width := description width) isReal ifTrue:[ |
198 |
|
199 width isReal ifTrue:[ |
|
200 width := (width * dataSet width) rounded. |
204 width := (width * dataSet width) rounded. |
201 ^ width |
205 ]. |
202 ]. |
206 |
203 |
207 (width := width max:(description minWidth)) ~~ 0 ifTrue:[ |
204 (width ~~ 0 or:[(width := description minWidth) ~~ 0]) ifFalse:[ |
208 ^ width |
205 self containsText ifTrue:[ |
209 ]. |
206 "/ take maximum 10 entries to calculate the width; |
210 |
207 "/ can be resized later if neccessary |
211 self containsText ifTrue:[ |
208 |
212 "/ take maximum 5 entries to calculate the width; |
209 max := 10 min:dataSet size. |
213 "/ can be resized later if neccessary |
210 |
214 |
211 1 to:max do:[:i| |
215 max := 5 min:dataSet size. |
212 w := self widthOfLabel:(shownValue value:(dataSet at:i)). |
216 |
213 width := width max:w |
217 1 to:max do:[:i| |
214 ]. |
218 width := width max:(self widthOfLabel:(shownValue value:(dataSet at:i))) |
215 description editorType ~~ #None ifTrue:[ |
219 ]. |
216 width := width + (dataSet font widthOn:dataSet device) |
220 description editorType ~~ #None ifTrue:[ |
217 ]. |
221 width := width + (dataSet font widthOn:dataSet device) |
218 ]. |
222 ]. |
219 width := width + buttonExtent x. |
223 ]. |
220 |
224 width := width + buttonExtent x. |
221 label notNil ifTrue:[ |
225 |
222 width := width max:(4 + (label preferredExtent x)) |
226 label notNil ifTrue:[ |
223 ] |
227 width := width max:(4 + (label preferredExtent x)) |
224 ]. |
228 ]. |
225 ^ width := minWidth := width + dataSet separatorSize + (2 * dataSet horizontalSpacing). |
229 ^ width := width + dataSet separatorSize + (2 * dataSet horizontalSpacing). |
|
230 |
|
231 |
226 ! |
232 ! |
227 |
233 |
228 width:aWidth |
234 width:aWidth |
229 "set the width |
235 "set the width |
230 " |
236 " |
231 |w| |
237 width := aWidth max:(description minWidth) |
232 |
|
233 (w := description width) ~~ 0 ifTrue:[ "/ fixed size |
|
234 width := minWidth := w |
|
235 ] ifFalse:[ |
|
236 width := aWidth max:minWidth |
|
237 ]. |
|
238 |
238 |
239 ! ! |
239 ! ! |
240 |
240 |
241 !DataSetColumn methodsFor:'drawing'! |
241 !DataSetColumn methodsFor:'drawing'! |
242 |
242 |
549 "grow the width for n pixels |
549 "grow the width for n pixels |
550 " |
550 " |
551 width := width + n. |
551 width := width + n. |
552 |
552 |
553 |
553 |
554 ! |
|
555 |
|
556 minWidth |
|
557 "get my minimum width required by the entries into the column |
|
558 " |
|
559 ^ minWidth notNil ifTrue:[minWidth] ifFalse:[self width] |
|
560 |
|
561 |
|
562 ! |
|
563 |
|
564 setMinWidth |
|
565 "set the width to the required width. returns the psitive delta width |
|
566 " |
|
567 |deltaX| |
|
568 |
|
569 width isNil ifTrue:[ self width ]. |
|
570 minWidth isNil ifTrue:[minWidth := width ]. |
|
571 |
|
572 deltaX := width - minWidth. |
|
573 width := minWidth. |
|
574 ^ deltaX |
|
575 ! ! |
554 ! ! |
576 |
555 |
577 !DataSetColumn methodsFor:'initialization'! |
556 !DataSetColumn methodsFor:'initialization'! |
578 |
557 |
579 on:aDSVColumnView description:aDescription columnNumber:aNumber label:aLabel |
558 on:aDSVColumnView description:aDescription columnNumber:aNumber label:aLabel |