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