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
|
|
18 |
selectedRowIndex rowHeight columnDescriptors viewOrigin
|
618
|
19 |
lockRowIndex rowIfAbsentBlock columnHolder registererImages list
|
|
20 |
fgColor canFit separatorSize listSizeChanged sizeOfListChanged
|
|
21 |
beDependentOfRows bgColor hgLgFgColor hgLgBgColor actionBlock
|
|
22 |
doubleClickActionBlock separatorLightColor separatorDarkColor
|
|
23 |
verticalSpacing horizontalSpacing toggleOnButton toggleOffButton
|
|
24 |
rowSelectorButton comboViewButton'
|
542
|
25 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor
|
|
26 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor
|
607
|
27 |
DefaultSeparatorDarkColor DefaultSeparatorLightColor
|
|
28 |
DefaultRowSelectorForm'
|
542
|
29 |
poolDictionaries:''
|
|
30 |
category:'Views-DataSet'
|
|
31 |
!
|
|
32 |
|
|
33 |
!DSVColumnView class methodsFor:'documentation'!
|
|
34 |
|
|
35 |
copyright
|
|
36 |
"
|
|
37 |
COPYRIGHT (c) 1997 by Claus Gittinger / eXept Software AG
|
|
38 |
All Rights Reserved
|
|
39 |
|
|
40 |
This software is furnished under a license and may be used
|
|
41 |
only in accordance with the terms of that license and with the
|
|
42 |
inclusion of the above copyright notice. This software may not
|
|
43 |
be provided or otherwise made available to, or used by, any
|
|
44 |
other person. No title to or ownership of the software is
|
|
45 |
hereby transferred.
|
|
46 |
"
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
!
|
|
51 |
|
|
52 |
documentation
|
|
53 |
"
|
|
54 |
implements a scrollable selection view based on rows and columns
|
|
55 |
|
|
56 |
[Instance variables:]
|
|
57 |
|
|
58 |
editValue <Model> current editing model
|
|
59 |
editView <View> current editing component
|
|
60 |
selectedColIndex <Integer> selected column index or 0
|
|
61 |
selectedRowIndex <Integer> selected row index or 0
|
|
62 |
rowHeight <Integer> maximum height of any row
|
|
63 |
columnDescriptors <SequancableCollection> list of column descriptors
|
|
64 |
list <SequancableCollection> list of rows
|
|
65 |
fgColor <Color> foreground color
|
|
66 |
registererImages <IdentityDictionary> list of images registered on the device
|
567
|
67 |
beDependentOfRows <Coolean> keep rows dependent; on default is disabled.
|
|
68 |
in case of enabled a row can raise a change
|
|
69 |
notification whithout a parameter which
|
|
70 |
will force a redraw of the row or the
|
|
71 |
readSelector of the column which will
|
|
72 |
redraw the cell in the row only.
|
542
|
73 |
|
|
74 |
[author:]
|
|
75 |
Claus Atzkern
|
|
76 |
|
|
77 |
[see also:]
|
|
78 |
DataSetColumnSpec
|
|
79 |
DataSetColumn
|
|
80 |
DataSetView
|
|
81 |
"
|
|
82 |
|
|
83 |
! !
|
|
84 |
|
|
85 |
!DSVColumnView class methodsFor:'defaults'!
|
|
86 |
|
607
|
87 |
defaultRowSelectorForm
|
|
88 |
|
|
89 |
DefaultRowSelectorForm isNil ifTrue:[
|
|
90 |
DefaultRowSelectorForm := Form
|
|
91 |
width:8
|
|
92 |
height:11
|
|
93 |
fromArray:#[2r01000000
|
|
94 |
2r01100000
|
|
95 |
2r01110000
|
|
96 |
2r01111000
|
|
97 |
2r01111100
|
|
98 |
2r01111110
|
|
99 |
2r01111100
|
|
100 |
2r01111000
|
|
101 |
2r01110000
|
|
102 |
2r01100000
|
|
103 |
2r01000000]
|
|
104 |
on:Display.
|
|
105 |
|
|
106 |
DefaultRowSelectorForm := DefaultRowSelectorForm asImage.
|
|
107 |
].
|
|
108 |
^ DefaultRowSelectorForm
|
|
109 |
|
|
110 |
!
|
|
111 |
|
563
|
112 |
horizontalSpacing
|
|
113 |
^ 4
|
|
114 |
|
|
115 |
!
|
|
116 |
|
542
|
117 |
updateStyleCache
|
|
118 |
"extract values from the styleSheet and cache them in class variables
|
|
119 |
"
|
582
|
120 |
<resource: #style (#textForegroundColor #'scrollableView.backgroundColor'
|
|
121 |
#'selection.hilightForegroundColor'
|
|
122 |
#'selection.hilightBackgroundColor' )>
|
542
|
123 |
|
|
124 |
DefaultForegroundColor := StyleSheet colorAt:'textForegroundColor' default:(Color black).
|
582
|
125 |
DefaultBackgroundColor := StyleSheet at:'scrollableView.backgroundColor' default:DefaultViewBackgroundColor.
|
542
|
126 |
|
582
|
127 |
DefaultHilightForegroundColor := StyleSheet colorAt:'selection.hilightForegroundColor' default:DefaultForegroundColor.
|
|
128 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'selection.hilightBackgroundColor' default:(Color veryLightGrey).
|
542
|
129 |
DefaultSeparatorDarkColor := DefaultShadowColor ? (Color grayPercent:40).
|
|
130 |
DefaultSeparatorLightColor := DefaultLightColor ? (Color grayPercent:75).
|
607
|
131 |
|
542
|
132 |
"
|
|
133 |
self updateStyleCache.
|
|
134 |
"
|
|
135 |
|
582
|
136 |
"Modified: / 26.10.1997 / 17:09:07 / cg"
|
563
|
137 |
!
|
|
138 |
|
|
139 |
verticalSpacing
|
|
140 |
^ 2
|
|
141 |
|
542
|
142 |
! !
|
|
143 |
|
|
144 |
!DSVColumnView methodsFor:'accessing'!
|
|
145 |
|
|
146 |
action:aOneArgAction
|
607
|
147 |
"set the action block to be performed on select
|
|
148 |
"
|
542
|
149 |
actionBlock := aOneArgAction
|
|
150 |
|
|
151 |
|
|
152 |
!
|
|
153 |
|
|
154 |
beDependentOfRows
|
|
155 |
"make myself dependent of any row; in this case any change notification
|
|
156 |
raised by a row is catched and the cell identified by the 'readSelector'
|
|
157 |
is redrawn. In case of a nil readSelector, the whole raw is redrawn.
|
|
158 |
-> row changed:'what'
|
|
159 |
On default the attribute is set to true (enabled).
|
|
160 |
"
|
|
161 |
^ beDependentOfRows
|
|
162 |
!
|
|
163 |
|
|
164 |
beDependentOfRows:aBool
|
|
165 |
"make myself dependent of any row; in this case any change notification
|
|
166 |
raised by a row is catched and the cell identified by the 'readSelector'
|
|
167 |
is redrawn. In case of a nil readSelector, the whole raw is redrawn.
|
|
168 |
-> row changed:'what'
|
|
169 |
On default the attribute is set to true (enabled).
|
|
170 |
"
|
|
171 |
aBool ~~ beDependentOfRows ifTrue:[
|
618
|
172 |
beDependentOfRows := aBool.
|
|
173 |
|
|
174 |
self size ~~ 0 ifTrue:[
|
|
175 |
list do:[:aRow| aRow notNil ifTrue:[
|
|
176 |
beDependentOfRows ifTrue:[aRow addDependent:self]
|
|
177 |
ifFalse:[aRow removeDependent:self]
|
|
178 |
]
|
|
179 |
]
|
542
|
180 |
]
|
618
|
181 |
]
|
607
|
182 |
!
|
|
183 |
|
|
184 |
doubleClickAction:aOneArgAction
|
|
185 |
"set the action block to be performed on doubleclick
|
|
186 |
"
|
|
187 |
doubleClickActionBlock := aOneArgAction
|
|
188 |
|
|
189 |
|
|
190 |
!
|
|
191 |
|
|
192 |
multipleSelectOk
|
|
193 |
"allow/disallow multiple row selections; the default is false
|
|
194 |
"
|
|
195 |
^ multipleSelectOk
|
|
196 |
!
|
|
197 |
|
|
198 |
multipleSelectOk:aState
|
|
199 |
"allow/disallow multiple row selections; the default is false
|
|
200 |
"
|
|
201 |
aState == multipleSelectOk ifFalse:[
|
|
202 |
multipleSelectOk := aState.
|
|
203 |
self deselect
|
|
204 |
]
|
618
|
205 |
!
|
|
206 |
|
|
207 |
rowIfAbsent:aOneArgAction
|
|
208 |
"set the action block to be performed on each 'nil' entry into the
|
|
209 |
list. The argument to the block is the index into the list. The
|
|
210 |
block returns the row which is put to the list
|
|
211 |
"
|
|
212 |
rowIfAbsentBlock := aOneArgAction
|
|
213 |
|
|
214 |
|
607
|
215 |
! !
|
|
216 |
|
|
217 |
!DSVColumnView methodsFor:'accessing buttons'!
|
|
218 |
|
|
219 |
comboViewButton
|
|
220 |
"returns the bitmap of a comboView button
|
|
221 |
"
|
|
222 |
comboViewButton isNil ifTrue:[
|
|
223 |
comboViewButton := (Image fromFile:'dsv_comboList.xpm') on:device.
|
|
224 |
comboViewButton clearMaskedPixels.
|
|
225 |
].
|
|
226 |
|
|
227 |
^ comboViewButton
|
|
228 |
!
|
|
229 |
|
|
230 |
rowSelectorButton
|
|
231 |
"returns the bitmap of a selected row
|
|
232 |
"
|
|
233 |
rowSelectorButton isNil ifTrue:[
|
|
234 |
rowSelectorButton := (self class defaultRowSelectorForm) on:device
|
|
235 |
].
|
|
236 |
^ rowSelectorButton
|
|
237 |
!
|
|
238 |
|
|
239 |
toggleOffButton
|
|
240 |
"returns the bitmap of a disabled toggle
|
|
241 |
"
|
|
242 |
toggleOffButton isNil ifTrue:[
|
|
243 |
toggleOffButton := (Image fromFile:'dsv_checkTgOff.xpm') on:device.
|
|
244 |
toggleOffButton clearMaskedPixels.
|
|
245 |
].
|
|
246 |
|
|
247 |
^ toggleOffButton
|
|
248 |
!
|
|
249 |
|
|
250 |
toggleOnButton
|
|
251 |
"returns the bitmap of an enabled toggle
|
|
252 |
"
|
|
253 |
toggleOnButton isNil ifTrue:[
|
|
254 |
toggleOnButton := (Image fromFile:'dsv_checkTgOn.xpm') on:device.
|
|
255 |
toggleOnButton clearMaskedPixels.
|
|
256 |
].
|
|
257 |
|
|
258 |
^ toggleOnButton
|
542
|
259 |
! !
|
|
260 |
|
|
261 |
!DSVColumnView methodsFor:'accessing columns'!
|
|
262 |
|
|
263 |
columnAt:anIndex
|
607
|
264 |
"returns the column at an index
|
542
|
265 |
"
|
|
266 |
^ columnDescriptors at:anIndex
|
|
267 |
!
|
|
268 |
|
|
269 |
columnDescriptors:colDesc
|
|
270 |
"set the columnDescriptors
|
|
271 |
"
|
612
|
272 |
|id sz|
|
|
273 |
|
|
274 |
sz := colDesc size.
|
607
|
275 |
|
612
|
276 |
(sz == 0 or:[selectedColIndex ~~ 0]) ifTrue:[ "/ cell selected
|
|
277 |
self deselect "/ remove selection
|
|
278 |
].
|
542
|
279 |
|
612
|
280 |
sz ~~ 0 ifTrue:[
|
607
|
281 |
id := 0.
|
|
282 |
|
542
|
283 |
columnDescriptors := colDesc collect:[:aCol|
|
607
|
284 |
id := id + 1.
|
|
285 |
DataSetColumn new on:self description:aCol columnNumber:id.
|
542
|
286 |
]
|
|
287 |
] ifFalse:[
|
|
288 |
columnDescriptors := #()
|
|
289 |
].
|
|
290 |
canFit := (columnDescriptors findFirst:[:aCol|aCol canResize]) ~~ 0.
|
|
291 |
preferredExtent := nil.
|
563
|
292 |
|
618
|
293 |
sizeOfListChanged := true.
|
542
|
294 |
self preferredExtentChanged.
|
|
295 |
|
612
|
296 |
shown ifTrue:[
|
556
|
297 |
self fitColumns ifFalse:[
|
|
298 |
self invalidate.
|
|
299 |
self contentsChanged.
|
|
300 |
]
|
563
|
301 |
].
|
|
302 |
self changed:#sizeOfColumns.
|
618
|
303 |
sizeOfListChanged := false.
|
542
|
304 |
|
|
305 |
|
|
306 |
!
|
|
307 |
|
|
308 |
firstColumn
|
607
|
309 |
"returns the first column
|
542
|
310 |
"
|
|
311 |
^ columnDescriptors at:1
|
|
312 |
|
|
313 |
!
|
|
314 |
|
|
315 |
lastColumn
|
607
|
316 |
"returns the last column
|
542
|
317 |
"
|
|
318 |
^ columnDescriptors last
|
|
319 |
|
|
320 |
! !
|
|
321 |
|
612
|
322 |
!DSVColumnView methodsFor:'accessing mvc'!
|
|
323 |
|
|
324 |
columnHolder
|
|
325 |
^ columnHolder
|
|
326 |
|
|
327 |
!
|
|
328 |
|
|
329 |
columnHolder:aValueHolder
|
|
330 |
|columns|
|
|
331 |
|
|
332 |
columnHolder notNil ifTrue:[
|
|
333 |
columnHolder removeDependent:self
|
|
334 |
].
|
|
335 |
|
|
336 |
(columnHolder := aValueHolder) notNil ifTrue:[
|
|
337 |
columnHolder addDependent:self.
|
|
338 |
columns := columnHolder value.
|
|
339 |
|
|
340 |
columns notNil ifTrue:[
|
|
341 |
self columnDescriptors:columns
|
|
342 |
]
|
|
343 |
].
|
|
344 |
|
|
345 |
! !
|
|
346 |
|
542
|
347 |
!DSVColumnView methodsFor:'accessing rows'!
|
|
348 |
|
|
349 |
at:aRowNr
|
|
350 |
"return the row at an index, aRowNr
|
|
351 |
"
|
618
|
352 |
|row|
|
|
353 |
|
|
354 |
(row := list at:aRowNr) isNil ifTrue:[
|
|
355 |
lockRowIndex := aRowNr.
|
|
356 |
|
|
357 |
(row := rowIfAbsentBlock value:aRowNr) notNil ifTrue:[
|
|
358 |
list at:aRowNr put:row.
|
|
359 |
beDependentOfRows ifTrue:[row addDependent:self].
|
|
360 |
].
|
|
361 |
|
|
362 |
lockRowIndex := 0
|
|
363 |
].
|
|
364 |
^ row
|
542
|
365 |
!
|
|
366 |
|
|
367 |
at:aRowNr ifAbsent:exceptionBlock
|
607
|
368 |
"return the row at a aRowNr. If the index is invalid, return the
|
542
|
369 |
result of evaluating the exceptionblock
|
|
370 |
"
|
618
|
371 |
(aRowNr between:1 and:self size) ifTrue:[
|
|
372 |
^ self at:aRowNr
|
|
373 |
].
|
|
374 |
^ exceptionBlock value
|
542
|
375 |
!
|
|
376 |
|
|
377 |
at:aRowNr put:aRow
|
|
378 |
"change the row at an index. The added row is returned
|
|
379 |
"
|
618
|
380 |
|row|
|
|
381 |
|
|
382 |
lockRowIndex == aRowNr ifTrue:[
|
|
383 |
^ self
|
|
384 |
].
|
|
385 |
row := list at:aRowNr.
|
|
386 |
row == aRow ifTrue:[
|
|
387 |
^ self
|
|
388 |
].
|
|
389 |
|
542
|
390 |
beDependentOfRows ifTrue:[
|
618
|
391 |
(row := list at:aRowNr) notNil ifTrue:[
|
|
392 |
row removeDependent:self
|
|
393 |
]
|
542
|
394 |
].
|
618
|
395 |
|
607
|
396 |
list at:aRowNr put:aRow.
|
618
|
397 |
|
|
398 |
aRow notNil ifTrue:[ "/ free list
|
|
399 |
beDependentOfRows ifTrue:[
|
|
400 |
aRow addDependent:self
|
|
401 |
].
|
|
402 |
self redrawRowAt:aRowNr
|
|
403 |
].
|
542
|
404 |
^ aRow.
|
|
405 |
!
|
|
406 |
|
|
407 |
first
|
|
408 |
"return the first row
|
|
409 |
"
|
618
|
410 |
^ self at:1
|
|
411 |
!
|
|
412 |
|
|
413 |
identityIndexOfRow:aRow
|
|
414 |
"returns index of a row or 0
|
|
415 |
"
|
|
416 |
(list size ~~ 0 and:[aRow notNil]) ifTrue:[
|
|
417 |
^ list identityIndexOf:aRow
|
|
418 |
].
|
|
419 |
^ 0
|
542
|
420 |
!
|
|
421 |
|
|
422 |
last
|
|
423 |
"return the last row
|
|
424 |
"
|
618
|
425 |
^ self at:(self size)
|
542
|
426 |
!
|
|
427 |
|
|
428 |
list
|
|
429 |
"get the list of rows
|
|
430 |
"
|
|
431 |
^ list
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
!
|
|
436 |
|
|
437 |
list:aList
|
|
438 |
"set the list of rows
|
|
439 |
"
|
|
440 |
|
618
|
441 |
"/ remove selection without redraw
|
622
|
442 |
|
|
443 |
editValue notNil ifTrue:[
|
|
444 |
editValue removeDependent:self.
|
|
445 |
editValue := nil
|
|
446 |
].
|
|
447 |
|
618
|
448 |
editView notNil ifTrue:[
|
|
449 |
editView destroy.
|
|
450 |
editView := nil.
|
|
451 |
].
|
622
|
452 |
|
618
|
453 |
selectedColIndex := 0.
|
|
454 |
selectedRowIndex := multipleSelectOk ifTrue:[nil] ifFalse:[0].
|
542
|
455 |
|
612
|
456 |
shown ifFalse:[
|
|
457 |
preferredExtent := nil
|
|
458 |
] ifTrue:[
|
|
459 |
aList size ~~ 0 ifTrue:[ "/ otherwise keep old values
|
|
460 |
self columnsDo:[:aCol| aCol invalidate ].
|
|
461 |
preferredExtent := nil.
|
618
|
462 |
]
|
542
|
463 |
].
|
|
464 |
|
|
465 |
beDependentOfRows ifTrue:[
|
618
|
466 |
self beDependentOfRows:false.
|
542
|
467 |
list := aList.
|
618
|
468 |
self beDependentOfRows:true.
|
542
|
469 |
] ifFalse:[
|
|
470 |
list := aList
|
|
471 |
].
|
618
|
472 |
|
542
|
473 |
list size == 0 ifTrue:[
|
|
474 |
list := nil
|
|
475 |
].
|
|
476 |
|
612
|
477 |
shown ifTrue:[
|
|
478 |
self recomputeHeightOfContents.
|
|
479 |
|
542
|
480 |
list size ~~ 0 ifTrue:[
|
|
481 |
self fitColumns ifTrue:[^ self ].
|
|
482 |
].
|
612
|
483 |
self invalidate
|
542
|
484 |
]
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
! !
|
|
489 |
|
|
490 |
!DSVColumnView methodsFor:'accessing visibility'!
|
|
491 |
|
|
492 |
backgroundColor
|
|
493 |
"get the background color of the rows
|
|
494 |
"
|
|
495 |
^ bgColor
|
|
496 |
|
|
497 |
|
|
498 |
!
|
|
499 |
|
|
500 |
backgroundColor:aColor
|
|
501 |
"set the background color of the rows
|
|
502 |
"
|
|
503 |
bgColor ~~ aColor ifTrue:[
|
|
504 |
super viewBackground:bgColor.
|
|
505 |
|
|
506 |
self realized ifTrue:[
|
|
507 |
bgColor := aColor on:device.
|
|
508 |
self invalidate
|
|
509 |
] ifFalse:[
|
|
510 |
bgColor := aColor
|
|
511 |
].
|
|
512 |
self changed:#style.
|
|
513 |
]
|
|
514 |
!
|
|
515 |
|
|
516 |
font:aFont
|
|
517 |
"set the font for all shown rows.
|
|
518 |
"
|
|
519 |
(aFont notNil and:[aFont ~~ font]) ifTrue:[
|
|
520 |
super font:(aFont on:device).
|
|
521 |
self columnsDo:[:aCol| aCol invalidate ].
|
|
522 |
self preferredExtentChanged.
|
|
523 |
|
|
524 |
realized ifTrue:[
|
|
525 |
self invalidate.
|
|
526 |
self contentsChanged
|
|
527 |
].
|
|
528 |
self changed:#style.
|
|
529 |
]
|
|
530 |
|
|
531 |
!
|
|
532 |
|
|
533 |
foregroundColor
|
|
534 |
"return the foreground color of the rows
|
|
535 |
"
|
|
536 |
^ fgColor
|
|
537 |
|
|
538 |
!
|
|
539 |
|
|
540 |
foregroundColor:aColor
|
|
541 |
"set the foreground color of the rows
|
|
542 |
"
|
|
543 |
fgColor ~~ aColor ifTrue:[
|
|
544 |
self realized ifTrue:[
|
|
545 |
fgColor := aColor on:device.
|
|
546 |
self invalidate
|
|
547 |
] ifFalse:[
|
|
548 |
fgColor := aColor
|
|
549 |
].
|
|
550 |
self changed:#style.
|
|
551 |
]
|
|
552 |
|
|
553 |
!
|
|
554 |
|
607
|
555 |
has3Dseparators
|
|
556 |
"returns true if shown in 3D mode
|
|
557 |
"
|
|
558 |
^ separatorSize ~~ 1
|
542
|
559 |
!
|
|
560 |
|
607
|
561 |
has3Dseparators:aBool
|
|
562 |
"enable or disable 3D mode
|
|
563 |
"
|
|
564 |
|newSepSize|
|
542
|
565 |
|
607
|
566 |
newSepSize := aBool ifTrue:[4] ifFalse:[1].
|
|
567 |
|
|
568 |
newSepSize ~~ separatorSize ifTrue:[
|
|
569 |
separatorSize := newSepSize.
|
|
570 |
|
542
|
571 |
self columnsDo:[:aCol| aCol invalidate ].
|
|
572 |
self preferredExtentChanged.
|
|
573 |
|
|
574 |
realized ifTrue:[
|
|
575 |
self invalidate.
|
|
576 |
self contentsChanged
|
|
577 |
].
|
|
578 |
self changed:#style.
|
|
579 |
]
|
|
580 |
|
|
581 |
|
|
582 |
!
|
|
583 |
|
|
584 |
hgLgBgColor
|
607
|
585 |
"returns the background color of a selected row
|
|
586 |
"
|
542
|
587 |
^ hgLgBgColor
|
|
588 |
!
|
|
589 |
|
|
590 |
hgLgFgColor
|
607
|
591 |
"returns the foreground color of a selected row
|
|
592 |
"
|
542
|
593 |
^ hgLgFgColor
|
|
594 |
!
|
|
595 |
|
|
596 |
horizontalSpacing
|
|
597 |
"horizontal spacing used by columns
|
|
598 |
"
|
563
|
599 |
^ horizontalSpacing
|
|
600 |
!
|
|
601 |
|
|
602 |
horizontalSpacing:aNumber
|
|
603 |
"horizontal spacing used by columns
|
|
604 |
"
|
|
605 |
horizontalSpacing ~~ aNumber ifTrue:[
|
|
606 |
horizontalSpacing := aNumber.
|
|
607 |
self preferredExtentChanged.
|
|
608 |
].
|
542
|
609 |
!
|
|
610 |
|
|
611 |
separatorDarkColor
|
607
|
612 |
"returns the dark color used for drawing a shadowed separator (3D)
|
|
613 |
"
|
542
|
614 |
^ separatorDarkColor
|
|
615 |
|
|
616 |
|
|
617 |
!
|
|
618 |
|
|
619 |
separatorLightColor
|
607
|
620 |
"returns the light color used for drawing a shadowed separator (3D)
|
|
621 |
"
|
542
|
622 |
^ separatorLightColor
|
|
623 |
|
|
624 |
|
|
625 |
!
|
|
626 |
|
|
627 |
verticalSpacing
|
|
628 |
"vertical spacing used by columns
|
|
629 |
"
|
563
|
630 |
^ verticalSpacing
|
|
631 |
!
|
|
632 |
|
|
633 |
verticalSpacing:aNumber
|
|
634 |
"vertical spacing used by columns
|
|
635 |
"
|
|
636 |
verticalSpacing ~~ aNumber ifTrue:[
|
|
637 |
verticalSpacing := aNumber.
|
|
638 |
self preferredExtentChanged.
|
|
639 |
].
|
542
|
640 |
! !
|
|
641 |
|
|
642 |
!DSVColumnView methodsFor:'adding & removing rows'!
|
|
643 |
|
|
644 |
add:aRow
|
618
|
645 |
"insert row at end
|
542
|
646 |
"
|
618
|
647 |
^ self add:aRow beforeIndex:(1 + self size)
|
542
|
648 |
!
|
|
649 |
|
|
650 |
add:aRow afterIndex:aRowNr
|
|
651 |
"add a new row after slot aRowNr and redisplay; returns nil in case
|
618
|
652 |
of an invalid index or the row
|
542
|
653 |
"
|
|
654 |
^ self add:aRow beforeIndex:(aRowNr + 1)
|
|
655 |
!
|
|
656 |
|
|
657 |
add:aRow beforeIndex:aRowNr
|
|
658 |
"add a new row before slot aRowNr and redisplay; returns nil in case
|
618
|
659 |
of an invalid index or the row
|
542
|
660 |
"
|
545
|
661 |
|y0 y1 h dH|
|
542
|
662 |
|
|
663 |
list isNil ifTrue:[
|
|
664 |
list := OrderedCollection new.
|
|
665 |
preferredExtent := nil. "/ force a recomputation
|
|
666 |
] ifFalse:[
|
618
|
667 |
list := list asOrderedCollection
|
|
668 |
].
|
|
669 |
beDependentOfRows ifTrue:[
|
|
670 |
aRow notNil ifTrue:[aRow addDependent:self].
|
542
|
671 |
].
|
|
672 |
list add:aRow beforeIndex:aRowNr.
|
|
673 |
self recomputeHeightOfContents.
|
|
674 |
|
607
|
675 |
(y0 := self numberOfSelections) ~~ 0 ifTrue:[
|
|
676 |
y0 == 1 ifTrue:[
|
|
677 |
(y0 := self firstIndexSelected) >= aRowNr ifTrue:[
|
|
678 |
y0 := y0 + 1.
|
|
679 |
multipleSelectOk ifFalse:[
|
|
680 |
selectedRowIndex := y0
|
|
681 |
] ifTrue:[
|
|
682 |
selectedRowIndex at:1 put:y0
|
|
683 |
]
|
|
684 |
]
|
|
685 |
] ifFalse:[
|
|
686 |
self deselect
|
|
687 |
]
|
542
|
688 |
].
|
|
689 |
y0 := (aRowNr - 1) * rowHeight.
|
|
690 |
|
|
691 |
y0 < viewOrigin y ifTrue:[
|
|
692 |
self originWillChange.
|
|
693 |
viewOrigin y:(rowHeight + viewOrigin y).
|
|
694 |
self originChanged:(0 @ rowHeight).
|
|
695 |
].
|
|
696 |
shown ifTrue:[
|
|
697 |
y0 := self yVisibleOfRowNr:aRowNr.
|
|
698 |
y1 := y0 + rowHeight.
|
|
699 |
|
|
700 |
(y1 > margin and:[y0 < (height - margin)]) ifTrue:[
|
|
701 |
h := height - margin - y1.
|
|
702 |
y0 := y0 max:margin.
|
|
703 |
dH := y1 - y0.
|
|
704 |
self catchExpose.
|
561
|
705 |
|
542
|
706 |
self copyFrom:self x:0 y:y0
|
|
707 |
toX:0 y:y1
|
|
708 |
width:width height:h async:true.
|
|
709 |
self waitForExpose.
|
|
710 |
self redrawX:margin y:y0 width:width height:dH.
|
|
711 |
]
|
|
712 |
].
|
618
|
713 |
sizeOfListChanged := true.
|
542
|
714 |
self contentsChanged.
|
618
|
715 |
sizeOfListChanged := false.
|
542
|
716 |
^ aRow
|
|
717 |
!
|
|
718 |
|
567
|
719 |
addAll:aCollection beforeIndex:aRowNr
|
|
720 |
"add a collection of rows before slot aRowNr and redisplay
|
|
721 |
"
|
|
722 |
aCollection size ~~ 0 ifTrue:[
|
618
|
723 |
self size == 0 ifTrue:[
|
567
|
724 |
^ self list:aCollection
|
|
725 |
].
|
|
726 |
aCollection reverseDo:[:aRow|
|
|
727 |
self add:aRow beforeIndex:aRowNr
|
|
728 |
]
|
|
729 |
].
|
|
730 |
!
|
|
731 |
|
542
|
732 |
addFirst:aRow
|
618
|
733 |
"insert a row at start
|
542
|
734 |
"
|
|
735 |
^ self add:aRow beforeIndex:1
|
|
736 |
!
|
|
737 |
|
|
738 |
removeFirst
|
|
739 |
"remove first row; returns the removed row
|
|
740 |
"
|
|
741 |
self removeIndex:1
|
|
742 |
!
|
|
743 |
|
|
744 |
removeIndex:aRowNr
|
|
745 |
"remove row at an index; returns the removed row
|
|
746 |
"
|
545
|
747 |
|y0 y1 h dY oY yB noRedraw row|
|
542
|
748 |
|
|
749 |
row := list at:aRowNr ifAbsent:[^ self subscriptBoundsError:aRowNr].
|
618
|
750 |
|
|
751 |
(beDependentOfRows and:[row notNil]) ifTrue:[
|
|
752 |
row removeDependent:self
|
|
753 |
].
|
|
754 |
|
607
|
755 |
list isArray ifTrue:[list := list asOrderedCollection].
|
542
|
756 |
|
607
|
757 |
(y0 := self numberOfSelections) ~~ 0 ifTrue:[
|
|
758 |
y0 == 1 ifTrue:[
|
|
759 |
(y0 := self firstIndexSelected) > aRowNr ifTrue:[
|
|
760 |
y0 := y0 - 1.
|
|
761 |
multipleSelectOk ifFalse:[
|
|
762 |
selectedRowIndex := y0
|
|
763 |
] ifTrue:[
|
|
764 |
selectedRowIndex at:1 put:y0
|
|
765 |
]
|
|
766 |
]
|
|
767 |
] ifFalse:[
|
|
768 |
self deselect
|
542
|
769 |
]
|
|
770 |
].
|
|
771 |
y1 := aRowNr * rowHeight.
|
|
772 |
y0 := y1 - rowHeight.
|
|
773 |
yB := y1 + margin - viewOrigin y.
|
|
774 |
|
|
775 |
list removeIndex:aRowNr.
|
|
776 |
self recomputeHeightOfContents.
|
|
777 |
|
|
778 |
y0 < (oY := viewOrigin y) ifTrue:[
|
|
779 |
(noRedraw := y1 <= oY) ifFalse:[dY := y0 - oY]
|
|
780 |
ifTrue:[dY := rowHeight negated].
|
|
781 |
self originWillChange.
|
|
782 |
viewOrigin y:(dY + oY).
|
|
783 |
self originChanged:(0 @ dY).
|
|
784 |
] ifFalse:[
|
|
785 |
noRedraw := y0 > (height + viewOrigin y)
|
|
786 |
].
|
|
787 |
|
|
788 |
(noRedraw or:[shown not]) ifFalse:[
|
|
789 |
y1 := yB.
|
|
790 |
y0 := self yVisibleOfRowNr:aRowNr.
|
|
791 |
h := height - margin - yB.
|
|
792 |
y0 := y0 max:margin.
|
|
793 |
|
561
|
794 |
h > 0 ifTrue:[
|
|
795 |
self catchExpose.
|
|
796 |
self copyFrom:self x:0 y:yB toX:0 y:y0 width:width height:h async:true.
|
|
797 |
self waitForExpose.
|
|
798 |
].
|
542
|
799 |
y0 := y0 + h.
|
|
800 |
self redrawX:margin y:y0 width:width height:(height - y0).
|
|
801 |
].
|
618
|
802 |
sizeOfListChanged := true.
|
542
|
803 |
self contentsChanged.
|
618
|
804 |
sizeOfListChanged := false.
|
542
|
805 |
|
|
806 |
^ row.
|
|
807 |
!
|
|
808 |
|
|
809 |
removeLast
|
|
810 |
"remove last row; the row is returned
|
|
811 |
"
|
618
|
812 |
^ self removeIndex:self size
|
542
|
813 |
! !
|
|
814 |
|
|
815 |
!DSVColumnView methodsFor:'change & update'!
|
|
816 |
|
|
817 |
update:something with:aParameter from:changedObject
|
|
818 |
"one of my rows/cells changed its value
|
|
819 |
"
|
618
|
820 |
|row|
|
542
|
821 |
|
612
|
822 |
changedObject == columnHolder ifTrue:[
|
|
823 |
^ self columnDescriptors:(columnHolder value)
|
622
|
824 |
].
|
|
825 |
|
|
826 |
changedObject == editValue ifTrue:[
|
|
827 |
^ self selectedColumn at:(self firstIndexSelected) put:(editValue value)
|
|
828 |
].
|
|
829 |
|
|
830 |
row := (something isNumber) ifTrue:[something] ifFalse:[changedObject].
|
|
831 |
self redrawVisibleRow:row.
|
542
|
832 |
! !
|
|
833 |
|
|
834 |
!DSVColumnView methodsFor:'enumerating columns'!
|
|
835 |
|
|
836 |
columnsDo:aOneArgBlock
|
|
837 |
"evaluate the argument, aOneArgBlock for every column
|
|
838 |
"
|
|
839 |
columnDescriptors do:aOneArgBlock
|
|
840 |
|
|
841 |
|
|
842 |
!
|
|
843 |
|
|
844 |
columnsFrom:start to:stop do:aOneArgBlock
|
|
845 |
"evaluate the argument, aOneArgBlock for the columns with index start to
|
|
846 |
stop in the collection of column descriptors
|
|
847 |
"
|
|
848 |
columnDescriptors from:start to:stop do:aOneArgBlock
|
|
849 |
|
|
850 |
|
|
851 |
! !
|
|
852 |
|
|
853 |
!DSVColumnView methodsFor:'event handling'!
|
|
854 |
|
607
|
855 |
buttonMotion:buttonMask x:x y:y
|
|
856 |
"mouse-move while button was pressed - handle multiple selection changes
|
|
857 |
"
|
|
858 |
|idx size scr|
|
|
859 |
|
|
860 |
self sensor ctrlDown ifTrue:[^ self ].
|
|
861 |
|
|
862 |
(multipleSelectOk and:[selectedColIndex == 0 and:[selectedRowIndex notNil]]) ifFalse:[
|
|
863 |
^ self
|
|
864 |
].
|
|
865 |
"is it the select or 1-button ?"
|
|
866 |
|
|
867 |
(device buttonMotionMask:buttonMask includesButton:#select) ifFalse:[
|
|
868 |
(device buttonMotionMask:buttonMask includesButton:1) ifFalse:[
|
|
869 |
^ self
|
|
870 |
].
|
|
871 |
].
|
|
872 |
|
|
873 |
scr := 0.
|
|
874 |
|
|
875 |
y > height ifTrue:[
|
|
876 |
scr := rowHeight.
|
|
877 |
idx := self yVisibleToRowNr:(height + rowHeight).
|
|
878 |
] ifFalse:[
|
|
879 |
y < 0 ifTrue:[
|
|
880 |
scr := rowHeight negated.
|
|
881 |
idx := self yVisibleToRowNr:scr.
|
|
882 |
] ifFalse:[
|
|
883 |
idx := self yVisibleToRowNr:y.
|
|
884 |
]
|
|
885 |
].
|
|
886 |
|
|
887 |
(idx isNil or:[idx < 1]) ifTrue:[^ self].
|
|
888 |
|
|
889 |
(self isInSelection:idx) ifTrue:[
|
|
890 |
^ self
|
|
891 |
].
|
|
892 |
|
|
893 |
selectedRowIndex := selectedRowIndex asOrderedCollection.
|
|
894 |
selectedRowIndex add:idx.
|
|
895 |
|
|
896 |
scr == 0 ifTrue:[
|
|
897 |
self redrawRowAt:idx
|
|
898 |
] ifFalse:[
|
|
899 |
self scrollTo:(viewOrigin + (0 @ scr)) redraw:true
|
|
900 |
].
|
|
901 |
self selectionChanged.
|
|
902 |
!
|
|
903 |
|
542
|
904 |
buttonMultiPress:button x:x y:y
|
|
905 |
"a button was pressed twice - handle doubleclick here
|
|
906 |
"
|
|
907 |
((button == 1) or:[button == #select]) ifFalse:[
|
|
908 |
^ super buttonMultiPress:button x:x y:y
|
|
909 |
].
|
607
|
910 |
self numberOfSelections == 1 ifTrue:[
|
|
911 |
self firstIndexSelected == (self yVisibleToRowNr:y) ifTrue:[
|
|
912 |
( selectedColIndex == 0
|
|
913 |
or:[selectedColIndex == (self xVisibleToColNr:x)]
|
|
914 |
) ifTrue:[
|
|
915 |
self doubleClicked
|
|
916 |
]
|
542
|
917 |
]
|
|
918 |
]
|
|
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
923 |
!
|
|
924 |
|
|
925 |
buttonPress:button x:x y:y
|
|
926 |
"a button was pressed - handle selection here
|
|
927 |
"
|
607
|
928 |
|rowNr colNr menu col sz|
|
542
|
929 |
|
|
930 |
( (rowNr := self yVisibleToRowNr:y) notNil
|
|
931 |
and:[(colNr := self xVisibleToColNr:x) notNil]
|
|
932 |
) ifTrue:[
|
607
|
933 |
((button == 2) or:[button == #menu]) ifTrue:[
|
|
934 |
(self numberOfSelections == 1 and:[self firstIndexSelected == rowNr]) ifTrue:[
|
|
935 |
selectedColIndex == colNr ifTrue:[ "/ cell menu ?
|
|
936 |
menu := self selectedColumn menuForRow:(self at:rowNr).
|
542
|
937 |
menu notNil ifTrue:[
|
|
938 |
^ menu startUp
|
|
939 |
].
|
|
940 |
].
|
607
|
941 |
col := columnDescriptors detect:[:c| c rendererType == #rowSelector]
|
|
942 |
ifNone:[nil].
|
|
943 |
|
|
944 |
col notNil ifTrue:[ "/ row menu ?
|
|
945 |
menu := col menuForRow:(self at:rowNr).
|
|
946 |
menu notNil ifTrue:[
|
|
947 |
^ menu startUp
|
|
948 |
]
|
|
949 |
] "/ view menu
|
|
950 |
]
|
542
|
951 |
] ifFalse:[
|
607
|
952 |
((button == 1) or:[button == #select]) ifTrue:[
|
|
953 |
(multipleSelectOk not or:[self sensor ctrlDown not]) ifFalse:[
|
|
954 |
selectedColIndex ~~ 0 ifTrue:[
|
|
955 |
colNr := 0
|
|
956 |
] ifFalse:[
|
|
957 |
(sz := self numberOfSelections == 0) ifFalse:[
|
|
958 |
(self isInSelection:rowNr) ifTrue:[
|
|
959 |
sz == 1 ifTrue:[
|
|
960 |
self selectColIndex:0 rowIndex:nil.
|
|
961 |
^ self sensor flushMotionEventsFor:self.
|
|
962 |
].
|
|
963 |
selectedRowIndex remove:rowNr.
|
|
964 |
] ifFalse:[
|
|
965 |
selectedRowIndex add:rowNr
|
|
966 |
].
|
|
967 |
self redrawRowAt:rowNr.
|
|
968 |
self selectionChanged.
|
|
969 |
^ self sensor flushMotionEventsFor:self.
|
|
970 |
]
|
|
971 |
]
|
|
972 |
].
|
542
|
973 |
^ self selectColIndex:colNr rowIndex:rowNr
|
|
974 |
]
|
|
975 |
]
|
|
976 |
].
|
|
977 |
^ super buttonPress:button x:x y:y
|
|
978 |
|
|
979 |
|
|
980 |
!
|
|
981 |
|
|
982 |
contentsChanged
|
|
983 |
"contents changed - move origin up if possible
|
|
984 |
"
|
|
985 |
|y|
|
|
986 |
|
|
987 |
shown ifTrue:[
|
|
988 |
self recomputeHeightOfContents.
|
|
989 |
y := self maxViewOriginY.
|
|
990 |
|
|
991 |
viewOrigin y > y ifTrue:[
|
|
992 |
self scrollTo:(viewOrigin x @ y)
|
|
993 |
] ifFalse:[
|
|
994 |
self updateEditViewOrigin.
|
|
995 |
]
|
|
996 |
].
|
|
997 |
super contentsChanged
|
|
998 |
|
|
999 |
|
|
1000 |
!
|
|
1001 |
|
|
1002 |
doubleClicked
|
|
1003 |
"handle a double click
|
|
1004 |
"
|
|
1005 |
(doubleClickActionBlock notNil and:[self hasSelection]) ifTrue:[
|
607
|
1006 |
doubleClickActionBlock value:(self firstIndexSelected)
|
542
|
1007 |
].
|
|
1008 |
!
|
|
1009 |
|
|
1010 |
keyPress:key x:x y:y
|
|
1011 |
"a key was pressed - handle page-keys here
|
|
1012 |
"
|
|
1013 |
<resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown
|
|
1014 |
#BeginOfText #EndOfText
|
|
1015 |
#ScrollUp #ScrollDown
|
|
1016 |
#CursorUp #CursorDown #CursorRight #CursorLeft)>
|
|
1017 |
|
607
|
1018 |
|sensor n max idx col selRowNr|
|
542
|
1019 |
|
|
1020 |
(key == #PreviousPage) ifTrue: [^ self pageUp].
|
|
1021 |
(key == #NextPage) ifTrue: [^ self pageDown].
|
|
1022 |
(key == #HalfPageUp) ifTrue: [^ self halfPageUp].
|
|
1023 |
(key == #HalfPageDown) ifTrue: [^ self halfPageDown].
|
|
1024 |
|
|
1025 |
(key == #BeginOfText) ifTrue:[^ self scrollToTop].
|
|
1026 |
(key == #EndOfText) ifTrue:[^ self scrollToBottom].
|
|
1027 |
|
|
1028 |
sensor := self sensor.
|
|
1029 |
|
|
1030 |
(key == #ScrollUp) ifTrue:[
|
|
1031 |
sensor isNil ifTrue:[
|
|
1032 |
n := 1
|
|
1033 |
] ifFalse:[
|
|
1034 |
n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollUp).
|
|
1035 |
].
|
|
1036 |
^ self scrollUp:(n * self verticalScrollStep)
|
|
1037 |
].
|
|
1038 |
(key == #ScrollDown) ifTrue:[
|
|
1039 |
sensor isNil ifTrue:[
|
|
1040 |
n := 1
|
|
1041 |
] ifFalse:[
|
|
1042 |
n := 1 + (sensor compressKeyPressEventsWithKey:#ScrollDown).
|
|
1043 |
].
|
|
1044 |
^ self scrollDown:(n * self verticalScrollStep)
|
|
1045 |
].
|
607
|
1046 |
self numberOfSelections == 1 ifFalse:[^ self].
|
|
1047 |
selRowNr := self firstIndexSelected.
|
542
|
1048 |
|
|
1049 |
key == #Return ifTrue:[
|
|
1050 |
^ self doubleClicked
|
|
1051 |
].
|
618
|
1052 |
max := self size.
|
542
|
1053 |
|
|
1054 |
(key == #CursorUp or:[key == #CursorDown]) ifTrue:[
|
|
1055 |
sensor isNil ifTrue:[
|
|
1056 |
n := 1
|
|
1057 |
] ifFalse:[
|
|
1058 |
n := 1 + (sensor compressKeyPressEventsWithKey:key).
|
|
1059 |
].
|
|
1060 |
(n := n \\ max) == 0 ifTrue:[^ self ].
|
|
1061 |
|
|
1062 |
key == #CursorUp ifTrue:[
|
607
|
1063 |
(n := selRowNr - n) <= 0 ifTrue:[n := max + n]
|
542
|
1064 |
] ifFalse:[
|
607
|
1065 |
(n := selRowNr + n) > max ifTrue:[n := n - max]
|
542
|
1066 |
].
|
|
1067 |
^ self selectColIndex:selectedColIndex rowIndex:n.
|
|
1068 |
].
|
|
1069 |
|
612
|
1070 |
selectedColIndex == 0 ifTrue:[ "/ line selected
|
|
1071 |
^ self
|
|
1072 |
].
|
|
1073 |
|
542
|
1074 |
(key == #CursorRight or:[key == #CursorLeft]) ifTrue:[
|
|
1075 |
sensor isNil ifTrue:[
|
|
1076 |
n := 1
|
|
1077 |
] ifFalse:[
|
|
1078 |
n := 1 + (sensor compressKeyPressEventsWithKey:key).
|
|
1079 |
].
|
|
1080 |
idx := selectedColIndex.
|
|
1081 |
max := self numberOfColumns.
|
|
1082 |
|
|
1083 |
key == #CursorLeft ifTrue:[
|
|
1084 |
[n ~~ 0] whileTrue:[
|
|
1085 |
(idx := idx - 1) == 0 ifTrue:[idx := max].
|
607
|
1086 |
((self columnAt:idx) canSelect:selRowNr) ifTrue:[n := n - 1]
|
542
|
1087 |
]
|
|
1088 |
] ifFalse:[
|
|
1089 |
[n ~~ 0] whileTrue:[
|
|
1090 |
idx == max ifTrue:[idx := 1]
|
|
1091 |
ifFalse:[idx := idx + 1].
|
607
|
1092 |
((self columnAt:idx) canSelect:selRowNr) ifTrue:[n := n - 1]
|
542
|
1093 |
]
|
|
1094 |
].
|
|
1095 |
|
607
|
1096 |
^ self selectColIndex:idx rowIndex:selRowNr.
|
542
|
1097 |
].
|
618
|
1098 |
(rowIfAbsentBlock isNil and:[key isCharacter]) ifFalse:[
|
563
|
1099 |
^ self
|
|
1100 |
].
|
542
|
1101 |
|
|
1102 |
col := self columnAt:selectedColIndex.
|
|
1103 |
|
|
1104 |
"/ search forward
|
618
|
1105 |
|
|
1106 |
max > selRowNr ifTrue:[
|
|
1107 |
idx := col findRowNrStartingWithChar:key start:(selRowNr + 1) stop:max.
|
|
1108 |
] ifFalse:[
|
|
1109 |
idx := 0
|
|
1110 |
].
|
542
|
1111 |
|
|
1112 |
idx == 0 ifTrue:[
|
618
|
1113 |
selRowNr ~~ 1 ifTrue:[
|
|
1114 |
"/ search from begin
|
|
1115 |
idx := col findRowNrStartingWithChar:key start:1 stop:(selRowNr - 1).
|
|
1116 |
]
|
542
|
1117 |
].
|
|
1118 |
idx ~~ 0 ifTrue:[
|
|
1119 |
self selectColIndex:selectedColIndex rowIndex:idx.
|
|
1120 |
].
|
|
1121 |
|
|
1122 |
|
|
1123 |
|
|
1124 |
|
|
1125 |
|
|
1126 |
!
|
|
1127 |
|
|
1128 |
originChanged:delta
|
|
1129 |
"this one is sent, after the origin of my contents has changed -
|
|
1130 |
tell dependents (i.e. scrollers) about this
|
|
1131 |
"
|
|
1132 |
super originChanged:delta.
|
|
1133 |
self updateEditViewOrigin.
|
|
1134 |
!
|
|
1135 |
|
|
1136 |
sizeChanged:how
|
|
1137 |
"size changed - move origin up if possible
|
|
1138 |
"
|
|
1139 |
super sizeChanged:how.
|
|
1140 |
|
|
1141 |
(shown and:[self numberOfColumns ~~ 0 and:[self fitColumns not]]) ifTrue:[
|
|
1142 |
self scrollTo:viewOrigin. "/ validates viewOrigin
|
|
1143 |
self invalidate.
|
|
1144 |
self scrollToSelection
|
|
1145 |
]
|
|
1146 |
|
|
1147 |
! !
|
|
1148 |
|
|
1149 |
!DSVColumnView methodsFor:'gc operations'!
|
|
1150 |
|
|
1151 |
registerImage:anImage key:aKey
|
|
1152 |
"any row can register an image with a unique identifier a key symbol
|
|
1153 |
"
|
|
1154 |
|img|
|
|
1155 |
|
|
1156 |
(img := registererImages at:aKey ifAbsent:nil) notNil ifTrue:[
|
|
1157 |
^ img
|
|
1158 |
].
|
567
|
1159 |
img := anImage onDevice:device.
|
|
1160 |
img clearMaskedPixels.
|
|
1161 |
registererImages at:aKey put:img.
|
|
1162 |
^ img
|
542
|
1163 |
!
|
|
1164 |
|
|
1165 |
registeredImageAt:aKey
|
|
1166 |
"any row can register an image with a unique identifier
|
|
1167 |
"
|
|
1168 |
^ registererImages at:aKey ifAbsent:nil
|
|
1169 |
!
|
|
1170 |
|
|
1171 |
releaseAllRegisteredImages
|
|
1172 |
"release all registered images
|
|
1173 |
"
|
|
1174 |
registererImages := IdentityDictionary new.
|
|
1175 |
! !
|
|
1176 |
|
|
1177 |
!DSVColumnView methodsFor:'initialization'!
|
|
1178 |
|
|
1179 |
create
|
607
|
1180 |
"set color on device
|
542
|
1181 |
"
|
|
1182 |
super create.
|
|
1183 |
fgColor := fgColor on:device.
|
|
1184 |
bgColor := bgColor on:device.
|
|
1185 |
hgLgFgColor := hgLgFgColor on:device.
|
|
1186 |
hgLgBgColor := hgLgBgColor on:device.
|
|
1187 |
separatorLightColor := separatorLightColor on:device.
|
|
1188 |
separatorDarkColor := separatorDarkColor on:device.
|
|
1189 |
|
|
1190 |
!
|
|
1191 |
|
|
1192 |
destroy
|
|
1193 |
"remove dependencies
|
|
1194 |
"
|
618
|
1195 |
self columnHolder:nil.
|
|
1196 |
self beDependentOfRows:false.
|
542
|
1197 |
super destroy
|
|
1198 |
!
|
|
1199 |
|
|
1200 |
initStyle
|
607
|
1201 |
"setup colors
|
|
1202 |
"
|
542
|
1203 |
super initStyle.
|
|
1204 |
|
|
1205 |
DefaultForegroundColor isNil ifTrue:[
|
|
1206 |
self class updateStyleCache
|
|
1207 |
].
|
|
1208 |
fgColor := DefaultForegroundColor.
|
|
1209 |
bgColor := DefaultBackgroundColor.
|
|
1210 |
hgLgFgColor := DefaultHilightForegroundColor.
|
|
1211 |
hgLgBgColor := DefaultHilightBackgroundColor.
|
|
1212 |
separatorDarkColor := DefaultSeparatorDarkColor.
|
|
1213 |
separatorLightColor := DefaultSeparatorLightColor.
|
|
1214 |
!
|
|
1215 |
|
|
1216 |
initialize
|
|
1217 |
"set default attributes
|
|
1218 |
"
|
|
1219 |
super initialize.
|
|
1220 |
|
607
|
1221 |
viewOrigin := 0@0.
|
|
1222 |
font := font on:device.
|
|
1223 |
rowHeight := font height.
|
|
1224 |
multipleSelectOk := false.
|
|
1225 |
selectedRowIndex := selectedColIndex := 0.
|
|
1226 |
registererImages := IdentityDictionary new.
|
|
1227 |
separatorSize := 1.
|
542
|
1228 |
columnDescriptors := #().
|
567
|
1229 |
beDependentOfRows := false.
|
618
|
1230 |
sizeOfListChanged := false.
|
563
|
1231 |
verticalSpacing := self class verticalSpacing.
|
|
1232 |
horizontalSpacing := self class horizontalSpacing.
|
610
|
1233 |
self lineWidth:0.
|
542
|
1234 |
!
|
|
1235 |
|
|
1236 |
realize
|
607
|
1237 |
"recompute contents and fit columns to view
|
542
|
1238 |
"
|
607
|
1239 |
self bitGravity:#NorthWest.
|
542
|
1240 |
self recomputeHeightOfContents.
|
|
1241 |
super realize.
|
607
|
1242 |
self fitColumns.
|
542
|
1243 |
|
607
|
1244 |
! !
|
|
1245 |
|
|
1246 |
!DSVColumnView methodsFor:'obsolete'!
|
|
1247 |
|
|
1248 |
has3Dsepartors
|
|
1249 |
"shouldn't be used any more
|
|
1250 |
"
|
|
1251 |
^ self has3Dseparators
|
|
1252 |
!
|
|
1253 |
|
|
1254 |
has3Dsepartors:aBool
|
|
1255 |
"shouldn't be used any more
|
|
1256 |
"
|
|
1257 |
self has3Dseparators:aBool
|
542
|
1258 |
|
|
1259 |
! !
|
|
1260 |
|
|
1261 |
!DSVColumnView methodsFor:'private'!
|
|
1262 |
|
|
1263 |
fitColumns
|
|
1264 |
"fit columns to view
|
|
1265 |
"
|
|
1266 |
|lastColumn dX sz expand resizables deltaWidth|
|
|
1267 |
|
|
1268 |
self canFit ifFalse:[^ false ].
|
|
1269 |
resizables := 0.
|
|
1270 |
self preferredExtent.
|
|
1271 |
|
|
1272 |
self columnsDo:[:aCol|
|
|
1273 |
aCol canResize ifTrue:[
|
|
1274 |
resizables := resizables + 1.
|
|
1275 |
deltaWidth := aCol setMinWidth.
|
|
1276 |
lastColumn := aCol.
|
|
1277 |
]
|
|
1278 |
].
|
|
1279 |
resizables == 0 ifTrue:[ ^ false ].
|
|
1280 |
|
|
1281 |
sz := self widthOfContents.
|
|
1282 |
|
|
1283 |
(expand := sz < width) ifTrue:[
|
|
1284 |
deltaWidth := width - sz + margin + margin.
|
|
1285 |
] ifFalse:[
|
|
1286 |
deltaWidth == 0 ifTrue:[ ^ false ].
|
|
1287 |
].
|
|
1288 |
|
|
1289 |
expand ifTrue:[
|
|
1290 |
(dX := deltaWidth // resizables) ~~ 0 ifTrue:[
|
|
1291 |
self columnsDo:[:aCol|aCol canResize ifTrue:[aCol growWidth:dX]]
|
|
1292 |
].
|
|
1293 |
lastColumn growWidth:(deltaWidth - (dX * resizables)).
|
|
1294 |
].
|
|
1295 |
self preferredExtentChanged.
|
612
|
1296 |
|
|
1297 |
shown ifTrue:[
|
|
1298 |
self invalidate.
|
542
|
1299 |
|
612
|
1300 |
self hasSelection ifTrue:[
|
|
1301 |
editView notNil ifTrue:[
|
|
1302 |
editView width:(self selectedColumn width - separatorSize)
|
|
1303 |
].
|
|
1304 |
self scrollToSelection.
|
542
|
1305 |
].
|
612
|
1306 |
self contentsChanged
|
542
|
1307 |
].
|
|
1308 |
^ true
|
|
1309 |
|
|
1310 |
|
|
1311 |
!
|
|
1312 |
|
|
1313 |
maxViewOriginY
|
|
1314 |
"returns the maximum possible y of the view origin
|
|
1315 |
"
|
|
1316 |
|y|
|
|
1317 |
|
|
1318 |
y := self heightOfContents - self innerHeight.
|
|
1319 |
^ y max:0
|
|
1320 |
|
|
1321 |
!
|
|
1322 |
|
|
1323 |
updateEditViewOrigin
|
|
1324 |
"update origin of the editView
|
|
1325 |
"
|
|
1326 |
|x y|
|
|
1327 |
|
|
1328 |
editView notNil ifTrue:[
|
607
|
1329 |
y := self yVisibleOfRowNr:(self firstIndexSelected).
|
|
1330 |
x := self xVisibleOfColNr:(self selectedColIndex).
|
542
|
1331 |
|
|
1332 |
editView origin:(x @ y).
|
|
1333 |
].
|
|
1334 |
|
|
1335 |
!
|
|
1336 |
|
|
1337 |
xVisibleOfColNr:aColNr
|
|
1338 |
"returns visible x assigned to a column number
|
|
1339 |
"
|
|
1340 |
|x|
|
|
1341 |
|
|
1342 |
x := margin - viewOrigin x.
|
|
1343 |
self columnsFrom:1 to:(aColNr - 1) do:[:aCol| x := x + aCol width ].
|
|
1344 |
^ x
|
|
1345 |
|
|
1346 |
!
|
|
1347 |
|
|
1348 |
xVisibleToColNr:x
|
607
|
1349 |
"returns the column number assigned to a physical x or nil
|
|
1350 |
"
|
542
|
1351 |
|x0 nr|
|
|
1352 |
|
|
1353 |
x0 := x + viewOrigin x - margin.
|
|
1354 |
nr := 1.
|
|
1355 |
|
|
1356 |
self columnsDo:[:aCol|
|
|
1357 |
(x0 := x0 - aCol width) <= 0 ifTrue:[^ nr].
|
|
1358 |
nr := nr + 1.
|
|
1359 |
].
|
|
1360 |
^ nil.
|
|
1361 |
|
|
1362 |
!
|
|
1363 |
|
|
1364 |
yVisibleOfRowNr:aRowNr
|
|
1365 |
"returns visible y assigned to the row number
|
|
1366 |
"
|
|
1367 |
^ (aRowNr - 1) * rowHeight + margin - viewOrigin y
|
|
1368 |
|
|
1369 |
!
|
|
1370 |
|
|
1371 |
yVisibleToRowNr:y
|
607
|
1372 |
"returns the row number assigned to a physical y or nil
|
542
|
1373 |
"
|
|
1374 |
|y0|
|
|
1375 |
|
|
1376 |
y0 := (y + viewOrigin y - margin) // rowHeight + 1.
|
618
|
1377 |
^ (y0 <= self size) ifTrue:[y0] ifFalse:[nil]
|
542
|
1378 |
|
|
1379 |
! !
|
|
1380 |
|
|
1381 |
!DSVColumnView methodsFor:'queries'!
|
|
1382 |
|
|
1383 |
canFit
|
|
1384 |
"returns true if columns can be fit to view
|
|
1385 |
"
|
|
1386 |
^ canFit
|
|
1387 |
!
|
|
1388 |
|
563
|
1389 |
indexOfFirstRowShown
|
|
1390 |
"returns index of first row shown
|
|
1391 |
"
|
|
1392 |
|idx|
|
|
1393 |
|
|
1394 |
idx := (self yOriginOfContents // rowHeight) + 1.
|
618
|
1395 |
^ (idx <= self size) ifTrue:[idx] ifFalse:[0]
|
563
|
1396 |
|
|
1397 |
!
|
|
1398 |
|
542
|
1399 |
numberOfColumns
|
|
1400 |
"returns number of columns
|
|
1401 |
"
|
|
1402 |
^ columnDescriptors size
|
|
1403 |
|
|
1404 |
!
|
|
1405 |
|
|
1406 |
numberOfRows
|
|
1407 |
"returns number of raws
|
|
1408 |
"
|
618
|
1409 |
^ self size
|
542
|
1410 |
|
|
1411 |
!
|
|
1412 |
|
|
1413 |
rowHeight
|
|
1414 |
"get the height of the highest row in pixels
|
|
1415 |
"
|
|
1416 |
^ rowHeight
|
|
1417 |
|
|
1418 |
!
|
|
1419 |
|
|
1420 |
separatorSize
|
|
1421 |
"returns vertical/horizontal size of a separator dependent on the
|
|
1422 |
3D effect.
|
|
1423 |
"
|
607
|
1424 |
^ separatorSize
|
542
|
1425 |
|
|
1426 |
!
|
|
1427 |
|
|
1428 |
size
|
|
1429 |
"returns number of raws
|
|
1430 |
"
|
|
1431 |
^ list size
|
|
1432 |
|
618
|
1433 |
!
|
|
1434 |
|
|
1435 |
sizeOfListChanged
|
|
1436 |
^ sizeOfListChanged
|
542
|
1437 |
! !
|
|
1438 |
|
|
1439 |
!DSVColumnView methodsFor:'recomputation'!
|
|
1440 |
|
|
1441 |
preferredExtent
|
|
1442 |
"recompute preferred extent
|
|
1443 |
"
|
|
1444 |
|x|
|
|
1445 |
|
|
1446 |
preferredExtent notNil ifTrue:[
|
|
1447 |
^ preferredExtent
|
|
1448 |
].
|
|
1449 |
x := 3.
|
|
1450 |
rowHeight := 0.
|
|
1451 |
|
|
1452 |
self columnsDo:[:aCol|
|
|
1453 |
rowHeight := (aCol heightOfHighestRow) max:rowHeight.
|
|
1454 |
x := x + (aCol minWidth).
|
|
1455 |
].
|
607
|
1456 |
rowHeight := rowHeight + separatorSize + verticalSpacing + verticalSpacing.
|
618
|
1457 |
preferredExtent := (x + margin + margin) @ (self size * rowHeight).
|
542
|
1458 |
|
607
|
1459 |
x := (rowHeight - separatorSize - font height) // 2 + font ascent.
|
542
|
1460 |
self columnsDo:[:aCol|aCol textInsetChanged:x].
|
|
1461 |
^ preferredExtent
|
|
1462 |
|
|
1463 |
|
|
1464 |
!
|
|
1465 |
|
|
1466 |
preferredExtentChanged
|
|
1467 |
|y x|
|
|
1468 |
|
|
1469 |
y := viewOrigin y.
|
|
1470 |
x := viewOrigin x.
|
|
1471 |
|
|
1472 |
(y ~~ 0 or:[x ~~ 0]) ifTrue:[
|
|
1473 |
self originWillChange.
|
|
1474 |
viewOrigin := 0 @ 0.
|
|
1475 |
preferredExtent := nil.
|
|
1476 |
self originChanged:(x negated @ y negated).
|
|
1477 |
]
|
|
1478 |
!
|
|
1479 |
|
|
1480 |
recomputeHeightOfContents
|
|
1481 |
|
|
1482 |
preferredExtent notNil ifTrue:[
|
618
|
1483 |
preferredExtent y:(rowHeight * self size)
|
542
|
1484 |
] ifFalse:[
|
|
1485 |
self preferredExtent
|
|
1486 |
].
|
|
1487 |
! !
|
|
1488 |
|
|
1489 |
!DSVColumnView methodsFor:'redrawing'!
|
|
1490 |
|
567
|
1491 |
forceRedraw
|
|
1492 |
"a redraw forced by any other component
|
|
1493 |
"
|
|
1494 |
self redraw
|
|
1495 |
!
|
|
1496 |
|
542
|
1497 |
invalidate
|
|
1498 |
"recompute extent before repair range
|
|
1499 |
"
|
|
1500 |
self recomputeHeightOfContents.
|
|
1501 |
super invalidate.
|
|
1502 |
|
|
1503 |
|
|
1504 |
!
|
|
1505 |
|
|
1506 |
redraw
|
|
1507 |
"redraw complete view
|
|
1508 |
"
|
|
1509 |
self redrawX:0 y:0 width:width height:height.
|
|
1510 |
|
|
1511 |
!
|
|
1512 |
|
|
1513 |
redrawRowAt:aRowNr
|
|
1514 |
"redraw total row at an index
|
|
1515 |
"
|
|
1516 |
self redrawRowAt:aRowNr colAt:0
|
|
1517 |
!
|
|
1518 |
|
|
1519 |
redrawRowAt:aRowNr colAt:aColNr
|
|
1520 |
"redraw visible row in case of aColNr == 0 or the column in a row;
|
|
1521 |
in case that the row/column is hidden no redraw is done
|
|
1522 |
"
|
|
1523 |
|x y h w|
|
|
1524 |
|
618
|
1525 |
(shown and:[aRowNr between:1 and:self size]) ifTrue:[
|
542
|
1526 |
h := rowHeight - 1.
|
|
1527 |
|
|
1528 |
(y := self yVisibleOfRowNr:aRowNr) < margin ifTrue:[
|
|
1529 |
(h := h + y) <= margin ifTrue:[
|
|
1530 |
^ self
|
|
1531 |
]. "/ row not visible
|
|
1532 |
h := h - margin.
|
|
1533 |
y := margin.
|
|
1534 |
] ifFalse:[
|
|
1535 |
y >= height ifTrue:[^ self].
|
|
1536 |
].
|
|
1537 |
aColNr ~~ 0 ifTrue:[ "/ redraw column in row
|
607
|
1538 |
w := (self columnAt:aColNr) width.
|
542
|
1539 |
|
|
1540 |
(x := self xVisibleOfColNr:aColNr) < margin ifTrue:[
|
|
1541 |
(w := w + x) <= margin ifTrue:[
|
|
1542 |
^ self
|
|
1543 |
]. "/ column not visible
|
|
1544 |
w := w - margin.
|
|
1545 |
x := margin.
|
|
1546 |
] ifFalse:[
|
|
1547 |
x >= width ifTrue:[^ self].
|
|
1548 |
]
|
|
1549 |
] ifFalse:[ "/ redraw whole row
|
|
1550 |
x := margin.
|
|
1551 |
w := width.
|
|
1552 |
].
|
|
1553 |
self redrawX:x y:y width:w height:h
|
|
1554 |
]
|
|
1555 |
!
|
|
1556 |
|
618
|
1557 |
redrawVisibleRow:aRow
|
|
1558 |
"redraw row if visible
|
|
1559 |
"
|
|
1560 |
|start "{ Class:SmallInteger }"
|
|
1561 |
stop "{ Class:SmallInteger }"
|
|
1562 |
|
|
|
1563 |
|
|
1564 |
(start := self indexOfFirstRowShown) ~~ 0 ifTrue:[
|
|
1565 |
stop := (start + (height // rowHeight)) min:(self size).
|
|
1566 |
|
|
1567 |
aRow isNumber ifTrue:[
|
|
1568 |
(aRow between:start and:stop) ifTrue:[
|
|
1569 |
self redrawRowAt:aRow colAt:0
|
|
1570 |
]
|
|
1571 |
] ifFalse:[
|
|
1572 |
start to:stop do:[:i|
|
|
1573 |
(self at:i) == aRow ifTrue:[
|
|
1574 |
^ self redrawRowAt:i colAt:0
|
|
1575 |
]
|
|
1576 |
]
|
|
1577 |
]
|
|
1578 |
]
|
|
1579 |
!
|
|
1580 |
|
542
|
1581 |
redrawX:x y:y width:w height:h
|
|
1582 |
"redraw part of myself immediately, given logical coordinates
|
|
1583 |
"
|
607
|
1584 |
|c0 c1 prevTrans prevClipArea clipHeight
|
|
1585 |
start "{ Class:SmallInteger }"
|
|
1586 |
stop "{ Class:SmallInteger }"
|
|
1587 |
x0 "{ Class:SmallInteger }"
|
|
1588 |
x1 "{ Class:SmallInteger }"
|
|
1589 |
yT "{ Class:SmallInteger }"
|
|
1590 |
xM "{ Class:SmallInteger }"
|
|
1591 |
yTop "{ Class:SmallInteger }"
|
|
1592 |
yBot "{ Class:SmallInteger }"
|
|
1593 |
wMinM "{ Class:SmallInteger }"
|
|
1594 |
|
|
542
|
1595 |
|
|
1596 |
shown ifFalse:[^ self].
|
|
1597 |
self paint:bgColor.
|
|
1598 |
self fillRectangleX:x y:y width:w height:h.
|
|
1599 |
|
607
|
1600 |
columnDescriptors size == 0 ifTrue:[
|
|
1601 |
^ self
|
|
1602 |
].
|
|
1603 |
yT := margin - viewOrigin y.
|
|
1604 |
c0 := y - yT.
|
542
|
1605 |
start := (c0 // rowHeight) + 1.
|
618
|
1606 |
stop := (c0 + h - 1 // rowHeight + 1) min:(self size).
|
542
|
1607 |
|
|
1608 |
stop < start ifTrue:[
|
|
1609 |
^ self
|
|
1610 |
].
|
607
|
1611 |
wMinM := width - margin.
|
|
1612 |
xM := (x + w) min:wMinM.
|
542
|
1613 |
prevTrans := transformation.
|
|
1614 |
prevClipArea := clipRect.
|
|
1615 |
clipRect := nil.
|
|
1616 |
transformation := WindowingTransformation new.
|
612
|
1617 |
clipHeight := height - margin - margin.
|
542
|
1618 |
|
612
|
1619 |
x0 := margin - viewOrigin x.
|
542
|
1620 |
yTop := (start - 1) * rowHeight.
|
|
1621 |
yBot := stop * rowHeight.
|
|
1622 |
|
607
|
1623 |
columnDescriptors do:[:aCol|
|
|
1624 |
((x1 := x0 + aCol width) > x and:[x0 < xM]) ifTrue:[
|
542
|
1625 |
c0 := x0 max:margin.
|
607
|
1626 |
c1 := x1 - c0.
|
542
|
1627 |
|
607
|
1628 |
x1 < xM ifFalse:[
|
612
|
1629 |
(c0 + c1) > wMinM ifTrue:[c1 := wMinM - c0]
|
607
|
1630 |
].
|
|
1631 |
device setClipX:c0 y:margin width:c1 height:clipHeight
|
542
|
1632 |
in:drawableId gc:gcId.
|
|
1633 |
|
607
|
1634 |
transformation translation:(x0 @ yT ).
|
542
|
1635 |
aCol drawFrom:start to:stop yTop:yTop yBot:yBot with:fgColor and:bgColor.
|
|
1636 |
].
|
|
1637 |
x0 := x1
|
|
1638 |
].
|
|
1639 |
transformation := prevTrans.
|
|
1640 |
clipRect := nil.
|
|
1641 |
prevClipArea isNil ifTrue:[device noClipIn:drawableId gc:gcId]
|
|
1642 |
ifFalse:[self clippingRectangle:prevClipArea].
|
|
1643 |
|
612
|
1644 |
|
542
|
1645 |
! !
|
|
1646 |
|
|
1647 |
!DSVColumnView methodsFor:'scroller interface'!
|
|
1648 |
|
|
1649 |
heightOfContents
|
|
1650 |
"return the height of the contents in pixels
|
|
1651 |
"
|
|
1652 |
^ self preferredExtent y
|
|
1653 |
|
|
1654 |
|
|
1655 |
!
|
|
1656 |
|
|
1657 |
innerHeight
|
|
1658 |
"returns the inner height of the contents shown
|
|
1659 |
"
|
|
1660 |
^ height - margin - margin
|
|
1661 |
|
|
1662 |
!
|
|
1663 |
|
|
1664 |
innerWidth
|
|
1665 |
"returns the inner width of the contents shown
|
|
1666 |
"
|
|
1667 |
^ width - margin - margin
|
|
1668 |
|
|
1669 |
!
|
|
1670 |
|
|
1671 |
verticalScrollStep
|
|
1672 |
"return the amount to scroll when stepping up/down.
|
|
1673 |
"
|
|
1674 |
^ rowHeight
|
|
1675 |
|
|
1676 |
|
|
1677 |
|
|
1678 |
!
|
|
1679 |
|
|
1680 |
viewOrigin
|
|
1681 |
"return the viewOrigin; thats the coordinate of the contents
|
|
1682 |
which is shown topLeft in the view.
|
|
1683 |
"
|
|
1684 |
^ viewOrigin
|
|
1685 |
|
|
1686 |
!
|
|
1687 |
|
|
1688 |
widthOfContents
|
|
1689 |
"return the width of the contents in pixels
|
|
1690 |
"
|
|
1691 |
^ self preferredExtent x
|
|
1692 |
|
|
1693 |
!
|
|
1694 |
|
|
1695 |
xOriginOfContents
|
|
1696 |
"return the horizontal origin of the contents in pixels
|
|
1697 |
"
|
|
1698 |
^ viewOrigin x
|
|
1699 |
|
|
1700 |
!
|
|
1701 |
|
|
1702 |
yOriginOfContents
|
|
1703 |
"return the vertical origin of the contents in pixels
|
|
1704 |
"
|
|
1705 |
^ viewOrigin y
|
|
1706 |
|
|
1707 |
! !
|
|
1708 |
|
|
1709 |
!DSVColumnView methodsFor:'scrolling'!
|
|
1710 |
|
|
1711 |
halfPageDown
|
|
1712 |
"scroll down half a page
|
|
1713 |
"
|
|
1714 |
self scrollDown:(self innerHeight // 2)
|
|
1715 |
|
|
1716 |
|
|
1717 |
!
|
|
1718 |
|
|
1719 |
halfPageUp
|
|
1720 |
"scroll up half a page
|
|
1721 |
"
|
|
1722 |
self scrollUp:(self innerHeight // 2)
|
|
1723 |
|
|
1724 |
!
|
|
1725 |
|
|
1726 |
scrollTo:anOrigin redraw:doRedraw
|
|
1727 |
"change origin to have newOrigin be visible at the top-left.
|
|
1728 |
"
|
|
1729 |
|x y dX dY newOrg dltOrg h innerWT innerHG|
|
|
1730 |
|
|
1731 |
shown ifFalse:[
|
|
1732 |
^ self
|
|
1733 |
].
|
612
|
1734 |
|
542
|
1735 |
[self sensor hasExposeEventFor:nil] whileTrue:[
|
|
1736 |
self windowGroup processExposeEvents
|
|
1737 |
].
|
612
|
1738 |
|
542
|
1739 |
innerWT := self innerWidth.
|
|
1740 |
innerHG := self innerHeight.
|
|
1741 |
|
|
1742 |
h := viewOrigin y.
|
|
1743 |
|
|
1744 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents
|
|
1745 |
y > (dY := self maxViewOriginY) ifTrue:[
|
|
1746 |
y := dY max:h
|
|
1747 |
]
|
|
1748 |
] ifFalse:[
|
|
1749 |
y := y max:0.
|
|
1750 |
].
|
|
1751 |
|
|
1752 |
(x := anOrigin x) > 0 ifTrue:[
|
|
1753 |
x := x min:(self widthOfContents - innerWT).
|
|
1754 |
].
|
|
1755 |
x := x max:0.
|
|
1756 |
newOrg := (x @ y).
|
|
1757 |
dltOrg := newOrg - viewOrigin.
|
|
1758 |
dX := dltOrg x.
|
|
1759 |
dY := dltOrg y.
|
|
1760 |
|
|
1761 |
(dX == 0 and:[dY == 0]) ifTrue:[
|
|
1762 |
^ self
|
|
1763 |
].
|
|
1764 |
self originWillChange.
|
|
1765 |
viewOrigin := newOrg.
|
|
1766 |
|
|
1767 |
doRedraw ifFalse:[
|
|
1768 |
^ self originChanged:dltOrg
|
|
1769 |
].
|
|
1770 |
|
|
1771 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL
|
|
1772 |
dY := dY abs.
|
|
1773 |
|
|
1774 |
(dX ~~ 0 or:[innerHG - dY < 20]) ifTrue:[
|
|
1775 |
self redraw.
|
|
1776 |
] ifFalse:[ "/ COPY VERTICAL
|
|
1777 |
|y0 y1|
|
|
1778 |
|
|
1779 |
y0 := y1 := margin + dY.
|
|
1780 |
h := innerHG - dY.
|
|
1781 |
|
|
1782 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0]
|
|
1783 |
ifFalse:[y1 := margin. y := y1 + h].
|
|
1784 |
|
|
1785 |
self catchExpose.
|
|
1786 |
self copyFrom:self x:0 y:y0 toX:0 y:y1 width:width height:h async:true.
|
|
1787 |
self waitForExpose.
|
|
1788 |
self redrawX:0 y:y width:width height:(innerHG - h).
|
|
1789 |
]
|
|
1790 |
] ifFalse:[ "/ SCROLL HORIZONTAL
|
|
1791 |
dX := dX abs.
|
|
1792 |
|
|
1793 |
innerWT - dX < 20 ifTrue:[
|
|
1794 |
self redraw.
|
|
1795 |
] ifFalse:[ "/ COPY HORIZONTAL
|
|
1796 |
|x0 x1 w|
|
|
1797 |
|
|
1798 |
x0 := x1 := dX.
|
|
1799 |
w := width - dX - margin.
|
|
1800 |
|
|
1801 |
dltOrg x < 0 ifTrue:[x0 := 0. x := x0]
|
|
1802 |
ifFalse:[x1 := 0. x := w].
|
|
1803 |
|
|
1804 |
self catchExpose.
|
|
1805 |
self copyFrom:self x:x0 y:0 toX:x1 y:0 width:w height:height async:true.
|
|
1806 |
self waitForExpose.
|
|
1807 |
self redrawX:x y:0 width:(width - w) height:height.
|
|
1808 |
]
|
|
1809 |
].
|
|
1810 |
self originChanged:dltOrg.
|
|
1811 |
!
|
|
1812 |
|
|
1813 |
scrollToRowAt:aRowNr colAt:aColNr
|
|
1814 |
"make row at a row number in column at a column number visible
|
|
1815 |
"
|
|
1816 |
|x y l dY dX|
|
|
1817 |
|
618
|
1818 |
( (aRowNr between:1 and:(self size))
|
542
|
1819 |
and:[aColNr between:0 and:(self numberOfColumns)]
|
|
1820 |
) ifFalse:[
|
|
1821 |
^ self
|
|
1822 |
].
|
|
1823 |
|
|
1824 |
dY := dX := 0.
|
|
1825 |
y := self yVisibleOfRowNr:aRowNr.
|
|
1826 |
|
|
1827 |
y < margin ifTrue:[
|
|
1828 |
dY := margin - y.
|
|
1829 |
] ifFalse:[
|
|
1830 |
y := y + rowHeight.
|
|
1831 |
l := height - margin.
|
|
1832 |
y > l ifTrue:[dY := l - y]
|
|
1833 |
].
|
|
1834 |
|
|
1835 |
aColNr == 0 ifTrue:[
|
|
1836 |
dY == 0 ifTrue:[^ self].
|
|
1837 |
dX := 0.
|
|
1838 |
] ifFalse:[
|
|
1839 |
x := self xVisibleOfColNr:aColNr.
|
|
1840 |
|
|
1841 |
x < margin ifTrue:[
|
|
1842 |
dX := margin - x
|
|
1843 |
] ifFalse:[
|
|
1844 |
x := x + (self columnAt:aColNr) width.
|
|
1845 |
l := width - margin.
|
|
1846 |
x > l ifTrue:[dX := l - x]
|
|
1847 |
]
|
|
1848 |
].
|
|
1849 |
|
|
1850 |
(dX == 0 and:[dY == 0]) ifFalse:[
|
|
1851 |
self scrollTo:(viewOrigin - (dX @ dY)).
|
|
1852 |
]
|
|
1853 |
|
|
1854 |
|
|
1855 |
!
|
|
1856 |
|
|
1857 |
scrollToSelection
|
|
1858 |
"make selection visible
|
|
1859 |
"
|
607
|
1860 |
|rowNr|
|
|
1861 |
|
|
1862 |
(rowNr := self firstIndexSelected) ~~ 0 ifTrue:[
|
|
1863 |
self scrollToRowAt:rowNr colAt:(self selectedColIndex)
|
542
|
1864 |
]
|
|
1865 |
|
|
1866 |
! !
|
|
1867 |
|
|
1868 |
!DSVColumnView methodsFor:'selection'!
|
|
1869 |
|
607
|
1870 |
deselect
|
|
1871 |
"deselect
|
|
1872 |
"
|
|
1873 |
self selectColIndex:0 rowIndex:0
|
|
1874 |
!
|
|
1875 |
|
|
1876 |
firstIndexSelected
|
|
1877 |
"returns index of first element selected or 0
|
|
1878 |
"
|
|
1879 |
multipleSelectOk ifFalse:[
|
|
1880 |
^ selectedRowIndex
|
|
1881 |
].
|
|
1882 |
selectedRowIndex size ~~ 0 ifTrue:[
|
|
1883 |
^ selectedRowIndex at:1
|
|
1884 |
].
|
|
1885 |
^ 0
|
|
1886 |
!
|
|
1887 |
|
542
|
1888 |
hasSelection
|
607
|
1889 |
"returns true if a selection exists
|
542
|
1890 |
"
|
607
|
1891 |
^ self numberOfSelections ~~ 0
|
542
|
1892 |
|
|
1893 |
|
|
1894 |
!
|
|
1895 |
|
607
|
1896 |
isInSelection:aRowNr
|
|
1897 |
"return true, if row, aRowNr is in the selection
|
542
|
1898 |
"
|
607
|
1899 |
aRowNr ~~ 0 ifTrue:[
|
|
1900 |
multipleSelectOk ifFalse:[
|
|
1901 |
^ aRowNr == selectedRowIndex
|
|
1902 |
].
|
|
1903 |
selectedRowIndex size ~~ 0 ifTrue:[
|
|
1904 |
^ selectedRowIndex includes:aRowNr
|
|
1905 |
]
|
|
1906 |
].
|
|
1907 |
^ false
|
|
1908 |
!
|
|
1909 |
|
|
1910 |
isSelected:aRowNr inColumn:aColNr
|
612
|
1911 |
"returns true if cell in a row; a row number, in a column, a column
|
|
1912 |
number is selected.
|
|
1913 |
"
|
607
|
1914 |
(self isInSelection:aRowNr) ifTrue:[
|
|
1915 |
^ (selectedColIndex == 0 or:[selectedColIndex == aColNr])
|
|
1916 |
].
|
|
1917 |
^ false
|
|
1918 |
!
|
|
1919 |
|
|
1920 |
numberOfSelections
|
|
1921 |
"return the number of selected rows
|
|
1922 |
"
|
|
1923 |
multipleSelectOk ifFalse:[
|
|
1924 |
^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0]
|
|
1925 |
].
|
|
1926 |
^ selectedRowIndex size
|
542
|
1927 |
!
|
|
1928 |
|
|
1929 |
selectColIndex:aColNr rowIndex:aRowNr
|
|
1930 |
"change selection with notification
|
|
1931 |
"
|
|
1932 |
|oC oR|
|
|
1933 |
|
607
|
1934 |
oC := self selectedColIndex.
|
|
1935 |
oR := self selectedRowIndex.
|
542
|
1936 |
|
|
1937 |
self setSelectColIndex:aColNr rowIndex:aRowNr.
|
|
1938 |
|
607
|
1939 |
(oC ~~ self selectedColIndex or:[oR ~= self selectedRowIndex]) ifTrue:[
|
542
|
1940 |
self selectionChanged
|
|
1941 |
].
|
|
1942 |
!
|
|
1943 |
|
607
|
1944 |
selectRow:something
|
542
|
1945 |
"select a row
|
|
1946 |
"
|
607
|
1947 |
^ self selectedRowIndex:something
|
542
|
1948 |
!
|
|
1949 |
|
607
|
1950 |
selectRowIndex:something
|
|
1951 |
"set selection of rows
|
542
|
1952 |
"
|
607
|
1953 |
self selectColIndex:selectedColIndex rowIndex:something
|
|
1954 |
|
|
1955 |
|
542
|
1956 |
!
|
|
1957 |
|
|
1958 |
selectedColIndex
|
|
1959 |
"returns selected column number or 0
|
|
1960 |
"
|
|
1961 |
^ selectedColIndex
|
|
1962 |
!
|
|
1963 |
|
|
1964 |
selectedColumn
|
|
1965 |
"returns selected column or nil
|
|
1966 |
"
|
|
1967 |
^ columnDescriptors at:selectedColIndex ifAbsent:nil.
|
|
1968 |
!
|
|
1969 |
|
|
1970 |
selectedRow
|
607
|
1971 |
"returns selected row (or collection if multiple selection) or nil
|
542
|
1972 |
"
|
607
|
1973 |
multipleSelectOk ifFalse:[
|
|
1974 |
^ self at:selectedRowIndex ifAbsent:nil
|
|
1975 |
].
|
|
1976 |
|
|
1977 |
selectedRowIndex size ~~ 0 ifTrue:[
|
|
1978 |
^ selectedRowIndex collect:[:i| self at:i]
|
|
1979 |
].
|
|
1980 |
^ nil
|
|
1981 |
!
|
|
1982 |
|
|
1983 |
selectedRow:something
|
|
1984 |
"select something
|
|
1985 |
"
|
|
1986 |
self selectedRowIndex:something
|
542
|
1987 |
!
|
|
1988 |
|
|
1989 |
selectedRowIndex
|
|
1990 |
"returns selected row number or 0
|
|
1991 |
"
|
|
1992 |
^ selectedRowIndex
|
|
1993 |
!
|
|
1994 |
|
607
|
1995 |
selectedRowIndex:something
|
|
1996 |
"set selection of rows
|
|
1997 |
"
|
|
1998 |
self selectColIndex:selectedColIndex rowIndex:something
|
|
1999 |
|
|
2000 |
|
542
|
2001 |
!
|
|
2002 |
|
|
2003 |
selectionChanged
|
|
2004 |
"selection has changed
|
|
2005 |
"
|
|
2006 |
self changed:#selection.
|
|
2007 |
|
|
2008 |
actionBlock notNil ifTrue:[
|
607
|
2009 |
actionBlock value:(self selectedRowIndex)
|
|
2010 |
]
|
|
2011 |
!
|
|
2012 |
|
|
2013 |
selectionIndicesDo:aOneArgBlock
|
|
2014 |
"evaluate block on each row selected; the argument to the row
|
|
2015 |
is the index of the selected row
|
|
2016 |
"
|
|
2017 |
multipleSelectOk ifFalse:[
|
|
2018 |
selectedRowIndex ~~ 0 ifTrue:[
|
|
2019 |
aOneArgBlock value:selectedRowIndex
|
|
2020 |
]
|
|
2021 |
] ifTrue:[
|
|
2022 |
selectedRowIndex size ~~ 0 ifTrue:[
|
|
2023 |
selectedRowIndex do:[:i| aOneArgBlock value:i ]
|
|
2024 |
]
|
542
|
2025 |
]
|
|
2026 |
!
|
|
2027 |
|
|
2028 |
setSelectColIndex:aColNr rowIndex:aRowNr
|
|
2029 |
"change selection without notification
|
|
2030 |
"
|
612
|
2031 |
|rowNr colNr newCol oldCol oldRow sensor sglSelRow index oldSz|
|
542
|
2032 |
|
607
|
2033 |
rowNr := self validateSelection:aRowNr.
|
542
|
2034 |
|
607
|
2035 |
multipleSelectOk ifTrue:[
|
|
2036 |
colNr := (rowNr size == 1) ifTrue:[aColNr] ifFalse:[0]
|
|
2037 |
] ifFalse:[
|
|
2038 |
colNr := rowNr ~~ 0 ifTrue:[aColNr] ifFalse:[0]
|
542
|
2039 |
].
|
|
2040 |
|
607
|
2041 |
(colNr := colNr ? 0) ~~ 0 ifTrue:[
|
|
2042 |
newCol := self columnAt:colNr.
|
|
2043 |
newCol rendererType == #rowSelector ifTrue:[
|
|
2044 |
colNr := 0.
|
|
2045 |
newCol := nil
|
|
2046 |
] ifFalse:[
|
|
2047 |
multipleSelectOk ifTrue:[sglSelRow := rowNr at:1]
|
|
2048 |
ifFalse:[sglSelRow := rowNr].
|
|
2049 |
|
|
2050 |
(newCol canSelect:sglSelRow) ifFalse:[
|
|
2051 |
newCol := nil.
|
|
2052 |
colNr := 0
|
|
2053 |
]
|
|
2054 |
]
|
|
2055 |
].
|
|
2056 |
|
|
2057 |
(rowNr = selectedRowIndex and:[colNr == selectedColIndex]) ifTrue:[
|
542
|
2058 |
^ self "/ nothing changed
|
|
2059 |
].
|
|
2060 |
|
|
2061 |
"/ release old selection
|
|
2062 |
|
612
|
2063 |
oldSz := self numberOfSelections.
|
542
|
2064 |
oldCol := selectedColIndex.
|
|
2065 |
oldRow := selectedRowIndex.
|
612
|
2066 |
|
542
|
2067 |
selectedRowIndex := rowNr.
|
|
2068 |
selectedColIndex := colNr.
|
|
2069 |
|
612
|
2070 |
oldSz == 1 ifTrue:[
|
|
2071 |
multipleSelectOk ifTrue:[oldRow := oldRow at:1].
|
542
|
2072 |
|
612
|
2073 |
editValue notNil ifTrue:[
|
622
|
2074 |
editValue removeDependent:self.
|
612
|
2075 |
(self columnAt:oldCol) at:oldRow put:editValue value.
|
|
2076 |
editValue := nil
|
|
2077 |
].
|
|
2078 |
editView notNil ifTrue:[
|
|
2079 |
editView destroy.
|
|
2080 |
editView := nil.
|
607
|
2081 |
]
|
612
|
2082 |
].
|
|
2083 |
shown ifFalse:[^ self ].
|
542
|
2084 |
|
618
|
2085 |
oldSz > 1 ifTrue:[ "/ redraw old selection
|
|
2086 |
oldRow do:[:aRowNr| "/ unselected if visible
|
|
2087 |
self redrawRowAt:aRowNr colAt:0
|
|
2088 |
]
|
|
2089 |
] ifFalse:[
|
|
2090 |
oldSz == 1 ifTrue:[
|
|
2091 |
self redrawRowAt:oldRow colAt:oldCol
|
|
2092 |
]
|
|
2093 |
].
|
|
2094 |
|
542
|
2095 |
"/ show new selection
|
|
2096 |
|
|
2097 |
newCol notNil ifTrue:[
|
607
|
2098 |
self scrollToRowAt:sglSelRow colAt:colNr.
|
542
|
2099 |
|
|
2100 |
newCol editorType ~~ #None ifTrue:[
|
607
|
2101 |
editView := SimpleView extent:( (newCol width - separatorSize)
|
|
2102 |
@ (rowHeight - separatorSize)
|
|
2103 |
)
|
|
2104 |
in:self.
|
542
|
2105 |
self updateEditViewOrigin.
|
|
2106 |
editView viewBackground:hgLgBgColor.
|
612
|
2107 |
editValue := newCol editorAt:sglSelRow in:editView with:hgLgFgColor bg:hgLgBgColor.
|
542
|
2108 |
editView realize.
|
622
|
2109 |
editValue addDependent:self.
|
542
|
2110 |
] ifFalse:[
|
607
|
2111 |
self redrawRowAt:sglSelRow colAt:colNr
|
612
|
2112 |
].
|
|
2113 |
] ifFalse:[
|
|
2114 |
self selectionIndicesDo:[:i| self redrawRowAt:i colAt:0 ].
|
|
2115 |
self scrollToRowAt:(self firstIndexSelected) colAt:0
|
|
2116 |
].
|
|
2117 |
|
|
2118 |
sensor := self sensor. "/ catch expose events
|
|
2119 |
|
|
2120 |
[sensor hasExposeEventFor:nil] whileTrue:[
|
|
2121 |
self windowGroup processExposeEvents
|
|
2122 |
].
|
|
2123 |
|
542
|
2124 |
|
607
|
2125 |
!
|
|
2126 |
|
|
2127 |
validateSelection:aSelection
|
|
2128 |
|newSel|
|
|
2129 |
|
|
2130 |
newSel := aSelection.
|
|
2131 |
|
618
|
2132 |
(self size == 0 or:[newSel isNil or:[newSel == 0]]) ifTrue:[
|
607
|
2133 |
^ multipleSelectOk ifFalse:[0] ifTrue:[nil]
|
|
2134 |
].
|
|
2135 |
|
|
2136 |
newSel isNumber ifTrue:[
|
|
2137 |
^ multipleSelectOk ifFalse:[newSel] ifTrue:[OrderedCollection with:newSel]
|
|
2138 |
].
|
|
2139 |
multipleSelectOk ifFalse:[
|
618
|
2140 |
newSel := self identityIndexOfRow:aSelection
|
607
|
2141 |
] ifTrue:[
|
|
2142 |
newSel := nil.
|
|
2143 |
|
|
2144 |
aSelection size ~~ 0 ifTrue:[
|
|
2145 |
aSelection first isNumber ifTrue:[
|
|
2146 |
newSel := aSelection
|
|
2147 |
] ifFalse:[
|
|
2148 |
aSelection do:[:el||n|
|
618
|
2149 |
(n := self identityIndexOfRow:el) ~~ 0 ifTrue:[
|
607
|
2150 |
newSel isNil ifTrue:[newSel := OrderedCollection new].
|
|
2151 |
newSel add:n
|
|
2152 |
]
|
|
2153 |
]
|
|
2154 |
]
|
|
2155 |
]
|
|
2156 |
].
|
|
2157 |
^ newSel
|
542
|
2158 |
! !
|
|
2159 |
|
|
2160 |
!DSVColumnView class methodsFor:'documentation'!
|
|
2161 |
|
|
2162 |
version
|
622
|
2163 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.14 1997-11-14 11:55:14 ca Exp $'
|
542
|
2164 |
! !
|