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 |
View subclass:#DataSetView
|
700
|
17 |
instanceVariableNames:'labelView columnView listHolder useIndex labels scrolledView'
|
542
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Views-DataSet'
|
|
21 |
!
|
|
22 |
|
|
23 |
!DataSetView class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
!
|
|
41 |
|
|
42 |
documentation
|
|
43 |
"
|
|
44 |
This class implements a selection list view based on rows and columns.
|
|
45 |
It allows for the dynamic editing of this information.
|
|
46 |
|
|
47 |
[author:]
|
|
48 |
Claus Atzkern
|
|
49 |
|
|
50 |
[see also:]
|
|
51 |
DataSetColumnSpec
|
|
52 |
DataSetColumn
|
|
53 |
DSVColumnView
|
|
54 |
"
|
|
55 |
!
|
|
56 |
|
|
57 |
examples
|
|
58 |
"
|
619
|
59 |
example 1: list with valid rows of type Array
|
611
|
60 |
[exBegin]
|
|
61 |
|top scr columns rows bool rdWtSel|
|
542
|
62 |
|
611
|
63 |
top := StandardSystemView new label:'select'; extent:700@440.
|
|
64 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
65 |
|
|
66 |
columns := OrderedCollection new.
|
|
67 |
rows := OrderedCollection new.
|
|
68 |
bool := true.
|
|
69 |
rdWtSel := #( #at: #at:put: ).
|
|
70 |
|
|
71 |
1 to:1000 do:[:i||n|
|
|
72 |
n := i printString.
|
|
73 |
rows add:(Array with:('text: ', n) with:('input: ', n) with:bool).
|
|
74 |
bool := bool not.
|
|
75 |
].
|
|
76 |
|
|
77 |
columns add:(DataSetColumnSpec label:'Text' editorType:#None selector:rdWtSel).
|
|
78 |
columns add:(DataSetColumnSpec label:'Input' editorType:#InputField selector:rdWtSel).
|
|
79 |
columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel).
|
|
80 |
|
|
81 |
scr columnDescriptors:columns.
|
|
82 |
scr list:rows.
|
|
83 |
top open.
|
|
84 |
[exEnd]
|
|
85 |
|
|
86 |
|
619
|
87 |
|
|
88 |
example 2: list with none valid rows; defining #rowIfAbsent: block
|
|
89 |
[exBegin]
|
|
90 |
|top scr columns bool rdWtSel|
|
|
91 |
|
|
92 |
top := StandardSystemView new label:'select'; extent:700@440.
|
|
93 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
94 |
|
|
95 |
columns := OrderedCollection new.
|
|
96 |
bool := true.
|
|
97 |
rdWtSel := #( #at: #at:put: ).
|
|
98 |
|
|
99 |
columns add:(DataSetColumnSpec label:'Text' editorType:#None selector:rdWtSel).
|
|
100 |
columns add:(DataSetColumnSpec label:'Input' editorType:#InputField selector:rdWtSel).
|
|
101 |
columns add:(DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:rdWtSel).
|
|
102 |
|
|
103 |
scr rowIfAbsent:[:i|
|
|
104 |
bool := bool not.
|
|
105 |
Array with:('text: ', i printString) with:('input: ') with:bool
|
|
106 |
].
|
|
107 |
|
|
108 |
scr columnDescriptors:columns.
|
|
109 |
scr list:(Array new:1000).
|
|
110 |
top open.
|
|
111 |
[exEnd]
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
example 3: list with valid rows of type Structure
|
542
|
116 |
[exBegin]
|
|
117 |
|top scr clDc rows slct list idx bool|
|
|
118 |
|
|
119 |
top := StandardSystemView new label:'select'; extent:700@440.
|
|
120 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
121 |
|
|
122 |
clDc := OrderedCollection new.
|
|
123 |
rows := OrderedCollection new.
|
|
124 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ).
|
|
125 |
slct := #( #text #field #cbox #clist #toggle #choices ).
|
|
126 |
idx := 11.
|
|
127 |
bool := true.
|
|
128 |
|
|
129 |
20 timesRepeat:[ |values|
|
|
130 |
values := list collect:[:n|
|
|
131 |
n isString ifTrue:[n, idx printString]
|
|
132 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
|
|
133 |
].
|
|
134 |
rows add:(Structure newWith:slct values:values).
|
|
135 |
bool := bool not.
|
|
136 |
idx := idx + 1.
|
|
137 |
].
|
|
138 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
139 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
140 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ).
|
|
141 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ).
|
|
142 |
clDc last choices:#choices.
|
|
143 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
|
|
144 |
clDc last choices:#choices.
|
|
145 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
|
|
146 |
|
607
|
147 |
scr has3Dseparators:true.
|
542
|
148 |
scr columnDescriptors:clDc.
|
|
149 |
scr list:rows.
|
|
150 |
top open.
|
|
151 |
[exEnd]
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
619
|
156 |
example 4: table includes a row selector and multiple select is enabled
|
542
|
157 |
[exBegin]
|
|
158 |
|top scr clDc rows slct list idx bool|
|
|
159 |
|
|
160 |
top := StandardSystemView new label:'select'; extent:700@440.
|
|
161 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
162 |
|
|
163 |
clDc := OrderedCollection new.
|
|
164 |
rows := OrderedCollection new.
|
|
165 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ).
|
|
166 |
slct := #( #text #field #cbox #clist #toggle #choices ).
|
|
167 |
idx := 11.
|
|
168 |
bool := true.
|
|
169 |
|
|
170 |
20 timesRepeat:[ |values|
|
|
171 |
values := list collect:[:n|
|
|
172 |
n isString ifTrue:[n, idx printString]
|
|
173 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
|
|
174 |
].
|
|
175 |
rows add:(Structure newWith:slct values:values).
|
|
176 |
bool := bool not.
|
|
177 |
idx := idx + 1.
|
|
178 |
].
|
|
179 |
clDc add:( DataSetColumnSpec rowSelector ).
|
|
180 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
181 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
182 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ).
|
|
183 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ).
|
|
184 |
clDc last choices:#choices.
|
|
185 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
|
|
186 |
clDc last choices:#choices.
|
|
187 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
|
|
188 |
|
607
|
189 |
scr has3Dseparators:true.
|
542
|
190 |
scr columnDescriptors:clDc.
|
619
|
191 |
scr multipleSelectOk:true.
|
542
|
192 |
scr list:rows.
|
|
193 |
top open.
|
|
194 |
[exEnd]
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
619
|
199 |
example 5: performance test; with valid rows
|
542
|
200 |
[exBegin]
|
|
201 |
|t1 top scr clDc rows slct list bool tmArr listModel|
|
|
202 |
|
|
203 |
top := StandardSystemView new label:'select'; extent:600@440.
|
|
204 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
205 |
|
|
206 |
clDc := OrderedCollection new.
|
|
207 |
rows := OrderedCollection new.
|
|
208 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true ).
|
|
209 |
slct := #( #text #field #cbox #clist #toggle ).
|
|
210 |
bool := true.
|
|
211 |
|
|
212 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
213 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ).
|
|
214 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ).
|
|
215 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
|
|
216 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
|
|
217 |
|
|
218 |
scr columnDescriptors:clDc.
|
|
219 |
scr beDependentOfRows:false.
|
607
|
220 |
scr has3Dseparators:false.
|
542
|
221 |
|
|
222 |
top openAndWait.
|
|
223 |
tmArr := Array new:4.
|
|
224 |
listModel := List new.
|
|
225 |
scr listHolder:listModel.
|
|
226 |
|
|
227 |
(1 to:tmArr size) do:[:i|
|
|
228 |
listModel removeAll.
|
|
229 |
|
|
230 |
t1 := Time millisecondsToRun:[
|
|
231 |
1 to:200 do:[:i| |values|
|
|
232 |
values := list collect:[:n|
|
|
233 |
n isString ifTrue:[n, i printString]
|
|
234 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
|
|
235 |
].
|
|
236 |
listModel add:(Structure newWith:slct values:values).
|
|
237 |
bool := bool not.
|
|
238 |
|
|
239 |
i even ifTrue:[
|
|
240 |
listModel removeFirst
|
|
241 |
]
|
|
242 |
].
|
|
243 |
].
|
|
244 |
tmArr at:i put:t1
|
|
245 |
].
|
|
246 |
t1 := 0.
|
|
247 |
|
|
248 |
Transcript showCR:'----------'.
|
|
249 |
tmArr do:[:t|
|
|
250 |
t1 := t1 + t.
|
|
251 |
Transcript showCR:'TIME : ', t printString.
|
|
252 |
].
|
|
253 |
Transcript showCR:'----------'.
|
|
254 |
Transcript showCR:'DIFF : ', (t1 // tmArr size) printString.
|
|
255 |
[exEnd]
|
|
256 |
|
|
257 |
|
|
258 |
|
619
|
259 |
example 6: performance test; with invalid rows: defining #rowIfAbsent:.
|
|
260 |
[exBegin]
|
|
261 |
|t1 top scr clDc rows slct list bool tmArr listModel ctr|
|
|
262 |
|
|
263 |
top := StandardSystemView new label:'select'; extent:600@440.
|
|
264 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
265 |
|
|
266 |
clDc := OrderedCollection new.
|
|
267 |
rows := OrderedCollection new.
|
|
268 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true ).
|
|
269 |
slct := #( #text #field #cbox #clist #toggle ).
|
|
270 |
bool := true.
|
|
271 |
|
|
272 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
273 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ).
|
|
274 |
clDc add:( DataSetColumnSpec label:'C-Box' editorType:#ComboBox selector:#cbox ).
|
|
275 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
|
|
276 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
|
|
277 |
ctr := 0.
|
|
278 |
|
|
279 |
scr rowIfAbsent:[:i||values|
|
|
280 |
bool := bool not.
|
|
281 |
ctr := ctr + 1.
|
|
282 |
values := list collect:[:n|
|
|
283 |
n isString ifTrue:[n, ctr printString]
|
|
284 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
|
|
285 |
].
|
|
286 |
Structure newWith:slct values:values
|
|
287 |
].
|
|
288 |
|
|
289 |
scr columnDescriptors:clDc.
|
|
290 |
scr beDependentOfRows:false.
|
|
291 |
scr has3Dseparators:true.
|
|
292 |
|
|
293 |
top openAndWait.
|
|
294 |
tmArr := Array new:4.
|
|
295 |
listModel := List new.
|
|
296 |
scr listHolder:listModel.
|
|
297 |
|
|
298 |
(1 to:tmArr size) do:[:i|
|
|
299 |
listModel removeAll.
|
|
300 |
|
|
301 |
t1 := Time millisecondsToRun:[
|
|
302 |
1 to:200 do:[:i| |values|
|
|
303 |
listModel add:nil.
|
|
304 |
i even ifTrue:[
|
|
305 |
listModel removeFirst
|
|
306 |
]
|
|
307 |
]
|
|
308 |
].
|
|
309 |
tmArr at:i put:t1
|
|
310 |
].
|
|
311 |
t1 := 0.
|
|
312 |
|
|
313 |
Transcript showCR:'----------'.
|
|
314 |
tmArr do:[:t|
|
|
315 |
t1 := t1 + t.
|
|
316 |
Transcript showCR:'TIME : ', t printString.
|
|
317 |
].
|
|
318 |
Transcript showCR:'----------'.
|
|
319 |
Transcript showCR:'DIFF : ', (t1 // tmArr size) printString.
|
|
320 |
[exEnd]
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
example 7: images as label
|
542
|
325 |
[exBegin]
|
|
326 |
|
|
327 |
|lbl top scr clDc rows slct list idx bool|
|
|
328 |
|
|
329 |
top := StandardSystemView new label:'select'; extent:400@440.
|
|
330 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top.
|
|
331 |
|
|
332 |
clDc := OrderedCollection new.
|
|
333 |
rows := OrderedCollection new.
|
|
334 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ).
|
|
335 |
slct := #( #text #field #cbox #clist #toggle #choices ).
|
|
336 |
idx := 11.
|
|
337 |
bool := true.
|
|
338 |
|
|
339 |
20 timesRepeat:[ |values|
|
|
340 |
values := list collect:[:n|
|
|
341 |
n isString ifTrue:[n, idx printString]
|
|
342 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]]
|
|
343 |
].
|
|
344 |
rows add:(Structure newWith:slct values:values).
|
|
345 |
bool := bool not.
|
|
346 |
idx := idx + 1.
|
|
347 |
].
|
|
348 |
lbl := Image fromFile:('gifImages/nexthand.gif' ).
|
|
349 |
|
|
350 |
clDc add:( DataSetColumnSpec label:lbl editorType:#None selector:#text ).
|
|
351 |
clDc add:( DataSetColumnSpec label:'Text' editorType:#None selector:#text ).
|
|
352 |
clDc add:( DataSetColumnSpec label:'Field' editorType:#InputField selector:#field ).
|
|
353 |
|
|
354 |
lbl := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ).
|
|
355 |
clDc add:( DataSetColumnSpec label:lbl editorType:#ComboBox selector:#cbox ).
|
|
356 |
clDc last choices:#choices.
|
|
357 |
clDc add:( DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ).
|
|
358 |
clDc last choices:#choices.
|
|
359 |
clDc add:( DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ).
|
|
360 |
|
607
|
361 |
scr has3Dseparators:true.
|
542
|
362 |
scr columnDescriptors:clDc.
|
|
363 |
scr list:rows.
|
|
364 |
top open.
|
|
365 |
[exEnd]
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
"
|
|
370 |
! !
|
|
371 |
|
|
372 |
!DataSetView methodsFor:'accessing'!
|
|
373 |
|
637
|
374 |
add:aRow
|
|
375 |
"add a row; reimplemented caused by add in base class
|
|
376 |
"
|
|
377 |
^ columnView add:aRow
|
|
378 |
!
|
|
379 |
|
542
|
380 |
useIndex
|
637
|
381 |
"specify, if the selected components value or its index in the
|
|
382 |
list should be sent to the model. The default is its index.
|
|
383 |
"
|
542
|
384 |
^ useIndex
|
|
385 |
!
|
|
386 |
|
|
387 |
useIndex:aBool
|
637
|
388 |
"specify, if the selected components value or its index in the
|
|
389 |
list should be sent to the model. The default is its index.
|
|
390 |
"
|
542
|
391 |
useIndex := aBool
|
|
392 |
! !
|
|
393 |
|
700
|
394 |
!DataSetView methodsFor:'accessing look'!
|
|
395 |
|
|
396 |
font:aFont
|
|
397 |
"set the font for all rows and labels.
|
|
398 |
"
|
|
399 |
columnView font:aFont
|
|
400 |
!
|
|
401 |
|
|
402 |
horizontalMini:aBool
|
|
403 |
"control the horizontal scrollBar to be either a miniScroller,
|
|
404 |
or a full scrollBar.
|
|
405 |
"
|
|
406 |
scrolledView horizontalMini:aBool.
|
|
407 |
self recomputeLabelView.
|
|
408 |
!
|
|
409 |
|
|
410 |
horizontalScrollable:aBool
|
|
411 |
"enable/disable horizontal scrollability.
|
|
412 |
If disabled, the horizontal scrollBar is made invisible.
|
|
413 |
"
|
|
414 |
scrolledView horizontalScrollable:aBool.
|
|
415 |
self recomputeLabelView.
|
|
416 |
!
|
|
417 |
|
|
418 |
isHorizontalScrollable
|
|
419 |
"returns true if horizontal scrollable
|
|
420 |
"
|
|
421 |
^ scrolledView isHorizontalScrollable
|
|
422 |
!
|
|
423 |
|
|
424 |
isVerticalScrollable
|
|
425 |
"returns true if vertical scrollable
|
|
426 |
"
|
|
427 |
^ scrolledView isVerticalScrollable
|
|
428 |
!
|
|
429 |
|
|
430 |
verticalMini:aBool
|
|
431 |
"control the vertical scrollBar to be either a miniScroller,
|
|
432 |
or a full scrollBar.
|
|
433 |
"
|
|
434 |
scrolledView verticalMini:aBool.
|
|
435 |
self recomputeLabelView.
|
|
436 |
|
|
437 |
!
|
|
438 |
|
|
439 |
verticalScrollable:aBool
|
|
440 |
"enable/disable vertical scrollability.
|
|
441 |
If disabled, the horizontal scrollBar is made invisible.
|
|
442 |
"
|
|
443 |
scrolledView verticalScrollable:aBool.
|
|
444 |
self recomputeLabelView
|
|
445 |
!
|
|
446 |
|
|
447 |
viewBackground
|
|
448 |
"get the background color of the rows and labels
|
|
449 |
"
|
|
450 |
^ columnView backgroundColor.
|
|
451 |
|
|
452 |
|
|
453 |
!
|
|
454 |
|
|
455 |
viewBackground:aColor
|
|
456 |
"set the background color of the rows and labels
|
|
457 |
"
|
|
458 |
^ columnView backgroundColor:aColor.
|
|
459 |
|
|
460 |
|
|
461 |
! !
|
|
462 |
|
542
|
463 |
!DataSetView methodsFor:'accessing menus'!
|
|
464 |
|
|
465 |
menuHolder:anObject
|
|
466 |
"set the menu holder in the column view too
|
|
467 |
"
|
|
468 |
super menuHolder:anObject.
|
|
469 |
columnView menuHolder:anObject.
|
|
470 |
|
|
471 |
!
|
|
472 |
|
|
473 |
menuMessage:aSymbol
|
|
474 |
"set the menu message in the column view too
|
|
475 |
"
|
|
476 |
super menuMessage:aSymbol.
|
|
477 |
columnView menuMessage:aSymbol.
|
|
478 |
|
|
479 |
!
|
|
480 |
|
|
481 |
menuPerformer:anObject
|
|
482 |
"set the performer in the column view too
|
|
483 |
"
|
|
484 |
super menuPerformer:anObject.
|
|
485 |
columnView menuPerformer:anObject.
|
|
486 |
|
|
487 |
! !
|
|
488 |
|
637
|
489 |
!DataSetView methodsFor:'accessing mvc'!
|
542
|
490 |
|
|
491 |
listHolder:aListHolder
|
637
|
492 |
"set the valueHolder which holds the list of rows
|
542
|
493 |
"
|
611
|
494 |
listHolder ~~ aListHolder ifTrue:[
|
|
495 |
listHolder notNil ifTrue:[
|
|
496 |
listHolder removeDependent:self
|
|
497 |
].
|
|
498 |
|
|
499 |
(listHolder := aListHolder) notNil ifTrue:[
|
|
500 |
listHolder addDependent:self
|
|
501 |
]
|
542
|
502 |
].
|
|
503 |
|
647
|
504 |
columnView list:(listHolder value)
|
542
|
505 |
!
|
|
506 |
|
|
507 |
model:aModel
|
637
|
508 |
"set the valueHolder which holds the selection and maybe the list of rows
|
542
|
509 |
"
|
|
510 |
(model respondsTo:#list) ifTrue:[
|
|
511 |
(model list == listHolder) ifTrue:[
|
|
512 |
self listHolder:nil
|
|
513 |
]
|
|
514 |
].
|
|
515 |
super model:aModel.
|
|
516 |
|
|
517 |
aModel notNil ifTrue:[
|
|
518 |
(aModel respondsTo:#list) ifTrue:[
|
|
519 |
self listHolder:model list
|
|
520 |
]
|
|
521 |
]
|
637
|
522 |
! !
|
|
523 |
|
700
|
524 |
!DataSetView methodsFor:'change & update'!
|
637
|
525 |
|
700
|
526 |
recomputeLabelView
|
|
527 |
"recompute label view
|
637
|
528 |
"
|
700
|
529 |
|p x|
|
637
|
530 |
|
700
|
531 |
p := columnView styleSheet at:'scrollBar.position' default:#left.
|
|
532 |
x := labelView width - columnView width.
|
637
|
533 |
|
700
|
534 |
p == #left ifTrue:[labelView leftInset:(columnView left)]
|
|
535 |
ifFalse:[labelView rightInset:(columnView right - columnView width)].
|
637
|
536 |
!
|
|
537 |
|
646
|
538 |
recomputeLabels
|
|
539 |
"labels changed; recompute labels
|
|
540 |
"
|
|
541 |
|hgt lbl prv lst|
|
|
542 |
|
|
543 |
labels size ~~ 0 ifTrue:[ labels do:[:b| b destroy] ].
|
|
544 |
labels := OrderedCollection new.
|
|
545 |
|
|
546 |
columnView numberOfColumns == 0 ifTrue:[
|
|
547 |
^ self
|
|
548 |
].
|
|
549 |
|
|
550 |
hgt := 0.
|
|
551 |
prv := nil.
|
|
552 |
lst := columnView lastColumn.
|
|
553 |
|
654
|
554 |
columnView columnsDo:[:aCol||l|
|
646
|
555 |
(aCol showColSeparator or:[aCol == lst]) ifTrue:[
|
700
|
556 |
lbl := DSVLabelView column:(prv ? aCol) in:labelView.
|
646
|
557 |
prv := nil.
|
|
558 |
hgt := (lbl preferredExtent y) max:hgt.
|
|
559 |
labels add:lbl.
|
|
560 |
] ifFalse:[
|
|
561 |
(prv isNil and:[aCol label notNil]) ifTrue:[prv := aCol]
|
|
562 |
]
|
|
563 |
].
|
745
|
564 |
hgt := hgt + (hgt // 5).
|
646
|
565 |
|
700
|
566 |
scrolledView topInset:hgt.
|
|
567 |
labelView bottomInset:(hgt negated).
|
646
|
568 |
|
|
569 |
realized ifTrue:[
|
|
570 |
self updateLabels.
|
|
571 |
labels do:[:l| l realize ].
|
|
572 |
]
|
|
573 |
|
|
574 |
!
|
|
575 |
|
542
|
576 |
update:what with:aPara from:chgObj
|
|
577 |
"one of my models changed
|
|
578 |
"
|
|
579 |
|val|
|
|
580 |
|
637
|
581 |
chgObj == columnView ifTrue:[
|
647
|
582 |
what == #selection ifTrue:[
|
|
583 |
model notNil ifTrue:[
|
759
|
584 |
val := columnView selectedRowIndex copy.
|
647
|
585 |
|
|
586 |
(model respondsTo:#selectionIndex:) ifTrue:[
|
|
587 |
model selectionIndex:val
|
|
588 |
] ifFalse:[
|
|
589 |
useIndex ifFalse:[ model value:(columnView selectedRow) ]
|
|
590 |
ifTrue:[ model value:val ]
|
|
591 |
]
|
|
592 |
].
|
|
593 |
^ self
|
|
594 |
].
|
|
595 |
|
|
596 |
what == #sizeOfColumns ifTrue:[ ^ self recomputeLabels ].
|
|
597 |
what == #columnsLayout ifTrue:[ ^ self updateLabels ].
|
|
598 |
|
|
599 |
shown ifTrue:[
|
|
600 |
what == #originOfContents ifTrue:[
|
|
601 |
(labels size ~~ 0 and:[(val := aPara x) ~~ 0]) ifTrue:[
|
|
602 |
labels do:[:b| b origin:((b origin) - (val @ 0)) ]
|
|
603 |
].
|
|
604 |
]
|
|
605 |
].
|
|
606 |
^ self
|
637
|
607 |
].
|
|
608 |
|
|
609 |
chgObj == model ifTrue:[
|
|
610 |
(what == #selectionIndex or:[what == #selection]) ifTrue:[
|
759
|
611 |
^ columnView selectRowIndex:(model selectionIndex copy)
|
637
|
612 |
].
|
|
613 |
what == #list ifTrue:[
|
|
614 |
^ self listHolder:model list
|
|
615 |
].
|
|
616 |
model == listHolder ifFalse:[
|
|
617 |
what == #value ifTrue:[
|
|
618 |
columnView selectRowIndex:model value
|
542
|
619 |
].
|
637
|
620 |
^ self
|
542
|
621 |
].
|
637
|
622 |
].
|
|
623 |
|
|
624 |
"/ listHolder and model could be the same
|
542
|
625 |
|
637
|
626 |
chgObj == listHolder ifTrue:[
|
|
627 |
what == #at: ifTrue:[
|
|
628 |
columnView at:aPara put:(listHolder at:aPara)
|
|
629 |
] ifFalse:[
|
714
|
630 |
(what isNil or:[what == #list or:[what == #size or:[what == #value]]]) ifTrue:[
|
637
|
631 |
^ self listHolder:listHolder "/ reread list from model
|
|
632 |
].
|
|
633 |
self perform:what with:aPara
|
|
634 |
]
|
542
|
635 |
].
|
637
|
636 |
!
|
|
637 |
|
|
638 |
updateLabels
|
646
|
639 |
"layout of labels changed; recompute layout
|
637
|
640 |
"
|
759
|
641 |
|x0 x1 dX id lst noCols size|
|
|
642 |
|
|
643 |
size := labels size.
|
|
644 |
noCols := columnView numberOfColumns.
|
637
|
645 |
|
759
|
646 |
size ~~ noCols ifTrue:[
|
|
647 |
noCols == 0 ifTrue:[
|
|
648 |
^ self recomputeLabels
|
|
649 |
].
|
654
|
650 |
id := columnView lastColumn showColSeparator ifTrue:[0] ifFalse:[1].
|
|
651 |
|
|
652 |
columnView columnsDo:[:aCol|
|
|
653 |
aCol showColSeparator ifTrue:[id := id + 1]
|
|
654 |
].
|
759
|
655 |
size ~~ id ifTrue:[
|
654
|
656 |
^ self recomputeLabels
|
|
657 |
].
|
652
|
658 |
].
|
759
|
659 |
size == 0 ifTrue:[ ^ self ].
|
637
|
660 |
|
700
|
661 |
x0 := columnView margin - columnView xOriginOfContents.
|
646
|
662 |
dX := columnView separatorSize - 1.
|
|
663 |
lst := columnView lastColumn.
|
|
664 |
id := 1.
|
|
665 |
x1 := 0.
|
637
|
666 |
|
646
|
667 |
columnView columnsDo:[:aCol|
|
|
668 |
x1 := x1 + aCol width.
|
|
669 |
|
|
670 |
(aCol showColSeparator or:[aCol == lst]) ifTrue:[
|
700
|
671 |
(labels at:id) origin:(x0 @ 0.0) extent:(x1 - dX @ 1.0).
|
637
|
672 |
x0 := x0 + x1.
|
646
|
673 |
x1 := 0.
|
|
674 |
id := id + 1.
|
|
675 |
]
|
700
|
676 |
]
|
637
|
677 |
|
700
|
678 |
|
542
|
679 |
! !
|
|
680 |
|
637
|
681 |
!DataSetView methodsFor:'change & update list'!
|
542
|
682 |
|
|
683 |
insert:anIndex
|
|
684 |
"raised from listHolder: insert row derived from listHolder at anIndex
|
|
685 |
"
|
|
686 |
|list|
|
|
687 |
|
|
688 |
list := listHolder value.
|
|
689 |
columnView add:(list at:anIndex) beforeIndex:anIndex
|
|
690 |
|
|
691 |
|
|
692 |
!
|
|
693 |
|
|
694 |
insertCollection:anArray
|
|
695 |
"raised from listHolder: insert collection of rows derived from listHolder
|
|
696 |
from start (anArray at:1) to stop (anArray at:2).
|
|
697 |
"
|
570
|
698 |
|start stop size list|
|
542
|
699 |
|
|
700 |
list := listHolder value.
|
|
701 |
start := anArray first.
|
|
702 |
size := anArray last.
|
|
703 |
|
611
|
704 |
size ~~ 0 ifTrue:[
|
|
705 |
stop := start + size - 1.
|
|
706 |
columnView addAll:(list copyFrom:start to:stop) beforeIndex:start
|
|
707 |
]
|
542
|
708 |
!
|
|
709 |
|
|
710 |
remove:anIndex
|
|
711 |
"raised from listHolder: remove row at anIndex
|
|
712 |
"
|
|
713 |
columnView removeIndex:anIndex
|
|
714 |
|
|
715 |
|
|
716 |
!
|
|
717 |
|
|
718 |
removeFrom:anArray
|
|
719 |
"raised from listHolder: remove rows from start (anArray at:1)
|
|
720 |
to stop (anArray at:2).
|
|
721 |
"
|
|
722 |
|start stop|
|
|
723 |
|
|
724 |
start := anArray first.
|
|
725 |
stop := anArray last.
|
|
726 |
|
619
|
727 |
listHolder value size == 0 ifTrue:[
|
542
|
728 |
columnView list:nil
|
|
729 |
] ifFalse:[
|
|
730 |
(stop - start + 1) timesRepeat:[
|
|
731 |
columnView removeIndex:start
|
|
732 |
]
|
|
733 |
]
|
|
734 |
!
|
|
735 |
|
|
736 |
replace:anArray
|
|
737 |
"raised from listHolder: replace collection of rows derived from listHolder
|
|
738 |
from start (anArray at:1) to stop (anArray at:2).
|
|
739 |
"
|
|
740 |
|start stop list|
|
|
741 |
|
|
742 |
start := anArray first.
|
|
743 |
stop := anArray last.
|
|
744 |
list := listHolder value.
|
|
745 |
|
|
746 |
start to:stop do:[:anIndex|
|
|
747 |
columnView at:anIndex put:(list at:anIndex)
|
|
748 |
].
|
|
749 |
|
|
750 |
! !
|
|
751 |
|
|
752 |
!DataSetView methodsFor:'error handling'!
|
|
753 |
|
|
754 |
doesNotUnderstand:aMessage
|
637
|
755 |
"does not understand message; delegate to column view
|
|
756 |
"
|
542
|
757 |
^ aMessage sendTo:columnView
|
|
758 |
! !
|
|
759 |
|
|
760 |
!DataSetView methodsFor:'initialize'!
|
|
761 |
|
|
762 |
destroy
|
|
763 |
"remove dependencies
|
|
764 |
"
|
|
765 |
listHolder notNil ifTrue:[
|
|
766 |
listHolder removeDependent:self
|
|
767 |
].
|
637
|
768 |
columnView removeDependent:self.
|
|
769 |
|
542
|
770 |
super destroy
|
|
771 |
|
|
772 |
|
|
773 |
|
|
774 |
!
|
|
775 |
|
|
776 |
initialize
|
|
777 |
"set column area
|
|
778 |
"
|
|
779 |
super initialize.
|
|
780 |
|
700
|
781 |
labelView := View origin:(0.0 @ 0.0) corner:(1.0 @ 0.0) in:self.
|
|
782 |
|
|
783 |
scrolledView := HVScrollableView for:DSVColumnView
|
542
|
784 |
miniScrollerH:true
|
|
785 |
miniScrollerV:false
|
|
786 |
origin:(0.0 @ 0.0)
|
|
787 |
corner:(1.0 @ 1.0)
|
|
788 |
in:self.
|
|
789 |
|
637
|
790 |
useIndex := true.
|
|
791 |
labels := OrderedCollection new.
|
700
|
792 |
columnView := scrolledView scrolledView.
|
637
|
793 |
|
542
|
794 |
columnView borderWidth:0.
|
|
795 |
columnView addDependent:self.
|
637
|
796 |
|
542
|
797 |
!
|
|
798 |
|
|
799 |
realize
|
637
|
800 |
"realize view; update labels
|
|
801 |
"
|
715
|
802 |
|selection|
|
|
803 |
|
|
804 |
selection := 0.
|
|
805 |
|
|
806 |
model notNil ifTrue:[
|
|
807 |
(model respondsTo:#selectionIndex) ifTrue:[
|
|
808 |
selection := model selectionIndex
|
|
809 |
] ifFalse:[
|
|
810 |
model == listHolder ifFalse:[
|
|
811 |
selection := model value
|
|
812 |
]
|
|
813 |
]
|
|
814 |
].
|
|
815 |
columnView selectRowIndex:selection.
|
|
816 |
|
542
|
817 |
super realize.
|
700
|
818 |
self recomputeLabelView.
|
637
|
819 |
self updateLabels.
|
542
|
820 |
! !
|
|
821 |
|
|
822 |
!DataSetView methodsFor:'queries'!
|
|
823 |
|
|
824 |
specClass
|
637
|
825 |
"returns my spec class
|
|
826 |
"
|
542
|
827 |
^ DataSetSpec
|
|
828 |
! !
|
|
829 |
|
|
830 |
!DataSetView class methodsFor:'documentation'!
|
|
831 |
|
|
832 |
version
|
759
|
833 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.16 1998-02-13 13:57:35 ca Exp $'
|
542
|
834 |
! !
|