author | ca |
Sun, 23 Aug 1998 15:14:46 +0200 | |
changeset 1088 | c2e474a7d0f2 |
parent 1065 | 332afeb89d6b |
child 1089 | 931865a72ba7 |
permissions | -rw-r--r-- |
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 |
|
1088 | 17 |
instanceVariableNames:'columnNumber dataSet minWidth width description buttonExtent |
18 |
drawableAction rendererType backgroundColor foregroundColor |
|
19 |
fgSelector bgSelector columnAlignment label readSelector |
|
20 |
columnAdaptor' |
|
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) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
52 |
|
542 | 53 |
dataSet <DSVColumnView> the view it belongs to |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
54 |
|
542 | 55 |
minWidth <Integer> minimum required width by the column |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
56 |
|
1088 | 57 |
width <Integer> width of column |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
58 |
|
1088 | 59 |
description <DataSetColumnSpec> the column description |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
60 |
|
1088 | 61 |
buttonExtent <Point> extent of drawable form |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
62 |
|
647 | 63 |
drawableAction <Action> action to access the printable |
64 |
label of a cell |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
65 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
66 |
rendererType <Type> renderer type (cached value from |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
67 |
the column specification). |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
68 |
|
647 | 69 |
backgroundColor <Color or nil> background color of all cells or nil |
70 |
(nil: use default background color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
71 |
|
647 | 72 |
foregroundColor <Color or nil> foreground color of all cells or nil |
73 |
(nil: use default foreground color). |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
74 |
|
647 | 75 |
fgSelector <Selector or nil> access specific foreground color for |
76 |
a cell |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
77 |
|
647 | 78 |
bgSelector <Selector or nil> access specific background color for |
79 |
a cell |
|
80 |
||
1088 | 81 |
columnAlignment <Symbol> align text/icon #left #right or #center |
82 |
in row (on default: #left). |
|
83 |
||
84 |
label <label/icon or nil> label resolved by the builder shown |
|
85 |
in the column description field. |
|
86 |
||
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
87 |
readSelector <Symbol> cached readSelector (from the spec) |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
88 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
89 |
columnAdaptor <nil or any> if non-nil, that one is asked (via |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
90 |
read-writeSelectors to extract a column |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
91 |
from a row object. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
92 |
If nil, the row object is used itself. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
93 |
|
542 | 94 |
|
95 |
[author:] |
|
96 |
Claus Atzkern |
|
97 |
||
98 |
[see also:] |
|
99 |
DataSetColumnSpec |
|
100 |
DSVColumnView |
|
101 |
DataSetView |
|
102 |
" |
|
103 |
||
104 |
||
105 |
! ! |
|
106 |
||
107 |
!DataSetColumn methodsFor:'accessing'! |
|
108 |
||
109 |
at:aRowNr |
|
110 |
"get the value of the raw at an index, aRowNr |
|
111 |
" |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
112 |
^ self extractColFromRow:(dataSet at:aRowNr). |
542 | 113 |
! |
114 |
||
115 |
at:aRowNr put:something |
|
116 |
"set the value of the raw at an index, aRowNr |
|
117 |
" |
|
1059 | 118 |
|row newRow| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
119 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
120 |
row := dataSet at:aRowNr. |
1059 | 121 |
newRow := self storeCol:something inRow:row. |
122 |
newRow ~~ row ifTrue:[ |
|
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
123 |
dataSet dataSetView listAt:aRowNr put:newRow. |
1059 | 124 |
] |
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
125 |
|
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
126 |
"Modified: / 7.8.1998 / 22:17:27 / cg" |
542 | 127 |
! |
128 |
||
584 | 129 |
backgroundColor |
130 |
^ backgroundColor |
|
131 |
! |
|
132 |
||
807 | 133 |
description |
134 |
"returns the column description |
|
135 |
" |
|
136 |
^ description |
|
137 |
||
138 |
||
139 |
! |
|
140 |
||
584 | 141 |
foregroundColor |
142 |
^ foregroundColor |
|
143 |
! |
|
144 |
||
542 | 145 |
label |
146 |
"get the label assigned to the column |
|
147 |
" |
|
891 | 148 |
^ label |
542 | 149 |
|
150 |
||
151 |
! |
|
152 |
||
647 | 153 |
rendererType |
154 |
"returns my renderer type |
|
155 |
" |
|
156 |
^ rendererType |
|
157 |
! |
|
158 |
||
542 | 159 |
width |
160 |
"returns the width in pixels |
|
161 |
" |
|
162 |
|end| |
|
163 |
||
164 |
width notNil ifTrue:[ ^ width ]. "/ already computed |
|
165 |
||
166 |
( (width := description width) ~~ 0 "/ fixed size |
|
167 |
or:[(width := description minWidth) ~~ 0] "/ start size |
|
607 | 168 |
) ifFalse:[ |
647 | 169 |
self containsText ifTrue:[ |
607 | 170 |
"/ take maximum 10 entries to calculate the width; |
171 |
"/ can be resized later if neccessary |
|
542 | 172 |
|
621 | 173 |
end := 10 min:dataSet size. |
542 | 174 |
|
607 | 175 |
1 to:end do:[:aRowNr||lbl| |
621 | 176 |
lbl := self drawableAt:aRowNr. |
542 | 177 |
|
607 | 178 |
(lbl respondsTo:#widthOn:) ifTrue:[ |
179 |
width := width max:(lbl widthOn:dataSet) |
|
180 |
] ifFalse:[ |
|
181 |
lbl notNil ifTrue:[ |
|
182 |
width := width max:(lbl displayString widthOn:dataSet) |
|
183 |
] |
|
542 | 184 |
] |
607 | 185 |
]. |
186 |
description editorType ~~ #None ifTrue:[ |
|
187 |
width := width + (dataSet font widthOn:dataSet device) |
|
188 |
]. |
|
542 | 189 |
]. |
1088 | 190 |
width := width + buttonExtent x. |
191 |
||
192 |
label notNil ifTrue:[ |
|
193 |
width := width max:(4 + (label widthOn:dataSet)) |
|
194 |
] |
|
542 | 195 |
]. |
196 |
^ width := minWidth := width + dataSet separatorSize + (2 * dataSet horizontalSpacing). |
|
197 |
! |
|
198 |
||
199 |
width:aWidth |
|
200 |
"set the width |
|
201 |
" |
|
202 |
|w| |
|
203 |
||
545 | 204 |
(w := description width) ~~ 0 ifTrue:[ "/ fixed size |
205 |
width := minWidth := w |
|
542 | 206 |
] ifFalse:[ |
207 |
width := aWidth max:minWidth |
|
208 |
]. |
|
209 |
||
210 |
! ! |
|
211 |
||
212 |
!DataSetColumn methodsFor:'drawing'! |
|
213 |
||
1088 | 214 |
drawCheckTogglesX:xTop y:yTop from:start to:stop with:fgColor and:bgColor |
215 |
"draw CheckToggles between start and stop |
|
216 |
" |
|
217 |
|extent toggleForm |
|
218 |
toggleLevel "{ Class:SmallInteger }" |
|
219 |
toggleWidth "{ Class:SmallInteger }" |
|
220 |
toggleHeight "{ Class:SmallInteger }" |
|
221 |
separatorSz "{ Class:SmallInteger }" |
|
222 |
height "{ Class:SmallInteger }" |
|
223 |
y "{ Class:SmallInteger }" |
|
224 |
x "{ Class:SmallInteger }" |
|
225 |
| |
|
226 |
toggleForm := dataSet checkToggleForm. |
|
227 |
toggleHeight := buttonExtent y. |
|
228 |
toggleWidth := buttonExtent x. |
|
229 |
toggleLevel := dataSet checkToggleLevel. |
|
230 |
height := dataSet rowHeight. |
|
231 |
extent := (buttonExtent - toggleForm extent) // 2. |
|
232 |
separatorSz := dataSet separatorSize - 1. |
|
833 | 233 |
|
1088 | 234 |
y := yTop + (height - toggleHeight - separatorSz // 2). |
235 |
x := xTop + (width - toggleWidth - separatorSz // 2). |
|
236 |
||
237 |
start to:stop do:[:aRowNr| |
|
238 |
dataSet drawEdgesAtX:x y:y width:toggleWidth height:toggleHeight level:toggleLevel. |
|
833 | 239 |
|
1088 | 240 |
(self extractColFromRow:(dataSet at:aRowNr)) ifTrue:[ |
241 |
(dataSet isRowSelected:aRowNr) ifFalse:[dataSet paint:fgColor on:bgColor] |
|
242 |
ifTrue:[dataSet paint:(dataSet hgLgFgColor) on:(dataSet hgLgBgColor)]. |
|
243 |
||
244 |
dataSet displayImage:toggleForm x:(x + extent x) y:(y + extent y). |
|
833 | 245 |
]. |
1088 | 246 |
y := y + height. |
247 |
] |
|
833 | 248 |
|
249 |
! |
|
250 |
||
1088 | 251 |
drawComboButtonsX:xTop y:yTop from:start to:stop with:fgColor and:bgColor |
252 |
"draw ComboButtons between start and stop |
|
253 |
" |
|
254 |
|extent buttonForm |
|
255 |
buttonLevel "{ Class:SmallInteger }" |
|
256 |
buttonWidth "{ Class:SmallInteger }" |
|
257 |
buttonHeight "{ Class:SmallInteger }" |
|
258 |
height "{ Class:SmallInteger }" |
|
259 |
y "{ Class:SmallInteger }" |
|
260 |
x "{ Class:SmallInteger }" |
|
261 |
| |
|
262 |
buttonForm := dataSet comboButtonForm. |
|
263 |
buttonLevel := dataSet comboButtonLevel. |
|
264 |
buttonWidth := buttonExtent x. |
|
265 |
buttonHeight := buttonExtent y. |
|
266 |
height := dataSet rowHeight. |
|
267 |
extent := (buttonExtent - buttonForm extent) // 2. |
|
268 |
||
269 |
y := yTop + (height - buttonHeight - (dataSet separatorSize) // 2). |
|
270 |
x := xTop + (width - buttonWidth - 4). |
|
271 |
||
272 |
start to:stop do:[:aRowNr| |
|
273 |
(self hasChoices:aRowNr) ifTrue:[ |
|
274 |
dataSet drawEdgesAtX:x y:y width:buttonWidth height:buttonHeight level:buttonLevel. |
|
275 |
||
276 |
(dataSet isRowSelected:aRowNr) ifFalse:[dataSet paint:fgColor on:bgColor] |
|
277 |
ifTrue:[dataSet paint:(dataSet hgLgFgColor) |
|
278 |
on:(dataSet hgLgBgColor) |
|
279 |
]. |
|
280 |
||
281 |
dataSet displayImage:buttonForm x:(x + extent x) y:(y + extent y) |
|
282 |
]. |
|
283 |
y := y + height. |
|
284 |
] |
|
285 |
! |
|
286 |
||
287 |
drawSeparatorsX:xTop y:yTop from:start to:stop with:fgColor |
|
542 | 288 |
"redraw rows between start and stop |
289 |
" |
|
1088 | 290 |
|lgCol showColSeparator showRowSeparator yBot |
637 | 291 |
h "{ Class:SmallInteger }" |
292 |
y "{ Class:SmallInteger }" |
|
293 |
x "{ Class:SmallInteger }" |
|
1088 | 294 |
n "{ Class:SmallInteger }" |
295 |
| |
|
296 |
h := dataSet rowHeight. |
|
297 |
x := xTop + width - 1. |
|
298 |
n := stop - start + 1. |
|
1040
c8e6a2ed7928
use the same background color for a selected rowSelector
ca
parents:
1007
diff
changeset
|
299 |
|
1088 | 300 |
(showColSeparator := description showColSeparator) ifTrue:[ |
301 |
yBot := yTop - 1 + (h * n). |
|
302 |
] ifFalse:[ |
|
303 |
(showRowSeparator := description showRowSeparator) ifFalse:[ |
|
304 |
^ self |
|
305 |
] |
|
542 | 306 |
]. |
307 |
||
1088 | 308 |
dataSet separatorSize == 1 ifTrue:[ |
604 | 309 |
dataSet paint:fgColor. |
542 | 310 |
|
1088 | 311 |
showColSeparator ifTrue:[ |
312 |
dataSet displayLineFromX:x y:yTop toX:x y:yBot |
|
542 | 313 |
]. |
1088 | 314 |
showRowSeparator ifTrue:[ |
607 | 315 |
y := yTop - 1. |
542 | 316 |
|
1088 | 317 |
n timesRepeat:[ |
637 | 318 |
y := y + h. |
1088 | 319 |
dataSet displayLineFromX:xTop y:y toX:x y:y |
542 | 320 |
] |
637 | 321 |
] |
322 |
] ifFalse:[ |
|
323 |
lgCol := dataSet separatorLightColor. |
|
568 | 324 |
|
1088 | 325 |
showColSeparator ifTrue:[ |
637 | 326 |
dataSet paint:lgCol. |
1088 | 327 |
dataSet displayLineFromX:x y:yTop toX:x y:yBot. |
637 | 328 |
x := x - 1. |
1088 | 329 |
dataSet paint:(dataSet separatorDarkColor). |
330 |
dataSet displayLineFromX:x y:yTop toX:x y:yBot. |
|
607 | 331 |
] ifFalse:[ |
1088 | 332 |
dataSet paint:(dataSet separatorDarkColor). |
333 |
x := x + 1. |
|
607 | 334 |
]. |
542 | 335 |
|
1088 | 336 |
showRowSeparator ifTrue:[ |
637 | 337 |
y := yTop - 2. |
607 | 338 |
|
1088 | 339 |
n timesRepeat:[ |
637 | 340 |
y := y + h. |
1088 | 341 |
dataSet displayLineFromX:xTop y:y toX:x y:y. |
637 | 342 |
]. |
343 |
y := yTop - 1. |
|
344 |
dataSet paint:lgCol. |
|
345 |
||
1088 | 346 |
n timesRepeat:[ |
637 | 347 |
y := y + h. |
1088 | 348 |
dataSet displayLineFromX:xTop y:y toX:x y:y. |
542 | 349 |
] |
607 | 350 |
] |
351 |
] |
|
807 | 352 |
|
607 | 353 |
! |
354 |
||
542 | 355 |
invalidate |
356 |
"set to invalidate; forces a recomputation |
|
357 |
" |
|
568 | 358 |
minWidth := width := nil. |
542 | 359 |
|
1088 | 360 |
! |
361 |
||
362 |
redrawX:xTop y:yTop from:start to:stop with:fgColor and:bgColor |
|
363 |
"redraw rows between start and stop |
|
364 |
" |
|
365 |
|lgCol dkCol fg bg lblFg lblBg label row sel |
|
366 |
h "{ Class:SmallInteger }" |
|
367 |
y "{ Class:SmallInteger }" |
|
368 |
x "{ Class:SmallInteger }" |
|
369 |
lblX "{ Class:SmallInteger }" |
|
370 |
space "{ Class:SmallInteger }" |
|
371 |
inset "{ Class:SmallInteger }" |
|
372 |
| |
|
373 |
h := dataSet rowHeight. |
|
374 |
||
375 |
(bg := backgroundColor) isNil ifTrue:[ |
|
376 |
bg := bgColor |
|
377 |
] ifFalse:[ |
|
378 |
dataSet paint:(dataSet colorOnDevice:bg). |
|
379 |
dataSet fillRectangleX:xTop y:yTop width:width height:(h * (stop - start + 1) - 1) |
|
380 |
]. |
|
381 |
fg := foregroundColor ? fgColor. |
|
382 |
lgCol := dataSet hgLgFgColor. |
|
383 |
dkCol := dataSet hgLgBgColor. |
|
384 |
space := dataSet horizontalSpacing. |
|
385 |
inset := dataSet rowFontAscent. |
|
386 |
y := yTop. |
|
387 |
x := xTop + space. |
|
388 |
||
389 |
start to:stop do:[:anIndex| |
|
390 |
row := dataSet at:anIndex. |
|
391 |
sel := dataSet isSelected:anIndex inColumn:columnNumber. |
|
392 |
||
393 |
rendererType == #rowSelector ifTrue:[ |
|
394 |
sel ifTrue:[ |
|
395 |
label := dataSet rowSelectorForm. |
|
396 |
sel := false. |
|
397 |
] ifFalse:[ |
|
398 |
label := nil |
|
399 |
] |
|
400 |
] ifFalse:[ |
|
401 |
label := drawableAction value:row |
|
402 |
]. |
|
403 |
||
404 |
sel ifTrue:[ |
|
405 |
dataSet paint:dkCol. |
|
406 |
dataSet fillRectangleX:xTop y:y width:width height:(h - 2). |
|
407 |
label isText ifTrue:[label := label string]. |
|
408 |
lblBg := dkCol. |
|
409 |
lblFg := lgCol. |
|
410 |
] ifFalse:[ |
|
411 |
(bgSelector notNil and:[(lblBg := row perform:bgSelector) notNil]) ifTrue:[ |
|
412 |
dataSet paint:(lblBg := dataSet colorOnDevice:lblBg). |
|
413 |
dataSet fillRectangleX:xTop y:y width:width height:(h - 2). |
|
414 |
] ifFalse:[ |
|
415 |
lblBg := bg |
|
416 |
]. |
|
417 |
label notNil ifTrue:[ |
|
418 |
(fgSelector notNil and:[(lblFg := row perform:fgSelector) notNil]) ifFalse:[ |
|
419 |
lblFg := fg. |
|
420 |
] ifTrue:[ |
|
421 |
lblFg := dataSet colorOnDevice:lblFg. |
|
422 |
]. |
|
423 |
] |
|
424 |
]. |
|
425 |
label notNil ifTrue:[ |
|
426 |
columnAlignment == #left ifTrue:[ |
|
427 |
lblX := x |
|
428 |
] ifFalse:[ |
|
429 |
lblX := width - (label widthOn:dataSet). |
|
430 |
||
431 |
columnAlignment == #right ifTrue:[lblX := lblX - space] |
|
432 |
ifFalse:[lblX := lblX // 2]. |
|
433 |
||
434 |
lblX := (xTop + lblX) max:0. |
|
435 |
]. |
|
436 |
dataSet paint:lblFg on:lblBg. |
|
437 |
||
438 |
label isImageOrForm ifFalse:[ |
|
439 |
label displayOn:dataSet x:lblX y:(y + inset) |
|
440 |
] ifTrue:[ |
|
441 |
label displayOn:dataSet x:lblX y:y + ((h - label height - dataSet separatorSize) // 2) |
|
442 |
] |
|
443 |
]. |
|
444 |
y := y + h. |
|
445 |
]. |
|
446 |
||
447 |
"/ DRAW FORM |
|
448 |
rendererType == #CheckToggle ifTrue:[ |
|
449 |
self drawCheckTogglesX:xTop y:yTop from:start to:stop with:fgColor and:bgColor |
|
450 |
] ifFalse:[ |
|
451 |
(rendererType == #ComboList or:[rendererType == #ComboBox]) ifTrue:[ |
|
452 |
self drawComboButtonsX:xTop y:yTop from:start to:stop with:fgColor and:bgColor |
|
453 |
] |
|
454 |
]. |
|
455 |
||
456 |
"/ DRAW SEPARATORS |
|
457 |
self drawSeparatorsX:xTop y:yTop from:start to:stop with:fgColor |
|
542 | 458 |
! ! |
459 |
||
614 | 460 |
!DataSetColumn methodsFor:'editing'! |
461 |
||
833 | 462 |
editorAt:aRowNr |
463 |
|val row| |
|
614 | 464 |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
465 |
row := (dataSet at:aRowNr). |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
466 |
val := self extractColFromRow:row. |
614 | 467 |
|
833 | 468 |
val isText ifTrue:[val := val string]. |
614 | 469 |
|
833 | 470 |
^ description editorOn:row value:val. |
614 | 471 |
! ! |
472 |
||
542 | 473 |
!DataSetColumn methodsFor:'event handling'! |
474 |
||
475 |
doesNotUnderstand:aMessage |
|
476 |
||
477 |
(description respondsTo:(aMessage selector)) ifTrue:[ |
|
478 |
^ aMessage sendTo:description |
|
479 |
]. |
|
480 |
^ super doesNotUnderstand:aMessage |
|
481 |
||
482 |
! ! |
|
483 |
||
484 |
!DataSetColumn methodsFor:'grow & degrow'! |
|
485 |
||
486 |
growWidth:n |
|
487 |
"grow the width for n pixels |
|
488 |
" |
|
489 |
width := width + n. |
|
490 |
||
491 |
||
492 |
! |
|
493 |
||
494 |
minWidth |
|
495 |
"get my minimum width required by the entries into the column |
|
496 |
" |
|
497 |
^ minWidth notNil ifTrue:[minWidth] ifFalse:[self width] |
|
498 |
||
499 |
||
500 |
! |
|
501 |
||
502 |
setMinWidth |
|
503 |
"set the width to the required width. returns the psitive delta width |
|
504 |
" |
|
505 |
|deltaX| |
|
506 |
||
507 |
deltaX := width - minWidth. |
|
508 |
width := minWidth. |
|
509 |
^ deltaX. |
|
510 |
||
511 |
||
512 |
! ! |
|
513 |
||
514 |
!DataSetColumn methodsFor:'initialization'! |
|
515 |
||
607 | 516 |
on:aDSVColumnView description:aDescription columnNumber:aNumber |
542 | 517 |
"instance creation; set attributes dependent on the description |
518 |
" |
|
891 | 519 |
|device selector format idx type oldFont newFont| |
542 | 520 |
|
607 | 521 |
columnNumber := aNumber. |
584 | 522 |
dataSet := aDSVColumnView. |
523 |
description := aDescription. |
|
524 |
rendererType := description rendererType. |
|
1088 | 525 |
width := nil. |
584 | 526 |
device := dataSet device. |
637 | 527 |
drawableAction := [:aRow| nil ]. |
621 | 528 |
fgSelector := description foregroundSelector. |
529 |
bgSelector := description backgroundSelector. |
|
584 | 530 |
backgroundColor := description backgroundColor. |
531 |
foregroundColor := description foregroundColor. |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
532 |
readSelector := description readSelector. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
533 |
columnAdaptor := dataSet columnAdaptor. |
647 | 534 |
buttonExtent := 0 @ 0. |
883 | 535 |
columnAlignment := #left. |
584 | 536 |
|
537 |
backgroundColor notNil ifTrue:[ |
|
824 | 538 |
backgroundColor := backgroundColor on:dataSet device |
584 | 539 |
]. |
540 |
foregroundColor notNil ifTrue:[ |
|
824 | 541 |
foregroundColor := foregroundColor on:dataSet device |
584 | 542 |
]. |
542 | 543 |
|
824 | 544 |
oldFont := nil. |
891 | 545 |
label := self resolveLabelWithBuilder:(dataSet builder). |
824 | 546 |
|
547 |
(label respondsTo:#string) ifTrue:[ |
|
548 |
"/ |
|
549 |
"/ must set the font to accumulate the real extent of a string label |
|
550 |
"/ |
|
551 |
(label isString and:[label isEmpty]) ifTrue:[ |
|
552 |
label := nil |
|
553 |
] ifFalse:[ |
|
554 |
(newFont := description labelFont) notNil ifTrue:[ |
|
555 |
oldFont := dataSet font. |
|
556 |
dataSet font:newFont. |
|
557 |
] |
|
558 |
] |
|
559 |
]. |
|
560 |
||
561 |
oldFont notNil ifTrue:[ |
|
562 |
dataSet font:oldFont |
|
542 | 563 |
]. |
564 |
||
565 |
rendererType == #CheckToggle ifTrue:[ |
|
807 | 566 |
buttonExtent := dataSet checkToggleExtent. |
647 | 567 |
^ self |
542 | 568 |
]. |
569 |
||
570 |
rendererType == #rowSelector ifTrue:[ |
|
807 | 571 |
buttonExtent := dataSet rowSelectorExtent. |
647 | 572 |
^ self |
542 | 573 |
]. |
574 |
||
575 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
807 | 576 |
buttonExtent := dataSet comboButtonExtent. |
883 | 577 |
] ifFalse:[ |
578 |
columnAlignment := description columnAlignment |
|
542 | 579 |
]. |
580 |
||
581 |
selector := description printSelector. |
|
582 |
||
583 |
selector notNil ifTrue:[ |
|
621 | 584 |
drawableAction := [:aRow| aRow perform:selector with:dataSet ]. |
542 | 585 |
^ self |
586 |
]. |
|
587 |
||
614 | 588 |
( (format := description formatString) notNil |
589 |
and:[(type := description type) == #number or:[type == #numberOrNil]] |
|
590 |
) ifTrue:[ |
|
542 | 591 |
"/ has a format string for number (supports only floats) |
592 |
||
614 | 593 |
(idx := format indexOf:$.) ~~ 0 ifTrue:[ |
594 |
idx := format size - idx |
|
542 | 595 |
]. |
614 | 596 |
format := '%0.', idx printString, 'f'. |
542 | 597 |
|
621 | 598 |
drawableAction := [:aRow||n| |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
599 |
n := self extractColFromRow:aRow. |
621 | 600 |
n isReal ifTrue:[n := n asFloat printfPrintString:format]. |
601 |
n |
|
614 | 602 |
] |
621 | 603 |
] ifFalse:[ "/ default: no format string |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
604 |
drawableAction := [:aRow| self extractColFromRow:aRow ] |
614 | 605 |
] |
542 | 606 |
|
607 |
||
891 | 608 |
! |
609 |
||
610 |
resolveLabelWithBuilder:aBuilder |
|
1043 | 611 |
|label appl l2| |
891 | 612 |
|
613 |
aBuilder isNil ifTrue:[ |
|
614 |
^ description rawLabel |
|
615 |
]. |
|
616 |
||
617 |
(label := description label) isString ifTrue:[ |
|
618 |
description labelIsImage ifTrue:[ |
|
619 |
aBuilder isEditing ifTrue:[ |
|
620 |
label := nil |
|
621 |
] ifFalse:[ |
|
1043 | 622 |
(label := aBuilder labelFor:(label asSymbol)) notNil ifTrue:[ |
623 |
^ label |
|
624 |
] |
|
891 | 625 |
]. |
1043 | 626 |
^ description class defaultIcon |
891 | 627 |
]. |
628 |
description translateLabel == true ifTrue:[ |
|
629 |
(appl := aBuilder application) notNil ifTrue:[ |
|
1043 | 630 |
(l2 := appl resources string:label) notNil ifTrue:[ |
631 |
^ l2 |
|
632 |
] |
|
891 | 633 |
] |
634 |
] |
|
635 |
]. |
|
636 |
^ label |
|
542 | 637 |
! ! |
638 |
||
621 | 639 |
!DataSetColumn methodsFor:'private'! |
640 |
||
641 |
drawableAt:aRowNr |
|
642 |
"get the drawable label at an index |
|
643 |
" |
|
637 | 644 |
^ drawableAction value:(dataSet at:aRowNr) |
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
645 |
! |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
646 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
647 |
extractColFromRow:aRow |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
648 |
|numArgs| |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
649 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
650 |
numArgs := readSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
651 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
652 |
numArgs == 1 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
653 |
^ columnAdaptor perform:readSelector with:aRow |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
654 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
655 |
^ columnAdaptor perform:readSelector with:aRow with:columnNumber |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
656 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
657 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
658 |
numArgs == 0 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
659 |
^ aRow perform:readSelector |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
660 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
661 |
^ aRow perform:readSelector with:columnNumber |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
662 |
! |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
663 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
664 |
storeCol:newValue inRow:aRow |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
665 |
|writeSelector numArgs| |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
666 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
667 |
writeSelector := description writeSelector. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
668 |
numArgs := writeSelector numArgs. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
669 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
670 |
columnAdaptor notNil ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
671 |
numArgs == 2 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
672 |
^ columnAdaptor perform:writeSelector with:aRow with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
673 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
674 |
^ columnAdaptor perform:writeSelector with:aRow with:columnNumber with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
675 |
]. |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
676 |
|
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
677 |
numArgs == 1 ifTrue:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
678 |
aRow perform:writeSelector with:newValue |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
679 |
] ifFalse:[ |
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
680 |
aRow perform:writeSelector with:columnNumber with:newValue |
1059 | 681 |
]. |
682 |
^ aRow |
|
1007
4ea1ecf23596
added support for columndAdaptors
Claus Gittinger <cg@exept.de>
parents:
991
diff
changeset
|
683 |
|
621 | 684 |
! ! |
685 |
||
542 | 686 |
!DataSetColumn methodsFor:'queries'! |
687 |
||
607 | 688 |
canSelect:aRowNr |
689 |
"returns true if cell in column is selectable |
|
690 |
" |
|
691 |
|s| |
|
692 |
||
693 |
description canSelect ifTrue:[ |
|
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
694 |
(s := description selectSelector) notNil ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
695 |
columnAdaptor notNil ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
696 |
s numArgs == 2 ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
697 |
^ columnAdaptor perform:s with:(dataSet at:aRowNr) with:columnNumber |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
698 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
699 |
^ columnAdaptor perform:s with:(dataSet at:aRowNr) |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
700 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
701 |
s numArgs == 1 ifTrue:[ |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
702 |
^ (dataSet at:aRowNr) perform:s with:columnNumber |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
703 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
704 |
^ (dataSet at:aRowNr) perform:s |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
705 |
]. |
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
706 |
^ true |
607 | 707 |
]. |
708 |
^ false |
|
709 |
||
1065
332afeb89d6b
modify the model (i.e. the list), when a
Claus Gittinger <cg@exept.de>
parents:
1059
diff
changeset
|
710 |
"Modified: / 7.8.1998 / 22:49:20 / cg" |
607 | 711 |
! |
712 |
||
647 | 713 |
containsText |
714 |
"returns true if text might exist |
|
715 |
" |
|
716 |
^ (rendererType ~~ #rowSelector and:[rendererType ~~ #CheckToggle]) |
|
717 |
! |
|
718 |
||
1088 | 719 |
drawableForm |
720 |
rendererType == #CheckToggle ifTrue:[ |
|
721 |
^ dataSet checkToggleForm. |
|
722 |
]. |
|
723 |
(rendererType == #ComboBox or:[rendererType == #ComboList]) ifTrue:[ |
|
724 |
^ dataSet comboButtonForm |
|
725 |
]. |
|
726 |
rendererType == #rowSelector ifTrue:[ |
|
727 |
^ dataSet rowSelectorForm |
|
728 |
]. |
|
729 |
^ nil |
|
730 |
||
731 |
||
732 |
! |
|
733 |
||
833 | 734 |
hasChoices:aRowNr |
735 |
^ (description choicesFor:(dataSet at:aRowNr)) notNil |
|
736 |
! |
|
737 |
||
542 | 738 |
heightOfHighestRow |
739 |
"returns the height of the highest row in pixels |
|
740 |
" |
|
741 |
|hObj hMin end| |
|
742 |
||
1088 | 743 |
hMin := (dataSet font heightOn:dataSet device) max:(buttonExtent y). |
542 | 744 |
|
745 |
(hObj := description height) == 0 ifTrue:[ |
|
647 | 746 |
self containsText ifTrue:[ |
542 | 747 |
"/ search first none empty drawable object |
621 | 748 |
end := 10 min:dataSet size. |
542 | 749 |
|
750 |
1 to:end do:[:aRowNr| |lbl| |
|
621 | 751 |
lbl := self drawableAt:aRowNr. |
542 | 752 |
|
753 |
lbl notNil ifTrue:[ |
|
754 |
(lbl respondsTo:#heightOn:) ifTrue:[ |
|
755 |
hObj := lbl heightOn:dataSet |
|
756 |
] ifFalse:[ |
|
757 |
hObj := lbl displayString heightOn:dataSet |
|
758 |
]. |
|
759 |
^ hMin max:hObj |
|
760 |
] |
|
761 |
] |
|
762 |
] |
|
763 |
]. |
|
764 |
^ hMin max:hObj. |
|
765 |
! ! |
|
766 |
||
767 |
!DataSetColumn methodsFor:'searching'! |
|
768 |
||
769 |
findRowNrStartingWithChar:aChar start:start stop:stop |
|
770 |
"find the first row starting at start to stop, which drawable label |
|
771 |
starts with the character, aChar. The index of the detected row is |
|
772 |
returned or if no row is found 0. |
|
773 |
" |
|
774 |
|char| |
|
775 |
||
647 | 776 |
self containsText ifTrue:[ |
542 | 777 |
char := aChar asLowercase. |
778 |
||
779 |
start to:stop do:[:aRowNr| |lbl| |
|
621 | 780 |
lbl := self drawableAt:aRowNr. |
542 | 781 |
|
782 |
lbl isString ifTrue:[ |
|
783 |
(lbl size ~~ 0 and:[(lbl at:1) asLowercase == char]) ifTrue:[ |
|
784 |
^ aRowNr |
|
785 |
] |
|
786 |
] ifFalse:[ |
|
787 |
lbl isNil ifFalse:[ |
|
788 |
^ 0 |
|
789 |
] |
|
790 |
] |
|
791 |
] |
|
792 |
]. |
|
793 |
^ 0 |
|
794 |
||
795 |
! ! |
|
796 |
||
797 |
!DataSetColumn class methodsFor:'documentation'! |
|
798 |
||
799 |
version |
|
1088 | 800 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetColumn.st,v 1.29 1998-08-23 13:14:46 ca Exp $' |
542 | 801 |
! ! |