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