author | tz |
Sun, 19 Jul 1998 22:34:50 +0200 | |
changeset 990 | 1740b564ca71 |
parent 989 | 70fd16dd0085 |
child 991 | c1bc86ebe79e |
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:#DSVColumnView |
|
607 | 17 |
instanceVariableNames:'editValue editView multipleSelectOk selectedColIndex |
637 | 18 |
selectedRowIndex rowHeight columnDescriptors viewOrigin colorMap |
618 | 19 |
lockRowIndex rowIfAbsentBlock columnHolder registererImages list |
647 | 20 |
fgColor canFit separatorSize catchChangeEvents beDependentOfRows |
892 | 21 |
bgColor hgLgFgColor hgLgBgColor actionBlock builder |
809 | 22 |
doubleClickActionBlock verticalSpacing horizontalSpacing |
824 | 23 |
rowSelectorForm buttonLightColor buttonShadowColor |
24 |
buttonHalfLightColor buttonHalfShadowColor checkToggleExtent |
|
25 |
checkToggleForm checkToggleLevel comboButtonExtent |
|
26 |
comboButtonForm comboButtonLevel clickPosition dragAccessPoint |
|
27 |
dragIsActive dropTarget dropSource' |
|
542 | 28 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
29 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor |
|
809 | 30 |
RowSelector ButtonLightColor ButtonShadowColor |
31 |
ButtonHalfLightColor ButtonHalfShadowColor ButtonEdgeStyle' |
|
542 | 32 |
poolDictionaries:'' |
33 |
category:'Views-DataSet' |
|
34 |
! |
|
35 |
||
36 |
!DSVColumnView class methodsFor:'documentation'! |
|
37 |
||
38 |
copyright |
|
39 |
" |
|
40 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG |
|
41 |
All Rights Reserved |
|
42 |
||
43 |
This software is furnished under a license and may be used |
|
44 |
only in accordance with the terms of that license and with the |
|
45 |
inclusion of the above copyright notice. This software may not |
|
46 |
be provided or otherwise made available to, or used by, any |
|
47 |
other person. No title to or ownership of the software is |
|
48 |
hereby transferred. |
|
49 |
" |
|
50 |
||
51 |
||
52 |
||
53 |
! |
|
54 |
||
55 |
documentation |
|
56 |
" |
|
57 |
implements a scrollable selection view based on rows and columns |
|
58 |
||
59 |
[Instance variables:] |
|
60 |
||
61 |
editValue <Model> current editing model |
|
62 |
editView <View> current editing component |
|
63 |
selectedColIndex <Integer> selected column index or 0 |
|
64 |
selectedRowIndex <Integer> selected row index or 0 |
|
65 |
rowHeight <Integer> maximum height of any row |
|
66 |
columnDescriptors <SequancableCollection> list of column descriptors |
|
67 |
list <SequancableCollection> list of rows |
|
68 |
fgColor <Color> foreground color |
|
69 |
registererImages <IdentityDictionary> list of images registered on the device |
|
567 | 70 |
beDependentOfRows <Coolean> keep rows dependent; on default is disabled. |
71 |
in case of enabled a row can raise a change |
|
72 |
notification whithout a parameter which |
|
73 |
will force a redraw of the row or the |
|
74 |
readSelector of the column which will |
|
75 |
redraw the cell in the row only. |
|
542 | 76 |
|
77 |
[author:] |
|
78 |
Claus Atzkern |
|
79 |
||
80 |
[see also:] |
|
81 |
DataSetColumnSpec |
|
82 |
DataSetColumn |
|
83 |
DataSetView |
|
84 |
" |
|
85 |
||
86 |
! ! |
|
87 |
||
647 | 88 |
!DSVColumnView class methodsFor:'accessing forms'! |
89 |
||
90 |
rowSelector |
|
989 | 91 |
"This resource specification was automatically generated |
92 |
by the ImageEditor of ST/X." |
|
93 |
||
94 |
"Do not manually edit this!! If it is corrupted, |
|
95 |
the ImageEditor may not be able to read the specification." |
|
96 |
||
97 |
" |
|
98 |
self rowSelector inspect |
|
99 |
ImageEditor openOnClass:self andSelector:#rowSelector |
|
100 |
" |
|
101 |
||
102 |
<resource: #image> |
|
103 |
||
104 |
^Icon |
|
105 |
constantNamed:#'DSVColumnView rowSelector' |
|
990 | 106 |
ifAbsentPut:[(Depth2Image new) width: 8; height: 11; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@P@AP@GPUWQ]7W]5W];)^@G @8@B@@@a') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 8; height: 11; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'DA \?/????8\FA@b') ; yourself); yourself]! ! |
647 | 107 |
|
108 |
!DSVColumnView class methodsFor:'defaults'! |
|
607 | 109 |
|
563 | 110 |
horizontalSpacing |
111 |
^ 4 |
|
112 |
||
113 |
! |
|
114 |
||
542 | 115 |
updateStyleCache |
116 |
"extract values from the styleSheet and cache them in class variables |
|
117 |
" |
|
582 | 118 |
<resource: #style (#textForegroundColor #'scrollableView.backgroundColor' |
119 |
#'selection.hilightForegroundColor' |
|
120 |
#'selection.hilightBackgroundColor' )> |
|
542 | 121 |
|
122 |
DefaultForegroundColor := StyleSheet colorAt:'textForegroundColor' default:(Color black). |
|
809 | 123 |
DefaultBackgroundColor := StyleSheet colorAt:'scrollableView.backgroundColor' default:DefaultViewBackgroundColor. |
542 | 124 |
|
988 | 125 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultBackgroundColor. |
126 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:DefaultForegroundColor. |
|
607 | 127 |
|
647 | 128 |
DefaultHilightForegroundColor = DefaultHilightBackgroundColor ifTrue:[ |
988 | 129 |
DefaultHilightBackgroundColor := Color black |
647 | 130 |
]. |
809 | 131 |
ButtonLightColor := StyleSheet colorAt:'button.lightColor'. |
132 |
ButtonShadowColor := StyleSheet colorAt:'button.shadowColor'. |
|
133 |
ButtonHalfLightColor := StyleSheet colorAt:'button.halfLightColor'. |
|
134 |
ButtonHalfShadowColor := StyleSheet colorAt:'button.halfShadowColor'. |
|
135 |
ButtonEdgeStyle := StyleSheet at:'button.edgeStyle'. |
|
647 | 136 |
|
542 | 137 |
" |
138 |
self updateStyleCache. |
|
139 |
" |
|
140 |
||
582 | 141 |
"Modified: / 26.10.1997 / 17:09:07 / cg" |
563 | 142 |
! |
143 |
||
144 |
verticalSpacing |
|
145 |
^ 2 |
|
146 |
||
542 | 147 |
! ! |
148 |
||
809 | 149 |
!DSVColumnView class methodsFor:'resources'! |
150 |
||
151 |
dragIconMulti |
|
988 | 152 |
"This resource specification was automatically generated |
153 |
by the ImageEditor of ST/X." |
|
154 |
||
155 |
"Do not manually edit this!! If it is corrupted, |
|
156 |
the ImageEditor may not be able to read the specification." |
|
157 |
||
809 | 158 |
" |
988 | 159 |
self dragIconMulti inspect |
160 |
ImageEditor openOnClass:self andSelector:#dragIconMulti |
|
809 | 161 |
" |
162 |
||
163 |
<resource: #image> |
|
164 |
||
165 |
^Icon |
|
166 |
constantNamed:#'DSVColumnView dragIconMulti' |
|
988 | 167 |
ifAbsentPut:[(Depth1Image new) width: 32; height: 32; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O?<0@C??L@@<@@@@O@@@@C3??L@<??3@OO?<<C3??O@<??0@OO?<@C3???0<???<OO???C3???0<???<OO???@C???0@???<@O???@C???0@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((ImageMask new) width: 32; height: 32; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@O??<@C???@@???<@O???@C????@????0O????C????0?????O????3?????????????????????????????????????????????????????@????0O???<C????@????0@@@@@@@@@@@@@@@@@@@@@b') ; yourself); yourself]! |
809 | 168 |
|
169 |
dragIconSingle |
|
988 | 170 |
"This resource specification was automatically generated |
171 |
by the ImageEditor of ST/X." |
|
172 |
||
173 |
"Do not manually edit this!! If it is corrupted, |
|
174 |
the ImageEditor may not be able to read the specification." |
|
175 |
||
809 | 176 |
" |
988 | 177 |
self dragIconSingle inspect |
178 |
ImageEditor openOnClass:self andSelector:#dragIconSingle |
|
809 | 179 |
" |
180 |
||
181 |
<resource: #image> |
|
182 |
||
183 |
^Icon |
|
184 |
constantNamed:#'DSVColumnView dragIconSingle' |
|
988 | 185 |
ifAbsentPut:[(Depth1Image new) width: 32; height: 32; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O?<0@C??L@@??30@O?<<@C??@@@??0@@O???@C???0@???<@O???@C???0@???<@O???@C???0@???<@O???@C???0@???<@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((ImageMask new) width: 32; height: 32; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@O??<@C???@@???<@O???@C???<@????@O???<C????@????0O???<C????@????0O???<C????@????0O???<C????@????0O???<C????@????0O???<@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; yourself); yourself]! ! |
809 | 186 |
|
886 | 187 |
!DSVColumnView methodsFor:'accessing'! |
188 |
||
189 |
columnView |
|
190 |
^ self |
|
191 |
! ! |
|
192 |
||
809 | 193 |
!DSVColumnView methodsFor:'accessing actions'! |
542 | 194 |
|
195 |
action:aOneArgAction |
|
607 | 196 |
"set the action block to be performed on select |
197 |
" |
|
542 | 198 |
actionBlock := aOneArgAction |
199 |
||
200 |
||
201 |
! |
|
202 |
||
809 | 203 |
doubleClickAction:aOneArgAction |
204 |
"set the action block to be performed on doubleclick |
|
205 |
" |
|
206 |
doubleClickActionBlock := aOneArgAction |
|
207 |
||
208 |
||
209 |
! |
|
210 |
||
211 |
rowIfAbsent:aOneArgAction |
|
212 |
"set the action block to be performed on each 'nil' entry into the |
|
213 |
list. The argument to the block is the index into the list. The |
|
214 |
block returns the row which is put to the list |
|
215 |
" |
|
216 |
rowIfAbsentBlock := aOneArgAction |
|
217 |
||
218 |
||
219 |
! ! |
|
220 |
||
221 |
!DSVColumnView methodsFor:'accessing behavior'! |
|
222 |
||
542 | 223 |
beDependentOfRows |
224 |
"make myself dependent of any row; in this case any change notification |
|
225 |
raised by a row is catched and the cell identified by the 'readSelector' |
|
226 |
is redrawn. In case of a nil readSelector, the whole raw is redrawn. |
|
227 |
-> row changed:'what' |
|
228 |
On default the attribute is set to true (enabled). |
|
229 |
" |
|
230 |
^ beDependentOfRows |
|
231 |
! |
|
232 |
||
233 |
beDependentOfRows:aBool |
|
234 |
"make myself dependent of any row; in this case any change notification |
|
235 |
raised by a row is catched and the cell identified by the 'readSelector' |
|
236 |
is redrawn. In case of a nil readSelector, the whole raw is redrawn. |
|
237 |
-> row changed:'what' |
|
238 |
On default the attribute is set to true (enabled). |
|
239 |
" |
|
240 |
aBool ~~ beDependentOfRows ifTrue:[ |
|
618 | 241 |
beDependentOfRows := aBool. |
242 |
||
243 |
self size ~~ 0 ifTrue:[ |
|
244 |
list do:[:aRow| aRow notNil ifTrue:[ |
|
245 |
beDependentOfRows ifTrue:[aRow addDependent:self] |
|
246 |
ifFalse:[aRow removeDependent:self] |
|
247 |
] |
|
248 |
] |
|
542 | 249 |
] |
618 | 250 |
] |
607 | 251 |
! |
252 |
||
253 |
multipleSelectOk |
|
254 |
"allow/disallow multiple row selections; the default is false |
|
255 |
" |
|
256 |
^ multipleSelectOk |
|
257 |
! |
|
258 |
||
259 |
multipleSelectOk:aState |
|
260 |
"allow/disallow multiple row selections; the default is false |
|
261 |
" |
|
262 |
aState == multipleSelectOk ifFalse:[ |
|
263 |
multipleSelectOk := aState. |
|
264 |
self deselect |
|
265 |
] |
|
542 | 266 |
! ! |
267 |
||
824 | 268 |
!DSVColumnView methodsFor:'accessing colors'! |
269 |
||
270 |
backgroundColor |
|
271 |
"get the background color of the rows |
|
272 |
" |
|
273 |
^ bgColor |
|
274 |
||
275 |
||
276 |
! |
|
277 |
||
278 |
backgroundColor:aColor |
|
279 |
"set the background color of the rows |
|
280 |
" |
|
281 |
bgColor ~~ aColor ifTrue:[ |
|
282 |
super viewBackground:bgColor. |
|
283 |
||
284 |
self realized ifTrue:[ |
|
285 |
bgColor := aColor on:device. |
|
286 |
self invalidate |
|
287 |
] ifFalse:[ |
|
288 |
bgColor := aColor |
|
289 |
] |
|
290 |
] |
|
291 |
! |
|
292 |
||
293 |
foregroundColor |
|
294 |
"return the foreground color of the rows |
|
295 |
" |
|
296 |
^ fgColor |
|
297 |
||
298 |
! |
|
299 |
||
300 |
foregroundColor:aColor |
|
301 |
"set the foreground color of the rows |
|
302 |
" |
|
303 |
fgColor ~~ aColor ifTrue:[ |
|
304 |
self realized ifTrue:[ |
|
305 |
fgColor := aColor on:device. |
|
306 |
self invalidate |
|
307 |
] ifFalse:[ |
|
308 |
fgColor := aColor |
|
309 |
] |
|
310 |
] |
|
311 |
||
312 |
! |
|
313 |
||
314 |
hgLgBgColor |
|
315 |
"returns the background color of a selected row |
|
316 |
" |
|
317 |
^ hgLgBgColor |
|
318 |
! |
|
319 |
||
320 |
hgLgFgColor |
|
321 |
"returns the foreground color of a selected row |
|
322 |
" |
|
323 |
^ hgLgFgColor |
|
324 |
! |
|
325 |
||
326 |
separatorDarkColor |
|
327 |
"returns the dark color used for drawing a shadowed separator (3D) |
|
328 |
" |
|
329 |
^ shadowColor |
|
330 |
||
331 |
||
332 |
! |
|
333 |
||
334 |
separatorLightColor |
|
335 |
"returns the light color used for drawing a shadowed separator (3D) |
|
336 |
" |
|
337 |
^ lightColor |
|
338 |
||
339 |
||
340 |
! ! |
|
341 |
||
542 | 342 |
!DSVColumnView methodsFor:'accessing columns'! |
343 |
||
344 |
columnAt:anIndex |
|
607 | 345 |
"returns the column at an index |
542 | 346 |
" |
347 |
^ columnDescriptors at:anIndex |
|
348 |
! |
|
349 |
||
886 | 350 |
columnDescriptors |
351 |
"returns list of column descriptors |
|
352 |
" |
|
353 |
^ columnDescriptors collect:[:aCol| aCol description ] |
|
354 |
! |
|
355 |
||
356 |
columnDescriptors:aColumnDescriptionList |
|
542 | 357 |
"set the columnDescriptors |
358 |
" |
|
612 | 359 |
|id sz| |
360 |
||
886 | 361 |
self deselect. |
362 |
||
363 |
(sz := aColumnDescriptionList size) ~~ 0 ifTrue:[ |
|
607 | 364 |
id := 0. |
365 |
||
886 | 366 |
columnDescriptors := aColumnDescriptionList collect:[:aCol||column| |
367 |
(column := aCol) isSequenceable ifTrue:[ |
|
368 |
column := DataSetColumnSpec new fromLiteralArrayEncoding:aCol |
|
369 |
]. |
|
607 | 370 |
id := id + 1. |
886 | 371 |
DataSetColumn new on:self description:column columnNumber:id |
542 | 372 |
] |
373 |
] ifFalse:[ |
|
374 |
columnDescriptors := #() |
|
375 |
]. |
|
886 | 376 |
catchChangeEvents := true. |
542 | 377 |
canFit := (columnDescriptors findFirst:[:aCol|aCol canResize]) ~~ 0. |
378 |
preferredExtent := nil. |
|
379 |
||
612 | 380 |
shown ifTrue:[ |
556 | 381 |
self fitColumns ifFalse:[ |
382 |
self invalidate. |
|
383 |
self contentsChanged. |
|
859 | 384 |
] ifTrue:[ |
385 |
self preferredExtentChanged. |
|
556 | 386 |
] |
563 | 387 |
]. |
859 | 388 |
catchChangeEvents := false. |
563 | 389 |
self changed:#sizeOfColumns. |
542 | 390 |
|
391 |
||
392 |
! |
|
393 |
||
394 |
firstColumn |
|
607 | 395 |
"returns the first column |
542 | 396 |
" |
397 |
^ columnDescriptors at:1 |
|
398 |
||
399 |
! |
|
400 |
||
401 |
lastColumn |
|
607 | 402 |
"returns the last column |
542 | 403 |
" |
404 |
^ columnDescriptors last |
|
405 |
||
406 |
! ! |
|
407 |
||
809 | 408 |
!DSVColumnView methodsFor:'accessing interactors'! |
409 |
||
410 |
checkToggleExtent |
|
411 |
^ checkToggleExtent |
|
412 |
! |
|
413 |
||
414 |
checkToggleForm |
|
415 |
^ checkToggleForm |
|
416 |
! |
|
417 |
||
418 |
checkToggleLevel |
|
419 |
^ checkToggleLevel |
|
420 |
! |
|
421 |
||
422 |
comboButtonExtent |
|
423 |
^ comboButtonExtent |
|
424 |
! |
|
425 |
||
426 |
comboButtonForm |
|
427 |
^ comboButtonForm |
|
428 |
! |
|
429 |
||
430 |
comboButtonLevel |
|
431 |
^ comboButtonLevel |
|
432 |
! |
|
433 |
||
434 |
rowSelectorExtent |
|
435 |
"returns the bitmap of a selected row |
|
436 |
" |
|
437 |
^ rowSelectorForm extent |
|
438 |
! |
|
439 |
||
440 |
rowSelectorForm |
|
441 |
"returns the bitmap of a selected row |
|
442 |
" |
|
990 | 443 |
rowSelectorForm isNil ifTrue:[ |
809 | 444 |
rowSelectorForm := (self class rowSelector) on:device |
445 |
]. |
|
446 |
^ rowSelectorForm |
|
447 |
! ! |
|
448 |
||
612 | 449 |
!DSVColumnView methodsFor:'accessing mvc'! |
450 |
||
451 |
columnHolder |
|
452 |
^ columnHolder |
|
453 |
||
454 |
! |
|
455 |
||
456 |
columnHolder:aValueHolder |
|
457 |
|columns| |
|
458 |
||
459 |
columnHolder notNil ifTrue:[ |
|
460 |
columnHolder removeDependent:self |
|
461 |
]. |
|
462 |
||
463 |
(columnHolder := aValueHolder) notNil ifTrue:[ |
|
464 |
columnHolder addDependent:self. |
|
465 |
columns := columnHolder value. |
|
466 |
||
467 |
columns notNil ifTrue:[ |
|
468 |
self columnDescriptors:columns |
|
469 |
] |
|
470 |
]. |
|
471 |
||
472 |
! ! |
|
473 |
||
542 | 474 |
!DSVColumnView methodsFor:'accessing rows'! |
475 |
||
476 |
at:aRowNr |
|
477 |
"return the row at an index, aRowNr |
|
478 |
" |
|
618 | 479 |
|row| |
480 |
||
481 |
(row := list at:aRowNr) isNil ifTrue:[ |
|
482 |
lockRowIndex := aRowNr. |
|
483 |
||
484 |
(row := rowIfAbsentBlock value:aRowNr) notNil ifTrue:[ |
|
485 |
list at:aRowNr put:row. |
|
486 |
beDependentOfRows ifTrue:[row addDependent:self]. |
|
487 |
]. |
|
488 |
||
489 |
lockRowIndex := 0 |
|
490 |
]. |
|
491 |
^ row |
|
542 | 492 |
! |
493 |
||
494 |
at:aRowNr ifAbsent:exceptionBlock |
|
607 | 495 |
"return the row at a aRowNr. If the index is invalid, return the |
542 | 496 |
result of evaluating the exceptionblock |
497 |
" |
|
618 | 498 |
(aRowNr between:1 and:self size) ifTrue:[ |
499 |
^ self at:aRowNr |
|
500 |
]. |
|
501 |
^ exceptionBlock value |
|
542 | 502 |
! |
503 |
||
504 |
at:aRowNr put:aRow |
|
505 |
"change the row at an index. The added row is returned |
|
506 |
" |
|
618 | 507 |
|row| |
508 |
||
509 |
lockRowIndex == aRowNr ifTrue:[ |
|
510 |
^ self |
|
511 |
]. |
|
512 |
row := list at:aRowNr. |
|
513 |
row == aRow ifTrue:[ |
|
514 |
^ self |
|
515 |
]. |
|
516 |
||
542 | 517 |
beDependentOfRows ifTrue:[ |
618 | 518 |
(row := list at:aRowNr) notNil ifTrue:[ |
519 |
row removeDependent:self |
|
520 |
] |
|
542 | 521 |
]. |
618 | 522 |
|
607 | 523 |
list at:aRowNr put:aRow. |
618 | 524 |
|
525 |
aRow notNil ifTrue:[ "/ free list |
|
526 |
beDependentOfRows ifTrue:[ |
|
527 |
aRow addDependent:self |
|
528 |
]. |
|
529 |
self redrawRowAt:aRowNr |
|
530 |
]. |
|
542 | 531 |
^ aRow. |
532 |
! |
|
533 |
||
534 |
first |
|
535 |
"return the first row |
|
536 |
" |
|
618 | 537 |
^ self at:1 |
538 |
! |
|
539 |
||
540 |
identityIndexOfRow:aRow |
|
541 |
"returns index of a row or 0 |
|
542 |
" |
|
543 |
(list size ~~ 0 and:[aRow notNil]) ifTrue:[ |
|
544 |
^ list identityIndexOf:aRow |
|
545 |
]. |
|
546 |
^ 0 |
|
542 | 547 |
! |
548 |
||
549 |
last |
|
550 |
"return the last row |
|
551 |
" |
|
618 | 552 |
^ self at:(self size) |
542 | 553 |
! |
554 |
||
555 |
list |
|
556 |
"get the list of rows |
|
557 |
" |
|
558 |
^ list |
|
559 |
||
560 |
||
561 |
||
562 |
! |
|
563 |
||
564 |
list:aList |
|
565 |
"set the list of rows |
|
566 |
" |
|
656 | 567 |
|makeDependent| |
568 |
||
618 | 569 |
"/ remove selection without redraw |
622 | 570 |
|
571 |
editValue notNil ifTrue:[ |
|
572 |
editValue removeDependent:self. |
|
573 |
editValue := nil |
|
574 |
]. |
|
575 |
||
618 | 576 |
editView notNil ifTrue:[ |
577 |
editView destroy. |
|
578 |
editView := nil. |
|
579 |
]. |
|
622 | 580 |
|
618 | 581 |
selectedColIndex := 0. |
582 |
selectedRowIndex := multipleSelectOk ifTrue:[nil] ifFalse:[0]. |
|
542 | 583 |
|
612 | 584 |
shown ifFalse:[ |
585 |
preferredExtent := nil |
|
586 |
] ifTrue:[ |
|
587 |
aList size ~~ 0 ifTrue:[ "/ otherwise keep old values |
|
588 |
self columnsDo:[:aCol| aCol invalidate ]. |
|
589 |
preferredExtent := nil. |
|
618 | 590 |
] |
542 | 591 |
]. |
592 |
||
656 | 593 |
(makeDependent := beDependentOfRows) ifTrue:[ |
594 |
self beDependentOfRows:false. |
|
595 |
]. |
|
643 | 596 |
|
597 |
aList size ~~ 0 ifTrue:[ |
|
598 |
list := OrderedCollection new:(aList size). |
|
645
53c78cc2ee08
redraw twice in case of expose event during adding a new entry
ca
parents:
643
diff
changeset
|
599 |
aList do:[:el| list add:el ]. |
542 | 600 |
] ifFalse:[ |
643 | 601 |
list := nil |
542 | 602 |
]. |
656 | 603 |
self beDependentOfRows:makeDependent. |
542 | 604 |
|
612 | 605 |
shown ifTrue:[ |
542 | 606 |
list size ~~ 0 ifTrue:[ |
607 |
self fitColumns ifTrue:[^ self ]. |
|
608 |
]. |
|
713 | 609 |
self recomputeHeightOfContents. |
637 | 610 |
self invalidate. |
611 |
self contentsChanged. |
|
612 |
]. |
|
613 |
||
542 | 614 |
|
615 |
||
616 |
||
617 |
! ! |
|
618 |
||
619 |
!DSVColumnView methodsFor:'accessing visibility'! |
|
620 |
||
621 |
font:aFont |
|
622 |
"set the font for all shown rows. |
|
623 |
" |
|
624 |
(aFont notNil and:[aFont ~~ font]) ifTrue:[ |
|
625 |
super font:(aFont on:device). |
|
626 |
self columnsDo:[:aCol| aCol invalidate ]. |
|
627 |
self preferredExtentChanged. |
|
628 |
||
629 |
realized ifTrue:[ |
|
630 |
self invalidate. |
|
631 |
self contentsChanged |
|
643 | 632 |
] |
542 | 633 |
] |
634 |
||
635 |
! |
|
636 |
||
607 | 637 |
has3Dseparators |
638 |
"returns true if shown in 3D mode |
|
639 |
" |
|
640 |
^ separatorSize ~~ 1 |
|
542 | 641 |
! |
642 |
||
607 | 643 |
has3Dseparators:aBool |
644 |
"enable or disable 3D mode |
|
645 |
" |
|
646 |
|newSepSize| |
|
542 | 647 |
|
637 | 648 |
newSepSize := aBool ifTrue:[2] ifFalse:[1]. |
607 | 649 |
|
650 |
newSepSize ~~ separatorSize ifTrue:[ |
|
651 |
separatorSize := newSepSize. |
|
652 |
||
542 | 653 |
self columnsDo:[:aCol| aCol invalidate ]. |
654 |
self preferredExtentChanged. |
|
655 |
||
656 |
realized ifTrue:[ |
|
657 |
self invalidate. |
|
658 |
self contentsChanged |
|
647 | 659 |
] |
542 | 660 |
] |
661 |
||
662 |
||
663 |
! |
|
664 |
||
665 |
horizontalSpacing |
|
666 |
"horizontal spacing used by columns |
|
667 |
" |
|
563 | 668 |
^ horizontalSpacing |
669 |
! |
|
670 |
||
671 |
horizontalSpacing:aNumber |
|
672 |
"horizontal spacing used by columns |
|
673 |
" |
|
674 |
horizontalSpacing ~~ aNumber ifTrue:[ |
|
675 |
horizontalSpacing := aNumber. |
|
676 |
self preferredExtentChanged. |
|
677 |
]. |
|
542 | 678 |
! |
679 |
||
680 |
verticalSpacing |
|
681 |
"vertical spacing used by columns |
|
682 |
" |
|
563 | 683 |
^ verticalSpacing |
684 |
! |
|
685 |
||
686 |
verticalSpacing:aNumber |
|
687 |
"vertical spacing used by columns |
|
688 |
" |
|
689 |
verticalSpacing ~~ aNumber ifTrue:[ |
|
690 |
verticalSpacing := aNumber. |
|
691 |
self preferredExtentChanged. |
|
692 |
]. |
|
542 | 693 |
! ! |
694 |
||
695 |
!DSVColumnView methodsFor:'adding & removing rows'! |
|
696 |
||
697 |
add:aRow |
|
618 | 698 |
"insert row at end |
542 | 699 |
" |
618 | 700 |
^ self add:aRow beforeIndex:(1 + self size) |
542 | 701 |
! |
702 |
||
703 |
add:aRow afterIndex:aRowNr |
|
704 |
"add a new row after slot aRowNr and redisplay; returns nil in case |
|
618 | 705 |
of an invalid index or the row |
542 | 706 |
" |
707 |
^ self add:aRow beforeIndex:(aRowNr + 1) |
|
708 |
! |
|
709 |
||
710 |
add:aRow beforeIndex:aRowNr |
|
711 |
"add a new row before slot aRowNr and redisplay; returns nil in case |
|
618 | 712 |
of an invalid index or the row |
542 | 713 |
" |
861 | 714 |
self addAll:(Array with:aRow) beforeIndex:aRowNr. |
715 |
^ aRow. |
|
716 |
! |
|
717 |
||
718 |
addAll:aList beforeIndex:start |
|
719 |
"add a collection of rows before slot start and redisplay |
|
720 |
" |
|
721 |
|y0 y1 yD h dH size noSel| |
|
722 |
||
723 |
(size := aList size) == 0 ifTrue:[ |
|
724 |
^ self |
|
725 |
]. |
|
726 |
||
727 |
self size == 0 ifTrue:[ |
|
728 |
^ self list:aList |
|
618 | 729 |
]. |
643 | 730 |
|
618 | 731 |
beDependentOfRows ifTrue:[ |
861 | 732 |
aList do:[:aRow| aRow notNil ifTrue:[aRow addDependent:self]] |
542 | 733 |
]. |
637 | 734 |
|
861 | 735 |
noSel := self numberOfSelections. |
736 |
||
737 |
noSel ~~ 0 ifTrue:[ |
|
738 |
multipleSelectOk ifFalse:[ |
|
739 |
selectedRowIndex >= start ifTrue:[ |
|
740 |
selectedRowIndex := selectedRowIndex + size |
|
741 |
] |
|
742 |
] ifTrue:[ |
|
743 |
1 to:noSel do:[:i||v| |
|
744 |
(v := selectedRowIndex at:i) >= start ifTrue:[ |
|
745 |
selectedRowIndex at:i put:(v + size) |
|
607 | 746 |
] |
747 |
] |
|
748 |
] |
|
542 | 749 |
]. |
861 | 750 |
list addAll:aList beforeIndex:start. |
751 |
self recomputeHeightOfContents. |
|
752 |
||
753 |
y0 := (start - 1) * rowHeight. |
|
754 |
yD := size * rowHeight. |
|
755 |
y1 := y0 + yD. |
|
542 | 756 |
|
757 |
y0 < viewOrigin y ifTrue:[ |
|
758 |
self originWillChange. |
|
861 | 759 |
viewOrigin y:(yD + viewOrigin y). |
760 |
self originChanged:(0 @ yD). |
|
761 |
]. |
|
762 |
||
763 |
(shown not or:[self sensor hasDamageFor:self]) ifTrue:[ |
|
764 |
^ self contentsChanged. |
|
542 | 765 |
]. |
645
53c78cc2ee08
redraw twice in case of expose event during adding a new entry
ca
parents:
643
diff
changeset
|
766 |
|
861 | 767 |
y0 := self yVisibleOfRowNr:start. |
768 |
y1 := y0 + yD. |
|
769 |
||
770 |
(y1 > margin and:[y0 < (h := height - margin)]) ifTrue:[ |
|
771 |
h := h - y1. |
|
772 |
y0 := y0 max:margin. |
|
773 |
dH := y1 - y0. |
|
774 |
||
775 |
start == list size ifFalse:[ |
|
776 |
self catchExpose. |
|
777 |
||
778 |
self copyFrom:self x:0 y:y0 |
|
779 |
toX:0 y:y1 |
|
780 |
width:width height:h async:true. |
|
781 |
||
782 |
self waitForExpose |
|
783 |
]. |
|
784 |
self redrawX:margin y:y0 width:width - margin - margin height:dH. |
|
542 | 785 |
]. |
786 |
self contentsChanged. |
|
861 | 787 |
|
567 | 788 |
! |
789 |
||
542 | 790 |
addFirst:aRow |
618 | 791 |
"insert a row at start |
542 | 792 |
" |
793 |
^ self add:aRow beforeIndex:1 |
|
794 |
! |
|
795 |
||
796 |
removeFirst |
|
797 |
"remove first row; returns the removed row |
|
798 |
" |
|
799 |
self removeIndex:1 |
|
800 |
! |
|
801 |
||
861 | 802 |
removeFrom:startIndex to:stopIndex |
803 |
"remove rows from start to stop |
|
542 | 804 |
" |
861 | 805 |
|coll noRedraw |
806 |
noSel "{ Class: SmallInteger }" |
|
807 |
size "{ Class: SmallInteger }" |
|
808 |
start "{ Class: SmallInteger }" |
|
809 |
stop "{ Class: SmallInteger }" |
|
810 |
y0 "{ Class: SmallInteger }" |
|
811 |
y1 "{ Class: SmallInteger }" |
|
812 |
oY "{ Class: SmallInteger }" |
|
813 |
dY "{ Class: SmallInteger }" |
|
814 |
yB "{ Class: SmallInteger }" |
|
815 |
h "{ Class: SmallInteger }" |
|
816 |
| |
|
817 |
||
818 |
( (start := startIndex) < 1 |
|
819 |
or:[(stop := stopIndex) > list size] |
|
820 |
) ifTrue:[ |
|
821 |
^ self subscriptBoundsError:start |
|
618 | 822 |
]. |
861 | 823 |
size := stop - start + 1. |
824 |
||
825 |
beDependentOfRows ifTrue:[ |
|
826 |
list from:start to:stop do:[:r| r notNil ifTrue:[r removeDependent:self]]. |
|
827 |
]. |
|
828 |
noSel := self numberOfSelections. |
|
829 |
||
830 |
noSel ~~ 0 ifTrue:[ |
|
831 |
noSel == 1 ifTrue:[ |
|
832 |
noSel := self firstIndexSelected. |
|
833 |
||
834 |
noSel < start ifFalse:[ |
|
835 |
noSel > stop ifTrue:[ |
|
836 |
noSel := noSel - size. |
|
837 |
||
838 |
multipleSelectOk ifFalse:[selectedRowIndex := noSel] |
|
839 |
ifTrue:[selectedRowIndex at:1 put:noSel] |
|
840 |
] ifFalse:[ |
|
637 | 841 |
editValue notNil ifTrue:[ |
842 |
editValue removeDependent:self. |
|
843 |
editValue := nil. |
|
844 |
]. |
|
861 | 845 |
self deselect. |
637 | 846 |
] |
607 | 847 |
] |
848 |
] ifFalse:[ |
|
861 | 849 |
coll := OrderedCollection new:noSel. |
850 |
||
851 |
selectedRowIndex do:[:i| |
|
852 |
i < start ifTrue:[ |
|
853 |
coll add:i |
|
854 |
] ifFalse:[ |
|
855 |
i > stop ifTrue:[ |
|
856 |
coll add:(i - size) |
|
857 |
] |
|
858 |
] |
|
859 |
]. |
|
860 |
coll size == 0 ifTrue:[ |
|
861 |
self deselect |
|
862 |
] ifFalse:[ |
|
863 |
selectedRowIndex := coll |
|
864 |
] |
|
542 | 865 |
] |
866 |
]. |
|
861 | 867 |
list removeFrom:start to:stop. |
868 |
||
869 |
y0 := start - 1 * rowHeight. |
|
870 |
dY := size * rowHeight. |
|
871 |
y1 := dY + y0. |
|
542 | 872 |
yB := y1 + margin - viewOrigin y. |
873 |
self recomputeHeightOfContents. |
|
874 |
||
875 |
y0 < (oY := viewOrigin y) ifTrue:[ |
|
876 |
(noRedraw := y1 <= oY) ifFalse:[dY := y0 - oY] |
|
861 | 877 |
ifTrue:[dY := dY negated]. |
542 | 878 |
self originWillChange. |
879 |
viewOrigin y:(dY + oY). |
|
880 |
self originChanged:(0 @ dY). |
|
881 |
] ifFalse:[ |
|
882 |
noRedraw := y0 > (height + viewOrigin y) |
|
883 |
]. |
|
884 |
||
885 |
(noRedraw or:[shown not]) ifFalse:[ |
|
886 |
y1 := yB. |
|
861 | 887 |
y0 := self yVisibleOfRowNr:start. |
542 | 888 |
h := height - margin - yB. |
889 |
y0 := y0 max:margin. |
|
890 |
||
561 | 891 |
h > 0 ifTrue:[ |
892 |
self catchExpose. |
|
893 |
self copyFrom:self x:0 y:yB toX:0 y:y0 width:width height:h async:true. |
|
894 |
self waitForExpose. |
|
895 |
]. |
|
542 | 896 |
y0 := y0 + h. |
643 | 897 |
self redrawX:margin y:y0 width:width - margin - margin height:(height - y0). |
542 | 898 |
]. |
899 |
self contentsChanged. |
|
861 | 900 |
|
901 |
! |
|
902 |
||
903 |
removeIndex:aRowNr |
|
904 |
"remove row at an index; returns the removed row |
|
905 |
" |
|
906 |
|row| |
|
907 |
||
908 |
row := list at:aRowNr ifAbsent:nil. |
|
909 |
self removeFrom:aRowNr to:aRowNr. |
|
910 |
^ row |
|
542 | 911 |
! |
912 |
||
913 |
removeLast |
|
914 |
"remove last row; the row is returned |
|
915 |
" |
|
618 | 916 |
^ self removeIndex:self size |
542 | 917 |
! ! |
918 |
||
892 | 919 |
!DSVColumnView methodsFor:'builder'! |
920 |
||
921 |
builder |
|
922 |
^ builder |
|
923 |
! |
|
924 |
||
925 |
builder:aBuilder |
|
926 |
builder := aBuilder |
|
927 |
! ! |
|
928 |
||
542 | 929 |
!DSVColumnView methodsFor:'change & update'! |
930 |
||
859 | 931 |
changed:aParameter with:anArgument |
932 |
"notify all dependents that the receiver has changed somehow. |
|
933 |
Each dependent gets a '#update:with:from:'-message, with aParameter |
|
934 |
and anArgument as arguments." |
|
935 |
||
936 |
catchChangeEvents ifTrue:[ |
|
937 |
( aParameter == #sizeOfColumns |
|
938 |
or:[aParameter == #columnsLayout] |
|
939 |
) ifTrue:[ |
|
940 |
^ self |
|
941 |
] |
|
942 |
]. |
|
943 |
super changed:aParameter with:anArgument |
|
944 |
||
945 |
! |
|
946 |
||
542 | 947 |
update:something with:aParameter from:changedObject |
948 |
"one of my rows/cells changed its value |
|
949 |
" |
|
618 | 950 |
|row| |
542 | 951 |
|
612 | 952 |
changedObject == columnHolder ifTrue:[ |
953 |
^ self columnDescriptors:(columnHolder value) |
|
622 | 954 |
]. |
955 |
||
956 |
changedObject == editValue ifTrue:[ |
|
957 |
^ self selectedColumn at:(self firstIndexSelected) put:(editValue value) |
|
958 |
]. |
|
959 |
||
960 |
row := (something isNumber) ifTrue:[something] ifFalse:[changedObject]. |
|
809 | 961 |
self redrawVisibleRow:row readSelector:aParameter. |
962 |
||
963 |
! ! |
|
964 |
||
965 |
!DSVColumnView methodsFor:'defaults'! |
|
966 |
||
967 |
updateStyleCache |
|
968 |
"extract values from the styleSheet and cache them in class variables |
|
969 |
" |
|
970 |
<resource: #style (#textForegroundColor #'scrollableView.backgroundColor' |
|
971 |
#'selection.hilightForegroundColor' |
|
972 |
#'selection.hilightBackgroundColor' )> |
|
973 |
||
974 |
DefaultForegroundColor := StyleSheet colorAt:'textForegroundColor' default:(Color black). |
|
975 |
DefaultBackgroundColor := StyleSheet at:'scrollableView.backgroundColor' default:DefaultViewBackgroundColor. |
|
976 |
||
977 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultForegroundColor. |
|
978 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:(Color veryLightGrey). |
|
979 |
||
980 |
DefaultHilightForegroundColor = DefaultHilightBackgroundColor ifTrue:[ |
|
981 |
DefaultHilightBackgroundColor := Color veryLightGrey |
|
982 |
]. |
|
983 |
||
984 |
ButtonLightColor := StyleSheet at:'button.lightColor'. |
|
985 |
ButtonShadowColor := StyleSheet at:'button.shadowColor'. |
|
986 |
ButtonEdgeStyle := StyleSheet at:'button.edgeStyle'. |
|
987 |
||
988 |
" |
|
989 |
self updateStyleCache. |
|
990 |
" |
|
991 |
||
992 |
"Modified: / 26.10.1997 / 17:09:07 / cg" |
|
993 |
! ! |
|
994 |
||
995 |
!DSVColumnView methodsFor:'drag & drop'! |
|
996 |
||
824 | 997 |
canDrag |
998 |
"returns true if dragging is enabled |
|
999 |
" |
|
1000 |
^ dropSource notNil |
|
1001 |
||
1002 |
! |
|
1003 |
||
1004 |
dropSource |
|
1005 |
"returns the dropSource or nil |
|
809 | 1006 |
" |
824 | 1007 |
^ dropSource |
1008 |
||
1009 |
||
1010 |
! |
|
1011 |
||
1012 |
dropSource:aDropSourceOrNil |
|
1013 |
"set the dropSource or nil |
|
1014 |
" |
|
1015 |
dropSource := aDropSourceOrNil. |
|
1016 |
||
809 | 1017 |
|
1018 |
! |
|
1019 |
||
824 | 1020 |
dropTarget |
1021 |
"returns the dropTarget or nil |
|
809 | 1022 |
" |
824 | 1023 |
^ dropTarget |
1024 |
||
1025 |
! |
|
1026 |
||
1027 |
dropTarget:aDropTragetOrNil |
|
1028 |
"set the dropTarget or nil |
|
1029 |
" |
|
1030 |
dropTarget := aDropTragetOrNil. |
|
1031 |
||
1032 |
! |
|
1033 |
||
1034 |
startDragAt:aPoint |
|
1035 |
(dragIsActive not and:[dropSource notNil]) ifTrue:[ |
|
809 | 1036 |
dragIsActive := true. |
824 | 1037 |
dropSource startDragIn:self at:aPoint |
809 | 1038 |
] |
824 | 1039 |
|
542 | 1040 |
! ! |
1041 |
||
637 | 1042 |
!DSVColumnView methodsFor:'drawing'! |
1043 |
||
1044 |
colorOnDevice:aColor |
|
1045 |
"returns color on device |
|
1046 |
" |
|
1047 |
|col| |
|
1048 |
||
641 | 1049 |
aColor = Color noColor ifFalse:[ |
1050 |
col := colorMap at:aColor ifAbsent:nil. |
|
637 | 1051 |
|
641 | 1052 |
col isNil ifTrue:[ |
1053 |
colorMap at:aColor put:(col := aColor on:device) |
|
1054 |
]. |
|
1055 |
^ col |
|
637 | 1056 |
]. |
641 | 1057 |
^ bgColor |
637 | 1058 |
! |
1059 |
||
809 | 1060 |
drawEdgesAtX:x y:y width:w height:h level:aLevel |
1061 |
"draw edges |
|
1062 |
" |
|
824 | 1063 |
self drawEdgesAtX:x y:y width:w height:h level:aLevel on:self |
1064 |
! |
|
1065 |
||
1066 |
drawEdgesAtX:x y:y width:w height:h level:aLevel on:aGC |
|
1067 |
"draw edges |
|
1068 |
" |
|
1069 |
aGC drawEdgesForX:x |
|
809 | 1070 |
y:y |
1071 |
width:w |
|
1072 |
height:h |
|
1073 |
level:aLevel |
|
1074 |
shadow:buttonShadowColor |
|
1075 |
light:buttonLightColor |
|
1076 |
halfShadow:buttonHalfShadowColor |
|
1077 |
halfLight:buttonHalfLightColor |
|
1078 |
style:ButtonEdgeStyle. |
|
1079 |
||
1080 |
! |
|
1081 |
||
637 | 1082 |
forceRedraw |
1083 |
"a redraw forced by any other component |
|
1084 |
" |
|
1085 |
self redraw |
|
1086 |
! |
|
1087 |
||
1088 |
invalidate |
|
1089 |
"recompute extent before repair range |
|
1090 |
" |
|
1091 |
self recomputeHeightOfContents. |
|
1092 |
super invalidate. |
|
1093 |
||
1094 |
||
1095 |
! |
|
1096 |
||
1097 |
redraw |
|
1098 |
"redraw complete view |
|
1099 |
" |
|
1100 |
self redrawX:0 y:0 width:width height:height. |
|
1101 |
||
1102 |
! |
|
1103 |
||
1104 |
redrawRowAt:aRowNr |
|
1105 |
"redraw total row at an index |
|
1106 |
" |
|
1107 |
self redrawRowAt:aRowNr colAt:0 |
|
1108 |
! |
|
1109 |
||
1110 |
redrawRowAt:aRowNr colAt:aColNr |
|
1111 |
"redraw visible row in case of aColNr == 0 or the column in a row; |
|
1112 |
in case that the row/column is hidden no redraw is done |
|
1113 |
" |
|
1114 |
|x y h w| |
|
1115 |
||
886 | 1116 |
aRowNr isNil ifTrue:[ |
1117 |
^ self |
|
1118 |
]. |
|
1119 |
||
637 | 1120 |
(shown and:[aRowNr between:1 and:self size]) ifTrue:[ |
1121 |
h := rowHeight - 1. |
|
1122 |
||
1123 |
(y := self yVisibleOfRowNr:aRowNr) < margin ifTrue:[ |
|
1124 |
(h := h + y) <= margin ifTrue:[ |
|
1125 |
^ self |
|
1126 |
]. "/ row not visible |
|
1127 |
h := h - margin. |
|
1128 |
y := margin. |
|
1129 |
] ifFalse:[ |
|
1130 |
y >= height ifTrue:[^ self]. |
|
1131 |
]. |
|
1132 |
aColNr ~~ 0 ifTrue:[ "/ redraw column in row |
|
1133 |
w := (self columnAt:aColNr) width. |
|
1134 |
||
1135 |
(x := self xVisibleOfColNr:aColNr) < margin ifTrue:[ |
|
1136 |
(w := w + x) <= margin ifTrue:[ |
|
1137 |
^ self |
|
1138 |
]. "/ column not visible |
|
1139 |
w := w - margin. |
|
1140 |
x := margin. |
|
1141 |
] ifFalse:[ |
|
1142 |
x >= width ifTrue:[^ self]. |
|
1143 |
] |
|
1144 |
] ifFalse:[ "/ redraw whole row |
|
1145 |
x := margin. |
|
1146 |
w := width. |
|
1147 |
]. |
|
1148 |
self redrawX:x y:y width:w height:h |
|
1149 |
] |
|
1150 |
! |
|
1151 |
||
1152 |
redrawVisibleRow:aRow |
|
1153 |
"redraw row if visible |
|
1154 |
" |
|
809 | 1155 |
self redrawVisibleRow:aRow colAt:0 |
1156 |
||
1157 |
! |
|
1158 |
||
1159 |
redrawVisibleRow:aRow colAt:aColNr |
|
1160 |
"redraw row if visible |
|
1161 |
" |
|
637 | 1162 |
|start "{ Class:SmallInteger }" |
1163 |
stop "{ Class:SmallInteger }" |
|
1164 |
| |
|
1165 |
||
1166 |
(start := self indexOfFirstRowShown) ~~ 0 ifTrue:[ |
|
1167 |
stop := (start + (height // rowHeight)) min:(self size). |
|
1168 |
||
1169 |
aRow isNumber ifTrue:[ |
|
1170 |
(aRow between:start and:stop) ifTrue:[ |
|
809 | 1171 |
self redrawRowAt:aRow colAt:aColNr |
637 | 1172 |
] |
1173 |
] ifFalse:[ |
|
1174 |
start to:stop do:[:i| |
|
1175 |
(self at:i) == aRow ifTrue:[ |
|
809 | 1176 |
^ self redrawRowAt:i colAt:aColNr |
637 | 1177 |
] |
1178 |
] |
|
1179 |
] |
|
1180 |
] |
|
809 | 1181 |
|
1182 |
||
1183 |
! |
|
1184 |
||
1185 |
redrawVisibleRow:aRow readSelector:aSelector |
|
1186 |
"redraw a column identified by its read selector; if no column with |
|
1187 |
the specified read selector is detected, the whole line is drawn. |
|
1188 |
" |
|
1189 |
|row idx| |
|
1190 |
||
1191 |
aSelector isNil ifTrue:[ |
|
1192 |
idx := 0 |
|
1193 |
] ifFalse:[ |
|
1194 |
(row := aRow) isNumber ifTrue:[ |
|
1195 |
(row := self at:aRow) isNil ifTrue:[ ^ self ] |
|
1196 |
]. |
|
1197 |
idx := columnDescriptors findFirst:[:aCol||desc| |
|
1198 |
aCol description readSelector == aSelector |
|
1199 |
] |
|
1200 |
]. |
|
1201 |
self redrawVisibleRow:aRow colAt:idx |
|
1202 |
||
1203 |
||
1204 |
||
1205 |
||
637 | 1206 |
! |
1207 |
||
1208 |
redrawX:x y:y width:w height:h |
|
1209 |
"redraw part of myself immediately, given logical coordinates |
|
1210 |
" |
|
859 | 1211 |
|c0 savClip |
637 | 1212 |
start "{ Class:SmallInteger }" |
1213 |
stop "{ Class:SmallInteger }" |
|
1214 |
x0 "{ Class:SmallInteger }" |
|
1215 |
x1 "{ Class:SmallInteger }" |
|
1216 |
maxX "{ Class:SmallInteger }" |
|
643 | 1217 |
minX "{ Class:SmallInteger }" |
637 | 1218 |
yTop "{ Class:SmallInteger }" |
1219 |
yBot "{ Class:SmallInteger }" |
|
1220 |
times "{ Class:SmallInteger }" |
|
641 | 1221 |
yMax "{ Class:SmallInteger }" |
637 | 1222 |
| |
1223 |
||
1224 |
shown ifFalse:[^ self]. |
|
859 | 1225 |
|
637 | 1226 |
self paint:bgColor. |
1227 |
self fillRectangleX:x y:y width:w height:h. |
|
1228 |
||
765
dfd884a8820f
#// has been fixed to round toward negative infinity.
Stefan Vogel <sv@exept.de>
parents:
732
diff
changeset
|
1229 |
columnDescriptors size ~~ 0 ifTrue:[ |
dfd884a8820f
#// has been fixed to round toward negative infinity.
Stefan Vogel <sv@exept.de>
parents:
732
diff
changeset
|
1230 |
yTop := margin - viewOrigin y. |
dfd884a8820f
#// has been fixed to round toward negative infinity.
Stefan Vogel <sv@exept.de>
parents:
732
diff
changeset
|
1231 |
c0 := y - yTop max:0. |
637 | 1232 |
start := (c0 // rowHeight) + 1. |
643 | 1233 |
stop := (c0 + h - 1 // rowHeight + 1) min:(list size). |
637 | 1234 |
|
1235 |
(times := stop - start + 1) > 0 ifTrue:[ |
|
874 | 1236 |
savClip := clipRect. |
1237 |
||
643 | 1238 |
maxX := (x + w) min:(width - margin). |
637 | 1239 |
x0 := margin - viewOrigin x. |
1240 |
yTop := yTop + ((start - 1) * rowHeight). |
|
1241 |
yBot := yTop + (times * rowHeight). |
|
642 | 1242 |
yMax := height - margin - margin. |
643 | 1243 |
minX := x max:margin. |
1244 |
||
874 | 1245 |
columnDescriptors do:[:aCol||rW| |
643 | 1246 |
x1 := x0 + aCol width. |
637 | 1247 |
|
1248 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
|
874 | 1249 |
rW := (x1 min:maxX) - x. |
1250 |
||
1251 |
self clippingRectangle:(Rectangle left:x top:y width:rW height:h). |
|
637 | 1252 |
aCol drawFrom:start times:times x0:x0 yTop:yTop yBot:yBot with:fgColor and:bgColor. |
1253 |
]. |
|
1254 |
x0 := x1 |
|
874 | 1255 |
]. |
1256 |
self clippingRectangle:savClip. |
|
1257 |
] |
|
859 | 1258 |
]. |
637 | 1259 |
! ! |
1260 |
||
542 | 1261 |
!DSVColumnView methodsFor:'enumerating columns'! |
1262 |
||
1263 |
columnsDo:aOneArgBlock |
|
1264 |
"evaluate the argument, aOneArgBlock for every column |
|
1265 |
" |
|
1266 |
columnDescriptors do:aOneArgBlock |
|
1267 |
||
1268 |
||
1269 |
! |
|
1270 |
||
1271 |
columnsFrom:start to:stop do:aOneArgBlock |
|
1272 |
"evaluate the argument, aOneArgBlock for the columns with index start to |
|
1273 |
stop in the collection of column descriptors |
|
1274 |
" |
|
1275 |
columnDescriptors from:start to:stop do:aOneArgBlock |
|
1276 |
||
1277 |
||
1278 |
! ! |
|
1279 |
||
1280 |
!DSVColumnView methodsFor:'event handling'! |
|
1281 |
||
607 | 1282 |
buttonMotion:buttonMask x:x y:y |
1283 |
"mouse-move while button was pressed - handle multiple selection changes |
|
1284 |
" |
|
824 | 1285 |
|idx size scr p| |
607 | 1286 |
|
809 | 1287 |
dragAccessPoint notNil ifTrue:[ |
1288 |
dragIsActive ifFalse:[ |
|
824 | 1289 |
p := x @ y. |
1290 |
(clickPosition dist:p) > 5.0 ifTrue:[ self startDragAt:p ] |
|
809 | 1291 |
]. |
1292 |
^ self |
|
1293 |
]. |
|
607 | 1294 |
self sensor ctrlDown ifTrue:[^ self ]. |
1295 |
||
1296 |
(multipleSelectOk and:[selectedColIndex == 0 and:[selectedRowIndex notNil]]) ifFalse:[ |
|
1297 |
^ self |
|
1298 |
]. |
|
1299 |
"is it the select or 1-button ?" |
|
1300 |
||
1301 |
(device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[ |
|
1302 |
(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[ |
|
1303 |
^ self |
|
1304 |
]. |
|
1305 |
]. |
|
1306 |
scr := 0. |
|
1307 |
||
1308 |
y > height ifTrue:[ |
|
1309 |
scr := rowHeight. |
|
1310 |
idx := self yVisibleToRowNr:(height + rowHeight). |
|
1311 |
] ifFalse:[ |
|
1312 |
y < 0 ifTrue:[ |
|
1313 |
scr := rowHeight negated. |
|
1314 |
idx := self yVisibleToRowNr:scr. |
|
1315 |
] ifFalse:[ |
|
1316 |
idx := self yVisibleToRowNr:y. |
|
1317 |
] |
|
1318 |
]. |
|
643 | 1319 |
(idx isNil or:[idx < 1 or:[self isInSelection:idx]]) ifTrue:[ |
607 | 1320 |
^ self |
1321 |
]. |
|
1322 |
selectedRowIndex := selectedRowIndex asOrderedCollection. |
|
643 | 1323 |
|
1324 |
clickPosition notNil ifTrue:[ |
|
1325 |
(clickPosition - idx) abs > 1 ifTrue:[|s e| |
|
1326 |
clickPosition < idx ifTrue:[ |
|
1327 |
s := clickPosition + 1. |
|
1328 |
e := idx - 1. |
|
1329 |
] ifFalse:[ |
|
1330 |
s := idx + 1. |
|
1331 |
e := clickPosition - 1. |
|
1332 |
]. |
|
1333 |
s to:e do:[:i| |
|
1334 |
(self isInSelection:i) ifFalse:[ |
|
1335 |
selectedRowIndex add:i. |
|
1336 |
self redrawRowAt:i colAt:0. |
|
1337 |
] |
|
1338 |
] |
|
1339 |
] |
|
1340 |
]. |
|
1341 |
selectedRowIndex add:(clickPosition := idx). |
|
607 | 1342 |
|
1343 |
scr == 0 ifTrue:[ |
|
861 | 1344 |
self redrawRowAt:idx colAt:0. |
607 | 1345 |
] ifFalse:[ |
1346 |
self scrollTo:(viewOrigin + (0 @ scr)) redraw:true |
|
1347 |
]. |
|
1348 |
! |
|
1349 |
||
542 | 1350 |
buttonMultiPress:button x:x y:y |
1351 |
"a button was pressed twice - handle doubleclick here |
|
1352 |
" |
|
1353 |
((button == 1) or:[button == #select]) ifFalse:[ |
|
1354 |
^ super buttonMultiPress:button x:x y:y |
|
1355 |
]. |
|
607 | 1356 |
self numberOfSelections == 1 ifTrue:[ |
1357 |
self firstIndexSelected == (self yVisibleToRowNr:y) ifTrue:[ |
|
1358 |
( selectedColIndex == 0 |
|
1359 |
or:[selectedColIndex == (self xVisibleToColNr:x)] |
|
1360 |
) ifTrue:[ |
|
1361 |
self doubleClicked |
|
1362 |
] |
|
542 | 1363 |
] |
1364 |
] |
|
1365 |
||
1366 |
||
1367 |
||
1368 |
||
1369 |
! |
|
1370 |
||
1371 |
buttonPress:button x:x y:y |
|
1372 |
"a button was pressed - handle selection here |
|
1373 |
" |
|
637 | 1374 |
|rowNr colNr menu col sz view point| |
542 | 1375 |
|
809 | 1376 |
clickPosition := nil. |
1377 |
dragAccessPoint := nil. |
|
1378 |
dragIsActive := false. |
|
1379 |
||
667 | 1380 |
((button == 2) or:[button == #menu]) ifTrue:[ |
1381 |
(menu := self findMenuForSelection) notNil ifTrue:[ |
|
1382 |
^ menu startUp |
|
1383 |
] |
|
1384 |
] ifFalse:[ |
|
1385 |
( (button == 1 or:[button == #select]) |
|
1386 |
and:[(rowNr := self yVisibleToRowNr:y) notNil |
|
1387 |
and:[(colNr := self xVisibleToColNr:x) notNil]] |
|
1388 |
) ifTrue:[ |
|
1389 |
(multipleSelectOk not or:[self sensor ctrlDown not]) ifFalse:[ |
|
1390 |
selectedColIndex ~~ 0 ifTrue:[ |
|
1391 |
colNr := 0 |
|
1392 |
] ifFalse:[ |
|
1393 |
(sz := self numberOfSelections == 0) ifFalse:[ |
|
1394 |
(self isInSelection:rowNr) ifTrue:[ |
|
1395 |
sz == 1 ifTrue:[ |
|
1396 |
self selectColIndex:0 rowIndex:nil. |
|
1397 |
^ self sensor flushMotionEventsFor:self. |
|
1398 |
]. |
|
1399 |
selectedRowIndex remove:rowNr. |
|
1400 |
] ifFalse:[ |
|
1401 |
selectedRowIndex add:rowNr |
|
1402 |
]. |
|
1403 |
self redrawRowAt:rowNr. |
|
1404 |
self selectionChanged. |
|
1405 |
^ self sensor flushMotionEventsFor:self. |
|
607 | 1406 |
] |
667 | 1407 |
] |
1408 |
]. |
|
824 | 1409 |
(self canDrag and:[self isSelected:rowNr inColumn:colNr]) ifTrue:[ |
1410 |
clickPosition := x @ y. |
|
809 | 1411 |
dragAccessPoint := (colNr @ rowNr). |
1412 |
] ifFalse:[ |
|
1413 |
self selectRowAt:rowNr colAt:colNr atPoint:(x @ y) |
|
667 | 1414 |
]. |
1415 |
^ self |
|
542 | 1416 |
] |
1417 |
]. |
|
667 | 1418 |
super buttonPress:button x:x y:y |
1419 |
||
542 | 1420 |
|
1421 |
||
1422 |
! |
|
1423 |
||
643 | 1424 |
buttonRelease:button x:x y:y |
1425 |
||
1426 |
clickPosition notNil ifTrue:[ |
|
809 | 1427 |
dragAccessPoint notNil ifTrue:[ |
1428 |
dragIsActive ifFalse:[ |
|
1429 |
self selectRowAt:(dragAccessPoint y) |
|
1430 |
colAt:(dragAccessPoint x) |
|
1431 |
atPoint:clickPosition |
|
1432 |
]. |
|
1433 |
dragAccessPoint := nil. |
|
824 | 1434 |
dragIsActive := false. |
809 | 1435 |
] ifFalse:[ |
1436 |
self selectionChanged |
|
1437 |
]. |
|
643 | 1438 |
clickPosition := nil. |
1439 |
]. |
|
1440 |
super buttonRelease:button x:x y:y |
|
1441 |
||
1442 |
||
1443 |
! |
|
1444 |
||
809 | 1445 |
characterPress:aChar x:x y:y |
1446 |
"search row in column at x/y starting its printable label with cahracter. |
|
1447 |
" |
|
1448 |
|colNr rowNr lsize found column| |
|
1449 |
||
872
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1450 |
(rowIfAbsentBlock notNil |
896
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1451 |
or:[x isNil |
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1452 |
or:[(colNr := self xVisibleToColNr:x) isNil]]) ifTrue:[ |
809 | 1453 |
^ self |
1454 |
]. |
|
1455 |
rowNr := self lastIndexSelected. |
|
1456 |
lsize := self size. |
|
1457 |
column := self columnAt:colNr. |
|
1458 |
found := 0. |
|
1459 |
||
1460 |
lsize > rowNr ifTrue:[ |
|
1461 |
"/ search to end |
|
1462 |
found := column findRowNrStartingWithChar:aChar start:(rowNr + 1) stop:lsize. |
|
1463 |
]. |
|
1464 |
||
1465 |
(found == 0 and:[rowNr > 1]) ifTrue:[ |
|
1466 |
"/ search from begin |
|
1467 |
found := column findRowNrStartingWithChar:aChar start:1 stop:(rowNr - 1) |
|
1468 |
]. |
|
1469 |
found ~~ 0 ifTrue:[ |
|
1470 |
self selectColIndex:colNr rowIndex:found. |
|
1471 |
]. |
|
1472 |
||
896
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
1473 |
"Modified: / 21.5.1998 / 03:30:22 / cg" |
809 | 1474 |
! |
1475 |
||
542 | 1476 |
contentsChanged |
1477 |
"contents changed - move origin up if possible |
|
1478 |
" |
|
1479 |
|y| |
|
1480 |
||
1481 |
shown ifTrue:[ |
|
1482 |
self recomputeHeightOfContents. |
|
1483 |
y := self maxViewOriginY. |
|
1484 |
||
1485 |
viewOrigin y > y ifTrue:[ |
|
1486 |
self scrollTo:(viewOrigin x @ y) |
|
1487 |
] ifFalse:[ |
|
1488 |
self updateEditViewOrigin. |
|
1489 |
] |
|
1490 |
]. |
|
1491 |
super contentsChanged |
|
1492 |
||
1493 |
||
1494 |
! |
|
1495 |
||
1496 |
doubleClicked |
|
1497 |
"handle a double click |
|
1498 |
" |
|
637 | 1499 |
|col sel idx| |
1500 |
||
1501 |
self hasSelection ifTrue:[ |
|
1502 |
idx := self firstIndexSelected. |
|
1503 |
col := self selectedColumn. |
|
1504 |
(col notNil and:[(sel := col doubleClickedSelector) notNil]) ifTrue:[ |
|
1505 |
(self at:idx) perform:sel |
|
1506 |
] ifFalse:[ |
|
1507 |
doubleClickActionBlock notNil ifTrue:[ |
|
1508 |
doubleClickActionBlock value:idx |
|
1509 |
] |
|
1510 |
] |
|
1511 |
] |
|
542 | 1512 |
! |
1513 |
||
667 | 1514 |
findMenuForSelection |
1515 |
"find the middle button menu for the current selection; returns the menu or nil |
|
1516 |
" |
|
1517 |
|col row menu| |
|
1518 |
||
1519 |
self numberOfSelections == 1 ifTrue:[ |
|
1520 |
row := self at:(self firstIndexSelected). |
|
1521 |
col := self selectedColumn. |
|
1522 |
||
1523 |
(col notNil and:[(menu := col menuForRow:row) notNil]) ifTrue:[ |
|
1524 |
^ menu |
|
1525 |
]. |
|
1526 |
col := columnDescriptors detect:[:c| c rendererType == #rowSelector] |
|
1527 |
ifNone:[nil]. |
|
1528 |
||
1529 |
col notNil ifTrue:[ |
|
1530 |
^ col menuForRow:row |
|
1531 |
] |
|
1532 |
]. |
|
1533 |
^ nil |
|
1534 |
! |
|
1535 |
||
542 | 1536 |
keyPress:key x:x y:y |
1537 |
"a key was pressed - handle page-keys here |
|
1538 |
" |
|
1539 |
<resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown |
|
809 | 1540 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
542 | 1541 |
#CursorUp #CursorDown #CursorRight #CursorLeft)> |
1542 |
||
607 | 1543 |
|sensor n max idx col selRowNr| |
542 | 1544 |
|
809 | 1545 |
(key == #PreviousPage) ifTrue:[^ self pageUp]. |
1546 |
(key == #NextPage) ifTrue:[^ self pageDown]. |
|
1547 |
(key == #HalfPageUp) ifTrue:[^ self halfPageUp]. |
|
1548 |
(key == #HalfPageDown) ifTrue:[^ self halfPageDown]. |
|
1549 |
(key == #BeginOfText) ifTrue:[^ self scrollToTop]. |
|
1550 |
(key == #EndOfText) ifTrue:[^ self scrollToBottom]. |
|
1551 |
||
1552 |
(key isCharacter) ifTrue:[^ self characterPress:key x:x y:y ]. |
|
542 | 1553 |
|
1554 |
sensor := self sensor. |
|
1555 |
||
1556 |
(key == #ScrollUp) ifTrue:[ |
|
1557 |
sensor isNil ifTrue:[ |
|
1558 |
n := 1 |
|
1559 |
] ifFalse:[ |
|
1560 |
n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollUp). |
|
1561 |
]. |
|
1562 |
^ self scrollUp:(n * self verticalScrollStep) |
|
1563 |
]. |
|
1564 |
(key == #ScrollDown) ifTrue:[ |
|
1565 |
sensor isNil ifTrue:[ |
|
1566 |
n := 1 |
|
1567 |
] ifFalse:[ |
|
1568 |
n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollDown). |
|
1569 |
]. |
|
1570 |
^ self scrollDown:(n * self verticalScrollStep) |
|
1571 |
]. |
|
872
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1572 |
self numberOfSelections == 1 ifFalse:[ |
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1573 |
super keyPress:key x:x y:y. |
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1574 |
^ self |
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1575 |
]. |
607 | 1576 |
selRowNr := self firstIndexSelected. |
542 | 1577 |
|
1578 |
key == #Return ifTrue:[ |
|
1579 |
^ self doubleClicked |
|
1580 |
]. |
|
618 | 1581 |
max := self size. |
542 | 1582 |
|
1583 |
(key == #CursorUp or:[key == #CursorDown]) ifTrue:[ |
|
1584 |
sensor isNil ifTrue:[ |
|
1585 |
n := 1 |
|
1586 |
] ifFalse:[ |
|
1587 |
n := 1 + (sensor compressKeyPressEventsWithKey:key). |
|
1588 |
]. |
|
1589 |
(n := n \\ max) == 0 ifTrue:[^ self ]. |
|
1590 |
||
1591 |
key == #CursorUp ifTrue:[ |
|
607 | 1592 |
(n := selRowNr - n) <= 0 ifTrue:[n := max + n] |
542 | 1593 |
] ifFalse:[ |
607 | 1594 |
(n := selRowNr + n) > max ifTrue:[n := n - max] |
542 | 1595 |
]. |
1596 |
^ self selectColIndex:selectedColIndex rowIndex:n. |
|
1597 |
]. |
|
1598 |
||
809 | 1599 |
selectedColIndex == 0 ifTrue:[ "/ line is selected |
872
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1600 |
super keyPress:key x:x y:y. |
612 | 1601 |
^ self |
1602 |
]. |
|
1603 |
||
542 | 1604 |
(key == #CursorRight or:[key == #CursorLeft]) ifTrue:[ |
1605 |
sensor isNil ifTrue:[ |
|
1606 |
n := 1 |
|
1607 |
] ifFalse:[ |
|
1608 |
n := 1 + (sensor compressKeyPressEventsWithKey:key). |
|
1609 |
]. |
|
1610 |
idx := selectedColIndex. |
|
1611 |
max := self numberOfColumns. |
|
1612 |
||
1613 |
key == #CursorLeft ifTrue:[ |
|
1614 |
[n ~~ 0] whileTrue:[ |
|
1615 |
(idx := idx - 1) == 0 ifTrue:[idx := max]. |
|
607 | 1616 |
((self columnAt:idx) canSelect:selRowNr) ifTrue:[n := n - 1] |
542 | 1617 |
] |
1618 |
] ifFalse:[ |
|
1619 |
[n ~~ 0] whileTrue:[ |
|
1620 |
idx == max ifTrue:[idx := 1] |
|
1621 |
ifFalse:[idx := idx + 1]. |
|
607 | 1622 |
((self columnAt:idx) canSelect:selRowNr) ifTrue:[n := n - 1] |
542 | 1623 |
] |
1624 |
]. |
|
1625 |
||
607 | 1626 |
^ self selectColIndex:idx rowIndex:selRowNr. |
542 | 1627 |
]. |
1628 |
||
872
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1629 |
super keyPress:key x:x y:y |
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1630 |
|
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
1631 |
"Modified: / 21.4.1998 / 20:43:47 / cg" |
542 | 1632 |
! |
1633 |
||
1634 |
originChanged:delta |
|
1635 |
"this one is sent, after the origin of my contents has changed - |
|
1636 |
tell dependents (i.e. scrollers) about this |
|
1637 |
" |
|
1638 |
super originChanged:delta. |
|
1639 |
self updateEditViewOrigin. |
|
1640 |
! |
|
1641 |
||
1642 |
sizeChanged:how |
|
1643 |
"size changed - move origin up if possible |
|
1644 |
" |
|
1645 |
super sizeChanged:how. |
|
1646 |
||
1647 |
(shown and:[self numberOfColumns ~~ 0 and:[self fitColumns not]]) ifTrue:[ |
|
1648 |
self scrollTo:viewOrigin. "/ validates viewOrigin |
|
1649 |
self invalidate. |
|
1650 |
self scrollToSelection |
|
1651 |
] |
|
1652 |
||
1653 |
! ! |
|
1654 |
||
1655 |
!DSVColumnView methodsFor:'gc operations'! |
|
1656 |
||
1657 |
registerImage:anImage key:aKey |
|
1658 |
"any row can register an image with a unique identifier a key symbol |
|
1659 |
" |
|
1660 |
|img| |
|
1661 |
||
1662 |
(img := registererImages at:aKey ifAbsent:nil) notNil ifTrue:[ |
|
1663 |
^ img |
|
1664 |
]. |
|
567 | 1665 |
img := anImage onDevice:device. |
1666 |
img clearMaskedPixels. |
|
1667 |
registererImages at:aKey put:img. |
|
1668 |
^ img |
|
542 | 1669 |
! |
1670 |
||
1671 |
registeredImageAt:aKey |
|
1672 |
"any row can register an image with a unique identifier |
|
1673 |
" |
|
1674 |
^ registererImages at:aKey ifAbsent:nil |
|
1675 |
! |
|
1676 |
||
1677 |
releaseAllRegisteredImages |
|
1678 |
"release all registered images |
|
1679 |
" |
|
1680 |
registererImages := IdentityDictionary new. |
|
1681 |
! ! |
|
1682 |
||
1683 |
!DSVColumnView methodsFor:'initialization'! |
|
1684 |
||
1685 |
create |
|
607 | 1686 |
"set color on device |
542 | 1687 |
" |
1688 |
super create. |
|
1689 |
fgColor := fgColor on:device. |
|
1690 |
bgColor := bgColor on:device. |
|
1691 |
hgLgFgColor := hgLgFgColor on:device. |
|
1692 |
hgLgBgColor := hgLgBgColor on:device. |
|
809 | 1693 |
|
1694 |
buttonShadowColor := buttonShadowColor on:device. |
|
1695 |
buttonLightColor := buttonLightColor on:device. |
|
1696 |
||
1697 |
buttonHalfShadowColor notNil ifTrue:[ |
|
1698 |
buttonHalfShadowColor := buttonHalfShadowColor on:device |
|
1699 |
]. |
|
1700 |
||
1701 |
buttonHalfLightColor notNil ifTrue:[ |
|
1702 |
buttonHalfLightColor := buttonHalfLightColor on:device |
|
1703 |
]. |
|
542 | 1704 |
! |
1705 |
||
1706 |
destroy |
|
1707 |
"remove dependencies |
|
1708 |
" |
|
618 | 1709 |
self columnHolder:nil. |
1710 |
self beDependentOfRows:false. |
|
542 | 1711 |
super destroy |
1712 |
! |
|
1713 |
||
1714 |
initStyle |
|
607 | 1715 |
"setup colors |
1716 |
" |
|
809 | 1717 |
|v b| |
1718 |
||
542 | 1719 |
super initStyle. |
1720 |
||
1721 |
DefaultForegroundColor isNil ifTrue:[ |
|
1722 |
self class updateStyleCache |
|
1723 |
]. |
|
1724 |
fgColor := DefaultForegroundColor. |
|
1725 |
bgColor := DefaultBackgroundColor. |
|
1726 |
hgLgFgColor := DefaultHilightForegroundColor. |
|
1727 |
hgLgBgColor := DefaultHilightBackgroundColor. |
|
809 | 1728 |
|
1729 |
shadowColor isNil ifTrue:[ |
|
1730 |
shadowColor := Color grayPercent:40. |
|
1731 |
]. |
|
1732 |
||
1733 |
lightColor isNil ifTrue:[ |
|
1734 |
lightColor := Color grayPercent:75 |
|
1735 |
]. |
|
1736 |
||
1737 |
buttonLightColor := ButtonLightColor ? lightColor. |
|
1738 |
buttonShadowColor := ButtonShadowColor ? shadowColor. |
|
1739 |
||
1740 |
(ButtonEdgeStyle == #soft) ifTrue:[ |
|
1741 |
buttonHalfShadowColor := ButtonHalfShadowColor. |
|
1742 |
buttonHalfLightColor := ButtonHalfLightColor. |
|
1743 |
||
1744 |
buttonHalfShadowColor isNil ifTrue:[ |
|
1745 |
buttonHalfShadowColor := buttonShadowColor lightened |
|
1746 |
] |
|
1747 |
]. |
|
1748 |
||
1749 |
v := ComboBoxView new. |
|
1750 |
b := v menuButton. |
|
1751 |
||
1752 |
(comboButtonForm := b label) isImage ifTrue:[ |
|
1753 |
comboButtonForm clearMaskedPixels |
|
1754 |
]. |
|
1755 |
||
1756 |
comboButtonLevel := b offLevel. |
|
1757 |
comboButtonExtent := (b preferredExtent x) @ (v preferredExtent y). |
|
1758 |
||
1759 |
b := CheckToggle new. |
|
1760 |
||
1761 |
(checkToggleForm := CheckToggle checkFormOn:device) isImage ifTrue:[ |
|
1762 |
checkToggleForm clearMaskedPixels |
|
1763 |
]. |
|
1764 |
checkToggleLevel := b offLevel. |
|
1765 |
checkToggleExtent := b preferredExtent. |
|
1766 |
||
1767 |
||
1768 |
||
1769 |
||
1770 |
||
1771 |
||
1772 |
||
1773 |
||
1774 |
||
1775 |
||
1776 |
||
1777 |
||
542 | 1778 |
! |
1779 |
||
1780 |
initialize |
|
1781 |
"set default attributes |
|
1782 |
" |
|
1783 |
super initialize. |
|
1784 |
||
607 | 1785 |
viewOrigin := 0@0. |
1786 |
font := font on:device. |
|
1787 |
rowHeight := font height. |
|
1788 |
multipleSelectOk := false. |
|
1789 |
selectedRowIndex := selectedColIndex := 0. |
|
1790 |
registererImages := IdentityDictionary new. |
|
1791 |
separatorSize := 1. |
|
542 | 1792 |
columnDescriptors := #(). |
567 | 1793 |
beDependentOfRows := false. |
563 | 1794 |
verticalSpacing := self class verticalSpacing. |
1795 |
horizontalSpacing := self class horizontalSpacing. |
|
637 | 1796 |
colorMap := Dictionary new. |
647 | 1797 |
catchChangeEvents := false. |
809 | 1798 |
dragIsActive := false. |
637 | 1799 |
|
610 | 1800 |
self lineWidth:0. |
542 | 1801 |
! |
1802 |
||
705 | 1803 |
mapped |
1804 |
"set selection if exists after mapping |
|
1805 |
" |
|
1806 |
|idx| |
|
1807 |
||
1808 |
super mapped. |
|
1809 |
||
1810 |
idx := self firstIndexSelected. |
|
1811 |
||
1812 |
idx ~~ 0 ifTrue:[ |
|
1813 |
self scrollToRowAt:idx colAt:0. |
|
1814 |
]. |
|
1815 |
! |
|
1816 |
||
542 | 1817 |
realize |
607 | 1818 |
"recompute contents and fit columns to view |
542 | 1819 |
" |
607 | 1820 |
self bitGravity:#NorthWest. |
542 | 1821 |
self recomputeHeightOfContents. |
1822 |
super realize. |
|
607 | 1823 |
self fitColumns. |
1824 |
! ! |
|
1825 |
||
1826 |
!DSVColumnView methodsFor:'obsolete'! |
|
1827 |
||
1828 |
has3Dsepartors |
|
1829 |
"shouldn't be used any more |
|
1830 |
" |
|
1831 |
^ self has3Dseparators |
|
1832 |
! |
|
1833 |
||
1834 |
has3Dsepartors:aBool |
|
1835 |
"shouldn't be used any more |
|
1836 |
" |
|
1837 |
self has3Dseparators:aBool |
|
542 | 1838 |
|
1839 |
! ! |
|
1840 |
||
1841 |
!DSVColumnView methodsFor:'private'! |
|
1842 |
||
637 | 1843 |
detectViewAt:aPoint in:aView |
1844 |
|p| |
|
1845 |
||
1846 |
(aView notNil and:[aView subViews notNil]) ifTrue:[ |
|
1847 |
aView subViews do:[:sv| |
|
1848 |
p := device translatePoint:aPoint from:(self id) to:(sv id). |
|
1849 |
||
1850 |
(p x >= 0 and:[p y >= 0 and:[p x <= sv width and:[p y <= sv height]]]) ifTrue:[ |
|
1851 |
^ self detectViewAt:aPoint in:sv |
|
1852 |
] |
|
1853 |
] |
|
1854 |
]. |
|
1855 |
^ aView |
|
1856 |
! |
|
1857 |
||
542 | 1858 |
fitColumns |
1859 |
"fit columns to view |
|
1860 |
" |
|
859 | 1861 |
|raiseNotify lastColumn dX sz expand resizables deltaWidth| |
542 | 1862 |
|
1863 |
self canFit ifFalse:[^ false ]. |
|
647 | 1864 |
|
859 | 1865 |
resizables := 0. |
1866 |
deltaWidth := 0. |
|
1867 |
||
1868 |
preferredExtent isNil ifTrue:[ |
|
1869 |
raiseNotify := catchChangeEvents. |
|
1870 |
catchChangeEvents := true. |
|
647 | 1871 |
self preferredExtent. |
859 | 1872 |
catchChangeEvents := raiseNotify. |
1873 |
raiseNotify := raiseNotify not. |
|
1874 |
] ifFalse:[ |
|
1875 |
raiseNotify := false |
|
647 | 1876 |
]. |
542 | 1877 |
|
1878 |
self columnsDo:[:aCol| |
|
1879 |
aCol canResize ifTrue:[ |
|
1880 |
resizables := resizables + 1. |
|
1881 |
deltaWidth := aCol setMinWidth. |
|
1882 |
lastColumn := aCol. |
|
1883 |
] |
|
1884 |
]. |
|
647 | 1885 |
|
1886 |
resizables == 0 ifFalse:[ |
|
1887 |
sz := self widthOfContents. |
|
1888 |
||
1889 |
(expand := sz < width) ifTrue:[ |
|
1890 |
deltaWidth := width - sz + margin + margin |
|
1891 |
] |
|
1892 |
]. |
|
1893 |
||
1894 |
deltaWidth == 0 ifTrue:[ |
|
859 | 1895 |
raiseNotify ifTrue:[ self changed:#columnsLayout ]. |
647 | 1896 |
^ false |
542 | 1897 |
]. |
1898 |
||
1899 |
expand ifTrue:[ |
|
1900 |
(dX := deltaWidth // resizables) ~~ 0 ifTrue:[ |
|
1901 |
self columnsDo:[:aCol|aCol canResize ifTrue:[aCol growWidth:dX]] |
|
1902 |
]. |
|
1903 |
lastColumn growWidth:(deltaWidth - (dX * resizables)). |
|
1904 |
]. |
|
732 | 1905 |
|
542 | 1906 |
self preferredExtentChanged. |
612 | 1907 |
|
1908 |
shown ifTrue:[ |
|
1909 |
self invalidate. |
|
542 | 1910 |
|
612 | 1911 |
self hasSelection ifTrue:[ |
1912 |
editView notNil ifTrue:[ |
|
1913 |
editView width:(self selectedColumn width - separatorSize) |
|
1914 |
]. |
|
1915 |
self scrollToSelection. |
|
542 | 1916 |
]. |
732 | 1917 |
self contentsChanged. |
542 | 1918 |
]. |
647 | 1919 |
|
1920 |
self changed:#columnsLayout. |
|
732 | 1921 |
^ true. |
542 | 1922 |
|
1923 |
||
1924 |
! |
|
1925 |
||
1926 |
maxViewOriginY |
|
1927 |
"returns the maximum possible y of the view origin |
|
1928 |
" |
|
1929 |
|y| |
|
1930 |
||
1931 |
y := self heightOfContents - self innerHeight. |
|
1932 |
^ y max:0 |
|
1933 |
||
1934 |
! |
|
1935 |
||
1936 |
updateEditViewOrigin |
|
1937 |
"update origin of the editView |
|
1938 |
" |
|
1939 |
|x y| |
|
1940 |
||
1941 |
editView notNil ifTrue:[ |
|
607 | 1942 |
y := self yVisibleOfRowNr:(self firstIndexSelected). |
1943 |
x := self xVisibleOfColNr:(self selectedColIndex). |
|
542 | 1944 |
|
1945 |
editView origin:(x @ y). |
|
1946 |
]. |
|
1947 |
||
1948 |
! |
|
1949 |
||
1950 |
xVisibleOfColNr:aColNr |
|
1951 |
"returns visible x assigned to a column number |
|
1952 |
" |
|
1953 |
|x| |
|
1954 |
||
1955 |
x := margin - viewOrigin x. |
|
1956 |
self columnsFrom:1 to:(aColNr - 1) do:[:aCol| x := x + aCol width ]. |
|
1957 |
^ x |
|
1958 |
||
1959 |
! |
|
1960 |
||
1961 |
xVisibleToColNr:x |
|
607 | 1962 |
"returns the column number assigned to a physical x or nil |
1963 |
" |
|
542 | 1964 |
|x0 nr| |
1965 |
||
1966 |
x0 := x + viewOrigin x - margin. |
|
1967 |
nr := 1. |
|
1968 |
||
1969 |
self columnsDo:[:aCol| |
|
1970 |
(x0 := x0 - aCol width) <= 0 ifTrue:[^ nr]. |
|
1971 |
nr := nr + 1. |
|
1972 |
]. |
|
1973 |
^ nil. |
|
1974 |
||
1975 |
! |
|
1976 |
||
1977 |
yVisibleOfRowNr:aRowNr |
|
1978 |
"returns visible y assigned to the row number |
|
1979 |
" |
|
1980 |
^ (aRowNr - 1) * rowHeight + margin - viewOrigin y |
|
1981 |
||
1982 |
! |
|
1983 |
||
1984 |
yVisibleToRowNr:y |
|
607 | 1985 |
"returns the row number assigned to a physical y or nil |
542 | 1986 |
" |
1987 |
|y0| |
|
1988 |
||
1989 |
y0 := (y + viewOrigin y - margin) // rowHeight + 1. |
|
618 | 1990 |
^ (y0 <= self size) ifTrue:[y0] ifFalse:[nil] |
542 | 1991 |
|
1992 |
! ! |
|
1993 |
||
1994 |
!DSVColumnView methodsFor:'queries'! |
|
1995 |
||
1996 |
canFit |
|
1997 |
"returns true if columns can be fit to view |
|
1998 |
" |
|
1999 |
^ canFit |
|
2000 |
! |
|
2001 |
||
563 | 2002 |
indexOfFirstRowShown |
2003 |
"returns index of first row shown |
|
2004 |
" |
|
2005 |
|idx| |
|
2006 |
||
2007 |
idx := (self yOriginOfContents // rowHeight) + 1. |
|
618 | 2008 |
^ (idx <= self size) ifTrue:[idx] ifFalse:[0] |
563 | 2009 |
|
2010 |
! |
|
2011 |
||
542 | 2012 |
numberOfColumns |
2013 |
"returns number of columns |
|
2014 |
" |
|
2015 |
^ columnDescriptors size |
|
2016 |
||
2017 |
! |
|
2018 |
||
2019 |
numberOfRows |
|
2020 |
"returns number of raws |
|
2021 |
" |
|
618 | 2022 |
^ self size |
542 | 2023 |
|
2024 |
! |
|
2025 |
||
2026 |
rowHeight |
|
2027 |
"get the height of the highest row in pixels |
|
2028 |
" |
|
2029 |
^ rowHeight |
|
2030 |
||
2031 |
! |
|
2032 |
||
2033 |
separatorSize |
|
2034 |
"returns vertical/horizontal size of a separator dependent on the |
|
2035 |
3D effect. |
|
2036 |
" |
|
607 | 2037 |
^ separatorSize |
542 | 2038 |
|
2039 |
! |
|
2040 |
||
2041 |
size |
|
2042 |
"returns number of raws |
|
2043 |
" |
|
2044 |
^ list size |
|
2045 |
||
2046 |
! ! |
|
2047 |
||
2048 |
!DSVColumnView methodsFor:'recomputation'! |
|
2049 |
||
647 | 2050 |
hasPreferredExtent |
2051 |
"returns true if preferred extent is accumulated |
|
2052 |
" |
|
2053 |
^ preferredExtent notNil |
|
2054 |
! |
|
2055 |
||
542 | 2056 |
preferredExtent |
647 | 2057 |
"recompute preferred extent; raise notification |
542 | 2058 |
" |
2059 |
|x| |
|
2060 |
||
2061 |
preferredExtent notNil ifTrue:[ |
|
2062 |
^ preferredExtent |
|
2063 |
]. |
|
2064 |
x := 3. |
|
2065 |
rowHeight := 0. |
|
2066 |
||
2067 |
self columnsDo:[:aCol| |
|
2068 |
rowHeight := (aCol heightOfHighestRow) max:rowHeight. |
|
2069 |
x := x + (aCol minWidth). |
|
2070 |
]. |
|
647 | 2071 |
rowHeight := (rowHeight + separatorSize + verticalSpacing + verticalSpacing + 1) // 2 * 2. |
618 | 2072 |
preferredExtent := (x + margin + margin) @ (self size * rowHeight). |
542 | 2073 |
|
607 | 2074 |
x := (rowHeight - separatorSize - font height) // 2 + font ascent. |
542 | 2075 |
self columnsDo:[:aCol|aCol textInsetChanged:x]. |
859 | 2076 |
self changed:#columnsLayout. |
542 | 2077 |
^ preferredExtent |
2078 |
||
2079 |
||
2080 |
! |
|
2081 |
||
2082 |
preferredExtentChanged |
|
2083 |
|y x| |
|
2084 |
||
2085 |
y := viewOrigin y. |
|
2086 |
x := viewOrigin x. |
|
2087 |
||
2088 |
(y ~~ 0 or:[x ~~ 0]) ifTrue:[ |
|
2089 |
self originWillChange. |
|
2090 |
viewOrigin := 0 @ 0. |
|
2091 |
preferredExtent := nil. |
|
2092 |
self originChanged:(x negated @ y negated). |
|
2093 |
] |
|
2094 |
! |
|
2095 |
||
2096 |
recomputeHeightOfContents |
|
2097 |
||
2098 |
preferredExtent notNil ifTrue:[ |
|
618 | 2099 |
preferredExtent y:(rowHeight * self size) |
542 | 2100 |
] ifFalse:[ |
2101 |
self preferredExtent |
|
2102 |
]. |
|
2103 |
! ! |
|
2104 |
||
2105 |
!DSVColumnView methodsFor:'scroller interface'! |
|
2106 |
||
2107 |
heightOfContents |
|
2108 |
"return the height of the contents in pixels |
|
2109 |
" |
|
2110 |
^ self preferredExtent y |
|
2111 |
||
2112 |
||
2113 |
! |
|
2114 |
||
2115 |
innerHeight |
|
2116 |
"returns the inner height of the contents shown |
|
2117 |
" |
|
2118 |
^ height - margin - margin |
|
2119 |
||
2120 |
! |
|
2121 |
||
2122 |
innerWidth |
|
2123 |
"returns the inner width of the contents shown |
|
2124 |
" |
|
2125 |
^ width - margin - margin |
|
2126 |
||
2127 |
! |
|
2128 |
||
2129 |
verticalScrollStep |
|
2130 |
"return the amount to scroll when stepping up/down. |
|
2131 |
" |
|
2132 |
^ rowHeight |
|
2133 |
||
2134 |
||
2135 |
||
2136 |
! |
|
2137 |
||
2138 |
viewOrigin |
|
2139 |
"return the viewOrigin; thats the coordinate of the contents |
|
2140 |
which is shown topLeft in the view. |
|
2141 |
" |
|
2142 |
^ viewOrigin |
|
2143 |
||
2144 |
! |
|
2145 |
||
2146 |
widthOfContents |
|
2147 |
"return the width of the contents in pixels |
|
2148 |
" |
|
647 | 2149 |
preferredExtent isNil ifTrue:[ |
2150 |
self preferredExtent |
|
2151 |
]. |
|
2152 |
^ preferredExtent x |
|
542 | 2153 |
|
2154 |
! |
|
2155 |
||
2156 |
xOriginOfContents |
|
2157 |
"return the horizontal origin of the contents in pixels |
|
2158 |
" |
|
2159 |
^ viewOrigin x |
|
2160 |
||
2161 |
! |
|
2162 |
||
2163 |
yOriginOfContents |
|
2164 |
"return the vertical origin of the contents in pixels |
|
2165 |
" |
|
2166 |
^ viewOrigin y |
|
2167 |
||
2168 |
! ! |
|
2169 |
||
2170 |
!DSVColumnView methodsFor:'scrolling'! |
|
2171 |
||
2172 |
halfPageDown |
|
2173 |
"scroll down half a page |
|
2174 |
" |
|
2175 |
self scrollDown:(self innerHeight // 2) |
|
2176 |
||
2177 |
||
2178 |
! |
|
2179 |
||
2180 |
halfPageUp |
|
2181 |
"scroll up half a page |
|
2182 |
" |
|
2183 |
self scrollUp:(self innerHeight // 2) |
|
2184 |
||
2185 |
! |
|
2186 |
||
2187 |
scrollTo:anOrigin redraw:doRedraw |
|
2188 |
"change origin to have newOrigin be visible at the top-left. |
|
2189 |
" |
|
2190 |
|x y dX dY newOrg dltOrg h innerWT innerHG| |
|
2191 |
||
2192 |
shown ifFalse:[ |
|
2193 |
^ self |
|
2194 |
]. |
|
612 | 2195 |
|
542 | 2196 |
[self sensor hasExposeEventFor:nil] whileTrue:[ |
2197 |
self windowGroup processExposeEvents |
|
2198 |
]. |
|
612 | 2199 |
|
542 | 2200 |
innerWT := self innerWidth. |
2201 |
innerHG := self innerHeight. |
|
2202 |
||
2203 |
h := viewOrigin y. |
|
2204 |
||
2205 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents |
|
2206 |
y > (dY := self maxViewOriginY) ifTrue:[ |
|
2207 |
y := dY max:h |
|
2208 |
] |
|
2209 |
] ifFalse:[ |
|
2210 |
y := y max:0. |
|
2211 |
]. |
|
2212 |
||
2213 |
(x := anOrigin x) > 0 ifTrue:[ |
|
2214 |
x := x min:(self widthOfContents - innerWT). |
|
2215 |
]. |
|
2216 |
x := x max:0. |
|
2217 |
newOrg := (x @ y). |
|
2218 |
dltOrg := newOrg - viewOrigin. |
|
2219 |
dX := dltOrg x. |
|
2220 |
dY := dltOrg y. |
|
2221 |
||
2222 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
2223 |
^ self |
|
2224 |
]. |
|
2225 |
self originWillChange. |
|
2226 |
viewOrigin := newOrg. |
|
2227 |
||
2228 |
doRedraw ifFalse:[ |
|
2229 |
^ self originChanged:dltOrg |
|
2230 |
]. |
|
2231 |
||
2232 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
|
2233 |
dY := dY abs. |
|
2234 |
||
2235 |
(dX ~~ 0 or:[innerHG - dY < 20]) ifTrue:[ |
|
2236 |
self redraw. |
|
2237 |
] ifFalse:[ "/ COPY VERTICAL |
|
2238 |
|y0 y1| |
|
2239 |
||
2240 |
y0 := y1 := margin + dY. |
|
2241 |
h := innerHG - dY. |
|
2242 |
||
2243 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
|
2244 |
ifFalse:[y1 := margin. y := y1 + h]. |
|
2245 |
||
2246 |
self catchExpose. |
|
643 | 2247 |
self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true. |
542 | 2248 |
self waitForExpose. |
643 | 2249 |
self redrawX:margin y:y width:innerWT height:(innerHG - h). |
542 | 2250 |
] |
2251 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
2252 |
dX := dX abs. |
|
2253 |
||
2254 |
innerWT - dX < 20 ifTrue:[ |
|
2255 |
self redraw. |
|
2256 |
] ifFalse:[ "/ COPY HORIZONTAL |
|
2257 |
|x0 x1 w| |
|
2258 |
||
643 | 2259 |
x0 := x1 := dX + margin. |
542 | 2260 |
w := width - dX - margin. |
2261 |
||
643 | 2262 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
2263 |
ifFalse:[x1 := margin. x := w]. |
|
542 | 2264 |
|
2265 |
self catchExpose. |
|
643 | 2266 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true. |
542 | 2267 |
self waitForExpose. |
643 | 2268 |
self redrawX:x y:margin width:(width - w) height:innerHG. |
542 | 2269 |
] |
2270 |
]. |
|
2271 |
self originChanged:dltOrg. |
|
2272 |
! |
|
2273 |
||
2274 |
scrollToRowAt:aRowNr colAt:aColNr |
|
2275 |
"make row at a row number in column at a column number visible |
|
2276 |
" |
|
2277 |
|x y l dY dX| |
|
2278 |
||
618 | 2279 |
( (aRowNr between:1 and:(self size)) |
542 | 2280 |
and:[aColNr between:0 and:(self numberOfColumns)] |
2281 |
) ifFalse:[ |
|
2282 |
^ self |
|
2283 |
]. |
|
2284 |
||
2285 |
dY := dX := 0. |
|
2286 |
y := self yVisibleOfRowNr:aRowNr. |
|
2287 |
||
2288 |
y < margin ifTrue:[ |
|
2289 |
dY := margin - y. |
|
2290 |
] ifFalse:[ |
|
2291 |
y := y + rowHeight. |
|
2292 |
l := height - margin. |
|
2293 |
y > l ifTrue:[dY := l - y] |
|
2294 |
]. |
|
2295 |
||
2296 |
aColNr == 0 ifTrue:[ |
|
2297 |
dY == 0 ifTrue:[^ self]. |
|
2298 |
dX := 0. |
|
2299 |
] ifFalse:[ |
|
2300 |
x := self xVisibleOfColNr:aColNr. |
|
2301 |
||
2302 |
x < margin ifTrue:[ |
|
2303 |
dX := margin - x |
|
2304 |
] ifFalse:[ |
|
2305 |
x := x + (self columnAt:aColNr) width. |
|
2306 |
l := width - margin. |
|
2307 |
x > l ifTrue:[dX := l - x] |
|
2308 |
] |
|
2309 |
]. |
|
2310 |
||
2311 |
(dX == 0 and:[dY == 0]) ifFalse:[ |
|
2312 |
self scrollTo:(viewOrigin - (dX @ dY)). |
|
2313 |
] |
|
2314 |
||
2315 |
||
2316 |
! |
|
2317 |
||
2318 |
scrollToSelection |
|
2319 |
"make selection visible |
|
2320 |
" |
|
607 | 2321 |
|rowNr| |
2322 |
||
2323 |
(rowNr := self firstIndexSelected) ~~ 0 ifTrue:[ |
|
2324 |
self scrollToRowAt:rowNr colAt:(self selectedColIndex) |
|
542 | 2325 |
] |
2326 |
||
2327 |
! ! |
|
2328 |
||
2329 |
!DSVColumnView methodsFor:'selection'! |
|
2330 |
||
607 | 2331 |
deselect |
2332 |
"deselect |
|
2333 |
" |
|
2334 |
self selectColIndex:0 rowIndex:0 |
|
2335 |
! |
|
2336 |
||
2337 |
firstIndexSelected |
|
809 | 2338 |
"returns index of first row selected or 0 |
607 | 2339 |
" |
2340 |
multipleSelectOk ifFalse:[ |
|
2341 |
^ selectedRowIndex |
|
2342 |
]. |
|
2343 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
2344 |
^ selectedRowIndex at:1 |
|
2345 |
]. |
|
2346 |
^ 0 |
|
2347 |
! |
|
2348 |
||
542 | 2349 |
hasSelection |
607 | 2350 |
"returns true if a selection exists |
542 | 2351 |
" |
607 | 2352 |
^ self numberOfSelections ~~ 0 |
542 | 2353 |
|
2354 |
||
2355 |
! |
|
2356 |
||
607 | 2357 |
isInSelection:aRowNr |
2358 |
"return true, if row, aRowNr is in the selection |
|
542 | 2359 |
" |
607 | 2360 |
aRowNr ~~ 0 ifTrue:[ |
2361 |
multipleSelectOk ifFalse:[ |
|
2362 |
^ aRowNr == selectedRowIndex |
|
2363 |
]. |
|
2364 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
2365 |
^ selectedRowIndex includes:aRowNr |
|
2366 |
] |
|
2367 |
]. |
|
2368 |
^ false |
|
2369 |
! |
|
2370 |
||
647 | 2371 |
isRowSelected:aRowNr |
2372 |
"return true, if row is in the selection |
|
2373 |
" |
|
2374 |
selectedColIndex == 0 ifTrue:[ |
|
2375 |
^ self isInSelection:aRowNr |
|
2376 |
]. |
|
2377 |
^ false |
|
2378 |
! |
|
2379 |
||
607 | 2380 |
isSelected:aRowNr inColumn:aColNr |
612 | 2381 |
"returns true if cell in a row; a row number, in a column, a column |
2382 |
number is selected. |
|
2383 |
" |
|
607 | 2384 |
(self isInSelection:aRowNr) ifTrue:[ |
2385 |
^ (selectedColIndex == 0 or:[selectedColIndex == aColNr]) |
|
2386 |
]. |
|
2387 |
^ false |
|
2388 |
! |
|
2389 |
||
809 | 2390 |
lastIndexSelected |
2391 |
"returns index of last row selected or 0 |
|
2392 |
" |
|
2393 |
multipleSelectOk ifFalse:[ |
|
2394 |
^ selectedRowIndex |
|
2395 |
]. |
|
2396 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
2397 |
^ selectedRowIndex last |
|
2398 |
]. |
|
2399 |
^ 0 |
|
2400 |
! |
|
2401 |
||
607 | 2402 |
numberOfSelections |
2403 |
"return the number of selected rows |
|
2404 |
" |
|
2405 |
multipleSelectOk ifFalse:[ |
|
2406 |
^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0] |
|
2407 |
]. |
|
2408 |
^ selectedRowIndex size |
|
542 | 2409 |
! |
2410 |
||
2411 |
selectColIndex:aColNr rowIndex:aRowNr |
|
2412 |
"change selection with notification |
|
2413 |
" |
|
2414 |
|oC oR| |
|
2415 |
||
607 | 2416 |
oC := self selectedColIndex. |
2417 |
oR := self selectedRowIndex. |
|
542 | 2418 |
|
2419 |
self setSelectColIndex:aColNr rowIndex:aRowNr. |
|
2420 |
||
607 | 2421 |
(oC ~~ self selectedColIndex or:[oR ~= self selectedRowIndex]) ifTrue:[ |
542 | 2422 |
self selectionChanged |
2423 |
]. |
|
2424 |
! |
|
2425 |
||
607 | 2426 |
selectRow:something |
542 | 2427 |
"select a row |
2428 |
" |
|
607 | 2429 |
^ self selectedRowIndex:something |
542 | 2430 |
! |
2431 |
||
809 | 2432 |
selectRowAt:rowNr colAt:colNr atPoint:aPoint |
2433 |
|v p| |
|
2434 |
||
2435 |
self selectColIndex:colNr rowIndex:rowNr. |
|
2436 |
||
2437 |
(v := self detectViewAt:aPoint in:editView) notNil ifTrue:[ |
|
2438 |
p := device translatePoint:aPoint from:(self id) to:(v id). |
|
2439 |
||
2440 |
self sensor pushEvent:(WindowEvent buttonEvent |
|
2441 |
for:v |
|
2442 |
type:#buttonPress:x:y: |
|
2443 |
arguments:(Array with:#select with:p x with:p y) |
|
2444 |
) |
|
2445 |
]. |
|
2446 |
||
2447 |
||
2448 |
! |
|
2449 |
||
607 | 2450 |
selectRowIndex:something |
2451 |
"set selection of rows |
|
542 | 2452 |
" |
607 | 2453 |
self selectColIndex:selectedColIndex rowIndex:something |
2454 |
||
2455 |
||
542 | 2456 |
! |
2457 |
||
2458 |
selectedColIndex |
|
2459 |
"returns selected column number or 0 |
|
2460 |
" |
|
2461 |
^ selectedColIndex |
|
2462 |
! |
|
2463 |
||
2464 |
selectedColumn |
|
2465 |
"returns selected column or nil |
|
2466 |
" |
|
2467 |
^ columnDescriptors at:selectedColIndex ifAbsent:nil. |
|
2468 |
! |
|
2469 |
||
2470 |
selectedRow |
|
607 | 2471 |
"returns selected row (or collection if multiple selection) or nil |
542 | 2472 |
" |
607 | 2473 |
multipleSelectOk ifFalse:[ |
2474 |
^ self at:selectedRowIndex ifAbsent:nil |
|
2475 |
]. |
|
2476 |
||
2477 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
2478 |
^ selectedRowIndex collect:[:i| self at:i] |
|
2479 |
]. |
|
2480 |
^ nil |
|
2481 |
! |
|
2482 |
||
2483 |
selectedRow:something |
|
2484 |
"select something |
|
2485 |
" |
|
2486 |
self selectedRowIndex:something |
|
542 | 2487 |
! |
2488 |
||
2489 |
selectedRowIndex |
|
2490 |
"returns selected row number or 0 |
|
2491 |
" |
|
2492 |
^ selectedRowIndex |
|
2493 |
! |
|
2494 |
||
607 | 2495 |
selectedRowIndex:something |
2496 |
"set selection of rows |
|
2497 |
" |
|
2498 |
self selectColIndex:selectedColIndex rowIndex:something |
|
2499 |
||
2500 |
||
542 | 2501 |
! |
2502 |
||
2503 |
selectionChanged |
|
2504 |
"selection has changed |
|
2505 |
" |
|
2506 |
self changed:#selection. |
|
2507 |
||
2508 |
actionBlock notNil ifTrue:[ |
|
607 | 2509 |
actionBlock value:(self selectedRowIndex) |
2510 |
] |
|
2511 |
! |
|
2512 |
||
2513 |
selectionIndicesDo:aOneArgBlock |
|
2514 |
"evaluate block on each row selected; the argument to the row |
|
2515 |
is the index of the selected row |
|
2516 |
" |
|
2517 |
multipleSelectOk ifFalse:[ |
|
2518 |
selectedRowIndex ~~ 0 ifTrue:[ |
|
2519 |
aOneArgBlock value:selectedRowIndex |
|
2520 |
] |
|
2521 |
] ifTrue:[ |
|
2522 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
2523 |
selectedRowIndex do:[:i| aOneArgBlock value:i ] |
|
2524 |
] |
|
542 | 2525 |
] |
2526 |
! |
|
2527 |
||
2528 |
setSelectColIndex:aColNr rowIndex:aRowNr |
|
2529 |
"change selection without notification |
|
2530 |
" |
|
833 | 2531 |
|editSpec rowNr colNr newCol oldCol oldRow sensor sglSelRow index oldSz| |
542 | 2532 |
|
607 | 2533 |
rowNr := self validateSelection:aRowNr. |
542 | 2534 |
|
607 | 2535 |
multipleSelectOk ifTrue:[ |
2536 |
colNr := (rowNr size == 1) ifTrue:[aColNr] ifFalse:[0] |
|
2537 |
] ifFalse:[ |
|
2538 |
colNr := rowNr ~~ 0 ifTrue:[aColNr] ifFalse:[0] |
|
542 | 2539 |
]. |
2540 |
||
607 | 2541 |
(colNr := colNr ? 0) ~~ 0 ifTrue:[ |
2542 |
newCol := self columnAt:colNr. |
|
2543 |
newCol rendererType == #rowSelector ifTrue:[ |
|
2544 |
colNr := 0. |
|
2545 |
newCol := nil |
|
2546 |
] ifFalse:[ |
|
2547 |
multipleSelectOk ifTrue:[sglSelRow := rowNr at:1] |
|
2548 |
ifFalse:[sglSelRow := rowNr]. |
|
2549 |
||
2550 |
(newCol canSelect:sglSelRow) ifFalse:[ |
|
2551 |
newCol := nil. |
|
2552 |
colNr := 0 |
|
2553 |
] |
|
2554 |
] |
|
2555 |
]. |
|
2556 |
||
2557 |
(rowNr = selectedRowIndex and:[colNr == selectedColIndex]) ifTrue:[ |
|
643 | 2558 |
^ self |
542 | 2559 |
]. |
2560 |
||
2561 |
"/ release old selection |
|
2562 |
||
612 | 2563 |
oldSz := self numberOfSelections. |
542 | 2564 |
oldCol := selectedColIndex. |
2565 |
oldRow := selectedRowIndex. |
|
612 | 2566 |
|
542 | 2567 |
selectedRowIndex := rowNr. |
2568 |
selectedColIndex := colNr. |
|
2569 |
||
612 | 2570 |
oldSz == 1 ifTrue:[ |
2571 |
multipleSelectOk ifTrue:[oldRow := oldRow at:1]. |
|
542 | 2572 |
|
612 | 2573 |
editValue notNil ifTrue:[ |
622 | 2574 |
editValue removeDependent:self. |
612 | 2575 |
(self columnAt:oldCol) at:oldRow put:editValue value. |
2576 |
editValue := nil |
|
2577 |
]. |
|
2578 |
editView notNil ifTrue:[ |
|
2579 |
editView destroy. |
|
2580 |
editView := nil. |
|
607 | 2581 |
] |
612 | 2582 |
]. |
2583 |
shown ifFalse:[^ self ]. |
|
542 | 2584 |
|
618 | 2585 |
oldSz > 1 ifTrue:[ "/ redraw old selection |
2586 |
oldRow do:[:aRowNr| "/ unselected if visible |
|
2587 |
self redrawRowAt:aRowNr colAt:0 |
|
2588 |
] |
|
2589 |
] ifFalse:[ |
|
2590 |
oldSz == 1 ifTrue:[ |
|
2591 |
self redrawRowAt:oldRow colAt:oldCol |
|
2592 |
] |
|
2593 |
]. |
|
2594 |
||
542 | 2595 |
"/ show new selection |
2596 |
||
2597 |
newCol notNil ifTrue:[ |
|
607 | 2598 |
self scrollToRowAt:sglSelRow colAt:colNr. |
833 | 2599 |
editSpec := newCol editorAt:sglSelRow. |
2600 |
||
2601 |
editSpec notNil ifTrue:[ |
|
607 | 2602 |
editView := SimpleView extent:( (newCol width - separatorSize) |
2603 |
@ (rowHeight - separatorSize) |
|
2604 |
) |
|
2605 |
in:self. |
|
542 | 2606 |
self updateEditViewOrigin. |
2607 |
editView viewBackground:hgLgBgColor. |
|
833 | 2608 |
editView add:(editSpec at:1). |
2609 |
||
2610 |
(editValue := (editSpec at:2)) notNil ifTrue:[ |
|
809 | 2611 |
editValue addDependent:self. |
648 | 2612 |
]. |
542 | 2613 |
editView realize. |
2614 |
] ifFalse:[ |
|
607 | 2615 |
self redrawRowAt:sglSelRow colAt:colNr |
612 | 2616 |
]. |
2617 |
] ifFalse:[ |
|
2618 |
self selectionIndicesDo:[:i| self redrawRowAt:i colAt:0 ]. |
|
2619 |
self scrollToRowAt:(self firstIndexSelected) colAt:0 |
|
2620 |
]. |
|
2621 |
||
2622 |
sensor := self sensor. "/ catch expose events |
|
2623 |
||
2624 |
[sensor hasExposeEventFor:nil] whileTrue:[ |
|
2625 |
self windowGroup processExposeEvents |
|
2626 |
]. |
|
2627 |
||
542 | 2628 |
|
607 | 2629 |
! |
2630 |
||
2631 |
validateSelection:aSelection |
|
2632 |
|newSel| |
|
2633 |
||
2634 |
newSel := aSelection. |
|
2635 |
||
618 | 2636 |
(self size == 0 or:[newSel isNil or:[newSel == 0]]) ifTrue:[ |
607 | 2637 |
^ multipleSelectOk ifFalse:[0] ifTrue:[nil] |
2638 |
]. |
|
2639 |
||
2640 |
newSel isNumber ifTrue:[ |
|
2641 |
^ multipleSelectOk ifFalse:[newSel] ifTrue:[OrderedCollection with:newSel] |
|
2642 |
]. |
|
2643 |
multipleSelectOk ifFalse:[ |
|
618 | 2644 |
newSel := self identityIndexOfRow:aSelection |
607 | 2645 |
] ifTrue:[ |
2646 |
newSel := nil. |
|
2647 |
||
2648 |
aSelection size ~~ 0 ifTrue:[ |
|
2649 |
aSelection first isNumber ifTrue:[ |
|
2650 |
newSel := aSelection |
|
2651 |
] ifFalse:[ |
|
2652 |
aSelection do:[:el||n| |
|
618 | 2653 |
(n := self identityIndexOfRow:el) ~~ 0 ifTrue:[ |
607 | 2654 |
newSel isNil ifTrue:[newSel := OrderedCollection new]. |
2655 |
newSel add:n |
|
2656 |
] |
|
2657 |
] |
|
2658 |
] |
|
2659 |
] |
|
2660 |
]. |
|
2661 |
^ newSel |
|
542 | 2662 |
! ! |
2663 |
||
2664 |
!DSVColumnView class methodsFor:'documentation'! |
|
2665 |
||
2666 |
version |
|
990 | 2667 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.42 1998-07-19 20:34:50 tz Exp $' |
542 | 2668 |
! ! |