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