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