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