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