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