542
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
Object subclass:#DataSetColumn
|
824
|
17 |
instanceVariableNames:'columnNumber dataSet labelExtent minWidth width description form
|
647
|
18 |
buttonInset buttonExtent textInset drawableAction toggleExtent
|
|
19 |
rendererType backgroundColor foregroundColor fgSelector
|
891
|
20 |
bgSelector columnAlignment label'
|
607
|
21 |
classVariableNames:''
|
542
|
22 |
poolDictionaries:''
|
|
23 |
category:'Views-DataSet'
|
|
24 |
!
|
|
25 |
|
|
26 |
!DataSetColumn class methodsFor:'documentation'!
|
|
27 |
|
|
28 |
copyright
|
|
29 |
"
|
|
30 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
31 |
All Rights Reserved
|
|
32 |
|
|
33 |
This software is furnished under a license and may be used
|
|
34 |
only in accordance with the terms of that license and with the
|
|
35 |
inclusion of the above copyright notice. This software may not
|
|
36 |
be provided or otherwise made available to, or used by, any
|
|
37 |
other person. No title to or ownership of the software is
|
|
38 |
hereby transferred.
|
|
39 |
"
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
!
|
|
44 |
|
|
45 |
documentation
|
|
46 |
"
|
|
47 |
represent one single column description of a DataSetView
|
|
48 |
|
|
49 |
[Instance variables:]
|
|
50 |
|
647
|
51 |
columnNumber <Integer> sequence number (into list of columns)
|
542
|
52 |
description <DataSetColumnSpec> the column description
|
|
53 |
dataSet <DSVColumnView> the view it belongs to
|
|
54 |
width <Integer> width of column
|
|
55 |
minWidth <Integer> minimum required width by the column
|
647
|
56 |
buttonInset <Integer> top inset of a button (toggle)
|
|
57 |
buttonExtent <Point> extent of form
|
542
|
58 |
textInset <Integer> top inset of a string
|
647
|
59 |
form <Form> a form drawn in the cell
|
824
|
60 |
labelExtent <Point> the preferred extent of the cell label on device
|
647
|
61 |
drawableAction <Action> action to access the printable
|
|
62 |
label of a cell
|
|
63 |
rendererType <Type> renderer type derived from
|
|
64 |
column specification.
|
|
65 |
backgroundColor <Color or nil> background color of all cells or nil
|
|
66 |
(nil: use default background color).
|
|
67 |
foregroundColor <Color or nil> foreground color of all cells or nil
|
|
68 |
(nil: use default foreground color).
|
|
69 |
fgSelector <Selector or nil> access specific foreground color for
|
|
70 |
a cell
|
|
71 |
bgSelector <Selector or nil> access specific background color for
|
|
72 |
a cell
|
|
73 |
|
542
|
74 |
|
|
75 |
[author:]
|
|
76 |
Claus Atzkern
|
|
77 |
|
|
78 |
[see also:]
|
|
79 |
DataSetColumnSpec
|
|
80 |
DSVColumnView
|
|
81 |
DataSetView
|
|
82 |
"
|
|
83 |
|
|
84 |
|
|
85 |
! !
|
|
86 |
|
|
87 |
!DataSetColumn methodsFor:'accessing'!
|
|
88 |
|
|
89 |
at:aRowNr
|
|
90 |
"get the value of the raw at an index, aRowNr
|
|
91 |
"
|
637
|
92 |
^ description row:(dataSet at:aRowNr) at:columnNumber
|
542
|
93 |
!
|
|
94 |
|
|
95 |
at:aRowNr put:something
|
|
96 |
"set the value of the raw at an index, aRowNr
|
|
97 |
"
|
614
|
98 |
description row:(dataSet at:aRowNr) at:columnNumber put:something
|
542
|
99 |
!
|
|
100 |
|
584
|
101 |
backgroundColor
|
|
102 |
^ backgroundColor
|
|
103 |
!
|
|
104 |
|
807
|
105 |
description
|
|
106 |
"returns the column description
|
|
107 |
"
|
|
108 |
^ description
|
|
109 |
|
|
110 |
|
|
111 |
!
|
|
112 |
|
584
|
113 |
foregroundColor
|
|
114 |
^ foregroundColor
|
|
115 |
!
|
|
116 |
|
542
|
117 |
label
|
|
118 |
"get the label assigned to the column
|
|
119 |
"
|
891
|
120 |
^ label
|
542
|
121 |
|
|
122 |
|
|
123 |
!
|
|
124 |
|
647
|
125 |
rendererType
|
|
126 |
"returns my renderer type
|
|
127 |
"
|
|
128 |
^ rendererType
|
|
129 |
!
|
|
130 |
|
542
|
131 |
width
|
|
132 |
"returns the width in pixels
|
|
133 |
"
|
|
134 |
|end|
|
|
135 |
|
|
136 |
width notNil ifTrue:[ ^ width ]. "/ already computed
|
|
137 |
|
|
138 |
( (width := description width) ~~ 0 "/ fixed size
|
|
139 |
or:[(width := description minWidth) ~~ 0] "/ start size
|
607
|
140 |
) ifFalse:[
|
647
|
141 |
self containsText ifTrue:[
|
607
|
142 |
"/ take maximum 10 entries to calculate the width;
|
|
143 |
"/ can be resized later if neccessary
|
542
|
144 |
|
621
|
145 |
end := 10 min:dataSet size.
|
542
|
146 |
|
607
|
147 |
1 to:end do:[:aRowNr||lbl|
|
621
|
148 |
lbl := self drawableAt:aRowNr.
|
542
|
149 |
|
607
|
150 |
(lbl respondsTo:#widthOn:) ifTrue:[
|
|
151 |
width := width max:(lbl widthOn:dataSet)
|
|
152 |
] ifFalse:[
|
|
153 |
lbl notNil ifTrue:[
|
|
154 |
width := width max:(lbl displayString widthOn:dataSet)
|
|
155 |
]
|
542
|
156 |
]
|
607
|
157 |
].
|
|
158 |
description editorType ~~ #None ifTrue:[
|
|
159 |
width := width + (dataSet font widthOn:dataSet device)
|
|
160 |
].
|
542
|
161 |
].
|
824
|
162 |
width := (width + buttonExtent x) max:(4 + labelExtent x)
|
542
|
163 |
].
|
|
164 |
^ width := minWidth := width + dataSet separatorSize + (2 * dataSet horizontalSpacing).
|
|
165 |
!
|
|
166 |
|
|
167 |
width:aWidth
|
|
168 |
"set the width
|
|
169 |
"
|
|
170 |
|w|
|
|
171 |
|
545
|
172 |
(w := description width) ~~ 0 ifTrue:[ "/ fixed size
|
|
173 |
width := minWidth := w
|
542
|
174 |
] ifFalse:[
|
|
175 |
width := aWidth max:minWidth
|
|
176 |
].
|
|
177 |
|
|
178 |
! !
|
|
179 |
|
|
180 |
!DataSetColumn methodsFor:'drawing'!
|
|
181 |
|
833
|
182 |
drawButtonAtIndex:anIndex x:xR y:yR with:fgColor and:bgColor
|
|
183 |
|y0 x0 extent lv w h|
|
|
184 |
|
|
185 |
w := buttonExtent x.
|
|
186 |
|
|
187 |
rendererType ~~ #CheckToggle ifTrue:[
|
|
188 |
(self hasChoices:anIndex) ifFalse:[
|
|
189 |
^ self
|
|
190 |
].
|
|
191 |
lv := dataSet comboButtonLevel.
|
|
192 |
x0 := width - w - 4
|
|
193 |
] ifFalse:[
|
|
194 |
lv := dataSet checkToggleLevel.
|
|
195 |
x0 := width - w - (dataSet separatorSize) + 1 // 2
|
|
196 |
].
|
|
197 |
|
|
198 |
y0 := yR + buttonInset.
|
|
199 |
x0 := xR + x0.
|
|
200 |
|
|
201 |
dataSet drawEdgesAtX:x0 y:y0 width:w height:(buttonExtent y) level:lv.
|
|
202 |
|
|
203 |
(rendererType ~~ #CheckToggle or:[self at:anIndex]) ifTrue:[
|
|
204 |
(dataSet isRowSelected:anIndex) ifFalse:[dataSet paint:fgColor on:bgColor]
|
|
205 |
ifTrue:[dataSet paint:(dataSet hgLgFgColor)
|
|
206 |
on:(dataSet hgLgBgColor)
|
|
207 |
].
|
|
208 |
extent := (buttonExtent - form extent) // 2.
|
|
209 |
dataSet displayImage:form x:(x0 + extent x) y:(y0 + extent y)
|
|
210 |
].
|
|
211 |
!
|
|
212 |
|
637
|
213 |
drawFrom:start times:nTimes x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor
|
542
|
214 |
"redraw rows between start and stop
|
|
215 |
"
|
807
|
216 |
|lgCol dkCol fg bg lblFg lblBg lbl row colSp fH fW fE sepSz level
|
637
|
217 |
h "{ Class:SmallInteger }"
|
|
218 |
n "{ Class:SmallInteger }"
|
|
219 |
y "{ Class:SmallInteger }"
|
|
220 |
x "{ Class:SmallInteger }"
|
647
|
221 |
xI "{ Class:SmallInteger }"
|
883
|
222 |
xCol "{ Class:SmallInteger }"
|
|
223 |
spacing "{ Class:SmallInteger }"|
|
882
|
224 |
|
637
|
225 |
h := dataSet rowHeight.
|
542
|
226 |
|
604
|
227 |
(bg := backgroundColor) isNil ifTrue:[
|
|
228 |
bg := bgColor
|
|
229 |
] ifFalse:[
|
637
|
230 |
dataSet paint:(dataSet colorOnDevice:bg).
|
644
|
231 |
dataSet fillRectangleX:x0 y:yTop width:width height:(yBot - yTop - 1)
|
584
|
232 |
].
|
647
|
233 |
fg := foregroundColor ? fgColor.
|
|
234 |
lgCol := dataSet hgLgFgColor.
|
|
235 |
dkCol := dataSet hgLgBgColor.
|
655
|
236 |
sepSz := dataSet separatorSize.
|
882
|
237 |
spacing := dataSet horizontalSpacing.
|
647
|
238 |
y := yTop + textInset.
|
882
|
239 |
x := x0 + spacing.
|
647
|
240 |
n := start.
|
542
|
241 |
|
637
|
242 |
nTimes timesRepeat:[
|
|
243 |
row := dataSet at:n.
|
|
244 |
lbl := drawableAction value:row.
|
621
|
245 |
|
637
|
246 |
(dataSet isSelected:n inColumn:columnNumber) ifTrue:[
|
607
|
247 |
dataSet paint:dkCol.
|
637
|
248 |
dataSet fillRectangleX:x0 y:y - textInset width:width height:(h - 2).
|
542
|
249 |
|
647
|
250 |
rendererType == #rowSelector ifTrue:[
|
|
251 |
lbl := form
|
|
252 |
] ifFalse:[
|
|
253 |
lbl isText ifTrue:[lbl := lbl string]
|
637
|
254 |
].
|
883
|
255 |
lblBg := dkCol.
|
|
256 |
lblFg := lgCol.
|
542
|
257 |
] ifFalse:[
|
621
|
258 |
(bgSelector notNil and:[(lblBg := row perform:bgSelector) notNil]) ifTrue:[
|
637
|
259 |
dataSet paint:(lblBg := dataSet colorOnDevice:lblBg).
|
|
260 |
dataSet fillRectangleX:x0 y:y - textInset width:width height:(h - 2).
|
621
|
261 |
] ifFalse:[
|
|
262 |
lblBg := bg
|
|
263 |
].
|
637
|
264 |
lbl notNil ifTrue:[
|
|
265 |
(fgSelector notNil and:[(lblFg := row perform:fgSelector) notNil]) ifFalse:[
|
883
|
266 |
lblFg := fg.
|
637
|
267 |
] ifTrue:[
|
883
|
268 |
lblFg := dataSet colorOnDevice:lblFg.
|
637
|
269 |
].
|
621
|
270 |
]
|
882
|
271 |
].
|
|
272 |
lbl notNil ifTrue:[
|
883
|
273 |
columnAlignment == #left ifTrue:[
|
|
274 |
xCol := x
|
882
|
275 |
] ifFalse:[
|
883
|
276 |
xCol := width - (lbl widthOn:dataSet).
|
|
277 |
|
|
278 |
columnAlignment == #right ifTrue:[xCol := xCol - spacing]
|
|
279 |
ifFalse:[xCol := xCol // 2].
|
|
280 |
|
|
281 |
xCol := (x0 + xCol) max:0.
|
882
|
282 |
].
|
883
|
283 |
dataSet paint:lblFg on:lblBg.
|
882
|
284 |
lbl displayOn:dataSet x:xCol y:y
|
|
285 |
].
|
637
|
286 |
y := y + h.
|
|
287 |
n := n + 1.
|
542
|
288 |
].
|
|
289 |
|
807
|
290 |
(form notNil and:[rendererType ~~ #rowSelector]) ifTrue:[
|
833
|
291 |
y := yTop.
|
|
292 |
n := start.
|
542
|
293 |
|
647
|
294 |
nTimes timesRepeat:[
|
833
|
295 |
self drawButtonAtIndex:n x:x0 y:y with:fgColor and:bgColor.
|
807
|
296 |
y := y + h.
|
|
297 |
n := n + 1.
|
|
298 |
].
|
542
|
299 |
].
|
|
300 |
|
637
|
301 |
"/ DRAW SEPARATORS
|
|
302 |
|
|
303 |
x := x0 + width - 1.
|
542
|
304 |
|
655
|
305 |
sepSz == 1 ifTrue:[
|
637
|
306 |
y := yTop.
|
542
|
307 |
|
604
|
308 |
dataSet paint:fgColor.
|
542
|
309 |
|
637
|
310 |
description showColSeparator ifTrue:[
|
644
|
311 |
dataSet displayLineFromX:x y:yTop toX:x y:yBot - 1
|
542
|
312 |
].
|
637
|
313 |
|
542
|
314 |
description showRowSeparator ifTrue:[
|
607
|
315 |
y := yTop - 1.
|
542
|
316 |
|
|
317 |
nTimes timesRepeat:[
|
637
|
318 |
y := y + h.
|
|
319 |
dataSet displayLineFromX:x0 y:y toX:x y:y
|
542
|
320 |
]
|
637
|
321 |
]
|
|
322 |
] ifFalse:[
|
|
323 |
dkCol := dataSet separatorDarkColor.
|
|
324 |
lgCol := dataSet separatorLightColor.
|
568
|
325 |
|
637
|
326 |
(colSp := description showColSeparator) ifTrue:[
|
|
327 |
y := yBot - 1.
|
|
328 |
dataSet paint:lgCol.
|
|
329 |
dataSet displayLineFromX:x y:yTop toX:x y:y.
|
|
330 |
x := x - 1.
|
|
331 |
dataSet paint:dkCol.
|
|
332 |
dataSet displayLineFromX:x y:yTop toX:x y:y.
|
607
|
333 |
] ifFalse:[
|
637
|
334 |
dataSet paint:dkCol
|
607
|
335 |
].
|
542
|
336 |
|
637
|
337 |
description showRowSeparator ifTrue:[
|
|
338 |
y := yTop - 2.
|
|
339 |
x := x0 + width.
|
607
|
340 |
|
637
|
341 |
colSp ifTrue:[x := x - 2].
|
542
|
342 |
|
637
|
343 |
nTimes timesRepeat:[
|
|
344 |
y := y + h.
|
|
345 |
dataSet displayLineFromX:x0 y:y toX:x y:y.
|
|
346 |
].
|
|
347 |
y := yTop - 1.
|
|
348 |
dataSet paint:lgCol.
|
|
349 |
|
|
350 |
nTimes timesRepeat:[
|
|
351 |
y := y + h.
|
|
352 |
dataSet displayLineFromX:x0 y:y toX:x y:y.
|
542
|
353 |
]
|
607
|
354 |
]
|
|
355 |
]
|
807
|
356 |
|
607
|
357 |
!
|
|
358 |
|
542
|
359 |
invalidate
|
|
360 |
"set to invalidate; forces a recomputation
|
|
361 |
"
|
568
|
362 |
minWidth := width := nil.
|
542
|
363 |
|
|
364 |
! !
|
|
365 |
|
614
|
366 |
!DataSetColumn methodsFor:'editing'!
|
|
367 |
|
833
|
368 |
editorAt:aRowNr
|
|
369 |
|val row|
|
614
|
370 |
|
833
|
371 |
row := dataSet at:aRowNr.
|
|
372 |
val := description row:row at:columnNumber.
|
614
|
373 |
|
833
|
374 |
val isText ifTrue:[val := val string].
|
614
|
375 |
|
833
|
376 |
^ description editorOn:row value:val.
|
614
|
377 |
! !
|
|
378 |
|
542
|
379 |
!DataSetColumn methodsFor:'event handling'!
|
|
380 |
|
|
381 |
doesNotUnderstand:aMessage
|
|
382 |
|
|
383 |
(description respondsTo:(aMessage selector)) ifTrue:[
|
|
384 |
^ aMessage sendTo:description
|
|
385 |
].
|
|
386 |
^ super doesNotUnderstand:aMessage
|
|
387 |
|
|
388 |
!
|
|
389 |
|
|
390 |
textInsetChanged:aTextInset
|
|
391 |
"recompute all attributes
|
|
392 |
"
|
647
|
393 |
|lbl|
|
542
|
394 |
|
647
|
395 |
self containsText ifTrue:[
|
542
|
396 |
textInset := dataSet verticalSpacing.
|
|
397 |
|
621
|
398 |
dataSet size ~~ 0 ifTrue:[
|
|
399 |
lbl := self drawableAt:1.
|
542
|
400 |
|
|
401 |
(lbl isString or:[lbl isNumber]) ifTrue:[
|
|
402 |
textInset := aTextInset
|
584
|
403 |
] ifFalse:[
|
|
404 |
(lbl isNil and:[description printSelector isNil]) ifTrue:[
|
|
405 |
textInset := aTextInset.
|
|
406 |
]
|
542
|
407 |
]
|
607
|
408 |
]
|
647
|
409 |
] ifFalse:[
|
|
410 |
textInset := ( (dataSet rowHeight)
|
|
411 |
- (form height)
|
|
412 |
- (dataSet separatorSize)
|
|
413 |
) // 2.
|
|
414 |
].
|
542
|
415 |
|
647
|
416 |
form isNil ifTrue:[
|
|
417 |
buttonInset := 0
|
607
|
418 |
] ifFalse:[
|
647
|
419 |
buttonInset := ( (dataSet rowHeight)
|
|
420 |
- (buttonExtent x)
|
|
421 |
- (dataSet separatorSize)
|
|
422 |
) // 2.
|
807
|
423 |
|
|
424 |
rendererType == #CheckToggle ifTrue:[
|
|
425 |
buttonInset := buttonInset + 1
|
|
426 |
]
|
542
|
427 |
].
|
|
428 |
|
|
429 |
|
|
430 |
! !
|
|
431 |
|
|
432 |
!DataSetColumn methodsFor:'grow & degrow'!
|
|
433 |
|
|
434 |
growWidth:n
|
|
435 |
"grow the width for n pixels
|
|
436 |
"
|
|
437 |
width := width + n.
|
|
438 |
|
|
439 |
|
|
440 |
!
|
|
441 |
|
|
442 |
minWidth
|
|
443 |
"get my minimum width required by the entries into the column
|
|
444 |
"
|
|
445 |
^ minWidth notNil ifTrue:[minWidth] ifFalse:[self width]
|
|
446 |
|
|
447 |
|
|
448 |
!
|
|
449 |
|
|
450 |
setMinWidth
|
|
451 |
"set the width to the required width. returns the psitive delta width
|
|
452 |
"
|
|
453 |
|deltaX|
|
|
454 |
|
|
455 |
deltaX := width - minWidth.
|
|
456 |
width := minWidth.
|
|
457 |
^ deltaX.
|
|
458 |
|
|
459 |
|
|
460 |
! !
|
|
461 |
|
|
462 |
!DataSetColumn methodsFor:'initialization'!
|
|
463 |
|
607
|
464 |
on:aDSVColumnView description:aDescription columnNumber:aNumber
|
542
|
465 |
"instance creation; set attributes dependent on the description
|
|
466 |
"
|
891
|
467 |
|device selector format idx type oldFont newFont|
|
542
|
468 |
|
607
|
469 |
columnNumber := aNumber.
|
584
|
470 |
dataSet := aDSVColumnView.
|
|
471 |
description := aDescription.
|
|
472 |
rendererType := description rendererType.
|
647
|
473 |
form := width := nil.
|
584
|
474 |
device := dataSet device.
|
637
|
475 |
drawableAction := [:aRow| nil ].
|
621
|
476 |
fgSelector := description foregroundSelector.
|
|
477 |
bgSelector := description backgroundSelector.
|
584
|
478 |
backgroundColor := description backgroundColor.
|
|
479 |
foregroundColor := description foregroundColor.
|
647
|
480 |
buttonExtent := 0 @ 0.
|
824
|
481 |
labelExtent := 0 @ 0.
|
883
|
482 |
columnAlignment := #left.
|
584
|
483 |
|
|
484 |
backgroundColor notNil ifTrue:[
|
824
|
485 |
backgroundColor := backgroundColor on:dataSet device
|
584
|
486 |
].
|
|
487 |
foregroundColor notNil ifTrue:[
|
824
|
488 |
foregroundColor := foregroundColor on:dataSet device
|
584
|
489 |
].
|
542
|
490 |
|
824
|
491 |
oldFont := nil.
|
891
|
492 |
label := self resolveLabelWithBuilder:(dataSet builder).
|
824
|
493 |
|
|
494 |
(label respondsTo:#string) ifTrue:[
|
|
495 |
"/
|
|
496 |
"/ must set the font to accumulate the real extent of a string label
|
|
497 |
"/
|
|
498 |
(label isString and:[label isEmpty]) ifTrue:[
|
|
499 |
label := nil
|
|
500 |
] ifFalse:[
|
|
501 |
(newFont := description labelFont) notNil ifTrue:[
|
|
502 |
oldFont := dataSet font.
|
|
503 |
dataSet font:newFont.
|
|
504 |
]
|
|
505 |
]
|
|
506 |
].
|
|
507 |
|
|
508 |
label notNil ifTrue:[
|
|
509 |
labelExtent := Point x:(label widthOn:dataSet) y:(label heightOn:dataSet).
|
|
510 |
].
|
|
511 |
|
|
512 |
oldFont notNil ifTrue:[
|
|
513 |
dataSet font:oldFont
|
542
|
514 |
].
|
|
515 |
|
|
516 |
rendererType == #CheckToggle ifTrue:[
|
647
|
517 |
form := dataSet checkToggleForm.
|
807
|
518 |
buttonExtent := dataSet checkToggleExtent.
|
647
|
519 |
^ self
|
542
|
520 |
].
|
|
521 |
|
|
522 |
rendererType == #rowSelector ifTrue:[
|
891
|
523 |
form := dataSet rowSelectorForm.
|
807
|
524 |
buttonExtent := dataSet rowSelectorExtent.
|
647
|
525 |
^ self
|
542
|
526 |
].
|
|
527 |
|
|
528 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[
|
647
|
529 |
form := dataSet comboButtonForm.
|
807
|
530 |
buttonExtent := dataSet comboButtonExtent.
|
883
|
531 |
] ifFalse:[
|
|
532 |
columnAlignment := description columnAlignment
|
542
|
533 |
].
|
|
534 |
|
|
535 |
selector := description printSelector.
|
|
536 |
|
|
537 |
selector notNil ifTrue:[
|
621
|
538 |
drawableAction := [:aRow| aRow perform:selector with:dataSet ].
|
542
|
539 |
^ self
|
|
540 |
].
|
|
541 |
|
614
|
542 |
( (format := description formatString) notNil
|
|
543 |
and:[(type := description type) == #number or:[type == #numberOrNil]]
|
|
544 |
) ifTrue:[
|
542
|
545 |
"/ has a format string for number (supports only floats)
|
|
546 |
|
614
|
547 |
(idx := format indexOf:$.) ~~ 0 ifTrue:[
|
|
548 |
idx := format size - idx
|
542
|
549 |
].
|
614
|
550 |
format := '%0.', idx printString, 'f'.
|
542
|
551 |
|
621
|
552 |
drawableAction := [:aRow||n|
|
|
553 |
n := description row:aRow at:columnNumber.
|
|
554 |
n isReal ifTrue:[n := n asFloat printfPrintString:format].
|
|
555 |
n
|
614
|
556 |
]
|
621
|
557 |
] ifFalse:[ "/ default: no format string
|
|
558 |
drawableAction := [:aRow| description row:aRow at:columnNumber ]
|
614
|
559 |
]
|
542
|
560 |
|
|
561 |
|
891
|
562 |
!
|
|
563 |
|
|
564 |
resolveLabelInBuilder:aBuilder
|
|
565 |
|label appl|
|
|
566 |
|
|
567 |
aBuilder isNil ifTrue:[
|
|
568 |
^ description rawLabel
|
|
569 |
].
|
|
570 |
|
|
571 |
(label := description label) isString ifTrue:[
|
|
572 |
description labelIsImage ifTrue:[
|
|
573 |
aBuilder isEditing ifTrue:[
|
|
574 |
label := nil
|
|
575 |
] ifFalse:[
|
|
576 |
label := aBuilder labelFor:(label asSymbol)
|
|
577 |
].
|
|
578 |
^ label ? description class defaultIcon
|
|
579 |
].
|
|
580 |
description translateLabel == true ifTrue:[
|
|
581 |
(appl := aBuilder application) notNil ifTrue:[
|
|
582 |
^ (appl resources string:label) ? label
|
|
583 |
]
|
|
584 |
]
|
|
585 |
].
|
|
586 |
^ label
|
|
587 |
!
|
|
588 |
|
|
589 |
resolveLabelWithBuilder:aBuilder
|
|
590 |
|label appl|
|
|
591 |
|
|
592 |
aBuilder isNil ifTrue:[
|
|
593 |
^ description rawLabel
|
|
594 |
].
|
|
595 |
|
|
596 |
(label := description label) isString ifTrue:[
|
|
597 |
description labelIsImage ifTrue:[
|
|
598 |
aBuilder isEditing ifTrue:[
|
|
599 |
label := nil
|
|
600 |
] ifFalse:[
|
|
601 |
label := aBuilder labelFor:(label asSymbol)
|
|
602 |
].
|
|
603 |
^ label ? description class defaultIcon
|
|
604 |
].
|
|
605 |
description translateLabel == true ifTrue:[
|
|
606 |
(appl := aBuilder application) notNil ifTrue:[
|
|
607 |
^ (appl resources string:label) ? label
|
|
608 |
]
|
|
609 |
]
|
|
610 |
].
|
|
611 |
^ label
|
542
|
612 |
! !
|
|
613 |
|
621
|
614 |
!DataSetColumn methodsFor:'private'!
|
|
615 |
|
|
616 |
drawableAt:aRowNr
|
|
617 |
"get the drawable label at an index
|
|
618 |
"
|
637
|
619 |
^ drawableAction value:(dataSet at:aRowNr)
|
621
|
620 |
! !
|
|
621 |
|
542
|
622 |
!DataSetColumn methodsFor:'queries'!
|
|
623 |
|
607
|
624 |
canSelect:aRowNr
|
|
625 |
"returns true if cell in column is selectable
|
|
626 |
"
|
|
627 |
|s|
|
|
628 |
|
|
629 |
description canSelect ifTrue:[
|
|
630 |
^ ((s := description selectSelector) isNil or:[(dataSet at:aRowNr) perform:s])
|
|
631 |
].
|
|
632 |
^ false
|
|
633 |
|
|
634 |
!
|
|
635 |
|
647
|
636 |
containsText
|
|
637 |
"returns true if text might exist
|
|
638 |
"
|
|
639 |
^ (rendererType ~~ #rowSelector and:[rendererType ~~ #CheckToggle])
|
|
640 |
!
|
|
641 |
|
833
|
642 |
hasChoices:aRowNr
|
|
643 |
^ (description choicesFor:(dataSet at:aRowNr)) notNil
|
|
644 |
!
|
|
645 |
|
542
|
646 |
heightOfHighestRow
|
|
647 |
"returns the height of the highest row in pixels
|
|
648 |
"
|
|
649 |
|hObj hMin end|
|
|
650 |
|
647
|
651 |
hMin := dataSet font heightOn:dataSet device.
|
|
652 |
|
|
653 |
form notNil ifTrue:[
|
|
654 |
hMin := hMin max:(buttonExtent y)
|
|
655 |
].
|
542
|
656 |
|
|
657 |
(hObj := description height) == 0 ifTrue:[
|
647
|
658 |
self containsText ifTrue:[
|
542
|
659 |
"/ search first none empty drawable object
|
621
|
660 |
end := 10 min:dataSet size.
|
542
|
661 |
|
|
662 |
1 to:end do:[:aRowNr| |lbl|
|
621
|
663 |
lbl := self drawableAt:aRowNr.
|
542
|
664 |
|
|
665 |
lbl notNil ifTrue:[
|
|
666 |
(lbl respondsTo:#heightOn:) ifTrue:[
|
|
667 |
hObj := lbl heightOn:dataSet
|
|
668 |
] ifFalse:[
|
|
669 |
hObj := lbl displayString heightOn:dataSet
|
|
670 |
].
|
|
671 |
^ hMin max:hObj
|
|
672 |
]
|
|
673 |
]
|
|
674 |
]
|
|
675 |
].
|
|
676 |
^ hMin max:hObj.
|
|
677 |
! !
|
|
678 |
|
|
679 |
!DataSetColumn methodsFor:'searching'!
|
|
680 |
|
|
681 |
findRowNrStartingWithChar:aChar start:start stop:stop
|
|
682 |
"find the first row starting at start to stop, which drawable label
|
|
683 |
starts with the character, aChar. The index of the detected row is
|
|
684 |
returned or if no row is found 0.
|
|
685 |
"
|
|
686 |
|char|
|
|
687 |
|
647
|
688 |
self containsText ifTrue:[
|
542
|
689 |
char := aChar asLowercase.
|
|
690 |
|
|
691 |
start to:stop do:[:aRowNr| |lbl|
|
621
|
692 |
lbl := self drawableAt:aRowNr.
|
542
|
693 |
|
|
694 |
lbl isString ifTrue:[
|
|
695 |
(lbl size ~~ 0 and:[(lbl at:1) asLowercase == char]) ifTrue:[
|
|
696 |
^ aRowNr
|
|
697 |
]
|
|
698 |
] ifFalse:[
|
|
699 |
lbl isNil ifFalse:[
|
|
700 |
^ 0
|
|
701 |
]
|
|
702 |
]
|
|
703 |
]
|
|
704 |
].
|
|
705 |
^ 0
|
|
706 |
|
|
707 |
! !
|
|
708 |
|
|
709 |
!DataSetColumn class methodsFor:'documentation'!
|
|
710 |
|
|
711 |
version
|
891
|
712 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.21 1998-05-20 07:38:03 ca Exp $'
|
542
|
713 |
! !
|