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