author | Claus Gittinger <cg@exept.de> |
Mon, 27 Jul 1998 09:51:30 +0200 | |
changeset 1012 | 5d98566099fa |
parent 885 | f45450252ba8 |
child 1066 | c588ca20e4b4 |
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 |
View subclass:#DataSetView |
|
824 | 17 |
instanceVariableNames:'labelView columnView listHolder useIndex 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 |
||
824 | 372 |
!DataSetView class methodsFor:'test'! |
373 |
||
374 |
test |
|
375 |
|top scr clDc rows slct list bool spc img| |
|
376 |
||
377 |
top := StandardSystemView new label:'select'; extent:600@500. |
|
378 |
scr := DataSetView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:top. |
|
379 |
||
380 |
clDc := OrderedCollection new. |
|
381 |
rows := OrderedCollection new. |
|
382 |
list := #( 'Text ' 'Field ' 'C-Box ' 'C-List ' true #( 'foo' 'bar' 'baz' ) ). |
|
383 |
slct := #( #text #field #cbox #clist #toggle #choices ). |
|
384 |
bool := true. |
|
385 |
||
386 |
10 to:30 do:[:i| |values| |
|
387 |
values := list collect:[:n| |
|
388 |
n isString ifTrue:[n, i printString] |
|
389 |
ifFalse:[n == true ifTrue:[bool] ifFalse:[n]] |
|
390 |
]. |
|
391 |
rows add:(Structure newWith:slct values:values). |
|
392 |
bool := bool not. |
|
393 |
]. |
|
394 |
clDc add:( spc := DataSetColumnSpec label:'Text' editorType:#None selector:#text ). |
|
395 |
spc labelAlignment:#left. |
|
396 |
||
397 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
398 |
clDc add:( spc := DataSetColumnSpec label:img editorType:#None selector:#text ). |
|
399 |
spc labelAlignment:#right. |
|
400 |
||
401 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
402 |
clDc add:( spc := DataSetColumnSpec label:img editorType:#InputField selector:#field ). |
|
403 |
spc labelAlignment:#left. |
|
404 |
||
405 |
img := Image fromFile:('xpmBitmaps/misc_tools/box_full.xpm' ). |
|
406 |
clDc add:( spc := DataSetColumnSpec label:(LabelAndIcon icon:img string:'Combo') editorType:#ComboBox selector:#cbox ). |
|
407 |
spc labelAlignment:#center. |
|
408 |
spc choices:#choices. |
|
409 |
||
410 |
clDc add:( spc := DataSetColumnSpec label:'C-List' editorType:#ComboList selector:#clist ). |
|
411 |
spc choices:#choices. |
|
412 |
clDc add:( spc := DataSetColumnSpec label:'Toggle' editorType:#CheckToggle selector:#toggle ). |
|
413 |
clDc do:[:el| |
|
414 |
el minWidth:80. |
|
415 |
el labelActionSelector:#dummy. |
|
416 |
]. |
|
417 |
scr has3Dseparators:true. |
|
418 |
scr columnDescriptors:clDc. |
|
419 |
scr list:rows. |
|
420 |
top open. |
|
421 |
||
422 |
||
423 |
! ! |
|
424 |
||
542 | 425 |
!DataSetView methodsFor:'accessing'! |
426 |
||
637 | 427 |
add:aRow |
428 |
"add a row; reimplemented caused by add in base class |
|
429 |
" |
|
430 |
^ columnView add:aRow |
|
431 |
! |
|
432 |
||
885 | 433 |
columnView |
434 |
"returns my scrolledView |
|
435 |
" |
|
436 |
^ columnView |
|
437 |
! |
|
438 |
||
439 |
labelView |
|
440 |
^ labelView |
|
441 |
! |
|
442 |
||
833 | 443 |
scrolledView |
444 |
"returns my scrolledView |
|
445 |
" |
|
446 |
^ columnView |
|
447 |
! |
|
448 |
||
542 | 449 |
useIndex |
637 | 450 |
"specify, if the selected components value or its index in the |
451 |
list should be sent to the model. The default is its index. |
|
452 |
" |
|
542 | 453 |
^ useIndex |
454 |
! |
|
455 |
||
456 |
useIndex:aBool |
|
637 | 457 |
"specify, if the selected components value or its index in the |
458 |
list should be sent to the model. The default is its index. |
|
459 |
" |
|
542 | 460 |
useIndex := aBool |
461 |
! ! |
|
462 |
||
700 | 463 |
!DataSetView methodsFor:'accessing look'! |
464 |
||
465 |
font:aFont |
|
466 |
"set the font for all rows and labels. |
|
467 |
" |
|
468 |
columnView font:aFont |
|
469 |
! |
|
470 |
||
471 |
horizontalMini:aBool |
|
472 |
"control the horizontal scrollBar to be either a miniScroller, |
|
473 |
or a full scrollBar. |
|
474 |
" |
|
475 |
scrolledView horizontalMini:aBool. |
|
824 | 476 |
self columnsSizeChanged. |
700 | 477 |
! |
478 |
||
479 |
horizontalScrollable:aBool |
|
480 |
"enable/disable horizontal scrollability. |
|
481 |
If disabled, the horizontal scrollBar is made invisible. |
|
482 |
" |
|
483 |
scrolledView horizontalScrollable:aBool. |
|
824 | 484 |
self columnsSizeChanged. |
700 | 485 |
! |
486 |
||
487 |
isHorizontalScrollable |
|
488 |
"returns true if horizontal scrollable |
|
489 |
" |
|
490 |
^ scrolledView isHorizontalScrollable |
|
491 |
! |
|
492 |
||
493 |
isVerticalScrollable |
|
494 |
"returns true if vertical scrollable |
|
495 |
" |
|
496 |
^ scrolledView isVerticalScrollable |
|
497 |
! |
|
498 |
||
499 |
verticalMini:aBool |
|
500 |
"control the vertical scrollBar to be either a miniScroller, |
|
501 |
or a full scrollBar. |
|
502 |
" |
|
503 |
scrolledView verticalMini:aBool. |
|
824 | 504 |
self columnsSizeChanged. |
700 | 505 |
|
506 |
! |
|
507 |
||
508 |
verticalScrollable:aBool |
|
509 |
"enable/disable vertical scrollability. |
|
510 |
If disabled, the horizontal scrollBar is made invisible. |
|
511 |
" |
|
512 |
scrolledView verticalScrollable:aBool. |
|
824 | 513 |
self columnsSizeChanged |
700 | 514 |
! |
515 |
||
516 |
viewBackground |
|
517 |
"get the background color of the rows and labels |
|
518 |
" |
|
519 |
^ columnView backgroundColor. |
|
520 |
||
521 |
||
522 |
! |
|
523 |
||
524 |
viewBackground:aColor |
|
525 |
"set the background color of the rows and labels |
|
526 |
" |
|
527 |
^ columnView backgroundColor:aColor. |
|
528 |
||
529 |
||
530 |
! ! |
|
531 |
||
542 | 532 |
!DataSetView methodsFor:'accessing menus'! |
533 |
||
534 |
menuHolder:anObject |
|
535 |
"set the menu holder in the column view too |
|
536 |
" |
|
537 |
super menuHolder:anObject. |
|
538 |
columnView menuHolder:anObject. |
|
539 |
||
540 |
! |
|
541 |
||
542 |
menuMessage:aSymbol |
|
543 |
"set the menu message in the column view too |
|
544 |
" |
|
545 |
super menuMessage:aSymbol. |
|
546 |
columnView menuMessage:aSymbol. |
|
547 |
||
548 |
! |
|
549 |
||
550 |
menuPerformer:anObject |
|
551 |
"set the performer in the column view too |
|
552 |
" |
|
553 |
super menuPerformer:anObject. |
|
554 |
columnView menuPerformer:anObject. |
|
555 |
||
556 |
! ! |
|
557 |
||
637 | 558 |
!DataSetView methodsFor:'accessing mvc'! |
542 | 559 |
|
1012
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
560 |
columnAdaptor |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
561 |
^ columnView columnAdaptor |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
562 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
563 |
"Modified: / 26.7.1998 / 12:16:17 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
564 |
"Created: / 27.7.1998 / 09:50:58 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
565 |
! |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
566 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
567 |
columnAdaptor:someone |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
568 |
columnView columnAdaptor:someone |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
569 |
|
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
570 |
"Created: / 26.7.1998 / 12:04:31 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
571 |
"Modified: / 26.7.1998 / 12:16:17 / cg" |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
572 |
! |
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
573 |
|
542 | 574 |
listHolder:aListHolder |
637 | 575 |
"set the valueHolder which holds the list of rows |
542 | 576 |
" |
611 | 577 |
listHolder ~~ aListHolder ifTrue:[ |
578 |
listHolder notNil ifTrue:[ |
|
579 |
listHolder removeDependent:self |
|
580 |
]. |
|
581 |
||
582 |
(listHolder := aListHolder) notNil ifTrue:[ |
|
583 |
listHolder addDependent:self |
|
584 |
] |
|
542 | 585 |
]. |
586 |
||
647 | 587 |
columnView list:(listHolder value) |
542 | 588 |
! |
589 |
||
590 |
model:aModel |
|
637 | 591 |
"set the valueHolder which holds the selection and maybe the list of rows |
542 | 592 |
" |
593 |
(model respondsTo:#list) ifTrue:[ |
|
594 |
(model list == listHolder) ifTrue:[ |
|
595 |
self listHolder:nil |
|
596 |
] |
|
597 |
]. |
|
598 |
super model:aModel. |
|
599 |
||
600 |
aModel notNil ifTrue:[ |
|
601 |
(aModel respondsTo:#list) ifTrue:[ |
|
602 |
self listHolder:model list |
|
603 |
] |
|
604 |
] |
|
637 | 605 |
! ! |
606 |
||
700 | 607 |
!DataSetView methodsFor:'change & update'! |
637 | 608 |
|
824 | 609 |
columnsSizeChanged |
610 |
"recompute label view |
|
611 |
" |
|
612 |
|pL pR| |
|
613 |
||
614 |
realized ifFalse:[ |
|
615 |
^ self |
|
616 |
]. |
|
617 |
||
618 |
pL := device translatePoint:(0@0) from:(columnView id) to:(self id). |
|
619 |
pR := device translatePoint:((columnView width) @ 0) from:(columnView id) to:(self id). |
|
620 |
||
621 |
labelView leftInset:pL x - 1. |
|
622 |
labelView rightInset:(self width - pR x). |
|
623 |
||
624 |
labelView columnsSizeChanged. |
|
625 |
scrolledView topInset:(labelView height). |
|
626 |
||
627 |
! |
|
628 |
||
542 | 629 |
update:what with:aPara from:chgObj |
630 |
"one of my models changed |
|
631 |
" |
|
632 |
|val| |
|
633 |
||
637 | 634 |
chgObj == columnView ifTrue:[ |
647 | 635 |
what == #selection ifTrue:[ |
636 |
model notNil ifTrue:[ |
|
759 | 637 |
val := columnView selectedRowIndex copy. |
647 | 638 |
|
639 |
(model respondsTo:#selectionIndex:) ifTrue:[ |
|
640 |
model selectionIndex:val |
|
641 |
] ifFalse:[ |
|
642 |
useIndex ifFalse:[ model value:(columnView selectedRow) ] |
|
643 |
ifTrue:[ model value:val ] |
|
644 |
] |
|
645 |
]. |
|
646 |
^ self |
|
647 |
]. |
|
824 | 648 |
realized ifTrue:[ |
649 |
what == #sizeOfColumns ifTrue:[ ^ self columnsSizeChanged ]. |
|
650 |
what == #columnsLayout ifTrue:[ ^ labelView columnsLayoutChanged ]. |
|
651 |
what == #originOfContents ifTrue:[ ^ labelView columnsOriginChanged:aPara ]. |
|
652 |
]. |
|
647 | 653 |
^ self |
637 | 654 |
]. |
655 |
||
656 |
chgObj == model ifTrue:[ |
|
657 |
(what == #selectionIndex or:[what == #selection]) ifTrue:[ |
|
759 | 658 |
^ columnView selectRowIndex:(model selectionIndex copy) |
637 | 659 |
]. |
660 |
what == #list ifTrue:[ |
|
661 |
^ self listHolder:model list |
|
662 |
]. |
|
663 |
model == listHolder ifFalse:[ |
|
664 |
what == #value ifTrue:[ |
|
665 |
columnView selectRowIndex:model value |
|
542 | 666 |
]. |
637 | 667 |
^ self |
542 | 668 |
]. |
637 | 669 |
]. |
670 |
||
671 |
"/ listHolder and model could be the same |
|
542 | 672 |
|
637 | 673 |
chgObj == listHolder ifTrue:[ |
674 |
what == #at: ifTrue:[ |
|
675 |
columnView at:aPara put:(listHolder at:aPara) |
|
676 |
] ifFalse:[ |
|
714 | 677 |
(what isNil or:[what == #list or:[what == #size or:[what == #value]]]) ifTrue:[ |
637 | 678 |
^ self listHolder:listHolder "/ reread list from model |
679 |
]. |
|
862 | 680 |
what == #selectionIndex ifTrue:[ |
681 |
^ self |
|
682 |
]. |
|
637 | 683 |
self perform:what with:aPara |
684 |
] |
|
542 | 685 |
]. |
808 | 686 |
! ! |
687 |
||
637 | 688 |
!DataSetView methodsFor:'change & update list'! |
542 | 689 |
|
690 |
insert:anIndex |
|
691 |
"raised from listHolder: insert row derived from listHolder at anIndex |
|
692 |
" |
|
693 |
|list| |
|
694 |
||
695 |
list := listHolder value. |
|
696 |
columnView add:(list at:anIndex) beforeIndex:anIndex |
|
697 |
||
698 |
||
699 |
! |
|
700 |
||
701 |
insertCollection:anArray |
|
702 |
"raised from listHolder: insert collection of rows derived from listHolder |
|
703 |
from start (anArray at:1) to stop (anArray at:2). |
|
704 |
" |
|
570 | 705 |
|start stop size list| |
542 | 706 |
|
707 |
list := listHolder value. |
|
862 | 708 |
start := anArray at:1. |
709 |
size := anArray at:2. |
|
542 | 710 |
|
611 | 711 |
size ~~ 0 ifTrue:[ |
712 |
stop := start + size - 1. |
|
713 |
columnView addAll:(list copyFrom:start to:stop) beforeIndex:start |
|
714 |
] |
|
542 | 715 |
! |
716 |
||
717 |
remove:anIndex |
|
718 |
"raised from listHolder: remove row at anIndex |
|
719 |
" |
|
720 |
columnView removeIndex:anIndex |
|
721 |
||
722 |
||
723 |
! |
|
724 |
||
725 |
removeFrom:anArray |
|
726 |
"raised from listHolder: remove rows from start (anArray at:1) |
|
727 |
to stop (anArray at:2). |
|
728 |
" |
|
619 | 729 |
listHolder value size == 0 ifTrue:[ |
542 | 730 |
columnView list:nil |
731 |
] ifFalse:[ |
|
862 | 732 |
columnView removeFrom:(anArray at:1) to:(anArray at:2) |
542 | 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 |
||
862 | 742 |
start := anArray at:1. |
743 |
stop := anArray at:2. |
|
542 | 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 |
||
824 | 781 |
labelView := DSVLabelView origin:(0.0 @ 0.0) corner:(1.0 @ 0.0) in:self. |
700 | 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. |
700 | 791 |
columnView := scrolledView scrolledView. |
637 | 792 |
|
542 | 793 |
columnView borderWidth:0. |
794 |
columnView addDependent:self. |
|
824 | 795 |
labelView for:columnView. |
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. |
|
542 | 816 |
super realize. |
824 | 817 |
self columnsSizeChanged. |
542 | 818 |
! ! |
819 |
||
820 |
!DataSetView methodsFor:'queries'! |
|
821 |
||
822 |
specClass |
|
637 | 823 |
"returns my spec class |
824 |
" |
|
542 | 825 |
^ DataSetSpec |
826 |
! ! |
|
827 |
||
828 |
!DataSetView class methodsFor:'documentation'! |
|
829 |
||
830 |
version |
|
1012
5d98566099fa
forward accesses to columnAdapter to the columnView.
Claus Gittinger <cg@exept.de>
parents:
885
diff
changeset
|
831 |
^ '$Header: /cvs/stx/stx/libwidg2/DataSetView.st,v 1.22 1998-07-27 07:51:30 cg Exp $' |
542 | 832 |
! ! |