1390
|
1 |
View subclass:#ListModelView
|
|
2 |
instanceVariableNames:'list listHolder textStartLeft viewOrigin enabled fgColor bgColor
|
1399
|
3 |
lineSpacing widthOfContents computeWidthInRange startOfLinesY
|
|
4 |
supportsDisplayInRange'
|
1390
|
5 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor
|
|
6 |
DefaultLightColor StopRedrawSignal'
|
|
7 |
poolDictionaries:''
|
|
8 |
category:'AAA'
|
|
9 |
!
|
|
10 |
|
|
11 |
!ListModelView class methodsFor:'documentation'!
|
|
12 |
|
|
13 |
documentation
|
|
14 |
"
|
|
15 |
This class can only passively display collections of elements.
|
|
16 |
The class doesn't keep its own list, it works directly on
|
|
17 |
the model( List or HierarchicalList ).
|
|
18 |
|
|
19 |
Each list item is obligated to provide 3 services:
|
|
20 |
- heightOn:aGC
|
|
21 |
- widthOn:aGC
|
|
22 |
- displayOn:aGC x:x y:y
|
|
23 |
|
|
24 |
[Instance variables:]
|
1399
|
25 |
list <List-Model> List or HierarchicalList ...
|
|
26 |
listHolder <Model> Model, which keeps a List
|
|
27 |
textStartLeft <Number> left inset of text
|
|
28 |
viewOrigin <Point> the current origin
|
|
29 |
enabled <Boolean> widget is enabled/disabeled
|
|
30 |
fgColor <Color> color to draw characters
|
|
31 |
bgColor <Color> the background
|
|
32 |
lineSpacing <Number> pixels between lines
|
|
33 |
widthOfContents <Number> cached width of widest line
|
|
34 |
computeWidthInRange <Point> used for recompute width of contents
|
|
35 |
startOfLinesY <Collection> keeps all the absolute Y-start positions
|
1390
|
36 |
for each line in the list. The first
|
|
37 |
entry into the list is the top Y inset.
|
1399
|
38 |
supportsDisplayInRange <Boolean> set to true if the list elements
|
|
39 |
supports the service:
|
|
40 |
#displayOn:x:y:toX:y:
|
1390
|
41 |
|
|
42 |
[author:]
|
|
43 |
Claus Atzkern
|
|
44 |
|
|
45 |
[see also:]
|
|
46 |
|
|
47 |
SelectionInListModelView
|
|
48 |
HierarchicalListView
|
|
49 |
List
|
|
50 |
HierarchicalList
|
|
51 |
"
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
!
|
|
56 |
|
|
57 |
examples
|
|
58 |
"
|
|
59 |
[exBegin]
|
|
60 |
|top list view up index|
|
|
61 |
|
|
62 |
list := List new.
|
|
63 |
|
|
64 |
top := StandardSystemView new; extent:300@300.
|
|
65 |
view := ScrollableView for:ListModelView miniScroller:true
|
|
66 |
origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
67 |
view list:list.
|
|
68 |
top openAndWait.
|
|
69 |
up := true.
|
|
70 |
|
|
71 |
[top shown] whileTrue:[
|
1399
|
72 |
Delay waitForSeconds:0.2.
|
1390
|
73 |
|
|
74 |
up ifTrue:[
|
|
75 |
index := 1 + (list size).
|
|
76 |
list add:('element: ', index printString).
|
|
77 |
up := index < 10
|
|
78 |
] ifFalse:[
|
|
79 |
list removeIndex:1.
|
|
80 |
up := list isEmpty.
|
|
81 |
]
|
|
82 |
].
|
|
83 |
[exEnd]
|
|
84 |
|
|
85 |
"
|
|
86 |
|
|
87 |
! !
|
|
88 |
|
|
89 |
!ListModelView class methodsFor:'initialization'!
|
|
90 |
|
|
91 |
initialize
|
1409
|
92 |
"setup the signals
|
|
93 |
"
|
|
94 |
super initialize.
|
1390
|
95 |
|
|
96 |
StopRedrawSignal := ErrorSignal newSignalMayProceed:false.
|
|
97 |
|
1409
|
98 |
DefaultForegroundColor isNil ifTrue:[
|
|
99 |
self updateStyleCache
|
|
100 |
].
|
1390
|
101 |
|
|
102 |
! !
|
|
103 |
|
|
104 |
!ListModelView class methodsFor:'Signal constants'!
|
|
105 |
|
|
106 |
stopRedrawSignal
|
|
107 |
^ StopRedrawSignal
|
|
108 |
! !
|
|
109 |
|
|
110 |
!ListModelView class methodsFor:'defaults'!
|
|
111 |
|
|
112 |
updateStyleCache
|
|
113 |
"extract values from the styleSheet and cache them in class variables"
|
|
114 |
|
|
115 |
<resource: #style (
|
|
116 |
#'text.backgroundColor' #'text.foregroundColor'
|
|
117 |
#'selection.shadowColor' #'selection.lightColor'
|
|
118 |
#'text.font'
|
|
119 |
)>
|
|
120 |
|
|
121 |
DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black.
|
|
122 |
DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor'.
|
|
123 |
DefaultShadowColor := StyleSheet colorAt:'selection.shadowColor'.
|
|
124 |
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'.
|
|
125 |
DefaultFont := StyleSheet fontAt:'text.font'.
|
|
126 |
|
|
127 |
"
|
|
128 |
self updateStyleCache
|
|
129 |
"
|
|
130 |
|
|
131 |
|
|
132 |
! !
|
|
133 |
|
|
134 |
!ListModelView methodsFor:'accessing'!
|
|
135 |
|
|
136 |
list
|
|
137 |
"get the list of items
|
|
138 |
"
|
|
139 |
^ list
|
|
140 |
|
|
141 |
|
|
142 |
!
|
|
143 |
|
|
144 |
list:aList
|
|
145 |
"set the list of items
|
|
146 |
"
|
|
147 |
|size changed negatedOrg|
|
|
148 |
|
|
149 |
changed := false.
|
|
150 |
|
|
151 |
list notNil ifTrue:[
|
|
152 |
changed := list notEmpty.
|
|
153 |
list removeDependent:self.
|
|
154 |
].
|
|
155 |
list := aList.
|
|
156 |
self recomputeHeightOfContents.
|
|
157 |
|
|
158 |
list notNil ifTrue:[
|
|
159 |
changed := list notEmpty.
|
|
160 |
list addDependent:self.
|
|
161 |
].
|
|
162 |
preferredExtent := nil.
|
|
163 |
widthOfContents := nil.
|
|
164 |
|
|
165 |
viewOrigin = (0@0) ifFalse:[
|
|
166 |
self originWillChange.
|
|
167 |
negatedOrg := viewOrigin negated.
|
|
168 |
viewOrigin := (0@0).
|
|
169 |
self originChanged:negatedOrg.
|
|
170 |
]
|
|
171 |
|
|
172 |
changed ifTrue:[
|
|
173 |
self invalidate.
|
|
174 |
self contentsChanged
|
|
175 |
]
|
|
176 |
|
|
177 |
!
|
|
178 |
|
|
179 |
size
|
|
180 |
"returns number of raws
|
|
181 |
"
|
|
182 |
^ list size
|
|
183 |
|
|
184 |
|
|
185 |
! !
|
|
186 |
|
|
187 |
!ListModelView methodsFor:'accessing behavior'!
|
|
188 |
|
|
189 |
enabled
|
|
190 |
"returns the enabled state
|
|
191 |
"
|
|
192 |
^ enabled
|
|
193 |
|
|
194 |
|
|
195 |
!
|
|
196 |
|
|
197 |
enabled:aBoolean
|
|
198 |
"set the enabled state
|
|
199 |
"
|
|
200 |
enabled := aBoolean
|
|
201 |
|
|
202 |
|
|
203 |
! !
|
|
204 |
|
|
205 |
!ListModelView methodsFor:'accessing items'!
|
|
206 |
|
|
207 |
at:anIndex
|
|
208 |
"return the list element at an index
|
|
209 |
"
|
|
210 |
^ list at:anIndex
|
|
211 |
!
|
|
212 |
|
|
213 |
at:anIndex ifAbsent:exceptionBlock
|
|
214 |
"return the list element at an index if valid.
|
|
215 |
If the index is invalid, return the result of evaluating
|
|
216 |
the exceptionblock.
|
|
217 |
"
|
|
218 |
list notNil ifTrue:[
|
|
219 |
^ list at:anIndex ifAbsent:exceptionBlock
|
|
220 |
].
|
|
221 |
^ nil.
|
|
222 |
!
|
|
223 |
|
|
224 |
identityIndexOf:anElement
|
|
225 |
"returns the index of an element or nil
|
|
226 |
"
|
|
227 |
^ list notNil ifTrue:[list identityIndexOf:anElement]
|
|
228 |
ifFalse:[0]
|
|
229 |
|
|
230 |
|
|
231 |
! !
|
|
232 |
|
|
233 |
!ListModelView methodsFor:'accessing look'!
|
|
234 |
|
|
235 |
backgroundColor
|
|
236 |
"get the background color
|
|
237 |
"
|
|
238 |
^ bgColor
|
|
239 |
|
|
240 |
|
|
241 |
!
|
|
242 |
|
|
243 |
backgroundColor:aColor
|
|
244 |
"set the background color
|
|
245 |
"
|
|
246 |
(aColor notNil and:[bgColor ~~ aColor]) ifTrue:[
|
|
247 |
super viewBackground:bgColor.
|
|
248 |
|
|
249 |
self realized ifTrue:[
|
|
250 |
bgColor := aColor on:device.
|
|
251 |
self invalidate
|
|
252 |
] ifFalse:[
|
|
253 |
bgColor := aColor
|
|
254 |
]
|
|
255 |
]
|
|
256 |
|
|
257 |
!
|
|
258 |
|
|
259 |
font:aFont
|
|
260 |
"set a new font
|
|
261 |
"
|
|
262 |
|oldWidth oldHeight|
|
|
263 |
|
|
264 |
(aFont isNil or:[aFont = font]) ifFalse:[
|
|
265 |
oldWidth := font width.
|
|
266 |
oldHeight := font height.
|
|
267 |
|
|
268 |
super font:aFont.
|
|
269 |
|
|
270 |
(font width) ~~ oldWidth ifTrue:[ "/ force a recomputation
|
|
271 |
preferredExtent := nil.
|
|
272 |
widthOfContents := nil.
|
|
273 |
].
|
|
274 |
oldHeight ~~ font height ifTrue:[
|
|
275 |
self recomputeHeightOfContents.
|
|
276 |
].
|
|
277 |
shown ifTrue:[ self invalidate ]
|
|
278 |
].
|
|
279 |
!
|
|
280 |
|
|
281 |
foregroundColor
|
|
282 |
"get the foreground color
|
|
283 |
"
|
|
284 |
^ fgColor
|
|
285 |
|
|
286 |
!
|
|
287 |
|
|
288 |
foregroundColor:aColor
|
|
289 |
"set the foreground color
|
|
290 |
"
|
|
291 |
(aColor notNil and:[fgColor ~~ aColor]) ifTrue:[
|
|
292 |
self realized ifTrue:[
|
|
293 |
fgColor := aColor on:device.
|
|
294 |
self invalidate
|
|
295 |
] ifFalse:[
|
|
296 |
fgColor := aColor
|
|
297 |
]
|
|
298 |
]
|
|
299 |
|
|
300 |
! !
|
|
301 |
|
|
302 |
!ListModelView methodsFor:'accessing mvc'!
|
|
303 |
|
|
304 |
listHolder
|
|
305 |
"returns the listHolder or nil
|
|
306 |
"
|
|
307 |
^ listHolder
|
|
308 |
!
|
|
309 |
|
|
310 |
listHolder:aListHolder
|
|
311 |
"set a new listHolder
|
|
312 |
"
|
|
313 |
|newList|
|
|
314 |
|
|
315 |
listHolder removeDependent:self.
|
|
316 |
|
|
317 |
(listHolder := aListHolder) notNil ifTrue:[
|
|
318 |
listHolder addDependent:self.
|
|
319 |
].
|
|
320 |
self list:(listHolder value).
|
|
321 |
! !
|
|
322 |
|
|
323 |
!ListModelView methodsFor:'change & update'!
|
|
324 |
|
|
325 |
lineChangedAt:aLnNr with:arg
|
|
326 |
"line changed at position; check whether line height changed
|
|
327 |
"
|
|
328 |
|
|
|
329 |
oldHeight "{ Class:SmallInteger }"
|
|
330 |
dltHeight "{ Class:SmallInteger }"
|
|
331 |
|
|
|
332 |
|
|
333 |
|
|
334 |
(arg notNil and:[(arg == #icon or:[arg == #hierarchy])]) ifTrue:[
|
|
335 |
^ self
|
|
336 |
].
|
|
337 |
oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr).
|
|
338 |
dltHeight := (self heightOfLineAt:aLnNr) - oldHeight.
|
|
339 |
|
|
340 |
dltHeight == 0 ifTrue:[
|
|
341 |
^ self redrawLineAt:aLnNr
|
|
342 |
].
|
|
343 |
|
|
344 |
aLnNr + 1 to:startOfLinesY size do:[:i|
|
|
345 |
startOfLinesY at:i put:((startOfLinesY at:i) + dltHeight)
|
|
346 |
].
|
|
347 |
self invalidate.
|
|
348 |
|
|
349 |
|
|
350 |
!
|
|
351 |
|
|
352 |
listChangedInsert:start nItems:nLines
|
|
353 |
"list changed; items are added
|
|
354 |
"
|
|
355 |
|
|
|
356 |
run "{ Class: SmallInteger }"
|
|
357 |
cpyHg "{ Class: SmallInteger }"
|
|
358 |
absY0 "{ Class: SmallInteger }"
|
|
359 |
absY1 "{ Class: SmallInteger }"
|
|
360 |
visY0 "{ Class: SmallInteger }"
|
|
361 |
visY1 "{ Class: SmallInteger }"
|
|
362 |
orgY "{ Class: SmallInteger }"
|
|
363 |
dltY "{ Class: SmallInteger }"
|
|
364 |
maxHg "{ Class: SmallInteger }"
|
|
365 |
|
|
|
366 |
|
|
367 |
nLines == 0 ifTrue:[^ self ].
|
|
368 |
self listSizeChanged:start nLines:nLines.
|
|
369 |
shown not ifTrue:[^ self].
|
|
370 |
|
|
371 |
startOfLinesY addAll:(Array new:nLines) beforeIndex:start + 1.
|
|
372 |
absY0 := startOfLinesY at:start.
|
|
373 |
absY1 := absY0.
|
|
374 |
run := start.
|
|
375 |
|
|
376 |
nLines timesRepeat:[
|
|
377 |
absY1 := absY1 + (self heightOfLineAt:run).
|
|
378 |
run := run + 1.
|
|
379 |
startOfLinesY at:run put:absY1.
|
|
380 |
].
|
|
381 |
|
|
382 |
dltY := absY1 - absY0.
|
|
383 |
run + 1 to:(startOfLinesY size) do:[:i|
|
|
384 |
startOfLinesY at:i put:((startOfLinesY at:i) + dltY)
|
|
385 |
].
|
|
386 |
|
|
387 |
orgY := viewOrigin y.
|
|
388 |
absY1 := absY0 + dltY.
|
|
389 |
visY0 := absY0 - orgY.
|
|
390 |
visY1 := absY1 - orgY.
|
|
391 |
maxHg := height - margin.
|
|
392 |
|
|
393 |
absY0 < orgY ifTrue:[
|
|
394 |
self originWillChange.
|
|
395 |
viewOrigin y:(dltY + orgY).
|
|
396 |
self originChanged:(0 @ dltY).
|
|
397 |
].
|
|
398 |
|
|
399 |
(self sensor hasDamageFor:self) ifTrue:[
|
|
400 |
^ self contentsChanged.
|
|
401 |
].
|
|
402 |
|
|
403 |
(visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[
|
|
404 |
^ self contentsChanged
|
|
405 |
].
|
|
406 |
visY0 := visY0 max:margin.
|
|
407 |
visY1 := visY1 min:maxHg.
|
|
408 |
|
|
409 |
(start == list size or:[(cpyHg := maxHg - visY1) < 20]) ifTrue:[
|
|
410 |
visY1 := maxHg
|
|
411 |
] ifFalse:[
|
|
412 |
self catchExpose.
|
|
413 |
|
|
414 |
self copyFrom:self x:0 y:visY0
|
|
415 |
toX:0 y:visY1
|
|
416 |
width:width height:cpyHg async:true.
|
|
417 |
|
|
418 |
self waitForExpose
|
|
419 |
].
|
|
420 |
|
1399
|
421 |
self redrawX:margin y:visY0
|
1390
|
422 |
width:width - margin - margin
|
|
423 |
height:(visY1 - visY0).
|
|
424 |
self contentsChanged.
|
|
425 |
|
|
426 |
|
|
427 |
!
|
|
428 |
|
|
429 |
listChangedRemove:start toIndex:stop
|
|
430 |
"list changed; items are removed
|
|
431 |
"
|
|
432 |
|noRedraw
|
|
433 |
size "{ Class: SmallInteger }"
|
|
434 |
absY0 "{ Class: SmallInteger }"
|
|
435 |
absY1 "{ Class: SmallInteger }"
|
|
436 |
visY0 "{ Class: SmallInteger }"
|
|
437 |
visY1 "{ Class: SmallInteger }"
|
|
438 |
orgY "{ Class: SmallInteger }"
|
|
439 |
orgX "{ Class: SmallInteger }"
|
|
440 |
dltY "{ Class: SmallInteger }"
|
|
441 |
cpyHg "{ Class: SmallInteger }"
|
|
442 |
maxHg "{ Class: SmallInteger }"
|
|
443 |
|
|
|
444 |
|
|
445 |
(size := stop - start + 1) == 0 ifTrue:[
|
|
446 |
^ self
|
|
447 |
].
|
|
448 |
self listSizeChanged:start nLines:(size negated).
|
|
449 |
shown not ifTrue:[^ self].
|
|
450 |
absY0 := self yAbsoluteOfLine:start.
|
|
451 |
absY1 := self yAbsoluteOfLine:(stop + 1).
|
|
452 |
dltY := absY1 - absY0.
|
|
453 |
|
|
454 |
startOfLinesY removeFromIndex:start toIndex:stop.
|
|
455 |
|
|
456 |
start to:(startOfLinesY size) do:[:i|
|
|
457 |
absY0 := startOfLinesY at:i.
|
|
458 |
startOfLinesY at:i put:(absY0 - dltY).
|
|
459 |
].
|
|
460 |
|
|
461 |
orgY := viewOrigin y.
|
|
462 |
orgX := viewOrigin x.
|
|
463 |
|
|
464 |
absY0 := self yAbsoluteOfLine:start.
|
|
465 |
absY1 := absY0 + dltY.
|
|
466 |
visY0 := absY0 - orgY.
|
|
467 |
visY1 := absY1 - orgY.
|
|
468 |
maxHg := height - margin.
|
|
469 |
|
|
470 |
(list size == 0 or:[(orgY ~~ 0 and:[self maxViewOriginY == 0])]) ifTrue:[
|
|
471 |
(orgX ~~ 0 or:[orgY ~~ 0]) ifTrue:[
|
|
472 |
self originWillChange.
|
|
473 |
viewOrigin := 0@0.
|
|
474 |
self originChanged:((orgX @ orgY) negated).
|
|
475 |
].
|
|
476 |
self invalidate.
|
|
477 |
^ self contentsChanged
|
|
478 |
].
|
|
479 |
|
|
480 |
visY0 < margin ifTrue:[
|
|
481 |
noRedraw := visY1 <= margin.
|
|
482 |
noRedraw ifTrue:[dltY := dltY negated] ifFalse:[dltY := visY0].
|
|
483 |
|
|
484 |
self originWillChange.
|
|
485 |
viewOrigin y:(dltY + orgY).
|
|
486 |
self originChanged:(0 @ dltY).
|
|
487 |
] ifFalse:[
|
|
488 |
noRedraw := visY0 >= maxHg
|
|
489 |
].
|
|
490 |
|
|
491 |
(noRedraw or:[self sensor hasDamageFor:self]) ifFalse:[
|
|
492 |
visY0 := visY0 max:margin.
|
|
493 |
cpyHg := maxHg - visY1.
|
|
494 |
|
|
495 |
cpyHg > 20 ifTrue:[
|
|
496 |
self catchExpose.
|
|
497 |
self copyFrom:self x:0 y:visY1 toX:0 y:visY0
|
|
498 |
width:width height:cpyHg async:true.
|
|
499 |
self waitForExpose.
|
|
500 |
visY0 := visY0 + cpyHg.
|
|
501 |
].
|
|
502 |
|
1399
|
503 |
self redrawX:margin y:visY0
|
1390
|
504 |
width:width - margin - margin
|
|
505 |
height:(maxHg - visY0).
|
|
506 |
].
|
|
507 |
self contentsChanged.
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
!
|
|
515 |
|
|
516 |
update:what with:aPara from:chgObj
|
|
517 |
"catch and handle any notification raised from the list model
|
|
518 |
or list holder
|
|
519 |
"
|
|
520 |
|arg1 arg2|
|
|
521 |
|
|
522 |
chgObj ~~ list ifTrue:[
|
|
523 |
chgObj == listHolder ifTrue:[self list:(listHolder value)]
|
|
524 |
ifFalse:[super update:what with:aPara from:chgObj].
|
|
525 |
^ self
|
|
526 |
].
|
|
527 |
|
|
528 |
aPara isCollection ifFalse:[
|
|
529 |
what == #at: ifTrue:[ ^ self lineChangedAt:aPara with:nil].
|
|
530 |
what == #insert: ifTrue:[ ^ self listChangedInsert:aPara nItems:1 ].
|
|
531 |
what == #remove: ifTrue:[ ^ self listChangedRemove:aPara toIndex:aPara ].
|
|
532 |
|
|
533 |
^ self
|
|
534 |
].
|
|
535 |
|
|
536 |
arg1 := aPara at:1.
|
|
537 |
arg2 := aPara at:2.
|
|
538 |
|
|
539 |
what == #at: ifTrue:[ ^ self lineChangedAt:arg1 with:arg2 ].
|
|
540 |
what == #insertCollection: ifTrue:[ ^ self listChangedInsert:arg1 nItems:arg2 ].
|
|
541 |
what == #removeFrom: ifTrue:[ ^ self listChangedRemove:arg1 toIndex:arg2 ].
|
|
542 |
|
|
543 |
what == #replace: ifTrue:[
|
|
544 |
arg1 to:arg2 do:[:i| self lineChangedAt:i with:nil ]
|
|
545 |
]
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
! !
|
|
552 |
|
|
553 |
!ListModelView methodsFor:'drawing'!
|
|
554 |
|
1399
|
555 |
displayElement:anItem x:xL y:yT toX:xR y:yB
|
|
556 |
"draw a label at xL/yT; fg/bg colors are already set
|
1390
|
557 |
"
|
1399
|
558 |
|ok
|
|
559 |
h "{ Class: SmallInteger }"
|
|
560 |
y "{ Class: SmallInteger }"
|
1390
|
561 |
|
|
1399
|
562 |
supportsDisplayInRange isNil ifTrue:[
|
|
563 |
supportsDisplayInRange := anItem respondsTo:#displayOn:x:y:toX:y:
|
|
564 |
].
|
|
565 |
supportsDisplayInRange ifTrue:[
|
|
566 |
anItem displayOn:self x:xL y:yT toX:xR y:yB
|
|
567 |
] ifFalse:[
|
|
568 |
h := yB - yT.
|
|
569 |
y := yT - ((anItem heightOn:self) + 1 - h // 2).
|
1390
|
570 |
|
|
571 |
anItem isImageOrForm ifFalse:[
|
|
572 |
(anItem isString or:[anItem isKindOf:LabelAndIcon]) ifTrue:[
|
1399
|
573 |
y := y + font ascent
|
1390
|
574 |
]
|
|
575 |
].
|
1399
|
576 |
anItem displayOn:self x:xL y:y
|
1390
|
577 |
]
|
|
578 |
|
|
579 |
|
|
580 |
!
|
|
581 |
|
1391
|
582 |
invalidateX:x y:y width:w height:h
|
|
583 |
"add a damage to redraw part of the view
|
1390
|
584 |
"
|
1399
|
585 |
shown ifTrue:[
|
|
586 |
self invalidate:(Rectangle left:x top:y width:w height:h)
|
|
587 |
repairNow:false
|
|
588 |
]
|
|
589 |
!
|
|
590 |
|
|
591 |
redraw
|
|
592 |
"redraw complete view
|
|
593 |
"
|
|
594 |
self redrawX:0 y:0 width:width height:height.
|
|
595 |
|
|
596 |
|
1390
|
597 |
!
|
|
598 |
|
|
599 |
redrawLineAt:aLineNr
|
|
600 |
"redraw a specific line
|
|
601 |
"
|
|
602 |
|y0 "{ Class:SmallInteger }"
|
|
603 |
y1 "{ Class:SmallInteger }"
|
|
604 |
yB "{ Class:SmallInteger }"
|
|
605 |
|
|
|
606 |
|
|
607 |
(shown and:[aLineNr notNil]) ifTrue:[
|
|
608 |
yB := height - margin.
|
|
609 |
y0 := (self yVisibleOfLine:aLineNr) max:margin.
|
|
610 |
|
|
611 |
y0 < yB ifTrue:[
|
|
612 |
y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB.
|
|
613 |
y1 > margin ifTrue:[
|
1399
|
614 |
self redrawX:0 y:y0 width:width height:(y1 - y0)
|
1390
|
615 |
]
|
|
616 |
]
|
|
617 |
]
|
|
618 |
|
|
619 |
!
|
|
620 |
|
|
621 |
redrawX:x y:y width:w height:h
|
|
622 |
"redraw part of myself immediately, given logical coordinates
|
|
623 |
"
|
|
624 |
|savClip start stop yAbs|
|
|
625 |
|
|
626 |
shown ifFalse:[^ self].
|
|
627 |
|
|
628 |
self paint:bgColor.
|
|
629 |
self fillRectangleX:x y:y width:w height:h.
|
|
630 |
|
|
631 |
(start := self yVisibleToLineNr:y) isNil ifTrue:[
|
|
632 |
^ self
|
|
633 |
].
|
|
634 |
yAbs := y + h.
|
|
635 |
|
|
636 |
(stop := self yVisibleToLineNr:yAbs) isNil ifTrue:[
|
|
637 |
stop := list size.
|
|
638 |
] ifFalse:[
|
|
639 |
yAbs == (startOfLinesY at:stop) ifTrue:[
|
|
640 |
stop := stop - 1
|
|
641 |
].
|
|
642 |
].
|
|
643 |
|
|
644 |
savClip := clipRect.
|
|
645 |
self clippingRectangle:(Rectangle left:x top:y width:w height:h).
|
|
646 |
|
|
647 |
StopRedrawSignal handle:[:ex| self invalidate.
|
|
648 |
ex return
|
|
649 |
] do:[ self drawFrom:start
|
|
650 |
to:stop
|
|
651 |
x:x
|
|
652 |
y:(self yVisibleOfLine:start)
|
1399
|
653 |
toX:x + w
|
1390
|
654 |
].
|
|
655 |
|
|
656 |
self clippingRectangle:savClip.
|
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
! !
|
|
662 |
|
|
663 |
!ListModelView methodsFor:'event handling'!
|
|
664 |
|
|
665 |
keyPress:aKey x:x y:y
|
|
666 |
"a key was pressed - handle page-keys here
|
|
667 |
"
|
|
668 |
<resource: #keyboard( #PreviousPage #NextPage #HalfPageUp #HalfPageDown
|
|
669 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown
|
|
670 |
)>
|
|
671 |
|
|
672 |
|n sensor|
|
|
673 |
|
|
674 |
list size ~~ 0 ifTrue:[
|
|
675 |
(aKey == #PreviousPage) ifTrue:[^ self pageUp].
|
|
676 |
(aKey == #NextPage) ifTrue:[^ self pageDown].
|
|
677 |
(aKey == #HalfPageUp) ifTrue:[^ self halfPageUp].
|
|
678 |
(aKey == #HalfPageDown) ifTrue:[^ self halfPageDown].
|
|
679 |
(aKey == #BeginOfText) ifTrue:[^ self scrollToTop].
|
|
680 |
(aKey == #EndOfText) ifTrue:[^ self scrollToBottom].
|
|
681 |
|
|
682 |
(aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[
|
|
683 |
sensor := self sensor.
|
|
684 |
|
|
685 |
n := sensor notNil ifTrue:[1 + (sensor compressKeyPressEventsWithKey:aKey)]
|
|
686 |
ifFalse:[1].
|
|
687 |
|
|
688 |
n := n * self verticalScrollStep.
|
|
689 |
|
|
690 |
aKey == #ScrollUp ifTrue:[self scrollUp:n]
|
|
691 |
ifFalse:[self scrollDown:n].
|
|
692 |
^ self
|
|
693 |
].
|
|
694 |
].
|
|
695 |
super keyPress:aKey x:x y:y
|
|
696 |
!
|
|
697 |
|
1417
|
698 |
pointerEnter:state x:x y:y
|
|
699 |
"mouse pointer entered - request the keyboard focus (sometimes)"
|
1390
|
700 |
|
1417
|
701 |
self wantsFocusWithPointerEnter ifTrue:[
|
|
702 |
self requestFocus.
|
|
703 |
].
|
1390
|
704 |
|
|
705 |
! !
|
|
706 |
|
|
707 |
!ListModelView methodsFor:'fetch resources'!
|
|
708 |
|
|
709 |
colorOnDevice:aColor
|
|
710 |
"fetch a device colors
|
|
711 |
"
|
|
712 |
^ aColor notNil ifTrue:[aColor on:device] ifFalse:[nil]
|
|
713 |
|
|
714 |
!
|
|
715 |
|
|
716 |
imageOnDevice:anImage
|
|
717 |
"associate image to device and clear pixel mask
|
|
718 |
returns the new image.
|
|
719 |
"
|
|
720 |
|image|
|
|
721 |
|
|
722 |
(image := anImage) notNil ifTrue:[
|
|
723 |
image device ~~ device ifTrue:[
|
|
724 |
image := image copy.
|
|
725 |
].
|
|
726 |
image := image on:device.
|
|
727 |
image := image clearMaskedPixels.
|
|
728 |
].
|
|
729 |
^ image
|
|
730 |
|
|
731 |
! !
|
|
732 |
|
1417
|
733 |
!ListModelView methodsFor:'focus handling'!
|
|
734 |
|
|
735 |
wantsFocusWithButtonPress
|
|
736 |
"catch the keyboard focus on button click
|
|
737 |
"
|
|
738 |
^ true
|
|
739 |
|
|
740 |
|
|
741 |
!
|
|
742 |
|
|
743 |
wantsFocusWithPointerEnter
|
|
744 |
"views which like to take the keyboard focus
|
|
745 |
when the pointer enters can do so by redefining this
|
|
746 |
to return true"
|
|
747 |
|
|
748 |
^ true
|
|
749 |
|
|
750 |
! !
|
|
751 |
|
1390
|
752 |
!ListModelView methodsFor:'initialize / release'!
|
|
753 |
|
|
754 |
create
|
|
755 |
"fetch device dependent resources
|
|
756 |
"
|
|
757 |
super create.
|
|
758 |
self fetchResources.
|
|
759 |
self recomputeHeightOfContents.
|
|
760 |
!
|
|
761 |
|
|
762 |
destroy
|
|
763 |
"remove dependencies
|
|
764 |
"
|
|
765 |
listHolder removeDependent:self.
|
|
766 |
list removeDependent:self.
|
|
767 |
super destroy
|
|
768 |
|
|
769 |
!
|
|
770 |
|
|
771 |
initStyle
|
|
772 |
"setup viewStyle specifics
|
|
773 |
"
|
|
774 |
super initStyle.
|
|
775 |
|
|
776 |
DefaultBackgroundColor notNil ifTrue:[
|
|
777 |
viewBackground := DefaultBackgroundColor
|
|
778 |
].
|
|
779 |
lineSpacing := 0.
|
|
780 |
textStartLeft := 2.
|
|
781 |
fgColor := DefaultForegroundColor.
|
|
782 |
bgColor := viewBackground.
|
|
783 |
startOfLinesY := OrderedCollection new.
|
|
784 |
|
|
785 |
startOfLinesY add:(2 + margin). "/ top inset of first line
|
|
786 |
|
|
787 |
DefaultShadowColor notNil ifTrue:[
|
|
788 |
shadowColor := DefaultShadowColor
|
|
789 |
].
|
|
790 |
|
|
791 |
DefaultLightColor notNil ifTrue:[
|
|
792 |
lightColor := DefaultLightColor
|
|
793 |
].
|
|
794 |
!
|
|
795 |
|
|
796 |
initialize
|
|
797 |
"setup default attributes
|
|
798 |
"
|
|
799 |
super initialize.
|
|
800 |
|
|
801 |
viewOrigin := 0@0.
|
|
802 |
bitGravity := #NorthWest.
|
|
803 |
enabled := true.
|
|
804 |
!
|
|
805 |
|
|
806 |
recreate
|
|
807 |
"fetch device dependent resources
|
|
808 |
"
|
|
809 |
super recreate.
|
|
810 |
self fetchResources.
|
|
811 |
|
|
812 |
! !
|
|
813 |
|
|
814 |
!ListModelView methodsFor:'private'!
|
|
815 |
|
|
816 |
yAbsoluteOfLine:aLineNr
|
|
817 |
"given a lineNr, return y-coordinate absolute
|
|
818 |
"
|
|
819 |
^ startOfLinesY at:aLineNr ifAbsent:[startOfLinesY last].
|
|
820 |
!
|
|
821 |
|
|
822 |
yVisibleOfLine:aLineNr
|
|
823 |
"given a lineNr, return y-coordinate in view
|
|
824 |
"
|
|
825 |
|y|
|
|
826 |
|
|
827 |
y := startOfLinesY at:aLineNr ifAbsent:[startOfLinesY last].
|
|
828 |
^ y - viewOrigin y
|
|
829 |
|
|
830 |
|
|
831 |
!
|
|
832 |
|
|
833 |
yVisibleToLineNr:yVisible
|
|
834 |
"returns the line number assigned to a physical y or nil
|
|
835 |
"
|
|
836 |
|
|
|
837 |
yAbs "{ Class: SmallInteger}"
|
|
838 |
yMid "{ Class: SmallInteger}"
|
|
839 |
size "{ Class: SmallInteger}"
|
|
840 |
next "{ Class: SmallInteger}"
|
|
841 |
low "{ Class: SmallInteger}"
|
|
842 |
high "{ Class: SmallInteger}"
|
|
843 |
middle "{ Class: SmallInteger}"
|
|
844 |
|
|
|
845 |
|
|
846 |
(size := startOfLinesY size) == 1 ifTrue:[^ nil]. "/ EMPTY LIST
|
|
847 |
yAbs := yVisible + viewOrigin y.
|
|
848 |
yAbs > (startOfLinesY at:size) ifTrue:[^ nil]. "/ END OF LIST
|
|
849 |
|
|
850 |
middle := size.
|
|
851 |
size := size - 1.
|
|
852 |
high := size.
|
|
853 |
low := 1.
|
|
854 |
|
|
855 |
[(next := low + high // 2) ~~ middle] whileTrue:[
|
|
856 |
yMid := startOfLinesY at:(middle := next).
|
|
857 |
|
|
858 |
yMid < yAbs ifTrue:[low := middle]
|
|
859 |
ifFalse:[high := middle]
|
|
860 |
].
|
|
861 |
|
|
862 |
yAbs < yMid ifTrue:[
|
|
863 |
^ (middle - 1) max:1.
|
|
864 |
].
|
|
865 |
middle < size ifTrue:[
|
|
866 |
next := middle + 1.
|
|
867 |
^ (startOfLinesY at:next) > yAbs ifTrue:[middle] ifFalse:[next]
|
|
868 |
].
|
|
869 |
^ size
|
|
870 |
! !
|
|
871 |
|
|
872 |
!ListModelView methodsFor:'protocol'!
|
|
873 |
|
1399
|
874 |
drawFrom:start to:stop x:xL y:yT toX:xR
|
1390
|
875 |
"draw lines from start to stop.
|
|
876 |
clipping and clearing the background is already done
|
|
877 |
"
|
1399
|
878 |
|item
|
|
879 |
y0 "{ Class:SmallInteger }"
|
1390
|
880 |
y1 "{ Class:SmallInteger }"
|
|
881 |
x0 "{ Class:SmallInteger }"
|
|
882 |
|
|
|
883 |
self paint:fgColor on:bgColor.
|
|
884 |
|
|
885 |
x0 := textStartLeft - viewOrigin x.
|
1399
|
886 |
y1 := yT.
|
1390
|
887 |
|
|
888 |
start to:stop do:[:i|
|
|
889 |
y0 := y1.
|
|
890 |
y1 := self yVisibleOfLine:(i + 1).
|
1399
|
891 |
|
|
892 |
(item := list at:i ifAbsent:nil) notNil ifTrue:[
|
|
893 |
self displayElement:item x:x0 y:y0 toX:xR y:y1
|
|
894 |
]
|
|
895 |
]
|
1390
|
896 |
|
|
897 |
!
|
|
898 |
|
|
899 |
fetchResources
|
|
900 |
"fetch device colors and ..., to avoid reallocation at redraw time;
|
|
901 |
*** called after a create or snapin to fetch all device resources
|
|
902 |
"
|
|
903 |
fgColor := self colorOnDevice:fgColor.
|
|
904 |
bgColor := self colorOnDevice:bgColor.
|
|
905 |
font := font on:device.
|
|
906 |
|
|
907 |
!
|
|
908 |
|
|
909 |
heightOfLineAt:aLineNr
|
|
910 |
"returns the total height for a line at an index( including lineSpacing ... )
|
|
911 |
"
|
|
912 |
|item|
|
|
913 |
|
|
914 |
item := list at:aLineNr ifAbsent:[^ 4].
|
|
915 |
^ lineSpacing + (item heightOn:self)
|
|
916 |
!
|
|
917 |
|
|
918 |
listSizeChanged:anIndex nLines:noLines
|
|
919 |
"list size changed; information is stored to recompute the
|
|
920 |
width if required( preferredExtent, horizontal scroller ... ).
|
|
921 |
see: widthOfContents
|
|
922 |
*** if nLines is negative, lines are removed otherwise added.
|
|
923 |
"
|
|
924 |
|start "{ Class:SmallInteger }"
|
|
925 |
stop "{ Class:SmallInteger }"
|
|
926 |
size "{ Class:SmallInteger }"
|
|
927 |
|
|
|
928 |
preferredExtent := nil.
|
|
929 |
|
|
930 |
widthOfContents isNil ifTrue:[ "/ recompute whole list
|
|
931 |
^ self
|
|
932 |
].
|
|
933 |
|
|
934 |
(noLines < 0 or:[(size := list size) <= noLines]) ifTrue:[
|
|
935 |
widthOfContents := nil. "/ force recompute whole list
|
|
936 |
^ self
|
|
937 |
].
|
|
938 |
|
|
939 |
stop := anIndex + noLines - 1. "/ recompute a range
|
|
940 |
start := anIndex.
|
|
941 |
|
|
942 |
computeWidthInRange notNil ifTrue:[
|
|
943 |
start := computeWidthInRange y.
|
|
944 |
stop < start ifTrue:[stop := start min:size].
|
|
945 |
start := (computeWidthInRange x) min:anIndex.
|
|
946 |
].
|
|
947 |
computeWidthInRange := start@stop
|
|
948 |
!
|
|
949 |
|
|
950 |
widthOfWidestLineBetween:firstLine and:lastLine
|
|
951 |
"return the width in pixels of the widest line in a range
|
|
952 |
"
|
|
953 |
|lbl item
|
|
954 |
width "{ Class: SmallInteger }"
|
|
955 |
|
|
|
956 |
width := textStartLeft.
|
|
957 |
|
|
958 |
firstLine to:lastLine do:[:anIndex|
|
|
959 |
item := list at:anIndex ifAbsent:[^ width + textStartLeft ].
|
|
960 |
width := (item widthOn:self) max:width
|
|
961 |
].
|
|
962 |
^ width + textStartLeft
|
|
963 |
|
|
964 |
|
|
965 |
|
|
966 |
|
|
967 |
! !
|
|
968 |
|
|
969 |
!ListModelView methodsFor:'recomputation'!
|
|
970 |
|
|
971 |
preferredExtent
|
|
972 |
"returns the preferred extent
|
|
973 |
"
|
|
974 |
|x y|
|
|
975 |
|
|
976 |
preferredExtent isNil ifTrue:[
|
|
977 |
y := self heightOfContents.
|
|
978 |
x := self widthOfContents.
|
|
979 |
preferredExtent := x@y
|
|
980 |
].
|
|
981 |
^ preferredExtent
|
|
982 |
|
|
983 |
|
|
984 |
!
|
|
985 |
|
|
986 |
recomputeHeightOfContents
|
|
987 |
"recompute all the y positions
|
|
988 |
"
|
|
989 |
|yAbs "{ Class: SmallInteger }"
|
|
990 |
lnHg "{ Class: SmallInteger }"
|
|
991 |
|
|
|
992 |
|
|
993 |
yAbs := startOfLinesY at:1. "/ top inset of first line
|
|
994 |
startOfLinesY removeAll.
|
|
995 |
startOfLinesY add:yAbs.
|
|
996 |
|
|
997 |
1 to:(list size) do:[:anIndex|
|
|
998 |
lnHg := self heightOfLineAt:anIndex.
|
|
999 |
startOfLinesY add:(yAbs := yAbs + lnHg)
|
|
1000 |
].
|
|
1001 |
! !
|
|
1002 |
|
|
1003 |
!ListModelView methodsFor:'scroller interface'!
|
|
1004 |
|
|
1005 |
heightOfContents
|
|
1006 |
"return the height of the contents in pixels
|
|
1007 |
"
|
|
1008 |
^ startOfLinesY last
|
|
1009 |
!
|
|
1010 |
|
|
1011 |
innerHeight
|
|
1012 |
"returns the inner height of the contents shown
|
|
1013 |
"
|
|
1014 |
^ height - margin - margin
|
|
1015 |
|
|
1016 |
!
|
|
1017 |
|
|
1018 |
innerWidth
|
|
1019 |
"returns the inner width of the contents shown
|
|
1020 |
"
|
|
1021 |
^ width - margin - margin
|
|
1022 |
|
|
1023 |
!
|
|
1024 |
|
|
1025 |
maxViewOriginY
|
|
1026 |
"returns the maximum possible y of the view origin
|
|
1027 |
"
|
|
1028 |
^ (self heightOfContents - self innerHeight) max:0
|
|
1029 |
|
|
1030 |
|
|
1031 |
!
|
|
1032 |
|
|
1033 |
verticalScrollStep
|
|
1034 |
"return the amount to scroll when stepping up/down.
|
|
1035 |
"
|
|
1036 |
^ 10
|
|
1037 |
|
|
1038 |
!
|
|
1039 |
|
|
1040 |
viewOrigin
|
|
1041 |
"return the viewOrigin; thats the coordinate of the contents
|
|
1042 |
which is shown topLeft in the view.
|
|
1043 |
"
|
|
1044 |
^ viewOrigin
|
|
1045 |
|
|
1046 |
!
|
|
1047 |
|
|
1048 |
widthOfContents
|
|
1049 |
"return the width of the contents in pixels
|
|
1050 |
"
|
|
1051 |
|range
|
|
1052 |
size "{ Class:SmallInteger }"
|
|
1053 |
start "{ Class:SmallInteger }"
|
|
1054 |
stop "{ Class:SmallInteger }"
|
|
1055 |
|
|
|
1056 |
(widthOfContents notNil and:[computeWidthInRange isNil]) ifTrue:[
|
|
1057 |
^ widthOfContents + textStartLeft
|
|
1058 |
].
|
|
1059 |
range := computeWidthInRange.
|
|
1060 |
computeWidthInRange := nil.
|
|
1061 |
preferredExtent := nil.
|
|
1062 |
size := list size.
|
|
1063 |
|
|
1064 |
size == 0 ifTrue:[
|
|
1065 |
widthOfContents := 20.
|
|
1066 |
] ifFalse:[
|
|
1067 |
widthOfContents isNil ifTrue:[
|
|
1068 |
widthOfContents := self widthOfWidestLineBetween:1 and:size
|
|
1069 |
] ifFalse:[
|
|
1070 |
start := range x.
|
|
1071 |
stop := range y min:size.
|
|
1072 |
|
|
1073 |
start > stop ifFalse:[
|
|
1074 |
size := self widthOfWidestLineBetween:start and:stop.
|
|
1075 |
|
|
1076 |
widthOfContents < size ifTrue:[
|
|
1077 |
widthOfContents := size
|
|
1078 |
]
|
|
1079 |
]
|
|
1080 |
]
|
|
1081 |
].
|
|
1082 |
^ widthOfContents + textStartLeft
|
|
1083 |
!
|
|
1084 |
|
|
1085 |
xOriginOfContents
|
|
1086 |
"return the horizontal origin of the contents in pixels
|
|
1087 |
"
|
|
1088 |
^ viewOrigin x
|
|
1089 |
|
|
1090 |
!
|
|
1091 |
|
|
1092 |
yOriginOfContents
|
|
1093 |
"return the vertical origin of the contents in pixels
|
|
1094 |
"
|
|
1095 |
^ viewOrigin y
|
|
1096 |
|
|
1097 |
! !
|
|
1098 |
|
|
1099 |
!ListModelView methodsFor:'scrolling'!
|
|
1100 |
|
|
1101 |
halfPageDown
|
|
1102 |
"scroll down half a page
|
|
1103 |
"
|
|
1104 |
self scrollDown:(width // 2).
|
|
1105 |
|
|
1106 |
!
|
|
1107 |
|
|
1108 |
halfPageUp
|
|
1109 |
"scroll up half a page
|
|
1110 |
"
|
|
1111 |
self scrollUp:(width // 2).
|
|
1112 |
|
|
1113 |
!
|
|
1114 |
|
|
1115 |
scrollTo:anOrigin redraw:doRedraw
|
|
1116 |
"change origin to have newOrigin be visible at the top-left.
|
|
1117 |
"
|
1399
|
1118 |
|newOrg dltOrg sensor
|
1390
|
1119 |
innerWT "{ Class:SmallInteger }"
|
|
1120 |
innerHG "{ Class:SmallInteger }"
|
|
1121 |
h "{ Class:SmallInteger }"
|
|
1122 |
x "{ Class:SmallInteger }"
|
|
1123 |
x0 "{ Class:SmallInteger }"
|
|
1124 |
x1 "{ Class:SmallInteger }"
|
|
1125 |
y "{ Class:SmallInteger }"
|
|
1126 |
w "{ Class:SmallInteger }"
|
|
1127 |
y0 "{ Class:SmallInteger }"
|
|
1128 |
y1 "{ Class:SmallInteger }"
|
|
1129 |
dX "{ Class:SmallInteger }"
|
|
1130 |
dY "{ Class:SmallInteger }"
|
|
1131 |
|
|
|
1132 |
(shown and:[(sensor := self sensor) notNil]) ifFalse:[
|
|
1133 |
^ self
|
|
1134 |
].
|
1399
|
1135 |
self windowGroup processExposeEvents.
|
1390
|
1136 |
|
|
1137 |
innerWT := self innerWidth.
|
|
1138 |
innerHG := self innerHeight.
|
|
1139 |
|
|
1140 |
h := viewOrigin y.
|
|
1141 |
|
|
1142 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents
|
|
1143 |
y > (dY := self maxViewOriginY) ifTrue:[
|
|
1144 |
y := dY max:h
|
|
1145 |
]
|
|
1146 |
] ifFalse:[
|
|
1147 |
y := y max:0.
|
|
1148 |
].
|
|
1149 |
|
|
1150 |
(x := anOrigin x) > 0 ifTrue:[
|
|
1151 |
x := x min:(self widthOfContents - innerWT).
|
|
1152 |
].
|
|
1153 |
x := x max:0.
|
|
1154 |
newOrg := (x @ y).
|
|
1155 |
dltOrg := newOrg - viewOrigin.
|
|
1156 |
dX := dltOrg x.
|
|
1157 |
dY := dltOrg y.
|
|
1158 |
|
|
1159 |
(dX == 0 and:[dY == 0]) ifTrue:[
|
|
1160 |
^ self
|
|
1161 |
].
|
|
1162 |
self originWillChange.
|
|
1163 |
viewOrigin := newOrg.
|
|
1164 |
|
|
1165 |
doRedraw ifFalse:[
|
|
1166 |
^ self originChanged:dltOrg
|
|
1167 |
].
|
|
1168 |
|
|
1169 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL
|
|
1170 |
dY := dY abs.
|
|
1171 |
|
|
1172 |
(dX ~~ 0 or:[innerHG - dY < 20]) ifTrue:[
|
1391
|
1173 |
self invalidate.
|
1390
|
1174 |
] ifFalse:[ "/ COPY VERTICAL
|
|
1175 |
y0 := y1 := margin + dY.
|
|
1176 |
h := innerHG - dY.
|
|
1177 |
|
|
1178 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0]
|
|
1179 |
ifFalse:[y1 := margin. y := y1 + h].
|
|
1180 |
|
|
1181 |
self catchExpose.
|
|
1182 |
self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true.
|
|
1183 |
self waitForExpose.
|
1391
|
1184 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h).
|
1390
|
1185 |
]
|
|
1186 |
] ifFalse:[ "/ SCROLL HORIZONTAL
|
|
1187 |
dX := dX abs.
|
|
1188 |
|
|
1189 |
innerWT - dX < 20 ifTrue:[
|
1391
|
1190 |
self invalidate.
|
1390
|
1191 |
] ifFalse:[ "/ COPY HORIZONTAL
|
|
1192 |
x0 := x1 := dX + margin.
|
1399
|
1193 |
w := innerWT - dX.
|
1390
|
1194 |
|
|
1195 |
dltOrg x < 0 ifTrue:[x0 := x := margin ]
|
|
1196 |
ifFalse:[x1 := margin. x := w].
|
|
1197 |
|
|
1198 |
self catchExpose.
|
|
1199 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true.
|
|
1200 |
self waitForExpose.
|
1391
|
1201 |
self invalidateX:x y:margin width:(width - w) height:innerHG.
|
1390
|
1202 |
]
|
|
1203 |
].
|
|
1204 |
self originChanged:dltOrg.
|
|
1205 |
!
|
|
1206 |
|
|
1207 |
scrollToLine:aLineNumber
|
|
1208 |
"make line visible
|
|
1209 |
"
|
|
1210 |
|y "{ Class:SmallInteger }"
|
|
1211 |
l "{ Class:SmallInteger }"
|
|
1212 |
|
|
|
1213 |
(aLineNumber notNil and:[aLineNumber between:1 and:(list size)]) ifFalse:[
|
|
1214 |
^ self
|
|
1215 |
].
|
|
1216 |
|
|
1217 |
y := self yVisibleOfLine:aLineNumber.
|
|
1218 |
|
|
1219 |
y < margin ifTrue:[
|
|
1220 |
y := margin - y.
|
|
1221 |
] ifFalse:[
|
|
1222 |
y := self yVisibleOfLine:(1 + aLineNumber).
|
|
1223 |
l := height - margin.
|
|
1224 |
y > l ifFalse:[^ self].
|
|
1225 |
y := l - y.
|
|
1226 |
].
|
|
1227 |
self scrollTo:(viewOrigin - (0 @ y)).
|
|
1228 |
|
|
1229 |
|
|
1230 |
! !
|
|
1231 |
|
|
1232 |
!ListModelView class methodsFor:'documentation'!
|
|
1233 |
|
|
1234 |
version
|
1417
|
1235 |
^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.6 1999-06-19 15:41:25 cg Exp $'
|
1390
|
1236 |
! !
|
|
1237 |
ListModelView initialize!
|