author | ps |
Wed, 14 Mar 2001 16:37:58 +0100 | |
changeset 1952 | 1da01418012a |
parent 1951 | 670b575a31a4 |
child 1953 | 9190339e9fad |
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 |
1951 | 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 |
|
24 |
hgLgFgColor hgLgBgColor actionBlock builder tabIntern |
|
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 |
|
32 |
tabAtStartAction modifiedChannel autoScroll autoScrollBlock |
|
33 |
needFitColumns scrollWhenUpdating' |
|
34 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor |
|
35 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor |
|
36 |
ButtonLightColor ButtonShadowColor CheckToggleActiveImage |
|
37 |
CheckTogglePassiveImage ButtonHalfLightColor |
|
38 |
ButtonHalfShadowColor ButtonEdgeStyle CheckToggleForm |
|
39 |
CheckToggleLevel CheckToggleExtent ComboButtonForm |
|
40 |
ComboButtonLevel ComboButtonExtent' |
|
41 |
poolDictionaries:'' |
|
42 |
category:'Views-DataSet' |
|
542 | 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:[ |
1948
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
971 |
list := nil. |
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
972 |
viewOrigin := 0 @ 0. |
542 | 973 |
]. |
656 | 974 |
self beDependentOfRows:makeDependent. |
542 | 975 |
|
612 | 976 |
shown ifTrue:[ |
1484 | 977 |
self fitColumns |
1949 | 978 |
] ifFalse:[ |
979 |
needFitColumns := true |
|
637 | 980 |
]. |
1259 | 981 |
selectionHasChanged ifTrue:[ |
982 |
self selectionChanged. |
|
983 |
]. |
|
542 | 984 |
! ! |
985 |
||
1818 | 986 |
!DSVColumnView methodsFor:'accessing-visibility'! |
542 | 987 |
|
988 |
font:aFont |
|
989 |
"set the font for all shown rows. |
|
990 |
" |
|
991 |
(aFont notNil and:[aFont ~~ font]) ifTrue:[ |
|
1480 | 992 |
super font:(aFont onDevice:device). |
542 | 993 |
realized ifTrue:[ |
1497 | 994 |
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
|
995 |
self preferredExtentChanged. |
542 | 996 |
self invalidate. |
997 |
self contentsChanged |
|
1842 | 998 |
]. |
999 |
labelView notNil ifTrue:[ |
|
1000 |
labelView font:font |
|
1001 |
]. |
|
542 | 1002 |
] |
1003 |
! |
|
1004 |
||
607 | 1005 |
has3Dseparators |
1006 |
"returns true if shown in 3D mode |
|
1007 |
" |
|
1008 |
^ separatorSize ~~ 1 |
|
542 | 1009 |
! |
1010 |
||
607 | 1011 |
has3Dseparators:aBool |
1012 |
"enable or disable 3D mode |
|
1013 |
" |
|
1014 |
|newSepSize| |
|
542 | 1015 |
|
637 | 1016 |
newSepSize := aBool ifTrue:[2] ifFalse:[1]. |
607 | 1017 |
|
1018 |
newSepSize ~~ separatorSize ifTrue:[ |
|
1019 |
separatorSize := newSepSize. |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1020 |
|
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1021 |
realized ifTrue:[ |
1497 | 1022 |
columnDescriptors do:[:aCol| aCol invalidate ]. |
1136 | 1023 |
self preferredExtentChanged. |
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1024 |
self invalidate. |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1025 |
self contentsChanged |
647 | 1026 |
] |
542 | 1027 |
] |
1028 |
||
1029 |
||
1030 |
! |
|
1031 |
||
1032 |
horizontalSpacing |
|
1033 |
"horizontal spacing used by columns |
|
1034 |
" |
|
563 | 1035 |
^ horizontalSpacing |
1036 |
! |
|
1037 |
||
1038 |
horizontalSpacing:aNumber |
|
1039 |
"horizontal spacing used by columns |
|
1040 |
" |
|
1041 |
horizontalSpacing ~~ aNumber ifTrue:[ |
|
1042 |
horizontalSpacing := aNumber. |
|
1043 |
self preferredExtentChanged. |
|
1044 |
]. |
|
542 | 1045 |
! |
1046 |
||
1487 | 1047 |
showLabels |
1048 |
"control the labels view to be visible or unvisible |
|
1049 |
" |
|
1050 |
^ labelView isVisible |
|
1051 |
||
1052 |
! |
|
1053 |
||
1054 |
showLabels:aState |
|
1055 |
"control the labels view to be visible or unvisible |
|
1056 |
" |
|
1057 |
labelView isVisible:aState |
|
1058 |
! |
|
1059 |
||
542 | 1060 |
verticalSpacing |
1061 |
"vertical spacing used by columns |
|
1062 |
" |
|
563 | 1063 |
^ verticalSpacing |
1064 |
! |
|
1065 |
||
1066 |
verticalSpacing:aNumber |
|
1067 |
"vertical spacing used by columns |
|
1068 |
" |
|
1069 |
verticalSpacing ~~ aNumber ifTrue:[ |
|
1070 |
verticalSpacing := aNumber. |
|
1071 |
self preferredExtentChanged. |
|
1072 |
]. |
|
542 | 1073 |
! ! |
1074 |
||
1075 |
!DSVColumnView methodsFor:'adding & removing rows'! |
|
1076 |
||
1077 |
add:aRow |
|
618 | 1078 |
"insert row at end |
542 | 1079 |
" |
1497 | 1080 |
^ self add:aRow beforeIndex:(1 + list size) |
542 | 1081 |
! |
1082 |
||
1083 |
add:aRow afterIndex:aRowNr |
|
1084 |
"add a new row after slot aRowNr and redisplay; returns nil in case |
|
618 | 1085 |
of an invalid index or the row |
542 | 1086 |
" |
1087 |
^ self add:aRow beforeIndex:(aRowNr + 1) |
|
1088 |
! |
|
1089 |
||
1090 |
add:aRow beforeIndex:aRowNr |
|
1091 |
"add a new row before slot aRowNr and redisplay; returns nil in case |
|
618 | 1092 |
of an invalid index or the row |
542 | 1093 |
" |
861 | 1094 |
self addAll:(Array with:aRow) beforeIndex:aRowNr. |
1095 |
^ aRow. |
|
1096 |
! |
|
1097 |
||
1098 |
addAll:aList beforeIndex:start |
|
1099 |
"add a collection of rows before slot start and redisplay |
|
1100 |
" |
|
1101 |
|y0 y1 yD h dH size noSel| |
|
1102 |
||
1103 |
(size := aList size) == 0 ifTrue:[ |
|
1104 |
^ self |
|
1105 |
]. |
|
1106 |
||
1497 | 1107 |
list size == 0 ifTrue:[ |
861 | 1108 |
^ self list:aList |
618 | 1109 |
]. |
643 | 1110 |
|
618 | 1111 |
beDependentOfRows ifTrue:[ |
861 | 1112 |
aList do:[:aRow| aRow notNil ifTrue:[aRow addDependent:self]] |
542 | 1113 |
]. |
637 | 1114 |
|
861 | 1115 |
noSel := self numberOfSelections. |
1116 |
||
1117 |
noSel ~~ 0 ifTrue:[ |
|
1118 |
multipleSelectOk ifFalse:[ |
|
1119 |
selectedRowIndex >= start ifTrue:[ |
|
1120 |
selectedRowIndex := selectedRowIndex + size |
|
1121 |
] |
|
1122 |
] ifTrue:[ |
|
1123 |
1 to:noSel do:[:i||v| |
|
1124 |
(v := selectedRowIndex at:i) >= start ifTrue:[ |
|
1125 |
selectedRowIndex at:i put:(v + size) |
|
607 | 1126 |
] |
1127 |
] |
|
1128 |
] |
|
542 | 1129 |
]. |
861 | 1130 |
list addAll:aList beforeIndex:start. |
1131 |
self recomputeHeightOfContents. |
|
1132 |
||
1133 |
y0 := (start - 1) * rowHeight. |
|
1134 |
yD := size * rowHeight. |
|
1135 |
y1 := y0 + yD. |
|
542 | 1136 |
|
1137 |
y0 < viewOrigin y ifTrue:[ |
|
1138 |
self originWillChange. |
|
1948
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
1139 |
viewOrigin := viewOrigin x @ (yD + viewOrigin y). |
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
1140 |
"/ viewOrigin y:(yD + viewOrigin y). |
861 | 1141 |
self originChanged:(0 @ yD). |
1142 |
]. |
|
1143 |
||
1144 |
(shown not or:[self sensor hasDamageFor:self]) ifTrue:[ |
|
1483 | 1145 |
self invalidate. |
861 | 1146 |
^ self contentsChanged. |
542 | 1147 |
]. |
645
53c78cc2ee08
redraw twice in case of expose event during adding a new entry
ca
parents:
643
diff
changeset
|
1148 |
|
861 | 1149 |
y0 := self yVisibleOfRowNr:start. |
1258 | 1150 |
h := height - margin. |
1151 |
y1 := y0 + yD min:h. |
|
1152 |
||
1153 |
(y1 > margin and:[y0 < h]) ifTrue:[ |
|
1952 | 1154 |
"/ cg: if I have a non-solid background color, |
1155 |
"/ or individual items have a bgColor selector, |
|
1156 |
"/ invalidate the area (and readraw) instead of a scroll. |
|
1157 |
(viewBackground isImageOrForm |
|
1158 |
or:[ self anyColumnHasPotentialNonConstantBackground ]) |
|
1159 |
ifTrue:[ |
|
1160 |
"/ do not scroll but invalidate ... |
|
1161 |
self invalidateX:margin y:y0 width:width - margin - margin height:(height - y0). |
|
1162 |
] ifFalse:[ |
|
1163 |
h := h - y1. |
|
1164 |
y0 := y0 max:margin. |
|
1165 |
dH := y1 - y0. |
|
1166 |
||
1167 |
start == list size ifFalse:[ |
|
1168 |
self copyFrom:self x:0 y:y0 toX:0 y:y1 width:width height:h async:false |
|
1169 |
]. |
|
1170 |
self invalidateX:margin y:y0 width:width - margin - margin height:dH. |
|
1171 |
] |
|
542 | 1172 |
]. |
1173 |
self contentsChanged. |
|
567 | 1174 |
! |
1175 |
||
542 | 1176 |
addFirst:aRow |
618 | 1177 |
"insert a row at start |
542 | 1178 |
" |
1179 |
^ self add:aRow beforeIndex:1 |
|
1180 |
! |
|
1181 |
||
1487 | 1182 |
remove:aRow |
1183 |
"remove a row |
|
1184 |
" |
|
1185 |
|idx| |
|
1186 |
||
1187 |
idx := list identityIndexOf:aRow. |
|
1188 |
||
1189 |
idx ~~ 0 ifTrue:[ |
|
1190 |
self removeFrom:idx to:idx. |
|
1191 |
]. |
|
1192 |
^ aRow |
|
1193 |
! |
|
1194 |
||
542 | 1195 |
removeFirst |
1196 |
"remove first row; returns the removed row |
|
1197 |
" |
|
1112 | 1198 |
^ self removeIndex:1 |
542 | 1199 |
! |
1200 |
||
861 | 1201 |
removeFrom:startIndex to:stopIndex |
1202 |
"remove rows from start to stop |
|
542 | 1203 |
" |
861 | 1204 |
|coll noRedraw |
1205 |
noSel "{ Class: SmallInteger }" |
|
1206 |
size "{ Class: SmallInteger }" |
|
1207 |
start "{ Class: SmallInteger }" |
|
1208 |
stop "{ Class: SmallInteger }" |
|
1209 |
y0 "{ Class: SmallInteger }" |
|
1210 |
y1 "{ Class: SmallInteger }" |
|
1211 |
oY "{ Class: SmallInteger }" |
|
1212 |
dY "{ Class: SmallInteger }" |
|
1213 |
yB "{ Class: SmallInteger }" |
|
1214 |
h "{ Class: SmallInteger }" |
|
1215 |
| |
|
1216 |
||
1217 |
( (start := startIndex) < 1 |
|
1218 |
or:[(stop := stopIndex) > list size] |
|
1219 |
) ifTrue:[ |
|
1220 |
^ self subscriptBoundsError:start |
|
618 | 1221 |
]. |
861 | 1222 |
size := stop - start + 1. |
1223 |
||
1224 |
beDependentOfRows ifTrue:[ |
|
1225 |
list from:start to:stop do:[:r| r notNil ifTrue:[r removeDependent:self]]. |
|
1226 |
]. |
|
1227 |
noSel := self numberOfSelections. |
|
1228 |
||
1229 |
noSel ~~ 0 ifTrue:[ |
|
1230 |
noSel == 1 ifTrue:[ |
|
1231 |
noSel := self firstIndexSelected. |
|
1232 |
||
1233 |
noSel < start ifFalse:[ |
|
1234 |
noSel > stop ifTrue:[ |
|
1235 |
noSel := noSel - size. |
|
1236 |
||
1237 |
multipleSelectOk ifFalse:[selectedRowIndex := noSel] |
|
1238 |
ifTrue:[selectedRowIndex at:1 put:noSel] |
|
1239 |
] ifFalse:[ |
|
637 | 1240 |
editValue notNil ifTrue:[ |
1241 |
editValue removeDependent:self. |
|
1242 |
editValue := nil. |
|
1243 |
]. |
|
861 | 1244 |
self deselect. |
637 | 1245 |
] |
607 | 1246 |
] |
1247 |
] ifFalse:[ |
|
861 | 1248 |
coll := OrderedCollection new:noSel. |
1249 |
||
1250 |
selectedRowIndex do:[:i| |
|
1251 |
i < start ifTrue:[ |
|
1252 |
coll add:i |
|
1253 |
] ifFalse:[ |
|
1254 |
i > stop ifTrue:[ |
|
1255 |
coll add:(i - size) |
|
1256 |
] |
|
1257 |
] |
|
1258 |
]. |
|
1259 |
coll size == 0 ifTrue:[ |
|
1260 |
self deselect |
|
1261 |
] ifFalse:[ |
|
1262 |
selectedRowIndex := coll |
|
1263 |
] |
|
542 | 1264 |
] |
1265 |
]. |
|
861 | 1266 |
list removeFrom:start to:stop. |
1267 |
||
1268 |
y0 := start - 1 * rowHeight. |
|
1269 |
dY := size * rowHeight. |
|
1270 |
y1 := dY + y0. |
|
542 | 1271 |
yB := y1 + margin - viewOrigin y. |
1272 |
self recomputeHeightOfContents. |
|
1273 |
||
1274 |
y0 < (oY := viewOrigin y) ifTrue:[ |
|
1275 |
(noRedraw := y1 <= oY) ifFalse:[dY := y0 - oY] |
|
861 | 1276 |
ifTrue:[dY := dY negated]. |
542 | 1277 |
self originWillChange. |
1948
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
1278 |
viewOrigin := viewOrigin x @ (dY + oY). |
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
1279 |
"/ viewOrigin y:(dY + oY). |
542 | 1280 |
self originChanged:(0 @ dY). |
1281 |
] ifFalse:[ |
|
1282 |
noRedraw := y0 > (height + viewOrigin y) |
|
1283 |
]. |
|
1284 |
||
1483 | 1285 |
(shown not or:[self sensor hasDamageFor:self]) ifTrue:[ |
1286 |
self invalidate. |
|
1287 |
^ self contentsChanged. |
|
1288 |
]. |
|
1289 |
||
542 | 1290 |
(noRedraw or:[shown not]) ifFalse:[ |
861 | 1291 |
y0 := self yVisibleOfRowNr:start. |
542 | 1292 |
y0 := y0 max:margin. |
1293 |
||
1951 | 1294 |
"/ cg: if I have a non-solid background color, |
1295 |
"/ or individual items have a bgColor selector, |
|
1296 |
"/ invalidate the area (and readraw) instead of a scroll. |
|
1297 |
(viewBackground isImageOrForm |
|
1298 |
or:[ self anyColumnHasPotentialNonConstantBackground ]) |
|
1299 |
ifTrue:[ |
|
1300 |
"/ do not scroll but invalidate ... |
|
1301 |
] ifFalse:[ |
|
1302 |
y1 := yB. |
|
1303 |
h := height - margin - yB. |
|
1304 |
||
1305 |
h > 0 ifTrue:[ |
|
1306 |
self copyFrom:self x:0 y:yB toX:0 y:y0 width:width height:h async:false |
|
1307 |
]. |
|
1308 |
y0 := y0 + h. |
|
561 | 1309 |
]. |
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1310 |
self invalidateX:margin y:y0 width:width - margin - margin height:(height - y0). |
542 | 1311 |
]. |
1312 |
self contentsChanged. |
|
861 | 1313 |
! |
1314 |
||
1315 |
removeIndex:aRowNr |
|
1316 |
"remove row at an index; returns the removed row |
|
1317 |
" |
|
1318 |
|row| |
|
1319 |
||
1320 |
row := list at:aRowNr ifAbsent:nil. |
|
1321 |
self removeFrom:aRowNr to:aRowNr. |
|
1322 |
^ row |
|
542 | 1323 |
! |
1324 |
||
1325 |
removeLast |
|
1326 |
"remove last row; the row is returned |
|
1327 |
" |
|
1497 | 1328 |
^ self removeIndex:(list size) |
542 | 1329 |
! ! |
1330 |
||
1331 |
!DSVColumnView methodsFor:'change & update'! |
|
1332 |
||
1492 | 1333 |
changeWidthOfColumn:aColumn deltaX:aDeltaX |
1334 |
||
1335 |
aColumn setDescWidth:(aColumn width + aDeltaX). |
|
1336 |
preferredExtent notNil ifTrue:[self fitColumns] |
|
1337 |
! |
|
1338 |
||
1487 | 1339 |
sizeChanged:how |
1340 |
"size changed - move origin up if possible |
|
1341 |
change the layout of the labelView dependent on my layout |
|
1342 |
" |
|
1343 |
|lyt| |
|
1344 |
||
1345 |
super sizeChanged:how. |
|
1346 |
||
1934 | 1347 |
"/ no - must compute even if not visible. |
1348 |
"/ (could be invisible in a notebook ...) |
|
1349 |
realized ifTrue:[ "used to be: shown" |
|
1487 | 1350 |
labelView isVisible ifTrue:[ |
1351 |
lyt := labelView layout. |
|
1352 |
lyt leftOffset:(layout leftOffset). |
|
1353 |
lyt rightOffset:(layout rightOffset). |
|
1354 |
labelView layout:lyt. |
|
1355 |
]. |
|
1356 |
self fitColumns. |
|
1357 |
] |
|
859 | 1358 |
! |
1359 |
||
1487 | 1360 |
update:what with:aPara from:chgObj |
542 | 1361 |
"one of my rows/cells changed its value |
1362 |
" |
|
1673
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1363 |
|row newValue realValue list arg1 arg2 col idx| |
1487 | 1364 |
|
1365 |
chgObj == columnHolder ifTrue:[ |
|
612 | 1366 |
^ self columnDescriptors:(columnHolder value) |
622 | 1367 |
]. |
1711 | 1368 |
|
1369 |
chgObj == columnAdaptor ifTrue:[ |
|
1370 |
col := columnAdaptor value. |
|
1371 |
columnDescriptors do:[:aCol| aCol columnAdaptor:col]. |
|
1372 |
^ self invalidate |
|
1373 |
]. |
|
1374 |
||
1487 | 1375 |
chgObj == editValue ifTrue:[ |
1227 | 1376 |
newValue := editValue value. |
1673
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1377 |
col := self selectedColumn. |
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1378 |
idx := self firstIndexSelected. |
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1379 |
|
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1380 |
col at:idx put:newValue. |
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1381 |
realValue := col at:idx. |
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1382 |
|
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1383 |
"/ !!!! 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
|
1384 |
|
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1385 |
(chgObj == editValue and:[realValue ~= newValue]) ifTrue:[ |
1227 | 1386 |
"/ some validation by the row-object; the stored value |
1387 |
"/ is different from what I think. |
|
1388 |
"/ update my input fields modelValue |
|
1389 |
editValue value:realValue. |
|
1390 |
]. |
|
1673
67898506ba03
bug fix in update:with:from: model can changed during setting
ca
parents:
1668
diff
changeset
|
1391 |
|
1661 | 1392 |
modifiedChannel notNil ifTrue:[ |
1393 |
modifiedChannel value:true. |
|
1394 |
]. |
|
1227 | 1395 |
^ self |
622 | 1396 |
]. |
1397 |
||
1487 | 1398 |
chgObj == model ifTrue:[ |
1399 |
(what == #selectionIndex or:[what == #selection]) ifTrue:[ |
|
1400 |
^ self selectRowIndex:(model selectionIndex copy) |
|
1401 |
]. |
|
1402 |
what == #list ifTrue:[ |
|
1403 |
^ self listHolder:model list |
|
1404 |
]. |
|
1405 |
what == #value ifTrue:[ |
|
1406 |
model == listHolder ifTrue:[ |
|
1407 |
self list:(listHolder value) |
|
1408 |
] ifFalse:[ |
|
1409 |
self selectRowIndex:model value |
|
1410 |
] |
|
1411 |
]. |
|
1412 |
^ self |
|
1413 |
]. |
|
1414 |
||
1415 |
chgObj == listHolder ifTrue:[ |
|
1416 |
list := listHolder value. |
|
1417 |
||
1418 |
what == #value ifTrue:[ |
|
1419 |
^ self list:list |
|
1420 |
]. |
|
1421 |
aPara isCollection ifTrue:[ |
|
1422 |
arg1 := aPara at:1. |
|
1423 |
arg2 := aPara at:2. |
|
1424 |
] ifFalse:[ |
|
1425 |
arg1 := arg2 := aPara |
|
1426 |
]. |
|
1427 |
||
1428 |
what == #at: ifTrue:[ |
|
1429 |
^ self at:arg1 put:(list at:arg1) |
|
1430 |
]. |
|
1431 |
||
1432 |
what == #insert: ifTrue:[ |
|
1433 |
^ self add:(list at:arg1) beforeIndex:arg1 |
|
1434 |
]. |
|
1435 |
||
1436 |
what == #remove: ifTrue:[ |
|
1437 |
^ self removeFrom:arg1 to:arg1 |
|
1438 |
]. |
|
1439 |
what == #removeFrom: ifTrue:[ |
|
1440 |
list size == 0 ifTrue:[self list:nil] |
|
1441 |
ifFalse:[self removeFrom:arg1 to:arg2]. |
|
1442 |
^ self |
|
1443 |
]. |
|
1444 |
||
1445 |
what == #insertCollection: ifTrue:[ |
|
1446 |
arg2 ~~ 0 ifTrue:[ |
|
1447 |
self addAll:(list copyFrom:arg1 to:(arg1 + arg2 - 1)) beforeIndex:arg1 |
|
1448 |
]. |
|
1449 |
^ self. |
|
1450 |
]. |
|
1451 |
what == #replace: ifTrue:[ |
|
1452 |
arg1 to:arg2 do:[:i| self at:i put:(list at:i) ]. |
|
1453 |
^ self |
|
1454 |
]. |
|
1455 |
^ self |
|
1456 |
]. |
|
1593 | 1457 |
arg1 := aPara ? what. |
1487 | 1458 |
row := (what isNumber) ifTrue:[what] ifFalse:[chgObj]. |
1593 | 1459 |
self redrawVisibleRow:row readSelector:arg1. |
1460 |
||
1661 | 1461 |
"Modified: / 30.1.2000 / 12:16:49 / cg" |
809 | 1462 |
! ! |
1463 |
||
1464 |
!DSVColumnView methodsFor:'drag & drop'! |
|
1465 |
||
824 | 1466 |
canDrag |
1467 |
"returns true if dragging is enabled |
|
1468 |
" |
|
1469 |
^ dropSource notNil |
|
1470 |
||
1471 |
! |
|
1472 |
||
1473 |
dropSource |
|
1474 |
"returns the dropSource or nil |
|
809 | 1475 |
" |
824 | 1476 |
^ dropSource |
1477 |
||
1478 |
||
1479 |
! |
|
1480 |
||
1481 |
dropSource:aDropSourceOrNil |
|
1482 |
"set the dropSource or nil |
|
1483 |
" |
|
1484 |
dropSource := aDropSourceOrNil. |
|
1485 |
||
809 | 1486 |
|
1487 |
! |
|
1488 |
||
824 | 1489 |
dropTarget |
1490 |
"returns the dropTarget or nil |
|
809 | 1491 |
" |
824 | 1492 |
^ dropTarget |
1493 |
||
1494 |
! |
|
1495 |
||
1496 |
dropTarget:aDropTragetOrNil |
|
1497 |
"set the dropTarget or nil |
|
1498 |
" |
|
1499 |
dropTarget := aDropTragetOrNil. |
|
1500 |
||
1501 |
! |
|
1502 |
||
1503 |
startDragAt:aPoint |
|
1504 |
(dragIsActive not and:[dropSource notNil]) ifTrue:[ |
|
809 | 1505 |
dragIsActive := true. |
824 | 1506 |
dropSource startDragIn:self at:aPoint |
809 | 1507 |
] |
824 | 1508 |
|
542 | 1509 |
! ! |
1510 |
||
637 | 1511 |
!DSVColumnView methodsFor:'drawing'! |
1512 |
||
1513 |
colorOnDevice:aColor |
|
1514 |
"returns color on device |
|
1515 |
" |
|
1516 |
|col| |
|
1517 |
||
641 | 1518 |
aColor = Color noColor ifFalse:[ |
1519 |
col := colorMap at:aColor ifAbsent:nil. |
|
637 | 1520 |
|
641 | 1521 |
col isNil ifTrue:[ |
1480 | 1522 |
colorMap at:aColor put:(col := aColor onDevice:device) |
641 | 1523 |
]. |
1524 |
^ col |
|
637 | 1525 |
]. |
641 | 1526 |
^ bgColor |
637 | 1527 |
! |
1528 |
||
1529 |
forceRedraw |
|
1530 |
"a redraw forced by any other component |
|
1531 |
" |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1532 |
shown ifTrue:[ |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1533 |
self invalidate |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1534 |
] |
637 | 1535 |
! |
1536 |
||
1537 |
invalidate |
|
1538 |
"recompute extent before repair range |
|
1539 |
" |
|
1540 |
self recomputeHeightOfContents. |
|
1541 |
super invalidate. |
|
1542 |
||
1543 |
||
1544 |
! |
|
1545 |
||
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1546 |
invalidateRowAt:aRowNr |
637 | 1547 |
"redraw total row at an index |
1548 |
" |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1549 |
self invalidateRowAt:aRowNr colAt:0 |
637 | 1550 |
! |
1551 |
||
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1552 |
invalidateRowAt:aRowNr colAt:aColNr |
637 | 1553 |
"redraw visible row in case of aColNr == 0 or the column in a row; |
1554 |
in case that the row/column is hidden no redraw is done |
|
1555 |
" |
|
1497 | 1556 |
|x "{ Class:SmallInteger }" |
1557 |
y "{ Class:SmallInteger }" |
|
1558 |
h "{ Class:SmallInteger }" |
|
1559 |
w "{ Class:SmallInteger }" |
|
1560 |
| |
|
1561 |
||
1562 |
(shown and:[aRowNr notNil and:[aRowNr between:1 and:list size]]) ifTrue:[ |
|
1131 | 1563 |
h := rowHeight. |
1497 | 1564 |
y := self yVisibleOfRowNr:aRowNr. |
1565 |
||
1566 |
y < margin ifTrue:[ |
|
637 | 1567 |
(h := h + y) <= margin ifTrue:[ |
1568 |
^ self |
|
1569 |
]. "/ row not visible |
|
1570 |
h := h - margin. |
|
1571 |
y := margin. |
|
1572 |
] ifFalse:[ |
|
1573 |
y >= height ifTrue:[^ self]. |
|
1574 |
]. |
|
1575 |
aColNr ~~ 0 ifTrue:[ "/ redraw column in row |
|
1576 |
w := (self columnAt:aColNr) width. |
|
1497 | 1577 |
x := self xVisibleOfColNr:aColNr. |
1578 |
||
1579 |
x < margin ifTrue:[ |
|
637 | 1580 |
(w := w + x) <= margin ifTrue:[ |
1581 |
^ self |
|
1582 |
]. "/ column not visible |
|
1583 |
w := w - margin. |
|
1584 |
x := margin. |
|
1585 |
] ifFalse:[ |
|
1586 |
x >= width ifTrue:[^ self]. |
|
1587 |
] |
|
1588 |
] ifFalse:[ "/ redraw whole row |
|
1589 |
x := margin. |
|
1590 |
w := width. |
|
1591 |
]. |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1592 |
self invalidateX:x y:y width:w height:h |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1593 |
] |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1594 |
! |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1595 |
|
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1596 |
invalidateX:x y:y width:w height:h |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1597 |
"invalidate a rectangle |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1598 |
" |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1599 |
shown ifTrue:[ |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1600 |
self invalidate:(Rectangle left:x top:y width:w height:h) |
637 | 1601 |
] |
1602 |
! |
|
1603 |
||
1604 |
redrawVisibleRow:aRow |
|
1605 |
"redraw row if visible |
|
1606 |
" |
|
809 | 1607 |
self redrawVisibleRow:aRow colAt:0 |
1608 |
||
1609 |
! |
|
1610 |
||
1611 |
redrawVisibleRow:aRow colAt:aColNr |
|
1612 |
"redraw row if visible |
|
1613 |
" |
|
637 | 1614 |
|start "{ Class:SmallInteger }" |
1615 |
stop "{ Class:SmallInteger }" |
|
1616 |
| |
|
1617 |
||
1618 |
(start := self indexOfFirstRowShown) ~~ 0 ifTrue:[ |
|
1497 | 1619 |
stop := (start + (height // rowHeight)) min:(list size). |
637 | 1620 |
|
1621 |
aRow isNumber ifTrue:[ |
|
1622 |
(aRow between:start and:stop) ifTrue:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1623 |
self invalidateRowAt:aRow colAt:aColNr |
637 | 1624 |
] |
1625 |
] ifFalse:[ |
|
1626 |
start to:stop do:[:i| |
|
1627 |
(self at:i) == aRow ifTrue:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
1628 |
^ self invalidateRowAt:i colAt:aColNr |
637 | 1629 |
] |
1630 |
] |
|
1631 |
] |
|
1632 |
] |
|
809 | 1633 |
|
1634 |
||
1635 |
! |
|
1636 |
||
1637 |
redrawVisibleRow:aRow readSelector:aSelector |
|
1638 |
"redraw a column identified by its read selector; if no column with |
|
1639 |
the specified read selector is detected, the whole line is drawn. |
|
1640 |
" |
|
1641 |
|row idx| |
|
1642 |
||
1643 |
aSelector isNil ifTrue:[ |
|
1644 |
idx := 0 |
|
1645 |
] ifFalse:[ |
|
1646 |
(row := aRow) isNumber ifTrue:[ |
|
1647 |
(row := self at:aRow) isNil ifTrue:[ ^ self ] |
|
1648 |
]. |
|
1649 |
idx := columnDescriptors findFirst:[:aCol||desc| |
|
1650 |
aCol description readSelector == aSelector |
|
1651 |
] |
|
1652 |
]. |
|
1653 |
self redrawVisibleRow:aRow colAt:idx |
|
1654 |
||
1655 |
||
1656 |
||
1657 |
||
637 | 1658 |
! |
1659 |
||
1660 |
redrawX:x y:y width:w height:h |
|
1661 |
"redraw part of myself immediately, given logical coordinates |
|
1662 |
" |
|
1941 | 1663 |
|c0 savClip |
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1664 |
start "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1665 |
stop "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1666 |
x0 "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1667 |
x1 "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1668 |
maxX "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1669 |
yTop "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1670 |
yBot "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1671 |
clHg "{ Class:SmallInteger }" |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1672 |
size "{ Class:SmallInteger }" |
637 | 1673 |
| |
1674 |
||
1675 |
shown ifFalse:[^ self]. |
|
1676 |
self paint:bgColor. |
|
1115 | 1677 |
|
1678 |
columnDescriptors isEmpty ifTrue:[ |
|
1679 |
^ self fillRectangleX:x y:y width:w height:h |
|
1680 |
]. |
|
1131 | 1681 |
size := list size. |
1115 | 1682 |
yTop := margin - viewOrigin y. |
1683 |
c0 := y - yTop max:0. |
|
1684 |
start := (c0 // rowHeight) + 1. |
|
1131 | 1685 |
stop := (c0 + h - 1 // rowHeight + 1) min:size. |
1115 | 1686 |
|
1687 |
stop < start ifTrue:[ |
|
1688 |
^ self fillRectangleX:x y:y width:w height:h |
|
1689 |
]. |
|
1690 |
savClip := clipRect. |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1691 |
|
1115 | 1692 |
maxX := (x + w) min:(width - margin). |
1693 |
x0 := margin - viewOrigin x. |
|
1694 |
yTop := yTop + ((start - 1) * rowHeight). |
|
1131 | 1695 |
clHg := (stop - start + 1) * rowHeight. |
1696 |
yBot := yTop + clHg. |
|
1697 |
||
1941 | 1698 |
columnDescriptors do:[:aCol| |cw| |
1115 | 1699 |
x1 := x0 + aCol width. |
1700 |
||
1701 |
(x1 > x and:[x0 < maxX]) ifTrue:[ |
|
1941 | 1702 |
|left right rect| |
1703 |
left := x0 max:x. |
|
1704 |
right := x1 min:maxX. |
|
1705 |
rect := Rectangle left:left top:y width:(right - left) height:h. |
|
1706 |
||
1115 | 1707 |
clipRect := nil. |
1941 | 1708 |
self clippingRectangle:rect. |
1131 | 1709 |
aCol redrawX:x0 y:yTop h:clHg from:start to:stop. |
1115 | 1710 |
]. |
1711 |
x0 := x1 |
|
1712 |
]. |
|
1131 | 1713 |
|
1714 |
"/ restore old clipping rectangle |
|
1115 | 1715 |
self clippingRectangle:savClip. |
1131 | 1716 |
|
1717 |
stop == size ifTrue:[ |
|
1115 | 1718 |
yTop := y + h. |
1719 |
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
|
1720 |
"/ clear to bottom of screen |
1115 | 1721 |
self paint:bgColor. |
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1722 |
self fillRectangleX:x y:yBot width:w height:(yTop - yBot). |
1112 | 1723 |
] |
1136 | 1724 |
]. |
1725 |
||
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1726 |
(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
|
1727 |
"/ clear to right of screen |
1136 | 1728 |
self paint:bgColor. |
1729 |
self fillRectangleX:x1 y:y width:c0 height:h. |
|
1730 |
]. |
|
1112 | 1731 |
! ! |
1732 |
||
1733 |
!DSVColumnView methodsFor:'drawing interactors'! |
|
1734 |
||
1131 | 1735 |
drawCheckToggleAtX:xTop y:yTop w:rowWidth state:aState |
1112 | 1736 |
"draw a check toggle button |
1737 |
" |
|
1738 |
|e form |
|
1739 |
y "{ Class:SmallInteger }" |
|
1740 |
x "{ Class:SmallInteger }" |
|
1741 |
h "{ Class:SmallInteger }" |
|
1742 |
w "{ Class:SmallInteger }" |
|
1743 |
| |
|
1744 |
w := checkToggleExtent x. |
|
1745 |
h := checkToggleExtent y. |
|
1746 |
y := yTop + (rowHeight - h // 2). |
|
1747 |
x := xTop + (rowWidth - w // 2). |
|
1529 | 1748 |
h odd ifTrue:[y := y + 1]. |
1112 | 1749 |
|
1750 |
(form := checkToggleActiveImage) isNil ifTrue:[ |
|
1131 | 1751 |
self paint:bgColor. |
1752 |
self fillRectangleX:x y:y width:w height:h. |
|
1753 |
self drawEdgesAtX:x y:y width:w height:h level:checkToggleLevel on:self. |
|
1754 |
||
1112 | 1755 |
aState ifFalse:[ |
1756 |
^ self |
|
1757 |
]. |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
1758 |
self paint:fgColor on:bgColor. |
1112 | 1759 |
form := checkToggleForm |
1760 |
] ifFalse:[ |
|
1761 |
aState ifFalse:[form := checkTogglePassiveImage] |
|
859 | 1762 |
]. |
1112 | 1763 |
e := (checkToggleExtent - form extent) // 2. |
1764 |
self displayForm:form x:(x + e x) y:(y + e y). |
|
1765 |
||
1766 |
||
1767 |
||
1768 |
||
1769 |
||
1770 |
! |
|
1771 |
||
1131 | 1772 |
drawComboButtonAtX:xTop y:yTop w:rowWidth |
1112 | 1773 |
"draw a combo button |
1774 |
" |
|
1775 |
|e |
|
1776 |
x "{ Class:SmallInteger }" |
|
1777 |
y "{ Class:SmallInteger }" |
|
1778 |
h "{ Class:SmallInteger }" |
|
1779 |
w "{ Class:SmallInteger }" |
|
1780 |
| |
|
1781 |
w := comboButtonExtent x. |
|
1782 |
h := comboButtonExtent y. |
|
1783 |
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
|
1784 |
x := xTop + (rowWidth - w - separatorSize - 1). |
1112 | 1785 |
e := (comboButtonExtent - comboButtonForm extent) // 2. |
1786 |
||
1131 | 1787 |
self paint:bgColor. |
1788 |
self fillRectangleX:x y:y width:w height:h. |
|
1789 |
self drawEdgesAtX:x y:y width:w height:h level:comboButtonLevel on:self. |
|
1136 | 1790 |
self paint:fgColor on:bgColor. |
1112 | 1791 |
self displayForm:comboButtonForm x:(x + e x) y:(y + e y) |
1792 |
||
1793 |
! |
|
1794 |
||
1795 |
drawEdgesAtX:x y:y width:w height:h level:aLevel on:aGC |
|
1796 |
"draw edges for a cell or label |
|
1797 |
" |
|
1798 |
aGC drawEdgesForX:x |
|
1799 |
y:y |
|
1800 |
width:w |
|
1801 |
height:h |
|
1802 |
level:aLevel |
|
1803 |
shadow:buttonShadowColor |
|
1804 |
light:buttonLightColor |
|
1805 |
halfShadow:buttonHalfShadowColor |
|
1806 |
halfLight:buttonHalfLightColor |
|
1807 |
style:ButtonEdgeStyle. |
|
1808 |
||
637 | 1809 |
! ! |
1810 |
||
542 | 1811 |
!DSVColumnView methodsFor:'enumerating columns'! |
1812 |
||
1813 |
columnsDo:aOneArgBlock |
|
1814 |
"evaluate the argument, aOneArgBlock for every column |
|
1815 |
" |
|
1816 |
columnDescriptors do:aOneArgBlock |
|
1817 |
||
1818 |
||
1819 |
! |
|
1820 |
||
1821 |
columnsFrom:start to:stop do:aOneArgBlock |
|
1822 |
"evaluate the argument, aOneArgBlock for the columns with index start to |
|
1823 |
stop in the collection of column descriptors |
|
1824 |
" |
|
1825 |
columnDescriptors from:start to:stop do:aOneArgBlock |
|
1826 |
||
1827 |
||
1828 |
! ! |
|
1829 |
||
1830 |
!DSVColumnView methodsFor:'event handling'! |
|
1831 |
||
607 | 1832 |
buttonMotion:buttonMask x:x y:y |
1833 |
"mouse-move while button was pressed - handle multiple selection changes |
|
1834 |
" |
|
1754 | 1835 |
|lnNr p oldSelection step| |
607 | 1836 |
|
1809 | 1837 |
self isEnabled ifFalse:[^ self]. |
1838 |
||
809 | 1839 |
dragAccessPoint notNil ifTrue:[ |
1840 |
dragIsActive ifFalse:[ |
|
824 | 1841 |
p := x @ y. |
1842 |
(clickPosition dist:p) > 5.0 ifTrue:[ self startDragAt:p ] |
|
809 | 1843 |
]. |
1844 |
^ self |
|
1845 |
]. |
|
607 | 1846 |
self sensor ctrlDown ifTrue:[^ self ]. |
1847 |
||
1848 |
(multipleSelectOk and:[selectedColIndex == 0 and:[selectedRowIndex notNil]]) ifFalse:[ |
|
1849 |
^ self |
|
1850 |
]. |
|
1851 |
"is it the select or 1-button ?" |
|
1852 |
||
1023
59c1888ca494
use another left-button-down test in #buttonMotion.
Claus Gittinger <cg@exept.de>
parents:
1008
diff
changeset
|
1853 |
self sensor leftButtonPressed ifFalse:[^ self]. |
1749 | 1854 |
|
1855 |
autoScroll ifTrue:[ |
|
1856 |
"/ if moved outside of view, start autoscroll |
|
1857 |
(y < 0) ifTrue:[ |
|
1858 |
^ self startAutoScroll:[self scrollUp] distance:y. |
|
1859 |
]. |
|
1860 |
(y > height) ifTrue:[ |
|
1861 |
^ self startAutoScroll:[self scrollDown] distance:(y - height). |
|
1862 |
]. |
|
1863 |
]. |
|
1864 |
||
1865 |
"move inside - stop autoscroll if any" |
|
1866 |
self stopAutoScroll. |
|
1867 |
||
607 | 1868 |
y > height ifTrue:[ |
1754 | 1869 |
lnNr := self yVisibleToRowNr:(height + rowHeight). |
607 | 1870 |
] ifFalse:[ |
1871 |
y < 0 ifTrue:[ |
|
1754 | 1872 |
lnNr := self yVisibleToRowNr:(rowHeight negated). |
607 | 1873 |
] ifFalse:[ |
1754 | 1874 |
lnNr := self yVisibleToRowNr:y. |
607 | 1875 |
] |
1876 |
]. |
|
1754 | 1877 |
|
1878 |
(lnNr isNil or:[lnNr < 1]) ifTrue:[ |
|
607 | 1879 |
^ self |
1880 |
]. |
|
1749 | 1881 |
|
1754 | 1882 |
oldSelection := selectedRowIndex asOrderedCollection. |
1883 |
selectedRowIndex := OrderedCollection new. |
|
1884 |
||
1885 |
clickPosition isNil ifTrue:[ |
|
1886 |
clickPosition := oldSelection at:1 ifAbsent:lnNr |
|
643 | 1887 |
]. |
1754 | 1888 |
|
1889 |
step := lnNr < clickPosition ifTrue:[-1] ifFalse:[1]. |
|
1890 |
||
1891 |
clickPosition to:lnNr by:step do:[:i| |
|
1892 |
selectedRowIndex add:i. |
|
1893 |
oldSelection removeIdentical:i ifAbsent:[ self invalidateRowAt:i colAt:0 ]. |
|
607 | 1894 |
]. |
1754 | 1895 |
oldSelection do:[:i| self invalidateRowAt:i colAt:0 ]. |
1896 |
self scrollToRowAt:lnNr colAt:0. |
|
607 | 1897 |
! |
1898 |
||
542 | 1899 |
buttonMultiPress:button x:x y:y |
1900 |
"a button was pressed twice - handle doubleclick here |
|
1901 |
" |
|
1805 | 1902 |
self isEnabled ifFalse:[^ self]. |
1903 |
||
542 | 1904 |
((button == 1) or:[button == #select]) ifFalse:[ |
1905 |
^ super buttonMultiPress:button x:x y:y |
|
1906 |
]. |
|
607 | 1907 |
self numberOfSelections == 1 ifTrue:[ |
1908 |
self firstIndexSelected == (self yVisibleToRowNr:y) ifTrue:[ |
|
1909 |
( selectedColIndex == 0 |
|
1910 |
or:[selectedColIndex == (self xVisibleToColNr:x)] |
|
1911 |
) ifTrue:[ |
|
1912 |
self doubleClicked |
|
1913 |
] |
|
542 | 1914 |
] |
1915 |
] |
|
1916 |
||
1917 |
||
1918 |
||
1919 |
||
1920 |
! |
|
1921 |
||
1922 |
buttonPress:button x:x y:y |
|
1923 |
"a button was pressed - handle selection here |
|
1924 |
" |
|
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1925 |
|rowNr colNr menu sz first sensor| |
542 | 1926 |
|
1805 | 1927 |
self isEnabled ifFalse:[^ self]. |
1928 |
||
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1929 |
sensor := self sensor. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1930 |
|
809 | 1931 |
clickPosition := nil. |
1932 |
dragAccessPoint := nil. |
|
1933 |
dragIsActive := false. |
|
1934 |
||
667 | 1935 |
((button == 2) or:[button == #menu]) ifTrue:[ |
1936 |
(menu := self findMenuForSelection) notNil ifTrue:[ |
|
1937 |
^ menu startUp |
|
1938 |
] |
|
1939 |
] ifFalse:[ |
|
1940 |
( (button == 1 or:[button == #select]) |
|
1941 |
and:[(rowNr := self yVisibleToRowNr:y) notNil |
|
1942 |
and:[(colNr := self xVisibleToColNr:x) notNil]] |
|
1943 |
) ifTrue:[ |
|
1603 | 1944 |
multipleSelectOk ifTrue:[ |
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1945 |
sensor ctrlDown ifTrue:[ |
1603 | 1946 |
selectedColIndex ~~ 0 ifTrue:[ |
1947 |
colNr := 0 |
|
1948 |
] ifFalse:[ |
|
1949 |
(sz := self numberOfSelections == 0) ifFalse:[ |
|
1950 |
(self isInSelection:rowNr) ifTrue:[ |
|
1951 |
sz == 1 ifTrue:[ |
|
1952 |
self selectColIndex:0 rowIndex:nil. |
|
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1953 |
sensor flushMotionEventsFor:self. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1954 |
^ self |
1603 | 1955 |
]. |
1956 |
selectedRowIndex remove:rowNr. |
|
1957 |
] ifFalse:[ |
|
1958 |
selectedRowIndex add:rowNr |
|
1959 |
]. |
|
1960 |
self invalidateRowAt:rowNr. |
|
1961 |
self selectionChanged. |
|
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1962 |
sensor flushMotionEventsFor:self. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1963 |
^ self |
1603 | 1964 |
] |
1965 |
] |
|
667 | 1966 |
] ifFalse:[ |
1603 | 1967 |
( selectedColIndex == 0 |
1968 |
and:[(first := self firstIndexSelected) ~~ 0 |
|
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
1969 |
and:[sensor shiftDown]] |
1603 | 1970 |
) ifTrue:[|step list| |
1971 |
list := OrderedCollection new. |
|
1972 |
step := first < rowNr ifTrue:[1] ifFalse:[-1]. |
|
1973 |
first to:rowNr by:step do:[:i|list add:i]. |
|
1974 |
self selectedRowIndex:list. |
|
1975 |
^ self. |
|
607 | 1976 |
] |
667 | 1977 |
] |
1978 |
]. |
|
824 | 1979 |
(self canDrag and:[self isSelected:rowNr inColumn:colNr]) ifTrue:[ |
1980 |
clickPosition := x @ y. |
|
809 | 1981 |
dragAccessPoint := (colNr @ rowNr). |
1982 |
] ifFalse:[ |
|
1983 |
self selectRowAt:rowNr colAt:colNr atPoint:(x @ y) |
|
667 | 1984 |
]. |
1985 |
^ self |
|
542 | 1986 |
] |
1987 |
]. |
|
667 | 1988 |
super buttonPress:button x:x y:y |
542 | 1989 |
! |
1990 |
||
643 | 1991 |
buttonRelease:button x:x y:y |
1992 |
||
1749 | 1993 |
self stopAutoScroll. |
1994 |
||
643 | 1995 |
clickPosition notNil ifTrue:[ |
809 | 1996 |
dragAccessPoint notNil ifTrue:[ |
1997 |
dragIsActive ifFalse:[ |
|
1998 |
self selectRowAt:(dragAccessPoint y) |
|
1999 |
colAt:(dragAccessPoint x) |
|
2000 |
atPoint:clickPosition |
|
2001 |
]. |
|
2002 |
dragAccessPoint := nil. |
|
824 | 2003 |
dragIsActive := false. |
809 | 2004 |
] ifFalse:[ |
2005 |
self selectionChanged |
|
2006 |
]. |
|
643 | 2007 |
clickPosition := nil. |
2008 |
]. |
|
2009 |
super buttonRelease:button x:x y:y |
|
2010 |
||
2011 |
||
2012 |
! |
|
2013 |
||
809 | 2014 |
characterPress:aChar x:x y:y |
2015 |
"search row in column at x/y starting its printable label with cahracter. |
|
2016 |
" |
|
2017 |
|colNr rowNr lsize found column| |
|
2018 |
||
872
ad92183a6e6b
pass unhandled keys up (for focus control)
Claus Gittinger <cg@exept.de>
parents:
861
diff
changeset
|
2019 |
(rowIfAbsentBlock notNil |
896
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
2020 |
or:[x isNil |
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
2021 |
or:[(colNr := self xVisibleToColNr:x) isNil]]) ifTrue:[ |
809 | 2022 |
^ self |
2023 |
]. |
|
2024 |
rowNr := self lastIndexSelected. |
|
1497 | 2025 |
lsize := list size. |
809 | 2026 |
column := self columnAt:colNr. |
2027 |
found := 0. |
|
2028 |
||
2029 |
lsize > rowNr ifTrue:[ |
|
2030 |
"/ search to end |
|
2031 |
found := column findRowNrStartingWithChar:aChar start:(rowNr + 1) stop:lsize. |
|
2032 |
]. |
|
2033 |
||
2034 |
(found == 0 and:[rowNr > 1]) ifTrue:[ |
|
2035 |
"/ search from begin |
|
2036 |
found := column findRowNrStartingWithChar:aChar start:1 stop:(rowNr - 1) |
|
2037 |
]. |
|
2038 |
found ~~ 0 ifTrue:[ |
|
2039 |
self selectColIndex:colNr rowIndex:found. |
|
2040 |
]. |
|
2041 |
||
896
aa07612a7c04
care for redirected messages in characterPress:
Claus Gittinger <cg@exept.de>
parents:
892
diff
changeset
|
2042 |
"Modified: / 21.5.1998 / 03:30:22 / cg" |
809 | 2043 |
! |
2044 |
||
542 | 2045 |
contentsChanged |
2046 |
"contents changed - move origin up if possible |
|
2047 |
" |
|
2048 |
|y| |
|
2049 |
||
2050 |
shown ifTrue:[ |
|
2051 |
self recomputeHeightOfContents. |
|
2052 |
y := self maxViewOriginY. |
|
2053 |
||
2054 |
viewOrigin y > y ifTrue:[ |
|
1948
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
2055 |
scrollWhenUpdating ~~ false ifTrue:[ |
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
2056 |
self scrollTo:(viewOrigin x @ y) |
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
2057 |
] |
542 | 2058 |
] ifFalse:[ |
2059 |
self updateEditViewOrigin. |
|
2060 |
] |
|
2061 |
]. |
|
2062 |
super contentsChanged |
|
2063 |
! |
|
2064 |
||
2065 |
doubleClicked |
|
2066 |
"handle a double click |
|
2067 |
" |
|
637 | 2068 |
|col sel idx| |
2069 |
||
2070 |
self hasSelection ifTrue:[ |
|
2071 |
idx := self firstIndexSelected. |
|
2072 |
col := self selectedColumn. |
|
2073 |
(col notNil and:[(sel := col doubleClickedSelector) notNil]) ifTrue:[ |
|
2074 |
(self at:idx) perform:sel |
|
2075 |
] ifFalse:[ |
|
2076 |
doubleClickActionBlock notNil ifTrue:[ |
|
2077 |
doubleClickActionBlock value:idx |
|
2078 |
] |
|
2079 |
] |
|
2080 |
] |
|
542 | 2081 |
! |
2082 |
||
667 | 2083 |
findMenuForSelection |
2084 |
"find the middle button menu for the current selection; returns the menu or nil |
|
2085 |
" |
|
2086 |
|col row menu| |
|
2087 |
||
2088 |
self numberOfSelections == 1 ifTrue:[ |
|
2089 |
row := self at:(self firstIndexSelected). |
|
2090 |
col := self selectedColumn. |
|
2091 |
||
2092 |
(col notNil and:[(menu := col menuForRow:row) notNil]) ifTrue:[ |
|
2093 |
^ menu |
|
2094 |
]. |
|
2095 |
col := columnDescriptors detect:[:c| c rendererType == #rowSelector] |
|
2096 |
ifNone:[nil]. |
|
2097 |
||
2098 |
col notNil ifTrue:[ |
|
1223
176702811314
kludge: when asking for an itemMenu, pass application to
tm
parents:
1215
diff
changeset
|
2099 |
^ col menuForRow:row inApplication:(self application) |
667 | 2100 |
] |
2101 |
]. |
|
2102 |
^ nil |
|
2103 |
! |
|
2104 |
||
1111 | 2105 |
keyPress:aKey x:x y:y |
542 | 2106 |
"a key was pressed - handle page-keys here |
2107 |
" |
|
2108 |
<resource: #keyboard (#PreviousPage #NextPage #HalfPageUp #HalfPageDown |
|
809 | 2109 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2110 |
#CursorUp #CursorDown #CursorRight #CursorLeft #SelectAll)> |
542 | 2111 |
|
1776 | 2112 |
|sensor maxColNr selRowNr selColNr key column isTab listSize hasSelectables| |
1111 | 2113 |
|
1805 | 2114 |
self isEnabled ifFalse:[^ self]. |
2115 |
||
1111 | 2116 |
(sensor := self sensor) isNil ifTrue:[ |
2117 |
^ self |
|
542 | 2118 |
]. |
1416 | 2119 |
(listSize := list size) == 0 ifTrue:[ |
2120 |
^ super keyPress:aKey x:x y:y |
|
2121 |
]. |
|
1776 | 2122 |
aKey isCharacter ifTrue:[ |
2123 |
^ self characterPress:aKey x:x y:y |
|
542 | 2124 |
]. |
1111 | 2125 |
|
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2126 |
(aKey == #SelectAll) ifTrue:[ |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2127 |
multipleSelectOk ifTrue:[ |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2128 |
self selectAllRows. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2129 |
]. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2130 |
^ self |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2131 |
]. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
2132 |
|
1776 | 2133 |
aKey == #PreviousPage ifTrue:[^ self pageUp]. |
2134 |
aKey == #NextPage ifTrue:[^ self pageDown]. |
|
2135 |
aKey == #HalfPageUp ifTrue:[^ self halfPageUp]. |
|
2136 |
aKey == #HalfPageDown ifTrue:[^ self halfPageDown]. |
|
2137 |
aKey == #BeginOfText ifTrue:[^ self scrollToTop]. |
|
2138 |
aKey == #EndOfText ifTrue:[^ self scrollToBottom]. |
|
2139 |
aKey == #ScrollUp ifTrue:[^ self scrollUp]. |
|
2140 |
aKey == #ScrollDown ifTrue:[^ self scrollDown]. |
|
2141 |
||
1111 | 2142 |
aKey == #Return ifTrue:[ |
1416 | 2143 |
self numberOfSelections == 1 ifTrue:[self doubleClicked]. |
2144 |
^ self |
|
542 | 2145 |
]. |
1111 | 2146 |
|
1668 | 2147 |
hasSelectables := false. |
2148 |
||
2149 |
columnDescriptors do:[:aCol| |
|
2150 |
(hasSelectables or:[aCol rendererType == #rowSelector]) ifFalse:[ |
|
2151 |
hasSelectables := aCol description canSelect |
|
2152 |
] |
|
2153 |
]. |
|
1776 | 2154 |
selRowNr := self firstIndexSelected. |
2155 |
||
2156 |
(aKey == #CursorUp or:[aKey == #CursorDown]) ifTrue:[ |
|
2157 |
(hasSelectables or:[selectRowOnDefault]) ifTrue:[ |
|
2158 |
selColNr := hasSelectables ifFalse:[0] |
|
2159 |
ifTrue:[selectedColIndex]. |
|
2160 |
||
2161 |
aKey == #CursorUp ifTrue:[ |
|
2162 |
selRowNr := selRowNr > 1 ifTrue:[selRowNr - 1] ifFalse:[listSize]. |
|
2163 |
] ifFalse:[ |
|
2164 |
selRowNr := selRowNr < listSize ifTrue:[selRowNr + 1] ifFalse:[1]. |
|
2165 |
]. |
|
2166 |
self selectColIndex:selColNr rowIndex:selRowNr |
|
2167 |
]. |
|
2168 |
^ self |
|
2169 |
]. |
|
1668 | 2170 |
|
2171 |
hasSelectables ifFalse:[ |
|
2172 |
^ super keyPress:aKey x:x y:y |
|
2173 |
]. |
|
2174 |
||
1776 | 2175 |
"/ CURSOR LEFT/RIGHT or TABING |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2176 |
(aKey == #CursorLeft or:[aKey == #CursorRight]) ifFalse:[ |
1668 | 2177 |
tabIntern ifFalse:[ |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2178 |
^ super keyPress:aKey x:x y:y |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2179 |
]. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2180 |
|
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2181 |
(aKey includesString:'Tab') ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2182 |
key := (sensor shiftDown or:[aKey includesString:'Left']) ifTrue:[#CursorLeft] |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2183 |
ifFalse:[#CursorRight] |
1416 | 2184 |
] ifFalse:[ |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2185 |
(aKey == #FocusPrevious or:[aKey == #FocusNext]) ifFalse:[ |
1416 | 2186 |
^ super keyPress:aKey x:x y:y |
2187 |
]. |
|
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2188 |
key := aKey == #FocusPrevious ifTrue:[#CursorLeft] ifFalse:[#CursorRight]. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2189 |
]. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2190 |
isTab := true. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2191 |
] ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2192 |
isTab := false. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2193 |
key := aKey. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2194 |
]. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2195 |
|
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2196 |
maxColNr := self numberOfColumns. |
1776 | 2197 |
selColNr := selectedColIndex. |
612 | 2198 |
|
1111 | 2199 |
key == #CursorLeft ifTrue:[ |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2200 |
selRowNr == 0 ifTrue:[selRowNr := listSize]. |
1776 | 2201 |
selColNr == 0 ifTrue:[selColNr := maxColNr + 1]. |
2202 |
||
2203 |
[true] whileTrue:[ |
|
2204 |
(selColNr := selColNr - 1) == 0 ifTrue:[ |
|
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2205 |
(selRowNr := selRowNr - 1) == 0 ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2206 |
isTab ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2207 |
tabAtStartAction notNil ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2208 |
tabAtStartAction value |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2209 |
] ifFalse:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2210 |
self deselect. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2211 |
self windowGroup focusPreviousFrom:self |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2212 |
] |
1416 | 2213 |
]. |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2214 |
^ self |
1111 | 2215 |
]. |
1776 | 2216 |
selColNr := maxColNr |
1111 | 2217 |
]. |
1776 | 2218 |
column := self columnAt:selColNr. |
1416 | 2219 |
|
1111 | 2220 |
(column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[ |
1776 | 2221 |
^ self selectColIndex:selColNr rowIndex:selRowNr. |
1111 | 2222 |
] |
2223 |
] |
|
542 | 2224 |
]. |
1776 | 2225 |
|
2226 |
selRowNr == 0 ifTrue:[selRowNr := 1]. |
|
2227 |
||
2228 |
[true] whileTrue:[ |
|
2229 |
(selColNr := selColNr + 1) > maxColNr ifTrue:[ |
|
2230 |
(selRowNr := selRowNr + 1) > listSize ifTrue:[ |
|
2231 |
isTab ifTrue:[ |
|
2232 |
tabAtEndAction notNil ifTrue:[ |
|
2233 |
tabAtEndAction value |
|
2234 |
] ifFalse:[ |
|
2235 |
self deselect. |
|
2236 |
self windowGroup focusNextFrom:self |
|
2237 |
] |
|
2238 |
]. |
|
2239 |
^ self |
|
2240 |
]. |
|
2241 |
selColNr := 1 |
|
2242 |
]. |
|
2243 |
column := self columnAt:selColNr. |
|
2244 |
||
2245 |
(column rendererType ~~ #rowSelector and:[column canSelect:selRowNr]) ifTrue:[ |
|
2246 |
^ self selectColIndex:selColNr rowIndex:selRowNr |
|
2247 |
] |
|
2248 |
]. |
|
542 | 2249 |
! |
2250 |
||
2251 |
originChanged:delta |
|
2252 |
"this one is sent, after the origin of my contents has changed - |
|
2253 |
tell dependents (i.e. scrollers) about this |
|
2254 |
" |
|
2255 |
super originChanged:delta. |
|
2256 |
self updateEditViewOrigin. |
|
2257 |
! ! |
|
2258 |
||
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2259 |
!DSVColumnView methodsFor:'focus handling'! |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2260 |
|
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2261 |
canTab |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2262 |
super canTab ifTrue:[ |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2263 |
^ editView isNil |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2264 |
]. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2265 |
^ false |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2266 |
! ! |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
2267 |
|
542 | 2268 |
!DSVColumnView methodsFor:'gc operations'! |
2269 |
||
1100 | 2270 |
imageOnDevice:anImage |
2271 |
"associate image to device and clear pixel mask; returns the new image. |
|
2272 |
" |
|
2273 |
|image| |
|
2274 |
||
2275 |
(image := anImage) notNil ifTrue:[ |
|
2276 |
image device ~~ device ifTrue:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2277 |
image := image copy onDevice:device. |
1100 | 2278 |
]. |
2279 |
image isImage ifTrue:[ |
|
2280 |
image := image clearMaskedPixels |
|
2281 |
] |
|
2282 |
]. |
|
2283 |
^ image |
|
2284 |
||
2285 |
! |
|
2286 |
||
542 | 2287 |
registerImage:anImage key:aKey |
2288 |
"any row can register an image with a unique identifier a key symbol |
|
2289 |
" |
|
2290 |
|img| |
|
2291 |
||
2292 |
(img := registererImages at:aKey ifAbsent:nil) notNil ifTrue:[ |
|
2293 |
^ img |
|
2294 |
]. |
|
1112 | 2295 |
img := self imageOnDevice:anImage. |
567 | 2296 |
registererImages at:aKey put:img. |
2297 |
^ img |
|
542 | 2298 |
! |
2299 |
||
2300 |
registeredImageAt:aKey |
|
2301 |
"any row can register an image with a unique identifier |
|
2302 |
" |
|
2303 |
^ registererImages at:aKey ifAbsent:nil |
|
2304 |
! |
|
2305 |
||
2306 |
releaseAllRegisteredImages |
|
2307 |
"release all registered images |
|
2308 |
" |
|
2309 |
registererImages := IdentityDictionary new. |
|
2310 |
! ! |
|
2311 |
||
1326 | 2312 |
!DSVColumnView methodsFor:'initialize / release'! |
542 | 2313 |
|
2314 |
create |
|
607 | 2315 |
"set color on device |
542 | 2316 |
" |
2317 |
super create. |
|
1480 | 2318 |
fgColor := fgColor onDevice:device. |
2319 |
bgColor := bgColor onDevice:device. |
|
2320 |
hgLgFgColor := hgLgFgColor onDevice:device. |
|
2321 |
hgLgBgColor := hgLgBgColor onDevice:device. |
|
2322 |
||
2323 |
buttonShadowColor := buttonShadowColor onDevice:device. |
|
2324 |
buttonLightColor := buttonLightColor onDevice:device. |
|
809 | 2325 |
|
2326 |
buttonHalfShadowColor notNil ifTrue:[ |
|
1480 | 2327 |
buttonHalfShadowColor := buttonHalfShadowColor onDevice:device |
809 | 2328 |
]. |
2329 |
||
2330 |
buttonHalfLightColor notNil ifTrue:[ |
|
1480 | 2331 |
buttonHalfLightColor := buttonHalfLightColor onDevice:device |
809 | 2332 |
]. |
1100 | 2333 |
rowSelectorForm := self imageOnDevice:rowSelectorForm. |
2334 |
checkToggleActiveImage := self imageOnDevice:checkToggleActiveImage. |
|
2335 |
checkTogglePassiveImage := self imageOnDevice:checkTogglePassiveImage. |
|
2336 |
comboButtonForm := self imageOnDevice:comboButtonForm. |
|
2337 |
checkToggleForm := self imageOnDevice:checkToggleForm. |
|
2338 |
||
2339 |
||
542 | 2340 |
! |
2341 |
||
2342 |
destroy |
|
2343 |
"remove dependencies |
|
2344 |
" |
|
618 | 2345 |
self columnHolder:nil. |
1805 | 2346 |
|
2347 |
listHolder removeDependent:self. |
|
1487 | 2348 |
|
1711 | 2349 |
columnAdaptor isValueModel ifTrue:[ |
2350 |
columnAdaptor removeDependent:self |
|
2351 |
]. |
|
2352 |
||
618 | 2353 |
self beDependentOfRows:false. |
542 | 2354 |
super destroy |
2355 |
! |
|
2356 |
||
2357 |
initStyle |
|
607 | 2358 |
"setup colors |
2359 |
" |
|
1100 | 2360 |
|button widget| |
809 | 2361 |
|
542 | 2362 |
super initStyle. |
2363 |
||
2364 |
DefaultForegroundColor isNil ifTrue:[ |
|
2365 |
self class updateStyleCache |
|
2366 |
]. |
|
2367 |
fgColor := DefaultForegroundColor. |
|
2368 |
bgColor := DefaultBackgroundColor. |
|
2369 |
hgLgFgColor := DefaultHilightForegroundColor. |
|
2370 |
hgLgBgColor := DefaultHilightBackgroundColor. |
|
809 | 2371 |
|
2372 |
shadowColor isNil ifTrue:[ |
|
2373 |
shadowColor := Color grayPercent:40. |
|
2374 |
]. |
|
2375 |
||
2376 |
lightColor isNil ifTrue:[ |
|
2377 |
lightColor := Color grayPercent:75 |
|
2378 |
]. |
|
2379 |
||
2380 |
buttonLightColor := ButtonLightColor ? lightColor. |
|
2381 |
buttonShadowColor := ButtonShadowColor ? shadowColor. |
|
2382 |
||
2383 |
(ButtonEdgeStyle == #soft) ifTrue:[ |
|
2384 |
buttonHalfShadowColor := ButtonHalfShadowColor. |
|
2385 |
buttonHalfLightColor := ButtonHalfLightColor. |
|
2386 |
||
2387 |
buttonHalfShadowColor isNil ifTrue:[ |
|
2388 |
buttonHalfShadowColor := buttonShadowColor lightened |
|
2389 |
] |
|
2390 |
]. |
|
1490 | 2391 |
|
2392 |
buttonHalfShadowColor isNil ifTrue:[ |
|
2393 |
buttonHalfShadowColor := Color gray |
|
2394 |
]. |
|
2395 |
||
1100 | 2396 |
rowSelectorForm := self class rowSelector. |
2397 |
checkToggleActiveImage := CheckToggleActiveImage. |
|
2398 |
checkTogglePassiveImage := CheckTogglePassiveImage. |
|
2399 |
||
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2400 |
ComboButtonForm isNil ifTrue:[ |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2401 |
widget := ComboListView new. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2402 |
button := widget menuButton. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2403 |
ComboButtonForm := button label. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2404 |
ComboButtonLevel := button offLevel. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2405 |
ComboButtonExtent := (button preferredExtent x) @ (widget preferredExtent y). |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2406 |
]. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2407 |
|
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2408 |
CheckToggleForm isNil ifTrue:[ |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2409 |
widget := CheckToggle new. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2410 |
CheckToggleForm := widget label. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2411 |
CheckToggleLevel := widget offLevel. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2412 |
CheckToggleExtent := widget preferredExtent. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2413 |
]. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2414 |
comboButtonForm := ComboButtonForm. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2415 |
comboButtonLevel := ComboButtonLevel. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2416 |
comboButtonExtent := ComboButtonExtent. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2417 |
|
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2418 |
checkToggleForm := CheckToggleForm. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2419 |
checkToggleLevel := CheckToggleLevel. |
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2420 |
checkToggleExtent := CheckToggleExtent. |
542 | 2421 |
! |
2422 |
||
2423 |
initialize |
|
2424 |
"set default attributes |
|
2425 |
" |
|
2426 |
super initialize. |
|
1487 | 2427 |
self lineWidth:0. |
2428 |
||
1668 | 2429 |
tabIntern := true. |
1487 | 2430 |
useIndex := true. |
1112 | 2431 |
viewOrigin := 0@0. |
1480 | 2432 |
font := font onDevice:device. |
1112 | 2433 |
rowHeight := font height. |
2434 |
multipleSelectOk := false. "/ multiselect disabled |
|
2435 |
selectedRowIndex := selectedColIndex := 0. "/ no selection |
|
1778
51bbd960baf9
change registeredIcons from IdentityDictionary to Dictionary
ca
parents:
1776
diff
changeset
|
2436 |
registererImages := Dictionary new. |
1112 | 2437 |
columnDescriptors := #(). |
2438 |
beDependentOfRows := false. |
|
2439 |
verticalSpacing := self class verticalSpacing. |
|
2440 |
horizontalSpacing := self class horizontalSpacing. |
|
2441 |
colorMap := Dictionary new. |
|
2442 |
catchChangeEvents := false. |
|
2443 |
dragIsActive := false. |
|
2444 |
rowFontAscent := 1. "/ dummy initialization |
|
2445 |
separatorSize := 1. "/ separators mode 2D |
|
2446 |
selectRowOnDefault := true. |
|
1749 | 2447 |
autoScroll := true. |
542 | 2448 |
! |
2449 |
||
705 | 2450 |
mapped |
2451 |
"set selection if exists after mapping |
|
2452 |
" |
|
2453 |
|idx| |
|
2454 |
||
2455 |
super mapped. |
|
1949 | 2456 |
needFitColumns == true ifTrue:[ |
2457 |
self fitColumns |
|
2458 |
]. |
|
705 | 2459 |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2460 |
(idx := self firstIndexSelected) ~~ 0 ifTrue:[ |
705 | 2461 |
self scrollToRowAt:idx colAt:0. |
2462 |
]. |
|
2463 |
! |
|
2464 |
||
542 | 2465 |
realize |
607 | 2466 |
"recompute contents and fit columns to view |
542 | 2467 |
" |
1487 | 2468 |
|selection| |
2469 |
||
607 | 2470 |
self bitGravity:#NorthWest. |
542 | 2471 |
self recomputeHeightOfContents. |
1487 | 2472 |
|
2473 |
selection := 0. |
|
2474 |
||
2475 |
model notNil ifTrue:[ |
|
2476 |
(model respondsTo:#selectionIndex) ifTrue:[ |
|
2477 |
selection := model selectionIndex |
|
2478 |
] ifFalse:[ |
|
2479 |
model == listHolder ifFalse:[ |
|
2480 |
selection := model value |
|
2481 |
] |
|
2482 |
] |
|
2483 |
]. |
|
2484 |
self selectRowIndex:selection. |
|
2485 |
||
542 | 2486 |
super realize. |
607 | 2487 |
self fitColumns. |
2488 |
! ! |
|
2489 |
||
2490 |
!DSVColumnView methodsFor:'obsolete'! |
|
2491 |
||
2492 |
has3Dsepartors |
|
2493 |
"shouldn't be used any more |
|
2494 |
" |
|
2495 |
^ self has3Dseparators |
|
2496 |
! |
|
2497 |
||
2498 |
has3Dsepartors:aBool |
|
2499 |
"shouldn't be used any more |
|
2500 |
" |
|
2501 |
self has3Dseparators:aBool |
|
542 | 2502 |
|
2503 |
! ! |
|
2504 |
||
2505 |
!DSVColumnView methodsFor:'private'! |
|
2506 |
||
1951 | 2507 |
anyColumnHasBackground |
2508 |
columnDescriptors isNil ifTrue:[^ false]. |
|
2509 |
columnDescriptors do:[:eachCol | |
|
2510 |
|bg| |
|
2511 |
||
2512 |
bg := eachCol backgroundColor. |
|
2513 |
(bg notNil and:[bg isImageOrForm]) ifTrue:[^ true]. |
|
2514 |
eachCol bgSelector notNil ifTrue:[^ true]. |
|
2515 |
]. |
|
2516 |
^ false. |
|
2517 |
! |
|
2518 |
||
2519 |
anyColumnHasPotentialNonConstantBackground |
|
2520 |
columnDescriptors isNil ifTrue:[^ false]. |
|
2521 |
columnDescriptors do:[:eachCol | eachCol hasPotentialNonConstantBackground ifTrue:[^ true]]. |
|
2522 |
^ false. |
|
2523 |
! |
|
2524 |
||
1111 | 2525 |
destroyEditView |
2526 |
"destroy the edit view; release KeyboardForwarder |
|
2527 |
" |
|
2528 |
editView notNil ifTrue:[ |
|
2529 |
editView withAllSubViewsDo:[:aView| |
|
2530 |
aView delegate:nil |
|
2531 |
]. |
|
2532 |
editView destroy. |
|
2533 |
editView := nil. |
|
2534 |
self windowGroup focusView:nil. |
|
2535 |
]. |
|
2536 |
||
2537 |
||
2538 |
! |
|
2539 |
||
637 | 2540 |
detectViewAt:aPoint in:aView |
1087 | 2541 |
"returns the view at a point |
2542 |
" |
|
637 | 2543 |
|p| |
2544 |
||
2545 |
(aView notNil and:[aView subViews notNil]) ifTrue:[ |
|
2546 |
aView subViews do:[:sv| |
|
2547 |
p := device translatePoint:aPoint from:(self id) to:(sv id). |
|
2548 |
||
2549 |
(p x >= 0 and:[p y >= 0 and:[p x <= sv width and:[p y <= sv height]]]) ifTrue:[ |
|
2550 |
^ self detectViewAt:aPoint in:sv |
|
2551 |
] |
|
2552 |
] |
|
2553 |
]. |
|
2554 |
^ aView |
|
2555 |
! |
|
2556 |
||
542 | 2557 |
fitColumns |
1484 | 2558 |
"fit columns to view; |
542 | 2559 |
" |
1498 | 2560 |
|list width changed dX sz oldOrgX newOrgX| |
1487 | 2561 |
|
2562 |
preferredExtent isNil ifTrue:[ |
|
2563 |
self preferredExtent. |
|
2564 |
]. |
|
1484 | 2565 |
|
2566 |
columnDescriptors isEmpty ifTrue:[ |
|
2567 |
^ self |
|
2568 |
]. |
|
1492 | 2569 |
width := 0. |
2570 |
list := OrderedCollection new. |
|
1484 | 2571 |
|
2572 |
columnDescriptors do:[:aCol| |
|
2573 |
aCol canResize ifTrue:[ |
|
2574 |
changed := true. |
|
2575 |
aCol invalidate. |
|
1492 | 2576 |
aCol hasRelativeWidth ifFalse:[list add:aCol]. |
1484 | 2577 |
]. |
1492 | 2578 |
width := width + aCol minWidth. |
1484 | 2579 |
]. |
1492 | 2580 |
preferredExtent x:width. |
2581 |
width := self innerWidth - width. |
|
2582 |
||
2583 |
(list notEmpty and:[width > 0]) ifTrue:[ |
|
2584 |
sz := list size. |
|
2585 |
width >= sz ifTrue:[ |
|
2586 |
dX := width // sz. |
|
1484 | 2587 |
list do:[:aCol|aCol growWidth:dX]. |
1492 | 2588 |
width := width - (dX * sz). |
1484 | 2589 |
]. |
1492 | 2590 |
width ~~ 0 ifTrue:[list last growWidth:width]. |
1484 | 2591 |
]. |
1492 | 2592 |
|
612 | 2593 |
shown ifTrue:[ |
1492 | 2594 |
self invalidate. |
1487 | 2595 |
labelView invalidate. |
542 | 2596 |
|
1498 | 2597 |
(oldOrgX := viewOrigin x) ~~ 0 ifTrue:[ |
2598 |
"/ UPDATE VIEW-ORIGIN X |
|
2599 |
||
2600 |
width := preferredExtent x. |
|
2601 |
newOrgX := (width - self innerWidth) max:0. |
|
2602 |
||
2603 |
newOrgX < oldOrgX ifTrue:[ |
|
2604 |
self originWillChange. |
|
2605 |
viewOrigin := newOrgX @ (viewOrigin y). |
|
2606 |
self originChanged:((newOrgX - oldOrgX) @ 0). |
|
2607 |
] |
|
2608 |
]. |
|
2609 |
||
1930
31274c3264d6
do not scroll to selection when a column-size is changed
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
2610 |
"/ 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
|
2611 |
"/ self hasSelection ifTrue:[ |
31274c3264d6
do not scroll to selection when a column-size is changed
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
2612 |
"/ editView notNil ifTrue:[ |
31274c3264d6
do not scroll to selection when a column-size is changed
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
2613 |
"/ 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
|
2614 |
"/ ]. |
31274c3264d6
do not scroll to selection when a column-size is changed
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
2615 |
"/ self scrollToSelection. |
31274c3264d6
do not scroll to selection when a column-size is changed
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
2616 |
"/ ]. |
1498 | 2617 |
self contentsChanged. |
542 | 2618 |
]. |
2619 |
! |
|
2620 |
||
2621 |
maxViewOriginY |
|
2622 |
"returns the maximum possible y of the view origin |
|
2623 |
" |
|
2624 |
|y| |
|
2625 |
||
2626 |
y := self heightOfContents - self innerHeight. |
|
2627 |
^ y max:0 |
|
2628 |
||
2629 |
! |
|
2630 |
||
2631 |
updateEditViewOrigin |
|
2632 |
"update origin of the editView |
|
2633 |
" |
|
2634 |
|x y| |
|
2635 |
||
2636 |
editView notNil ifTrue:[ |
|
607 | 2637 |
y := self yVisibleOfRowNr:(self firstIndexSelected). |
1498 | 2638 |
x := self xVisibleOfColNr:selectedColIndex. |
542 | 2639 |
|
1112 | 2640 |
editView origin:(x @ y + separatorSize). |
542 | 2641 |
]. |
2642 |
||
2643 |
! |
|
2644 |
||
2645 |
xVisibleOfColNr:aColNr |
|
2646 |
"returns visible x assigned to a column number |
|
2647 |
" |
|
1497 | 2648 |
|x |
2649 |
end "{ Class:SmallInteger }" |
|
2650 |
| |
|
542 | 2651 |
x := margin - viewOrigin x. |
1497 | 2652 |
|
1498 | 2653 |
aColNr > 1 ifTrue:[ |
1497 | 2654 |
end := aColNr - 1. |
2655 |
||
2656 |
columnDescriptors from:1 to:end do:[:aCol| |
|
2657 |
x := x + aCol width |
|
2658 |
] |
|
2659 |
]. |
|
542 | 2660 |
^ x |
2661 |
||
2662 |
! |
|
2663 |
||
2664 |
xVisibleToColNr:x |
|
607 | 2665 |
"returns the column number assigned to a physical x or nil |
2666 |
" |
|
1497 | 2667 |
|x0 |
2668 |
nr "{ Class:SmallInteger }" |
|
2669 |
| |
|
542 | 2670 |
|
2671 |
x0 := x + viewOrigin x - margin. |
|
2672 |
nr := 1. |
|
2673 |
||
1497 | 2674 |
columnDescriptors do:[:aCol| |
1951 | 2675 |
x0 := x0 - aCol width. |
2676 |
x0 <= 0 ifTrue:[^ nr]. |
|
542 | 2677 |
nr := nr + 1. |
2678 |
]. |
|
2679 |
^ nil. |
|
2680 |
||
2681 |
! |
|
2682 |
||
2683 |
yVisibleOfRowNr:aRowNr |
|
2684 |
"returns visible y assigned to the row number |
|
2685 |
" |
|
2686 |
^ (aRowNr - 1) * rowHeight + margin - viewOrigin y |
|
2687 |
||
2688 |
! |
|
2689 |
||
2690 |
yVisibleToRowNr:y |
|
607 | 2691 |
"returns the row number assigned to a physical y or nil |
542 | 2692 |
" |
2693 |
|y0| |
|
2694 |
||
2695 |
y0 := (y + viewOrigin y - margin) // rowHeight + 1. |
|
1497 | 2696 |
^ (y0 <= list size) ifTrue:[y0] ifFalse:[nil] |
542 | 2697 |
|
2698 |
! ! |
|
2699 |
||
2700 |
!DSVColumnView methodsFor:'queries'! |
|
2701 |
||
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
2702 |
hasOpenEditor |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
2703 |
^ editView notNil |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
2704 |
! |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
2705 |
|
563 | 2706 |
indexOfFirstRowShown |
2707 |
"returns index of first row shown |
|
2708 |
" |
|
2709 |
|idx| |
|
2710 |
||
1498 | 2711 |
idx := (viewOrigin y // rowHeight) + 1. |
1497 | 2712 |
^ (idx <= list size) ifTrue:[idx] ifFalse:[0] |
563 | 2713 |
|
2714 |
! |
|
2715 |
||
1805 | 2716 |
isEnabled |
2717 |
^ enableChannel value ~~ false |
|
2718 |
! |
|
2719 |
||
542 | 2720 |
numberOfColumns |
2721 |
"returns number of columns |
|
2722 |
" |
|
2723 |
^ columnDescriptors size |
|
2724 |
||
2725 |
! |
|
2726 |
||
2727 |
numberOfRows |
|
2728 |
"returns number of raws |
|
2729 |
" |
|
1497 | 2730 |
^ list size |
542 | 2731 |
|
2732 |
! |
|
2733 |
||
2734 |
rowHeight |
|
2735 |
"get the height of the highest row in pixels |
|
2736 |
" |
|
2737 |
^ rowHeight |
|
2738 |
||
2739 |
! |
|
2740 |
||
2741 |
separatorSize |
|
2742 |
"returns vertical/horizontal size of a separator dependent on the |
|
2743 |
3D effect. |
|
2744 |
" |
|
607 | 2745 |
^ separatorSize |
542 | 2746 |
|
2747 |
! |
|
2748 |
||
2749 |
size |
|
2750 |
"returns number of raws |
|
2751 |
" |
|
2752 |
^ list size |
|
2753 |
||
2754 |
! ! |
|
2755 |
||
2756 |
!DSVColumnView methodsFor:'recomputation'! |
|
2757 |
||
647 | 2758 |
hasPreferredExtent |
2759 |
"returns true if preferred extent is accumulated |
|
2760 |
" |
|
2761 |
^ preferredExtent notNil |
|
2762 |
! |
|
2763 |
||
542 | 2764 |
preferredExtent |
647 | 2765 |
"recompute preferred extent; raise notification |
542 | 2766 |
" |
1497 | 2767 |
|x "{ Class:SmallInteger }" |
2768 |
h "{ Class:SmallInteger }" |
|
2769 |
| |
|
542 | 2770 |
|
2771 |
preferredExtent notNil ifTrue:[ |
|
2772 |
^ preferredExtent |
|
2773 |
]. |
|
2774 |
x := 3. |
|
1521 | 2775 |
h := 0. |
1497 | 2776 |
|
2777 |
columnDescriptors do:[:aCol| |
|
2778 |
h := (aCol heightOfHighestRow) max:h. |
|
2779 |
x := x + (aCol minWidth). |
|
542 | 2780 |
]. |
1521 | 2781 |
h == 0 ifTrue:[h := font height]. |
1497 | 2782 |
rowHeight := (h + separatorSize + verticalSpacing + verticalSpacing + 1) // 2 * 2. |
2783 |
preferredExtent := x @ (list size * rowHeight). |
|
1201 | 2784 |
rowFontAscent := font ascent. |
2785 |
||
542 | 2786 |
^ preferredExtent |
2787 |
||
2788 |
||
2789 |
! |
|
2790 |
||
2791 |
preferredExtentChanged |
|
1087 | 2792 |
"called if the preffered extent changed |
2793 |
" |
|
1497 | 2794 |
|x "{ Class:SmallInteger }" |
2795 |
y "{ Class:SmallInteger }" |
|
2796 |
| |
|
542 | 2797 |
y := viewOrigin y. |
2798 |
x := viewOrigin x. |
|
2799 |
||
2800 |
(y ~~ 0 or:[x ~~ 0]) ifTrue:[ |
|
2801 |
self originWillChange. |
|
1948
9ed8131d94bb
viewOrigin fix (when list is set to nil while not shown);
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
2802 |
|
542 | 2803 |
viewOrigin := 0 @ 0. |
2804 |
preferredExtent := nil. |
|
2805 |
self originChanged:(x negated @ y negated). |
|
2806 |
] |
|
2807 |
! |
|
2808 |
||
2809 |
recomputeHeightOfContents |
|
1087 | 2810 |
"recompute height of contents( scrolling ) |
2811 |
" |
|
542 | 2812 |
preferredExtent notNil ifTrue:[ |
1497 | 2813 |
preferredExtent y:(rowHeight * list size) |
542 | 2814 |
] ifFalse:[ |
2815 |
self preferredExtent |
|
2816 |
]. |
|
2817 |
! ! |
|
2818 |
||
2819 |
!DSVColumnView methodsFor:'scroller interface'! |
|
2820 |
||
2821 |
heightOfContents |
|
2822 |
"return the height of the contents in pixels |
|
2823 |
" |
|
1498 | 2824 |
preferredExtent isNil ifTrue:[ |
2825 |
self preferredExtent |
|
2826 |
]. |
|
2827 |
^ preferredExtent y |
|
542 | 2828 |
! |
2829 |
||
2830 |
innerHeight |
|
2831 |
"returns the inner height of the contents shown |
|
2832 |
" |
|
2833 |
^ height - margin - margin |
|
2834 |
||
2835 |
! |
|
2836 |
||
2837 |
innerWidth |
|
2838 |
"returns the inner width of the contents shown |
|
2839 |
" |
|
2840 |
^ width - margin - margin |
|
2841 |
||
2842 |
! |
|
2843 |
||
2844 |
verticalScrollStep |
|
2845 |
"return the amount to scroll when stepping up/down. |
|
2846 |
" |
|
2847 |
^ rowHeight |
|
2848 |
||
2849 |
||
2850 |
||
2851 |
! |
|
2852 |
||
2853 |
viewOrigin |
|
2854 |
"return the viewOrigin; thats the coordinate of the contents |
|
2855 |
which is shown topLeft in the view. |
|
2856 |
" |
|
2857 |
^ viewOrigin |
|
2858 |
||
2859 |
! |
|
2860 |
||
2861 |
widthOfContents |
|
2862 |
"return the width of the contents in pixels |
|
2863 |
" |
|
647 | 2864 |
preferredExtent isNil ifTrue:[ |
2865 |
self preferredExtent |
|
2866 |
]. |
|
2867 |
^ preferredExtent x |
|
542 | 2868 |
|
2869 |
! |
|
2870 |
||
2871 |
xOriginOfContents |
|
2872 |
"return the horizontal origin of the contents in pixels |
|
2873 |
" |
|
2874 |
^ viewOrigin x |
|
2875 |
||
2876 |
! |
|
2877 |
||
2878 |
yOriginOfContents |
|
2879 |
"return the vertical origin of the contents in pixels |
|
2880 |
" |
|
2881 |
^ viewOrigin y |
|
2882 |
||
2883 |
! ! |
|
2884 |
||
2885 |
!DSVColumnView methodsFor:'scrolling'! |
|
2886 |
||
2887 |
scrollTo:anOrigin redraw:doRedraw |
|
2888 |
"change origin to have newOrigin be visible at the top-left. |
|
2889 |
" |
|
1497 | 2890 |
|newOrg dltOrg wg |
2891 |
h "{ Class:SmallInteger }" |
|
2892 |
w "{ Class:SmallInteger }" |
|
2893 |
x "{ Class:SmallInteger }" |
|
2894 |
x0 "{ Class:SmallInteger }" |
|
2895 |
x1 "{ Class:SmallInteger }" |
|
2896 |
y "{ Class:SmallInteger }" |
|
2897 |
y0 "{ Class:SmallInteger }" |
|
2898 |
y1 "{ Class:SmallInteger }" |
|
2899 |
dX "{ Class:SmallInteger }" |
|
2900 |
dY "{ Class:SmallInteger }" |
|
2901 |
innerHG "{ Class:SmallInteger }" |
|
2902 |
innerWT "{ Class:SmallInteger }" |
|
2903 |
| |
|
542 | 2904 |
shown ifFalse:[ |
2905 |
^ self |
|
2906 |
]. |
|
612 | 2907 |
|
1448 | 2908 |
(wg := self windowGroup) notNil ifTrue:[ |
2909 |
wg processRealExposeEventsFor:self. |
|
542 | 2910 |
]. |
612 | 2911 |
|
542 | 2912 |
innerWT := self innerWidth. |
2913 |
innerHG := self innerHeight. |
|
2914 |
||
2915 |
h := viewOrigin y. |
|
2916 |
||
2917 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents |
|
2918 |
y > (dY := self maxViewOriginY) ifTrue:[ |
|
2919 |
y := dY max:h |
|
2920 |
] |
|
2921 |
] ifFalse:[ |
|
2922 |
y := y max:0. |
|
2923 |
]. |
|
2924 |
||
2925 |
(x := anOrigin x) > 0 ifTrue:[ |
|
2926 |
x := x min:(self widthOfContents - innerWT). |
|
2927 |
]. |
|
2928 |
x := x max:0. |
|
2929 |
newOrg := (x @ y). |
|
2930 |
dltOrg := newOrg - viewOrigin. |
|
2931 |
dX := dltOrg x. |
|
2932 |
dY := dltOrg y. |
|
2933 |
||
2934 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
2935 |
^ self |
|
2936 |
]. |
|
2937 |
self originWillChange. |
|
2938 |
viewOrigin := newOrg. |
|
2939 |
||
2940 |
doRedraw ifFalse:[ |
|
2941 |
^ self originChanged:dltOrg |
|
2942 |
]. |
|
2943 |
||
2944 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
|
2945 |
dY := dY abs. |
|
2946 |
||
2947 |
(dX ~~ 0 or:[innerHG - dY < 20]) ifTrue:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2948 |
self invalidate. |
542 | 2949 |
] ifFalse:[ "/ COPY VERTICAL |
2950 |
y0 := y1 := margin + dY. |
|
2951 |
h := innerHG - dY. |
|
2952 |
||
2953 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
|
2954 |
ifFalse:[y1 := margin. y := y1 + h]. |
|
2955 |
||
1460 | 2956 |
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
|
2957 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h). |
542 | 2958 |
] |
2959 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
2960 |
dX := dX abs. |
|
2961 |
||
2962 |
innerWT - dX < 20 ifTrue:[ |
|
1487 | 2963 |
labelView invalidate. |
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2964 |
self invalidate. |
542 | 2965 |
] ifFalse:[ "/ COPY HORIZONTAL |
643 | 2966 |
x0 := x1 := dX + margin. |
542 | 2967 |
w := width - dX - margin. |
2968 |
||
643 | 2969 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
2970 |
ifFalse:[x1 := margin. x := w]. |
|
542 | 2971 |
|
1460 | 2972 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:false. |
1487 | 2973 |
|
2974 |
labelView notNil ifTrue:[ |
|
2975 |
labelView copyFromX:x0 y:margin toX:x1 y:margin width:w invalidateX:x. |
|
2976 |
]. |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
2977 |
self invalidateX:x y:margin width:(width - w) height:innerHG. |
542 | 2978 |
] |
2979 |
]. |
|
2980 |
self originChanged:dltOrg. |
|
1123
ea32a2e3d44d
care for sensor becoming nil while handling exposeEvents
Claus Gittinger <cg@exept.de>
parents:
1115
diff
changeset
|
2981 |
|
ea32a2e3d44d
care for sensor becoming nil while handling exposeEvents
Claus Gittinger <cg@exept.de>
parents:
1115
diff
changeset
|
2982 |
"Modified: / 7.9.1998 / 16:39:49 / cg" |
542 | 2983 |
! |
2984 |
||
2985 |
scrollToRowAt:aRowNr colAt:aColNr |
|
2986 |
"make row at a row number in column at a column number visible |
|
2987 |
" |
|
1497 | 2988 |
|x "{ Class:SmallInteger }" |
2989 |
y "{ Class:SmallInteger }" |
|
2990 |
l "{ Class:SmallInteger }" |
|
2991 |
dY "{ Class:SmallInteger }" |
|
2992 |
dX "{ Class:SmallInteger }" |
|
2993 |
| |
|
2994 |
||
2995 |
( (aRowNr between:1 and:(list size)) |
|
2996 |
and:[aColNr between:0 and:(columnDescriptors size)] |
|
542 | 2997 |
) ifFalse:[ |
2998 |
^ self |
|
2999 |
]. |
|
3000 |
||
3001 |
dY := dX := 0. |
|
3002 |
y := self yVisibleOfRowNr:aRowNr. |
|
3003 |
||
3004 |
y < margin ifTrue:[ |
|
3005 |
dY := margin - y. |
|
3006 |
] ifFalse:[ |
|
3007 |
y := y + rowHeight. |
|
3008 |
l := height - margin. |
|
3009 |
y > l ifTrue:[dY := l - y] |
|
3010 |
]. |
|
3011 |
||
3012 |
aColNr == 0 ifTrue:[ |
|
3013 |
dY == 0 ifTrue:[^ self]. |
|
3014 |
dX := 0. |
|
3015 |
] ifFalse:[ |
|
3016 |
x := self xVisibleOfColNr:aColNr. |
|
3017 |
||
1163 | 3018 |
x <= margin ifTrue:[ |
542 | 3019 |
dX := margin - x |
3020 |
] ifFalse:[ |
|
1497 | 3021 |
x := x + (columnDescriptors at:aColNr) width. |
542 | 3022 |
l := width - margin. |
3023 |
x > l ifTrue:[dX := l - x] |
|
3024 |
] |
|
3025 |
]. |
|
3026 |
||
3027 |
(dX == 0 and:[dY == 0]) ifFalse:[ |
|
3028 |
self scrollTo:(viewOrigin - (dX @ dY)). |
|
3029 |
] |
|
3030 |
||
3031 |
||
3032 |
! |
|
3033 |
||
3034 |
scrollToSelection |
|
3035 |
"make selection visible |
|
3036 |
" |
|
607 | 3037 |
|rowNr| |
3038 |
||
3039 |
(rowNr := self firstIndexSelected) ~~ 0 ifTrue:[ |
|
1497 | 3040 |
self scrollToRowAt:rowNr colAt:selectedColIndex |
542 | 3041 |
] |
3042 |
||
1506 | 3043 |
! |
3044 |
||
3045 |
scrollVerticalTo:aPixelOffset |
|
3046 |
"change origin to make aPixelOffset be the top line" |
|
3047 |
||
3048 |
|orgX orgY| |
|
3049 |
||
3050 |
orgX := viewOrigin x. |
|
3051 |
orgY := (aPixelOffset + rowHeight - 1) // rowHeight * rowHeight. |
|
3052 |
^ self scrollTo:(orgX @ orgY). |
|
3053 |
||
1749 | 3054 |
! |
3055 |
||
3056 |
startAutoScroll:aBlock distance:aDistance |
|
3057 |
"setup for auto-scroll (when button-press-moving below view); |
|
3058 |
- timeDelta for scroll is computed from distance |
|
3059 |
" |
|
3060 |
|timeDelta| |
|
3061 |
||
3062 |
(autoScroll and:[aBlock notNil]) ifFalse:[ |
|
3063 |
^ self stopAutoScroll |
|
3064 |
]. |
|
3065 |
autoScrollBlock notNil ifTrue:[ |
|
3066 |
Processor removeTimedBlock:autoScrollBlock. |
|
3067 |
] ifFalse:[ |
|
3068 |
self compressMotionEvents:false. |
|
3069 |
]. |
|
3070 |
||
3071 |
timeDelta := 0.5 / (aDistance abs). |
|
3072 |
||
3073 |
autoScrollBlock := [ |
|
3074 |
aBlock value. |
|
3075 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
3076 |
]. |
|
3077 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
3078 |
||
3079 |
||
3080 |
! |
|
3081 |
||
3082 |
stopAutoScroll |
|
3083 |
"stop any autoScroll |
|
3084 |
" |
|
3085 |
autoScrollBlock notNil ifTrue:[ |
|
3086 |
Processor removeTimedBlock:autoScrollBlock. |
|
3087 |
autoScrollBlock := nil. |
|
3088 |
self compressMotionEvents:true. |
|
3089 |
]. |
|
3090 |
||
3091 |
||
542 | 3092 |
! ! |
3093 |
||
3094 |
!DSVColumnView methodsFor:'selection'! |
|
3095 |
||
607 | 3096 |
deselect |
3097 |
"deselect |
|
3098 |
" |
|
3099 |
self selectColIndex:0 rowIndex:0 |
|
3100 |
! |
|
3101 |
||
3102 |
firstIndexSelected |
|
809 | 3103 |
"returns index of first row selected or 0 |
607 | 3104 |
" |
3105 |
multipleSelectOk ifFalse:[ |
|
3106 |
^ selectedRowIndex |
|
3107 |
]. |
|
3108 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
3109 |
^ selectedRowIndex at:1 |
|
3110 |
]. |
|
3111 |
^ 0 |
|
3112 |
! |
|
3113 |
||
542 | 3114 |
hasSelection |
607 | 3115 |
"returns true if a selection exists |
542 | 3116 |
" |
607 | 3117 |
^ self numberOfSelections ~~ 0 |
542 | 3118 |
|
3119 |
||
3120 |
! |
|
3121 |
||
607 | 3122 |
isInSelection:aRowNr |
3123 |
"return true, if row, aRowNr is in the selection |
|
542 | 3124 |
" |
607 | 3125 |
aRowNr ~~ 0 ifTrue:[ |
3126 |
multipleSelectOk ifFalse:[ |
|
3127 |
^ aRowNr == selectedRowIndex |
|
3128 |
]. |
|
3129 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
3130 |
^ selectedRowIndex includes:aRowNr |
|
3131 |
] |
|
3132 |
]. |
|
3133 |
^ false |
|
3134 |
! |
|
3135 |
||
647 | 3136 |
isRowSelected:aRowNr |
3137 |
"return true, if row is in the selection |
|
3138 |
" |
|
3139 |
selectedColIndex == 0 ifTrue:[ |
|
3140 |
^ self isInSelection:aRowNr |
|
3141 |
]. |
|
3142 |
^ false |
|
3143 |
! |
|
3144 |
||
607 | 3145 |
isSelected:aRowNr inColumn:aColNr |
612 | 3146 |
"returns true if cell in a row; a row number, in a column, a column |
3147 |
number is selected. |
|
3148 |
" |
|
1042 | 3149 |
multipleSelectOk ifFalse:[ |
3150 |
aRowNr ~~ selectedRowIndex ifTrue:[ |
|
3151 |
^ false |
|
3152 |
] |
|
3153 |
] ifTrue:[ |
|
3154 |
(selectedRowIndex size ~~ 0 and:[selectedRowIndex includes:aRowNr]) ifFalse:[ |
|
3155 |
^ false |
|
3156 |
] |
|
607 | 3157 |
]. |
1042 | 3158 |
^ (selectedColIndex == 0 or:[selectedColIndex == aColNr]) |
3159 |
||
607 | 3160 |
! |
3161 |
||
809 | 3162 |
lastIndexSelected |
3163 |
"returns index of last row selected or 0 |
|
3164 |
" |
|
3165 |
multipleSelectOk ifFalse:[ |
|
3166 |
^ selectedRowIndex |
|
3167 |
]. |
|
3168 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
3169 |
^ selectedRowIndex last |
|
3170 |
]. |
|
3171 |
^ 0 |
|
3172 |
! |
|
3173 |
||
607 | 3174 |
numberOfSelections |
3175 |
"return the number of selected rows |
|
3176 |
" |
|
3177 |
multipleSelectOk ifFalse:[ |
|
3178 |
^ selectedRowIndex ~~ 0 ifTrue:[1] ifFalse:[0] |
|
3179 |
]. |
|
3180 |
^ selectedRowIndex size |
|
542 | 3181 |
! |
3182 |
||
1947
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3183 |
selectAllRows |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3184 |
1 to:list size do:[:eachRowNr | |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3185 |
selectedRowIndex add:eachRowNr. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3186 |
self invalidateRowAt:eachRowNr. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3187 |
]. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3188 |
self selectionChanged. |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3189 |
! |
1e11b36633b2
added selectAllRows (Alt-Shift-A) key function
Claus Gittinger <cg@exept.de>
parents:
1946
diff
changeset
|
3190 |
|
542 | 3191 |
selectColIndex:aColNr rowIndex:aRowNr |
3192 |
"change selection with notification |
|
3193 |
" |
|
3194 |
|oC oR| |
|
3195 |
||
607 | 3196 |
oC := self selectedColIndex. |
3197 |
oR := self selectedRowIndex. |
|
542 | 3198 |
|
3199 |
self setSelectColIndex:aColNr rowIndex:aRowNr. |
|
3200 |
||
607 | 3201 |
(oC ~~ self selectedColIndex or:[oR ~= self selectedRowIndex]) ifTrue:[ |
542 | 3202 |
self selectionChanged |
3203 |
]. |
|
3204 |
! |
|
3205 |
||
607 | 3206 |
selectRow:something |
542 | 3207 |
"select a row |
3208 |
" |
|
607 | 3209 |
^ self selectedRowIndex:something |
542 | 3210 |
! |
3211 |
||
809 | 3212 |
selectRowAt:rowNr colAt:colNr atPoint:aPoint |
3213 |
|v p| |
|
3214 |
||
3215 |
self selectColIndex:colNr rowIndex:rowNr. |
|
3216 |
||
3217 |
(v := self detectViewAt:aPoint in:editView) notNil ifTrue:[ |
|
3218 |
p := device translatePoint:aPoint from:(self id) to:(v id). |
|
3219 |
||
3220 |
self sensor pushEvent:(WindowEvent buttonEvent |
|
3221 |
for:v |
|
3222 |
type:#buttonPress:x:y: |
|
3223 |
arguments:(Array with:#select with:p x with:p y) |
|
3224 |
) |
|
3225 |
]. |
|
3226 |
||
3227 |
||
3228 |
! |
|
3229 |
||
607 | 3230 |
selectRowIndex:something |
3231 |
"set selection of rows |
|
542 | 3232 |
" |
607 | 3233 |
self selectColIndex:selectedColIndex rowIndex:something |
3234 |
||
3235 |
||
542 | 3236 |
! |
3237 |
||
3238 |
selectedColIndex |
|
3239 |
"returns selected column number or 0 |
|
3240 |
" |
|
3241 |
^ selectedColIndex |
|
3242 |
! |
|
3243 |
||
3244 |
selectedColumn |
|
3245 |
"returns selected column or nil |
|
3246 |
" |
|
3247 |
^ columnDescriptors at:selectedColIndex ifAbsent:nil. |
|
3248 |
! |
|
3249 |
||
3250 |
selectedRow |
|
607 | 3251 |
"returns selected row (or collection if multiple selection) or nil |
542 | 3252 |
" |
607 | 3253 |
multipleSelectOk ifFalse:[ |
3254 |
^ self at:selectedRowIndex ifAbsent:nil |
|
3255 |
]. |
|
3256 |
||
3257 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
3258 |
^ selectedRowIndex collect:[:i| self at:i] |
|
3259 |
]. |
|
3260 |
^ nil |
|
3261 |
! |
|
3262 |
||
3263 |
selectedRow:something |
|
3264 |
"select something |
|
3265 |
" |
|
3266 |
self selectedRowIndex:something |
|
542 | 3267 |
! |
3268 |
||
3269 |
selectedRowIndex |
|
3270 |
"returns selected row number or 0 |
|
3271 |
" |
|
3272 |
^ selectedRowIndex |
|
3273 |
! |
|
3274 |
||
607 | 3275 |
selectedRowIndex:something |
3276 |
"set selection of rows |
|
3277 |
" |
|
3278 |
self selectColIndex:selectedColIndex rowIndex:something |
|
3279 |
||
3280 |
||
542 | 3281 |
! |
3282 |
||
3283 |
selectionChanged |
|
3284 |
"selection has changed |
|
3285 |
" |
|
1487 | 3286 |
|val| |
3287 |
||
3288 |
model notNil ifTrue:[ |
|
3289 |
val := self selectedRowIndex copy. |
|
3290 |
||
3291 |
(model respondsTo:#selectionIndex:) ifTrue:[ |
|
3292 |
model selectionIndex:val |
|
3293 |
] ifFalse:[ |
|
3294 |
useIndex ifFalse:[ model value:(self selectedRow) ] |
|
3295 |
ifTrue:[ model value:val ] |
|
3296 |
] |
|
3297 |
]. |
|
542 | 3298 |
|
3299 |
actionBlock notNil ifTrue:[ |
|
607 | 3300 |
actionBlock value:(self selectedRowIndex) |
3301 |
] |
|
3302 |
! |
|
3303 |
||
3304 |
selectionIndicesDo:aOneArgBlock |
|
3305 |
"evaluate block on each row selected; the argument to the row |
|
3306 |
is the index of the selected row |
|
3307 |
" |
|
3308 |
multipleSelectOk ifFalse:[ |
|
3309 |
selectedRowIndex ~~ 0 ifTrue:[ |
|
3310 |
aOneArgBlock value:selectedRowIndex |
|
3311 |
] |
|
3312 |
] ifTrue:[ |
|
3313 |
selectedRowIndex size ~~ 0 ifTrue:[ |
|
3314 |
selectedRowIndex do:[:i| aOneArgBlock value:i ] |
|
3315 |
] |
|
542 | 3316 |
] |
3317 |
! |
|
3318 |
||
3319 |
setSelectColIndex:aColNr rowIndex:aRowNr |
|
3320 |
"change selection without notification |
|
3321 |
" |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3322 |
|editSpec rowNr colNr newCol oldCol oldRow sensor sglSelRow oldSz |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
3323 |
keyBrdFwd filter edValue edView| |
542 | 3324 |
|
607 | 3325 |
rowNr := self validateSelection:aRowNr. |
542 | 3326 |
|
607 | 3327 |
multipleSelectOk ifTrue:[ |
3328 |
colNr := (rowNr size == 1) ifTrue:[aColNr] ifFalse:[0] |
|
3329 |
] ifFalse:[ |
|
3330 |
colNr := rowNr ~~ 0 ifTrue:[aColNr] ifFalse:[0] |
|
542 | 3331 |
]. |
3332 |
||
607 | 3333 |
(colNr := colNr ? 0) ~~ 0 ifTrue:[ |
3334 |
newCol := self columnAt:colNr. |
|
3335 |
newCol rendererType == #rowSelector ifTrue:[ |
|
3336 |
colNr := 0. |
|
3337 |
newCol := nil |
|
3338 |
] ifFalse:[ |
|
3339 |
multipleSelectOk ifTrue:[sglSelRow := rowNr at:1] |
|
3340 |
ifFalse:[sglSelRow := rowNr]. |
|
3341 |
||
3342 |
(newCol canSelect:sglSelRow) ifFalse:[ |
|
3343 |
newCol := nil. |
|
1112 | 3344 |
colNr := 0. |
3345 |
||
3346 |
selectRowOnDefault ifFalse:[ |
|
3347 |
rowNr := multipleSelectOk ifFalse:[0] ifTrue:[nil] |
|
3348 |
] |
|
607 | 3349 |
] |
3350 |
] |
|
3351 |
]. |
|
3352 |
||
3353 |
(rowNr = selectedRowIndex and:[colNr == selectedColIndex]) ifTrue:[ |
|
643 | 3354 |
^ self |
542 | 3355 |
]. |
3356 |
||
3357 |
"/ release old selection |
|
3358 |
||
612 | 3359 |
oldSz := self numberOfSelections. |
542 | 3360 |
oldCol := selectedColIndex. |
3361 |
oldRow := selectedRowIndex. |
|
612 | 3362 |
|
542 | 3363 |
selectedRowIndex := rowNr. |
3364 |
selectedColIndex := colNr. |
|
3365 |
||
612 | 3366 |
oldSz == 1 ifTrue:[ |
3367 |
multipleSelectOk ifTrue:[oldRow := oldRow at:1]. |
|
542 | 3368 |
|
612 | 3369 |
editValue notNil ifTrue:[ |
1215 | 3370 |
editValue removeDependent:self |
3371 |
]. |
|
3372 |
editView notNil ifTrue:[ |
|
3373 |
editView allSubViewsDo:[:aSubView| |
|
3374 |
aSubView perform:#accept ifNotUnderstood:nil. |
|
3375 |
] |
|
3376 |
]. |
|
3377 |
||
3378 |
editValue notNil ifTrue:[ |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3379 |
edValue := editValue value. |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3380 |
edValue isSequenceable ifTrue:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3381 |
edValue size == 0 ifTrue:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3382 |
edValue := nil |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3383 |
] ifFalse:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3384 |
edValue isString not ifTrue:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3385 |
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
|
3386 |
edValue size == 0 ifTrue:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3387 |
edValue := nil |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3388 |
] |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3389 |
] |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3390 |
] |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3391 |
]. |
1661 | 3392 |
(self columnAt:oldCol) at:oldRow put:edValue. |
3393 |
modifiedChannel notNil ifTrue:[ |
|
3394 |
modifiedChannel value:true |
|
3395 |
]. |
|
612 | 3396 |
editValue := nil |
3397 |
]. |
|
1111 | 3398 |
self destroyEditView. |
612 | 3399 |
]. |
3400 |
shown ifFalse:[^ self ]. |
|
542 | 3401 |
|
618 | 3402 |
oldSz > 1 ifTrue:[ "/ redraw old selection |
3403 |
oldRow do:[:aRowNr| "/ unselected if visible |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
3404 |
self invalidateRowAt:aRowNr colAt:0 |
618 | 3405 |
] |
3406 |
] ifFalse:[ |
|
3407 |
oldSz == 1 ifTrue:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
3408 |
self invalidateRowAt:oldRow colAt:oldCol |
618 | 3409 |
] |
3410 |
]. |
|
3411 |
||
542 | 3412 |
"/ show new selection |
3413 |
||
3414 |
newCol notNil ifTrue:[ |
|
607 | 3415 |
self scrollToRowAt:sglSelRow colAt:colNr. |
833 | 3416 |
editSpec := newCol editorAt:sglSelRow. |
3417 |
||
3418 |
editSpec notNil ifTrue:[ |
|
1112 | 3419 |
editView := SimpleView extent:( (newCol width - (2 * separatorSize)) |
3420 |
@ (rowHeight - (2 * separatorSize)) |
|
607 | 3421 |
) |
3422 |
in:self. |
|
542 | 3423 |
self updateEditViewOrigin. |
1112 | 3424 |
|
1134 | 3425 |
(newCol containsText or:[newCol showSelectionHighLighted not]) ifTrue:[ |
1565 | 3426 |
editView viewBackground:(newCol backgroundColorAt:sglSelRow) |
1112 | 3427 |
] ifFalse:[ |
3428 |
editView viewBackground:hgLgBgColor |
|
3429 |
]. |
|
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
3430 |
edView := editSpec at:1. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
3431 |
editView add:edView. |
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3432 |
oldSz := editSpec size. |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3433 |
|
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3434 |
oldSz == 3 ifTrue:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3435 |
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
|
3436 |
] ifFalse:[ |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3437 |
filter := [:aKey| aKey == #Tab] |
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3438 |
]. |
1111 | 3439 |
keyBrdFwd := KeyboardForwarder toView:self |
3440 |
condition:nil |
|
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3441 |
filter:filter. |
1111 | 3442 |
|
3443 |
editView withAllSubViewsDo:[:aView| |
|
1112 | 3444 |
aView delegate:keyBrdFwd. |
3445 |
aView font:font. |
|
1111 | 3446 |
]. |
3447 |
||
1149
c212f122c8b3
allow collections of string and icons for a cell label
Claus Gittinger <cg@exept.de>
parents:
1136
diff
changeset
|
3448 |
(editValue := editSpec at:2 ifAbsent:nil) notNil ifTrue:[ |
809 | 3449 |
editValue addDependent:self. |
648 | 3450 |
]. |
542 | 3451 |
editView realize. |
1665
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
3452 |
edView canTab:true. |
51c444bfe5ae
default behavour tabing; not yet configurable (next step)
ca
parents:
1661
diff
changeset
|
3453 |
self windowGroup focusView:edView. |
1111 | 3454 |
|
542 | 3455 |
] ifFalse:[ |
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
3456 |
self invalidateRowAt:sglSelRow colAt:colNr |
612 | 3457 |
]. |
3458 |
] ifFalse:[ |
|
1408
1cda0a4fb566
use invalidate... insteat of redraw...
Claus Gittinger <cg@exept.de>
parents:
1333
diff
changeset
|
3459 |
self selectionIndicesDo:[:i| self invalidateRowAt:i colAt:0 ]. |
612 | 3460 |
self scrollToRowAt:(self firstIndexSelected) colAt:0 |
3461 |
]. |
|
3462 |
||
3463 |
sensor := self sensor. "/ catch expose events |
|
3464 |
||
3465 |
[sensor hasExposeEventFor:nil] whileTrue:[ |
|
3466 |
self windowGroup processExposeEvents |
|
3467 |
]. |
|
3468 |
||
1661 | 3469 |
"Modified: / 30.1.2000 / 12:18:25 / cg" |
607 | 3470 |
! |
3471 |
||
3472 |
validateSelection:aSelection |
|
3473 |
|newSel| |
|
3474 |
||
3475 |
newSel := aSelection. |
|
3476 |
||
1497 | 3477 |
(list size == 0 or:[newSel isNil or:[newSel == 0]]) ifTrue:[ |
607 | 3478 |
^ multipleSelectOk ifFalse:[0] ifTrue:[nil] |
3479 |
]. |
|
3480 |
||
3481 |
newSel isNumber ifTrue:[ |
|
3482 |
^ multipleSelectOk ifFalse:[newSel] ifTrue:[OrderedCollection with:newSel] |
|
3483 |
]. |
|
3484 |
multipleSelectOk ifFalse:[ |
|
618 | 3485 |
newSel := self identityIndexOfRow:aSelection |
607 | 3486 |
] ifTrue:[ |
3487 |
newSel := nil. |
|
3488 |
||
3489 |
aSelection size ~~ 0 ifTrue:[ |
|
3490 |
aSelection first isNumber ifTrue:[ |
|
3491 |
newSel := aSelection |
|
3492 |
] ifFalse:[ |
|
3493 |
aSelection do:[:el||n| |
|
618 | 3494 |
(n := self identityIndexOfRow:el) ~~ 0 ifTrue:[ |
607 | 3495 |
newSel isNil ifTrue:[newSel := OrderedCollection new]. |
3496 |
newSel add:n |
|
3497 |
] |
|
3498 |
] |
|
3499 |
] |
|
3500 |
] |
|
3501 |
]. |
|
3502 |
^ newSel |
|
542 | 3503 |
! ! |
3504 |
||
3505 |
!DSVColumnView class methodsFor:'documentation'! |
|
3506 |
||
3507 |
version |
|
1952 | 3508 |
^ '$Header: /cvs/stx/stx/libwidg2/DSVColumnView.st,v 1.124 2001-03-14 15:37:58 ps Exp $' |
542 | 3509 |
! ! |