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