author | ca |
Wed, 07 Jan 2004 09:18:38 +0100 | |
changeset 2598 | b0c2d20f4062 |
parent 2595 | 1ab5dc7d4796 |
child 2599 | 4945da23d4e9 |
permissions | -rw-r--r-- |
1431 | 1 |
" |
2 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
2265 | 3 |
All Rights Reserved |
1431 | 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 |
||
1752 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
1390 | 16 |
View subclass:#ListModelView |
17 |
instanceVariableNames:'list listHolder textStartLeft viewOrigin enabled fgColor bgColor |
|
1399 | 18 |
lineSpacing widthOfContents computeWidthInRange startOfLinesY |
2329 | 19 |
autoScroll autoScrollBlock scrollWhenUpdating hasConstantHeight |
2352 | 20 |
constantHeight previousExtent renderer' |
1390 | 21 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor |
22 |
DefaultLightColor StopRedrawSignal' |
|
23 |
poolDictionaries:'' |
|
1430 | 24 |
category:'Views-Lists' |
1390 | 25 |
! |
26 |
||
2352 | 27 |
Object subclass:#Renderer |
28 |
instanceVariableNames:'view' |
|
29 |
classVariableNames:'' |
|
30 |
poolDictionaries:'' |
|
31 |
privateIn:ListModelView |
|
32 |
! |
|
33 |
||
1390 | 34 |
!ListModelView class methodsFor:'documentation'! |
35 |
||
1431 | 36 |
copyright |
37 |
" |
|
38 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
2265 | 39 |
All Rights Reserved |
1431 | 40 |
|
41 |
This software is furnished under a license and may be used |
|
42 |
only in accordance with the terms of that license and with the |
|
43 |
inclusion of the above copyright notice. This software may not |
|
44 |
be provided or otherwise made available to, or used by, any |
|
45 |
other person. No title to or ownership of the software is |
|
46 |
hereby transferred. |
|
47 |
" |
|
48 |
||
49 |
! |
|
50 |
||
1390 | 51 |
documentation |
52 |
" |
|
1431 | 53 |
This widget is a new improved revision of the good-old ListView. |
54 |
In contrast to ListView, this one reacts on changes of the |
|
55 |
underlying model and performs optimized redraws. |
|
56 |
It requires a List (or alike) as model. |
|
57 |
||
1390 | 58 |
This class can only passively display collections of elements. |
59 |
The class doesn't keep its own list, it works directly on |
|
60 |
the model( List or HierarchicalList ). |
|
61 |
||
62 |
Each list item is obligated to provide 3 services: |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
63 |
- heightOn:aGC |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
64 |
- widthOn:aGC |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
65 |
- displayOn:aGC x:x y:y |
1390 | 66 |
|
67 |
[Instance variables:] |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
68 |
list <List-Model> List or HierarchicalList ... |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
69 |
listHolder <Model> Model, which keeps a List |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
70 |
textStartLeft <Number> left inset of text |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
71 |
viewOrigin <Point> the current origin |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
72 |
enabled <Boolean> widget is enabled/disabeled |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
73 |
fgColor <Color> color to draw characters |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
74 |
bgColor <Color> the background |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
75 |
lineSpacing <Number> pixels between lines |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
76 |
widthOfContents <Number> cached width of widest line |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
77 |
computeWidthInRange <Point> used for recompute width of contents |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
78 |
startOfLinesY <Collection> keeps all the absolute Y-start positions |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
79 |
for each line in the list. The first |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
80 |
entry into the list is the top Y inset. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
81 |
supportsDisplayInRange <Boolean> set to true if the list elements |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
82 |
supports the service: |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
83 |
#displayOn:x:y:h: |
1535
872422bc0e81
support frames (views) within the list
Claus Gittinger <cg@exept.de>
parents:
1534
diff
changeset
|
84 |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
85 |
hasConstantHeight <Boolean> true, than each line has the same height |
1554 | 86 |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
87 |
constantHeight <SmallInteger> hasConstantHeight is turned on, this |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
88 |
is the used line height |
2264 | 89 |
|
1390 | 90 |
[author:] |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
91 |
Claus Atzkern |
1390 | 92 |
|
93 |
[see also:] |
|
94 |
||
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
95 |
SelectionInListModelView |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
96 |
HierarchicalListView |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
97 |
List |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
98 |
HierarchicalList |
1390 | 99 |
" |
100 |
! |
|
101 |
||
102 |
examples |
|
103 |
" |
|
2265 | 104 |
[exBegin] |
1390 | 105 |
|top list view up index| |
106 |
||
107 |
list := List new. |
|
108 |
||
109 |
top := StandardSystemView new; extent:300@300. |
|
110 |
view := ScrollableView for:ListModelView miniScroller:true |
|
2265 | 111 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
1827 | 112 |
|
1390 | 113 |
view list:list. |
114 |
top openAndWait. |
|
115 |
up := true. |
|
116 |
||
117 |
[top shown] whileTrue:[ |
|
2265 | 118 |
Delay waitForSeconds:0.2. |
1390 | 119 |
|
2265 | 120 |
up ifTrue:[ |
121 |
index := 1 + (list size). |
|
122 |
list add:('element: ', index printString). |
|
123 |
up := index < 20 |
|
124 |
] ifFalse:[ |
|
125 |
list removeIndex:1. |
|
126 |
up := list isEmpty. |
|
127 |
] |
|
1390 | 128 |
]. |
2265 | 129 |
[exEnd] |
1390 | 130 |
|
131 |
" |
|
132 |
||
133 |
! ! |
|
134 |
||
135 |
!ListModelView class methodsFor:'initialization'! |
|
136 |
||
137 |
initialize |
|
1409 | 138 |
"setup the signals |
139 |
" |
|
2552
7f6a07978018
notifications are proceedable
Claus Gittinger <cg@exept.de>
parents:
2551
diff
changeset
|
140 |
StopRedrawSignal := Notification newSignalMayProceed:true. |
2551 | 141 |
StopRedrawSignal nameClass:self message:#stopRedrawSignal. |
1390 | 142 |
! ! |
143 |
||
144 |
!ListModelView class methodsFor:'Signal constants'! |
|
145 |
||
146 |
stopRedrawSignal |
|
147 |
^ StopRedrawSignal |
|
148 |
! ! |
|
149 |
||
150 |
!ListModelView class methodsFor:'defaults'! |
|
151 |
||
2352 | 152 |
defaultRenderer |
153 |
^ Renderer |
|
154 |
! |
|
155 |
||
1390 | 156 |
updateStyleCache |
157 |
"extract values from the styleSheet and cache them in class variables" |
|
158 |
||
159 |
<resource: #style ( |
|
2265 | 160 |
#'text.backgroundColor' #'text.foregroundColor' |
161 |
#'selection.shadowColor' #'selection.lightColor' |
|
162 |
#'text.font' |
|
163 |
)> |
|
1390 | 164 |
|
165 |
DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Black. |
|
166 |
DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor'. |
|
167 |
DefaultShadowColor := StyleSheet colorAt:'selection.shadowColor'. |
|
168 |
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'. |
|
169 |
DefaultFont := StyleSheet fontAt:'text.font'. |
|
170 |
||
171 |
" |
|
172 |
self updateStyleCache |
|
173 |
" |
|
174 |
||
175 |
||
176 |
! ! |
|
177 |
||
178 |
!ListModelView methodsFor:'accessing'! |
|
179 |
||
180 |
list |
|
181 |
"get the list of items |
|
182 |
" |
|
183 |
^ list |
|
184 |
||
185 |
||
186 |
! |
|
187 |
||
188 |
list:aList |
|
189 |
"set the list of items |
|
190 |
" |
|
2264 | 191 |
|negatedOrg| |
1443 | 192 |
|
1452 | 193 |
list ~~ aList ifTrue:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
194 |
list removeDependent:self. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
195 |
list := aList. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
196 |
list isNil ifTrue:[list := self newDefaultList ]. |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
197 |
list addDependent:self |
1452 | 198 |
]. |
2264 | 199 |
preferredExtent := nil. |
200 |
widthOfContents := nil. |
|
201 |
||
202 |
self realized ifFalse:[^ self]. |
|
203 |
||
1390 | 204 |
self recomputeHeightOfContents. |
205 |
||
206 |
||
1827 | 207 |
scrollWhenUpdating == #beginOfText ifTrue:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
208 |
viewOrigin = (0@0) ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
209 |
self originWillChange. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
210 |
negatedOrg := viewOrigin negated. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
211 |
viewOrigin := (0@0). |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
212 |
self originChanged:negatedOrg. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
213 |
]. |
1827 | 214 |
] ifFalse:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
215 |
scrollWhenUpdating == #endOfText ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
216 |
self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
217 |
] |
1422 | 218 |
]. |
1827 | 219 |
|
1422 | 220 |
self invalidate. |
1457 | 221 |
self contentsChanged |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
222 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
223 |
|
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
224 |
newDefaultList |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
225 |
"creates and returns a new default list class, on default a List |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
226 |
" |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
227 |
^ List new |
1390 | 228 |
! ! |
229 |
||
1818 | 230 |
!ListModelView methodsFor:'accessing-behavior'! |
1390 | 231 |
|
1748 | 232 |
autoScroll |
233 |
"returns true if auto scrolling is enabled |
|
234 |
" |
|
235 |
^ autoScroll |
|
236 |
! |
|
237 |
||
238 |
autoScroll:aBool |
|
239 |
"returns true if auto scrolling is enabled |
|
240 |
" |
|
241 |
autoScroll := aBool ? true. |
|
242 |
! |
|
243 |
||
1390 | 244 |
enabled |
245 |
"returns the enabled state |
|
246 |
" |
|
247 |
^ enabled |
|
248 |
||
249 |
||
250 |
! |
|
251 |
||
252 |
enabled:aBoolean |
|
253 |
"set the enabled state |
|
254 |
" |
|
255 |
enabled := aBoolean |
|
256 |
||
257 |
||
1742 | 258 |
! |
259 |
||
2261 | 260 |
hasConstantHeight |
261 |
"user configured; true if each line has the same lineHeight |
|
262 |
optimize for scroller update |
|
263 |
" |
|
264 |
^ hasConstantHeight |
|
265 |
! |
|
266 |
||
267 |
hasConstantHeight:aBool |
|
268 |
"user configured; true if each line has the same lineHeight |
|
269 |
optimize for scroller update |
|
270 |
" |
|
271 |
aBool == hasConstantHeight ifTrue:[ |
|
2265 | 272 |
^ self |
2261 | 273 |
]. |
2264 | 274 |
constantHeight := nil. |
2261 | 275 |
hasConstantHeight := aBool. |
276 |
||
277 |
self lostSynchronisation. |
|
278 |
! |
|
279 |
||
1742 | 280 |
scrollWhenUpdating:aSymbolOrNil |
281 |
"define how to scroll, when I get a new text |
|
282 |
(via the model or the #contents/#list) |
|
283 |
Allowed arguments are: |
|
2265 | 284 |
#keep / nil -> no change |
285 |
#endOfText -> scroll to the end |
|
286 |
#beginOfText -> scroll to the top |
|
1742 | 287 |
The default is #beginOfText. |
288 |
This may be useful for fields which get new values assigned from |
|
289 |
the program (i.e. not from the user) |
|
290 |
" |
|
291 |
||
1827 | 292 |
scrollWhenUpdating := aSymbolOrNil |
1742 | 293 |
|
294 |
||
1390 | 295 |
! ! |
296 |
||
1818 | 297 |
!ListModelView methodsFor:'accessing-items'! |
1390 | 298 |
|
299 |
at:anIndex |
|
300 |
"return the list element at an index |
|
301 |
" |
|
302 |
^ list at:anIndex |
|
303 |
! |
|
304 |
||
305 |
at:anIndex ifAbsent:exceptionBlock |
|
306 |
"return the list element at an index if valid. |
|
307 |
If the index is invalid, return the result of evaluating |
|
308 |
the exceptionblock. |
|
309 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
310 |
^ list at:anIndex ifAbsent:exceptionBlock |
2408 | 311 |
! |
312 |
||
313 |
findLast:aOneArgBlock |
|
314 |
"find the last list entry, for which evaluation of the argument, aOneArgBlock |
|
315 |
returns true; return its index or 0 if none detected. |
|
316 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
317 |
^ list findLast:aOneArgBlock |
1390 | 318 |
! |
319 |
||
320 |
identityIndexOf:anElement |
|
321 |
"returns the index of an element or nil |
|
322 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
323 |
^ list identityIndexOf:anElement |
2408 | 324 |
! |
1390 | 325 |
|
2408 | 326 |
last |
327 |
"returns the last list entry |
|
328 |
" |
|
329 |
^ list last |
|
1390 | 330 |
! ! |
331 |
||
1818 | 332 |
!ListModelView methodsFor:'accessing-look'! |
1390 | 333 |
|
334 |
backgroundColor |
|
335 |
"get the background color |
|
336 |
" |
|
337 |
^ bgColor |
|
338 |
||
339 |
||
340 |
! |
|
341 |
||
342 |
backgroundColor:aColor |
|
343 |
"set the background color |
|
344 |
" |
|
345 |
(aColor notNil and:[bgColor ~~ aColor]) ifTrue:[ |
|
2265 | 346 |
super viewBackground:bgColor. |
1390 | 347 |
|
2265 | 348 |
self realized ifTrue:[ |
349 |
bgColor := aColor onDevice:device. |
|
350 |
self invalidate |
|
351 |
] ifFalse:[ |
|
352 |
bgColor := aColor |
|
353 |
] |
|
1390 | 354 |
] |
355 |
! |
|
356 |
||
357 |
font:aFont |
|
358 |
"set a new font |
|
359 |
" |
|
360 |
|oldWidth oldHeight| |
|
361 |
||
362 |
(aFont isNil or:[aFont = font]) ifFalse:[ |
|
2265 | 363 |
oldWidth := font width. |
364 |
oldHeight := font height. |
|
1390 | 365 |
|
2265 | 366 |
super font:aFont. |
1390 | 367 |
|
2265 | 368 |
(font widthOn:device) ~~ oldWidth ifTrue:[ "/ force a recomputation |
369 |
preferredExtent := nil. |
|
370 |
widthOfContents := nil. |
|
371 |
]. |
|
372 |
oldHeight ~~ (font heightOn:device) ifTrue:[ |
|
373 |
self recomputeHeightOfContents. |
|
374 |
]. |
|
375 |
shown ifTrue:[ self invalidate ] |
|
1390 | 376 |
]. |
377 |
! |
|
378 |
||
379 |
foregroundColor |
|
380 |
"get the foreground color |
|
381 |
" |
|
382 |
^ fgColor |
|
383 |
||
384 |
! |
|
385 |
||
386 |
foregroundColor:aColor |
|
387 |
"set the foreground color |
|
388 |
" |
|
389 |
(aColor notNil and:[fgColor ~~ aColor]) ifTrue:[ |
|
2265 | 390 |
self realized ifTrue:[ |
391 |
fgColor := aColor onDevice:device. |
|
392 |
self invalidate |
|
393 |
] ifFalse:[ |
|
394 |
fgColor := aColor |
|
395 |
] |
|
1390 | 396 |
] |
1945 | 397 |
! |
398 |
||
399 |
lineSpacing |
|
400 |
"get the lineSpacing - thats an additional number of pixels, |
|
401 |
by which lines are vertically separated. |
|
402 |
" |
|
403 |
^ lineSpacing |
|
404 |
! |
|
405 |
||
406 |
lineSpacing:aNumber |
|
407 |
"set the lineSpacing - thats an additional number of pixels, |
|
408 |
by which lines are vertically separated. |
|
409 |
" |
|
410 |
lineSpacing ~= aNumber ifTrue:[ |
|
2265 | 411 |
lineSpacing := aNumber. |
1945 | 412 |
|
2265 | 413 |
self recomputeHeightOfContents. |
1945 | 414 |
|
2265 | 415 |
shown ifTrue:[ |
416 |
self invalidate |
|
417 |
] |
|
1945 | 418 |
] |
1390 | 419 |
! ! |
420 |
||
1818 | 421 |
!ListModelView methodsFor:'accessing-mvc'! |
1390 | 422 |
|
423 |
listHolder |
|
424 |
"returns the listHolder or nil |
|
425 |
" |
|
426 |
^ listHolder |
|
427 |
! |
|
428 |
||
429 |
listHolder:aListHolder |
|
430 |
"set a new listHolder |
|
431 |
" |
|
432 |
listHolder removeDependent:self. |
|
433 |
||
434 |
(listHolder := aListHolder) notNil ifTrue:[ |
|
2265 | 435 |
listHolder addDependent:self. |
1390 | 436 |
]. |
437 |
self list:(listHolder value). |
|
438 |
! ! |
|
439 |
||
440 |
!ListModelView methodsFor:'change & update'! |
|
441 |
||
442 |
lineChangedAt:aLnNr with:arg |
|
2548 | 443 |
"line changed at position; check whether line height changed" |
444 |
||
445 |
|cache |
|
1390 | 446 |
oldHeight "{ Class:SmallInteger }" |
2548 | 447 |
dltHeight "{ Class:SmallInteger }" | |
448 |
||
449 |
(arg == #icon or:[arg == #hierarchy]) ifTrue:[ |
|
2385 | 450 |
^ self |
1390 | 451 |
]. |
2264 | 452 |
hasConstantHeight ifTrue:[ |
2385 | 453 |
self invalidateLineAt:aLnNr. |
454 |
^ self |
|
2264 | 455 |
]. |
456 |
||
1390 | 457 |
oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr). |
458 |
dltHeight := (self heightOfLineAt:aLnNr) - oldHeight. |
|
459 |
||
460 |
dltHeight == 0 ifTrue:[ |
|
2385 | 461 |
self invalidateLineAt:aLnNr. |
462 |
^ self |
|
1390 | 463 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
464 |
cache := self startOfLinesY. |
1390 | 465 |
|
2548 | 466 |
aLnNr + 1 to:cache size do:[:i| |
467 |
cache at:i put:((cache at:i) + dltHeight) |
|
1390 | 468 |
]. |
469 |
self invalidate. |
|
470 |
! |
|
471 |
||
472 |
listChangedInsert:start nItems:nLines |
|
473 |
"list changed; items are added |
|
474 |
" |
|
2385 | 475 |
|newLines |
1390 | 476 |
run "{ Class: SmallInteger }" |
1457 | 477 |
newSz "{ Class: SmallInteger }" |
1390 | 478 |
cpyHg "{ Class: SmallInteger }" |
479 |
absY0 "{ Class: SmallInteger }" |
|
480 |
absY1 "{ Class: SmallInteger }" |
|
481 |
visY0 "{ Class: SmallInteger }" |
|
482 |
visY1 "{ Class: SmallInteger }" |
|
483 |
orgY "{ Class: SmallInteger }" |
|
484 |
dltY "{ Class: SmallInteger }" |
|
485 |
maxHg "{ Class: SmallInteger }" |
|
486 |
| |
|
487 |
||
488 |
nLines == 0 ifTrue:[^ self ]. |
|
489 |
self listSizeChanged:start nLines:nLines. |
|
2569 | 490 |
shown ifFalse:[^ self]. |
1390 | 491 |
|
1457 | 492 |
newSz := startOfLinesY size + nLines. |
493 |
||
2408 | 494 |
(newSz - 1) ~~ self size ifTrue:[ |
2385 | 495 |
"/ |
496 |
"/ no longer synchrounous |
|
497 |
"/ |
|
498 |
^ self lostSynchronisation |
|
1451 | 499 |
]. |
2385 | 500 |
newLines := startOfLinesY copy. |
501 |
newLines addAll:(Array new:nLines) beforeIndex:start + 1. |
|
502 |
absY0 := newLines at:start. |
|
1390 | 503 |
absY1 := absY0. |
504 |
run := start. |
|
505 |
||
506 |
nLines timesRepeat:[ |
|
2385 | 507 |
absY1 := absY1 + (self heightOfLineAt:run). |
508 |
run := run + 1. |
|
509 |
newLines at:run put:absY1. |
|
1390 | 510 |
]. |
511 |
dltY := absY1 - absY0. |
|
1457 | 512 |
|
513 |
run + 1 to:newSz do:[:i||v| |
|
2385 | 514 |
newLines at:i put:((newLines at:i) + dltY) |
1390 | 515 |
]. |
2385 | 516 |
startOfLinesY := newLines. |
1390 | 517 |
|
518 |
orgY := viewOrigin y. |
|
519 |
absY1 := absY0 + dltY. |
|
520 |
visY0 := absY0 - orgY. |
|
521 |
visY1 := absY1 - orgY. |
|
522 |
maxHg := height - margin. |
|
523 |
||
524 |
absY0 < orgY ifTrue:[ |
|
2385 | 525 |
self originWillChange. |
526 |
viewOrigin y:(dltY + orgY). |
|
527 |
self originChanged:(0 @ dltY). |
|
1390 | 528 |
]. |
1457 | 529 |
|
1390 | 530 |
(visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[ |
2385 | 531 |
^ self contentsChanged |
1390 | 532 |
]. |
533 |
visY0 := visY0 max:margin. |
|
534 |
visY1 := visY1 min:maxHg. |
|
535 |
||
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
536 |
self hasDamage ifTrue:[ |
2385 | 537 |
self invalidate:(Rectangle left:0 |
538 |
top:visY0 |
|
539 |
width:width |
|
540 |
height:height - visY0). |
|
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
541 |
|
2385 | 542 |
^ self contentsChanged. |
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
543 |
]. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
544 |
|
2408 | 545 |
(start == self size or:[(cpyHg := maxHg - visY1) < 20]) ifTrue:[ |
2385 | 546 |
visY1 := maxHg |
1390 | 547 |
] ifFalse:[ |
2385 | 548 |
self catchExpose. |
1390 | 549 |
|
2385 | 550 |
self copyFrom:self x:0 y:visY0 |
551 |
toX:0 y:visY1 |
|
552 |
width:width height:cpyHg async:true. |
|
1390 | 553 |
|
2385 | 554 |
self waitForExpose |
1390 | 555 |
]. |
556 |
||
1457 | 557 |
self invalidateX:margin |
2385 | 558 |
y:visY0 |
559 |
width:width - margin - margin |
|
560 |
height:(visY1 - visY0). |
|
1457 | 561 |
|
1390 | 562 |
self contentsChanged. |
563 |
! |
|
564 |
||
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
565 |
listChangedRemove:aStart toIndex:aStop |
1390 | 566 |
"list changed; items are removed |
567 |
" |
|
2385 | 568 |
|noRedraw newLines |
1390 | 569 |
size "{ Class: SmallInteger }" |
570 |
absY0 "{ Class: SmallInteger }" |
|
571 |
absY1 "{ Class: SmallInteger }" |
|
572 |
visY0 "{ Class: SmallInteger }" |
|
573 |
visY1 "{ Class: SmallInteger }" |
|
574 |
orgY "{ Class: SmallInteger }" |
|
575 |
orgX "{ Class: SmallInteger }" |
|
576 |
dltY "{ Class: SmallInteger }" |
|
577 |
cpyHg "{ Class: SmallInteger }" |
|
578 |
maxHg "{ Class: SmallInteger }" |
|
1444
0b7cd00e2537
check range before delete lines
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
579 |
stop "{ Class: SmallInteger }" |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
580 |
start "{ Class: SmallInteger }" |
1457 | 581 |
newSz "{ Class: SmallInteger }" |
1390 | 582 |
| |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
583 |
stop := aStop. |
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
584 |
start := aStart. |
1390 | 585 |
|
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
586 |
(size := stop - start + 1) == 0 ifTrue:[ |
2385 | 587 |
^ self |
1390 | 588 |
]. |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
589 |
|
1390 | 590 |
self listSizeChanged:start nLines:(size negated). |
2569 | 591 |
shown ifFalse:[^ self]. |
1451 | 592 |
|
1457 | 593 |
newSz := startOfLinesY size - size. |
594 |
||
2408 | 595 |
(newSz - 1) ~~ self size ifTrue:[ |
2385 | 596 |
"/ |
597 |
"/ no longer synchrounous |
|
598 |
"/ |
|
599 |
^ self lostSynchronisation |
|
1451 | 600 |
]. |
601 |
||
1390 | 602 |
absY0 := self yAbsoluteOfLine:start. |
1457 | 603 |
absY1 := self yAbsoluteOfLine:stop + 1. |
1390 | 604 |
dltY := absY1 - absY0. |
605 |
||
2385 | 606 |
newLines := startOfLinesY copy. |
607 |
newLines removeFromIndex:(start + 1) toIndex:(stop + 1). |
|
1390 | 608 |
|
1457 | 609 |
(start + 1) to:newSz do:[:i| |
2385 | 610 |
absY0 := newLines at:i. |
611 |
newLines at:i put:(absY0 - dltY). |
|
1390 | 612 |
]. |
2385 | 613 |
startOfLinesY := newLines. |
1390 | 614 |
|
615 |
orgY := viewOrigin y. |
|
616 |
orgX := viewOrigin x. |
|
617 |
||
618 |
absY0 := self yAbsoluteOfLine:start. |
|
619 |
absY1 := absY0 + dltY. |
|
620 |
visY0 := absY0 - orgY. |
|
621 |
visY1 := absY1 - orgY. |
|
622 |
maxHg := height - margin. |
|
623 |
||
2408 | 624 |
(self size == 0 or:[(orgY ~~ 0 and:[self maxViewOriginY == 0])]) ifTrue:[ |
2385 | 625 |
(orgX ~~ 0 or:[orgY ~~ 0]) ifTrue:[ |
626 |
self originWillChange. |
|
627 |
viewOrigin := 0@0. |
|
628 |
self originChanged:((orgX @ orgY) negated). |
|
629 |
]. |
|
630 |
self invalidate. |
|
631 |
^ self contentsChanged |
|
1390 | 632 |
]. |
633 |
||
634 |
visY0 < margin ifTrue:[ |
|
2385 | 635 |
noRedraw := visY1 <= margin. |
636 |
noRedraw ifTrue:[dltY := dltY negated] ifFalse:[dltY := visY0]. |
|
1390 | 637 |
|
2385 | 638 |
self originWillChange. |
639 |
viewOrigin y:(dltY + orgY). |
|
640 |
self originChanged:(0 @ dltY). |
|
1390 | 641 |
] ifFalse:[ |
2385 | 642 |
noRedraw := visY0 >= maxHg |
1390 | 643 |
]. |
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
644 |
visY0 := visY0 max:margin. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
645 |
|
1457 | 646 |
self hasDamage ifTrue:[ |
2385 | 647 |
self invalidate:(Rectangle left:0 |
648 |
top:visY0 |
|
649 |
width:width |
|
650 |
height:height - visY0). |
|
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
651 |
|
2385 | 652 |
noRedraw := true |
1457 | 653 |
]. |
1390 | 654 |
|
1457 | 655 |
noRedraw ifFalse:[ |
2385 | 656 |
cpyHg := maxHg - visY1. |
1390 | 657 |
|
2385 | 658 |
cpyHg > 20 ifTrue:[ |
659 |
self catchExpose. |
|
660 |
self copyFrom:self x:0 y:visY1 toX:0 y:visY0 |
|
661 |
width:width height:cpyHg async:true. |
|
662 |
self waitForExpose. |
|
663 |
visY0 := visY0 + cpyHg. |
|
664 |
]. |
|
1390 | 665 |
|
2385 | 666 |
self invalidateX:margin |
667 |
y:visY0 |
|
668 |
width:width - margin - margin |
|
669 |
height:(maxHg - visY0). |
|
1390 | 670 |
]. |
671 |
self contentsChanged. |
|
672 |
! |
|
673 |
||
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
674 |
update:what with:aPara from:chgObj |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
675 |
"catch and handle any notification raised from the list model |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
676 |
or list holder |
1390 | 677 |
" |
1443 | 678 |
|a1 a2| |
1390 | 679 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
680 |
chgObj ~~ self list ifTrue:[ |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
681 |
chgObj == self listHolder ifTrue:[ |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
682 |
self list:(chgObj value). |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
683 |
] ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
684 |
super update:what with:aPara from:chgObj |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
685 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
686 |
^ self |
1995 | 687 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
688 |
"the list has changed |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
689 |
" |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
690 |
aPara isCollection ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
691 |
what == #at: ifTrue:[self lineChangedAt:aPara with:nil. ^ self]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
692 |
what == #insert: ifTrue:[self listChangedInsert:aPara nItems:1. ^ self]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
693 |
what == #remove: ifTrue:[self listChangedRemove:aPara toIndex:aPara. ^ self]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
694 |
^ self. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
695 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
696 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
697 |
a1 := aPara at:1. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
698 |
a2 := aPara at:2. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
699 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
700 |
(a1 == 1 and:[a2 == self size]) ifTrue:[ |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
701 |
self list:chgObj. "/ reload list |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
702 |
^ self |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
703 |
]. |
1390 | 704 |
|
1995 | 705 |
what == #at: ifTrue:[self lineChangedAt:a1 with:a2. ^ self]. |
706 |
what == #insertCollection: ifTrue:[self listChangedInsert:a1 nItems:a2. ^ self]. |
|
707 |
what == #removeFrom: ifTrue:[self listChangedRemove:a1 toIndex:a2. ^ self]. |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
708 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
709 |
what == #replace: ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
710 |
a1 to:a2 do:[:i|self lineChangedAt:i with:nil]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
711 |
^ self |
1995 | 712 |
]. |
1390 | 713 |
! ! |
714 |
||
715 |
!ListModelView methodsFor:'drawing'! |
|
716 |
||
2304 | 717 |
drawFrom:start to:stop x:x y:y w:w |
718 |
"draw lines from start to stop. |
|
719 |
clipping and clearing the background is already done |
|
1399 | 720 |
" |
2304 | 721 |
|item |
722 |
y0 "{ Class:SmallInteger }" |
|
723 |
y1 "{ Class:SmallInteger }" |
|
724 |
x0 "{ Class:SmallInteger }" |
|
725 |
| |
|
726 |
self paint:fgColor on:bgColor. |
|
727 |
||
728 |
x0 := textStartLeft - viewOrigin x. |
|
729 |
y1 := y. |
|
730 |
||
731 |
start to:stop do:[:i| |
|
2408 | 732 |
item := self at:i ifAbsent:self. "/ list changed during draw |
2304 | 733 |
item == self ifTrue:[^ self]. |
734 |
||
735 |
y0 := y1. |
|
736 |
y1 := self yVisibleOfLine:(i + 1). |
|
737 |
||
738 |
item notNil ifTrue:[ |
|
2352 | 739 |
renderer display:item atX:x0 y:y0 lineHeight:(y1 - y0). |
2304 | 740 |
] |
741 |
] |
|
1390 | 742 |
! |
743 |
||
2304 | 744 |
invalidateLineAt:aLineNr |
745 |
"add a damage to redraw a line specified by its line number to the |
|
746 |
input event queue. |
|
1390 | 747 |
" |
2322 | 748 |
^ self invalidateLineAt:aLineNr fromX:0. |
749 |
! |
|
750 |
||
751 |
invalidateLineAt:aLineNr fromX:x |
|
752 |
"add a damage to redraw a line specified by its line number to the |
|
753 |
input event queue. |
|
754 |
" |
|
1390 | 755 |
|y0 "{ Class:SmallInteger }" |
756 |
y1 "{ Class:SmallInteger }" |
|
757 |
yB "{ Class:SmallInteger }" |
|
2322 | 758 |
x0 "{ Class:SmallInteger }" |
759 |
xR "{ Class:SmallInteger }" |
|
1390 | 760 |
| |
761 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
762 |
(shown and:[aLineNr notNil and:[aLineNr > 0]]) ifFalse:[ |
2304 | 763 |
^ self |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
764 |
]. |
1390 | 765 |
|
2322 | 766 |
xR := width - margin. |
767 |
x0 := x max:margin. |
|
768 |
x0 < xR ifFalse:[ ^ self]. |
|
769 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
770 |
yB := height - margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
771 |
y0 := (self yVisibleOfLine:aLineNr) max:margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
772 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
773 |
y0 < yB ifTrue:[ |
2304 | 774 |
y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB. |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
775 |
|
2304 | 776 |
y1 > y0 ifTrue:[ |
2322 | 777 |
self invalidateX:x0 y:y0 width:(xR - x0) height:(y1 - y0) repairNow:false. |
2304 | 778 |
] |
779 |
]. |
|
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
780 |
! |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
781 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
782 |
redraw |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
783 |
"redraw complete view |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
784 |
" |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
785 |
self redrawX:0 y:0 width:width height:height. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
786 |
|
1390 | 787 |
|
788 |
! |
|
789 |
||
790 |
redrawX:x y:y width:w height:h |
|
791 |
"redraw part of myself immediately, given logical coordinates |
|
792 |
" |
|
2304 | 793 |
|start stop yAbs drawFailed| |
1390 | 794 |
|
795 |
shown ifFalse:[^ self]. |
|
796 |
||
2598
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
797 |
(self startOfLinesY == 1 and:[self size > 1]) ifTrue:[ |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
798 |
"oops, recompute the height of the contents (the first time after creation). |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
799 |
" |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
800 |
self recomputeHeightOfContents. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
801 |
|
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
802 |
self startOfLinesY > 1 ifTrue:[ |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
803 |
"oops, the contents height changed |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
804 |
" |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
805 |
self invalidate. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
806 |
self contentsChanged. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
807 |
^ self |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
808 |
]. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
809 |
]. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
810 |
|
1390 | 811 |
self paint:bgColor. |
812 |
self fillRectangleX:x y:y width:w height:h. |
|
813 |
||
2304 | 814 |
widthOfContents isNil ifTrue:[ |
815 |
self preferredExtent |
|
2188 | 816 |
]. |
1390 | 817 |
|
2304 | 818 |
start := self yVisibleToLineNr:y. |
819 |
start isNil ifTrue:[ ^ self ]. |
|
820 |
||
821 |
yAbs := y + h. |
|
822 |
stop := self yVisibleToLineNr:yAbs. |
|
823 |
||
824 |
stop isNil ifTrue:[ |
|
2408 | 825 |
stop := self size. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
826 |
] ifFalse:[ |y0| |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
827 |
y0 := self startOfLinesY at:stop ifAbsent:nil. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
828 |
y0 isNil ifTrue:[^ self]. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
829 |
|
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
830 |
yAbs == y0 ifTrue:[ |
2304 | 831 |
stop := (stop - 1) max:start |
832 |
]. |
|
833 |
]. |
|
1390 | 834 |
|
2304 | 835 |
drawFailed := true. |
1390 | 836 |
|
2304 | 837 |
"/ test whether list changed during redraw |
838 |
stop >= start ifTrue:[ |
|
839 |
StopRedrawSignal handle:[:ex| ] |
|
840 |
do:[ self drawFrom:start to:stop x:x |
|
841 |
y:(self yVisibleOfLine:start) w:w. |
|
842 |
||
843 |
drawFailed := false. "/ success drawn |
|
844 |
] |
|
845 |
]. |
|
846 |
||
847 |
drawFailed ifTrue:[ self invalidate ]. |
|
1390 | 848 |
! ! |
849 |
||
850 |
!ListModelView methodsFor:'event handling'! |
|
851 |
||
852 |
keyPress:aKey x:x y:y |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
853 |
"a key was pressed - handle page-keys here" |
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
854 |
|
1390 | 855 |
<resource: #keyboard( #PreviousPage #NextPage #HalfPageUp #HalfPageDown |
2408 | 856 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
857 |
)> |
|
1390 | 858 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
859 |
|n| |
1390 | 860 |
|
2408 | 861 |
self size ~~ 0 ifTrue:[ |
862 |
(aKey == #PreviousPage) ifTrue:[^ self pageUp]. |
|
863 |
(aKey == #NextPage) ifTrue:[^ self pageDown]. |
|
864 |
(aKey == #HalfPageUp) ifTrue:[^ self halfPageUp]. |
|
865 |
(aKey == #HalfPageDown) ifTrue:[^ self halfPageDown]. |
|
866 |
(aKey == #BeginOfText) ifTrue:[^ self scrollToTop]. |
|
867 |
(aKey == #EndOfText) ifTrue:[^ self scrollToBottom]. |
|
1390 | 868 |
|
2408 | 869 |
(aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[ |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
870 |
n := 1 + (self sensor compressKeyPressEventsWithKey:aKey). |
2408 | 871 |
n := n * self verticalScrollStep. |
1390 | 872 |
|
2408 | 873 |
aKey == #ScrollUp ifTrue:[self scrollUp:n] |
874 |
ifFalse:[self scrollDown:n]. |
|
875 |
^ self |
|
876 |
]. |
|
1390 | 877 |
]. |
878 |
super keyPress:aKey x:x y:y |
|
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
879 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
880 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
881 |
sizeChanged:how |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
882 |
previousExtent := self extent. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
883 |
super sizeChanged:how. |
1390 | 884 |
! ! |
885 |
||
1554 | 886 |
!ListModelView methodsFor:'event simulation'! |
887 |
||
888 |
syncronizeEvents |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
889 |
self obsoleteMethodWarning:'no longer supported'. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
890 |
^ false |
1554 | 891 |
! |
892 |
||
893 |
syncronizeEvents:aBoolean |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
894 |
self obsoleteMethodWarning:'no longer supported'. |
1554 | 895 |
! ! |
896 |
||
1390 | 897 |
!ListModelView methodsFor:'fetch resources'! |
898 |
||
899 |
colorOnDevice:aColor |
|
900 |
"fetch a device colors |
|
901 |
" |
|
2097 | 902 |
^ aColor notNil ifTrue:[aColor onDevice:device] ifFalse:[nil] |
1390 | 903 |
! |
904 |
||
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
905 |
imageOnMyDevice:anImage |
1390 | 906 |
"associate image to device and clear pixel mask |
907 |
returns the new image. |
|
908 |
" |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
909 |
|deviceImage| |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
910 |
|
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
911 |
anImage isNil ifTrue:[^ anImage]. |
1390 | 912 |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
913 |
deviceImage := anImage onDevice:device. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
914 |
deviceImage isImage ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
915 |
deviceImage clearMaskedPixels. |
1390 | 916 |
]. |
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
917 |
^ deviceImage |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
918 |
"/ |image| |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
919 |
"/ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
920 |
"/ (image := anImage) notNil ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
921 |
"/ image device ~~ device ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
922 |
"/ image := image copy. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
923 |
"/ ]. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
924 |
"/ image := image onDevice:device. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
925 |
"/ image := image clearMaskedPixels. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
926 |
"/ ]. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
927 |
"/ ^ image |
1390 | 928 |
! ! |
929 |
||
1417 | 930 |
!ListModelView methodsFor:'focus handling'! |
931 |
||
932 |
wantsFocusWithButtonPress |
|
933 |
"catch the keyboard focus on button click |
|
934 |
" |
|
935 |
^ true |
|
936 |
||
937 |
||
938 |
! |
|
939 |
||
940 |
wantsFocusWithPointerEnter |
|
941 |
"views which like to take the keyboard focus |
|
942 |
when the pointer enters can do so by redefining this |
|
943 |
to return true" |
|
944 |
||
945 |
^ true |
|
946 |
||
947 |
! ! |
|
948 |
||
2501 | 949 |
!ListModelView methodsFor:'initialization & release'! |
1390 | 950 |
|
951 |
create |
|
952 |
"fetch device dependent resources |
|
953 |
" |
|
954 |
super create. |
|
955 |
self fetchResources. |
|
956 |
! |
|
957 |
||
958 |
initStyle |
|
959 |
"setup viewStyle specifics |
|
960 |
" |
|
961 |
super initStyle. |
|
962 |
||
963 |
DefaultBackgroundColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
964 |
viewBackground := DefaultBackgroundColor |
1390 | 965 |
]. |
966 |
lineSpacing := 0. |
|
967 |
textStartLeft := 2. |
|
968 |
fgColor := DefaultForegroundColor. |
|
969 |
bgColor := viewBackground. |
|
970 |
startOfLinesY := OrderedCollection new. |
|
971 |
||
972 |
startOfLinesY add:(2 + margin). "/ top inset of first line |
|
973 |
||
974 |
DefaultShadowColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
975 |
shadowColor := DefaultShadowColor |
1390 | 976 |
]. |
977 |
||
978 |
DefaultLightColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
979 |
lightColor := DefaultLightColor |
1390 | 980 |
]. |
981 |
! |
|
982 |
||
983 |
initialize |
|
984 |
"setup default attributes |
|
985 |
" |
|
986 |
super initialize. |
|
987 |
||
2261 | 988 |
viewOrigin := 0@0. |
989 |
bitGravity := #NorthWest. |
|
990 |
enabled := true. |
|
991 |
autoScroll := true. |
|
1827 | 992 |
scrollWhenUpdating := #beginOfText. |
2261 | 993 |
hasConstantHeight := false. |
2352 | 994 |
|
995 |
renderer isNil ifTrue:[ |
|
996 |
renderer := self class defaultRenderer forView:self. |
|
997 |
]. |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
998 |
self list:(self list). |
1390 | 999 |
! |
1000 |
||
1562 | 1001 |
mapped |
1002 |
"recompute list |
|
1003 |
" |
|
1004 |
shown ifFalse:[ |
|
2265 | 1005 |
self recomputeHeightOfContents. |
1006 |
self contentsChanged. |
|
1562 | 1007 |
]. |
1008 |
super mapped |
|
1009 |
||
1010 |
! |
|
1011 |
||
1390 | 1012 |
recreate |
1832 | 1013 |
"sent after a snapin or a migration, reinit for new device" |
1828 | 1014 |
|
1390 | 1015 |
super recreate. |
1016 |
self fetchResources. |
|
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1017 |
! |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1018 |
|
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1019 |
reinitialize |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1020 |
"reinit after snapIn (font geometry might be different) |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1021 |
" |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1022 |
super reinitialize. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1023 |
self recomputeHeightOfContents. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1024 |
self contentsChanged. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1025 |
|
2156 | 1026 |
! |
1027 |
||
1028 |
release |
|
1029 |
"remove dependencies |
|
1030 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1031 |
self listHolder removeDependent:self. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1032 |
self list removeDependent:self. |
2156 | 1033 |
|
1034 |
super release |
|
1390 | 1035 |
! ! |
1036 |
||
1037 |
!ListModelView methodsFor:'private'! |
|
1038 |
||
1457 | 1039 |
hasDamage |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1040 |
"return true, if any damage events (i.e. expose or resize) are pending" |
1457 | 1041 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1042 |
^ self sensor hasDamageFor:self |
1457 | 1043 |
! |
1044 |
||
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1045 |
startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1046 |
"returns a sequencable list which keeps all the absolute Y-start positions |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1047 |
for each line into the list. The first entry is the top Y inset. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1048 |
" |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1049 |
^ startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1050 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1051 |
|
1390 | 1052 |
yAbsoluteOfLine:aLineNr |
1053 |
"given a lineNr, return y-coordinate absolute |
|
1054 |
" |
|
1744 | 1055 |
|y y2 y1 cash| |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1056 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1057 |
cash := self startOfLinesY. |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1058 |
|
1744 | 1059 |
(y := cash at:aLineNr ifAbsent:nil) notNil ifTrue:[ |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1060 |
^ y |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1061 |
]. |
1744 | 1062 |
|
1063 |
"/ recompute a y position |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1064 |
y1 := cash at:1 ifAbsent:2. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1065 |
y2 := cash at:2 ifAbsent:10. |
1744 | 1066 |
^ aLineNr * (y2 - y1) + y1 |
1390 | 1067 |
! |
1068 |
||
1069 |
yVisibleOfLine:aLineNr |
|
1070 |
"given a lineNr, return y-coordinate in view |
|
1071 |
" |
|
1744 | 1072 |
^ (self yAbsoluteOfLine:aLineNr) - viewOrigin y |
1390 | 1073 |
|
1074 |
||
1075 |
! |
|
1076 |
||
1077 |
yVisibleToLineNr:yVisible |
|
2301 | 1078 |
"returns the line number assigned to a physical y or nil if out of list |
1390 | 1079 |
" |
2301 | 1080 |
|cash |
1081 |
yAbs "{ Class: SmallInteger}" |
|
1082 |
size "{ Class: SmallInteger}" |
|
1083 |
ictr "{ Class: SmallInteger}" |
|
1084 |
yRun "{ Class: SmallInteger}" |
|
1390 | 1085 |
| |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1086 |
cash := self startOfLinesY. |
1390 | 1087 |
|
2301 | 1088 |
(size := cash size) < 2 ifTrue:[^ nil]. "/ empty list |
1390 | 1089 |
|
2301 | 1090 |
yAbs := yVisible + viewOrigin y. |
1091 |
yRun := cash at:size. |
|
1390 | 1092 |
|
2301 | 1093 |
yAbs >= yRun ifTrue:[ |
1094 |
yAbs == yRun ifTrue:[ ^ size - 1]. |
|
1095 |
^ nil "/ out of list |
|
1096 |
]. |
|
1390 | 1097 |
|
2301 | 1098 |
constantHeight notNil ifTrue:[ |
1099 |
yAbs := yAbs - (cash at:1). |
|
1100 |
yAbs < constantHeight ifTrue:[ ^ 1 ]. |
|
1101 |
^ yAbs // constantHeight + 1 |
|
1390 | 1102 |
]. |
1103 |
||
2301 | 1104 |
ictr := yAbs // (cash at:2). |
1105 |
ictr < 1 ifTrue:[ ictr := 1 ] |
|
1106 |
ifFalse:[ ictr := ictr min:size ]. |
|
1107 |
||
1108 |
yRun := cash at:ictr. |
|
1109 |
||
1110 |
yRun > yAbs ifTrue:[ |
|
1111 |
[(ictr := ictr - 1) > 0 ] whileTrue:[ |
|
1112 |
yRun := cash at:ictr. |
|
1113 |
yRun <= yAbs ifTrue:[ ^ ictr ]. |
|
1114 |
]. |
|
1115 |
^ 1 |
|
1390 | 1116 |
]. |
2301 | 1117 |
|
1118 |
[ yRun ~~ yAbs ] whileTrue:[ |
|
1119 |
ictr := ictr + 1. |
|
1120 |
yRun := cash at:ictr. |
|
1121 |
yRun > yAbs ifTrue:[ ^ ictr - 1 ]. |
|
1390 | 1122 |
]. |
2301 | 1123 |
^ ictr |
2464
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1124 |
! |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1125 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1126 |
yVisibleToRowNr:yVisible |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1127 |
"for protocol compatibility with DSVColumnView" |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1128 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1129 |
^ self yVisibleToLineNr:yVisible |
1390 | 1130 |
! ! |
1131 |
||
1132 |
!ListModelView methodsFor:'protocol'! |
|
1133 |
||
1134 |
fetchResources |
|
1135 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1136 |
*** called after a create or snapin to fetch all device resources |
|
1137 |
" |
|
1138 |
fgColor := self colorOnDevice:fgColor. |
|
1139 |
bgColor := self colorOnDevice:bgColor. |
|
2097 | 1140 |
font := font onDevice:device. |
1390 | 1141 |
! |
1142 |
||
2352 | 1143 |
lineHeightFor:anItem |
1144 |
"returns the computed line height for an item |
|
1390 | 1145 |
" |
2352 | 1146 |
^ lineSpacing + (renderer heightFor:anItem) |
1390 | 1147 |
! |
1148 |
||
1149 |
listSizeChanged:anIndex nLines:noLines |
|
1150 |
"list size changed; information is stored to recompute the |
|
1151 |
width if required( preferredExtent, horizontal scroller ... ). |
|
1152 |
see: widthOfContents |
|
1153 |
*** if nLines is negative, lines are removed otherwise added. |
|
1154 |
" |
|
1155 |
|start "{ Class:SmallInteger }" |
|
1156 |
stop "{ Class:SmallInteger }" |
|
1157 |
size "{ Class:SmallInteger }" |
|
1158 |
| |
|
1159 |
preferredExtent := nil. |
|
1160 |
||
1161 |
widthOfContents isNil ifTrue:[ "/ recompute whole list |
|
2408 | 1162 |
^ self |
1390 | 1163 |
]. |
1164 |
||
2408 | 1165 |
(noLines < 0 or:[(size := self size) <= noLines]) ifTrue:[ |
1166 |
widthOfContents := nil. "/ force recompute whole list |
|
1167 |
^ self |
|
1390 | 1168 |
]. |
1169 |
||
1170 |
stop := anIndex + noLines - 1. "/ recompute a range |
|
1171 |
start := anIndex. |
|
1172 |
||
1173 |
computeWidthInRange notNil ifTrue:[ |
|
2408 | 1174 |
start := computeWidthInRange y. |
1175 |
stop < start ifTrue:[stop := start min:size]. |
|
1176 |
start := (computeWidthInRange x) min:anIndex. |
|
1390 | 1177 |
]. |
1178 |
computeWidthInRange := start@stop |
|
1179 |
! |
|
1180 |
||
1457 | 1181 |
lostSynchronisation |
1182 |
"called when the changes derived from the model are faster than the handling |
|
1183 |
" |
|
1184 |
shown ifTrue:[ |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1185 |
self recomputeHeightOfContents. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1186 |
self invalidate. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1187 |
self contentsChanged |
1457 | 1188 |
]. |
1189 |
! |
|
1190 |
||
1390 | 1191 |
widthOfWidestLineBetween:firstLine and:lastLine |
1192 |
"return the width in pixels of the widest line in a range |
|
1193 |
" |
|
2265 | 1194 |
|item |
1390 | 1195 |
width "{ Class: SmallInteger }" |
1196 |
| |
|
1197 |
width := textStartLeft. |
|
1198 |
||
1199 |
firstLine to:lastLine do:[:anIndex| |
|
2408 | 1200 |
item := self at:anIndex ifAbsent:nil. |
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
1201 |
|
2352 | 1202 |
item isNil ifTrue:[^ width + textStartLeft]. |
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
1203 |
|
2352 | 1204 |
width := (renderer widthFor:item) max:width |
1390 | 1205 |
]. |
1206 |
^ width + textStartLeft |
|
1207 |
! ! |
|
1208 |
||
1820 | 1209 |
!ListModelView methodsFor:'queries'! |
1210 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1211 |
isLineVisible:aLineNr |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1212 |
"returns true if the line is visible" |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1213 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1214 |
^ self isLineVisible:aLineNr in:self extent |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1215 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1216 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1217 |
isLineVisible:aLineNr in:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1218 |
"returns true if the line is visible" |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1219 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1220 |
|y| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1221 |
y := self yVisibleOfLine:aLineNr. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1222 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1223 |
^ (y between:margin and:(anExtentPoint y - margin)) |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1224 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1225 |
|
1820 | 1226 |
size |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1227 |
"returns the number of list entries |
1820 | 1228 |
" |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1229 |
^ self list size |
1820 | 1230 |
! ! |
1231 |
||
1390 | 1232 |
!ListModelView methodsFor:'recomputation'! |
1233 |
||
1234 |
preferredExtent |
|
1235 |
"returns the preferred extent |
|
1236 |
" |
|
1237 |
|x y| |
|
1238 |
||
1239 |
preferredExtent isNil ifTrue:[ |
|
2265 | 1240 |
y := self heightOfContents. |
1241 |
x := self widthOfContents. |
|
1242 |
preferredExtent := x@y |
|
1390 | 1243 |
]. |
1244 |
^ preferredExtent |
|
1245 |
||
1246 |
||
1247 |
! |
|
1248 |
||
1249 |
recomputeHeightOfContents |
|
1250 |
"recompute all the y positions |
|
1251 |
" |
|
1643 | 1252 |
|newList |
1253 |
yAbs "{ Class: SmallInteger }" |
|
1390 | 1254 |
lnHg "{ Class: SmallInteger }" |
1643 | 1255 |
size "{ Class: SmallInteger }" |
1390 | 1256 |
| |
1257 |
||
1643 | 1258 |
yAbs := startOfLinesY at:1. "/ top inset of first line |
2408 | 1259 |
size := self size. |
1643 | 1260 |
newList := OrderedCollection new:(size + 1). |
1261 |
||
1262 |
newList add:yAbs. |
|
1390 | 1263 |
|
2264 | 1264 |
size == 0 ifTrue:[ |
2408 | 1265 |
startOfLinesY := newList. |
1266 |
^ self |
|
2264 | 1267 |
]. |
1268 |
||
1269 |
hasConstantHeight ifTrue:[ |
|
2408 | 1270 |
constantHeight notNil ifTrue:[ lnHg := constantHeight ] |
1271 |
ifFalse:[ lnHg := self heightOfLineAt:1 ]. |
|
2265 | 1272 |
|
2408 | 1273 |
1 to:size do:[:anIndex| |
1274 |
newList add:(yAbs := yAbs + lnHg) |
|
1275 |
]. |
|
1276 |
startOfLinesY := newList. |
|
1277 |
^ self |
|
2264 | 1278 |
]. |
1279 |
||
1643 | 1280 |
1 to:size do:[:anIndex| |
2408 | 1281 |
lnHg := self heightOfLineAt:anIndex. |
1282 |
newList add:(yAbs := yAbs + lnHg) |
|
1390 | 1283 |
]. |
1643 | 1284 |
startOfLinesY := newList. |
1390 | 1285 |
! ! |
1286 |
||
1287 |
!ListModelView methodsFor:'scroller interface'! |
|
1288 |
||
1289 |
heightOfContents |
|
1290 |
"return the height of the contents in pixels |
|
1291 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1292 |
^ self startOfLinesY last ? 0 |
1390 | 1293 |
! |
1294 |
||
2261 | 1295 |
heightOfLineAt:aLineNr |
1296 |
"returns the total height for a line at an index( including lineSpacing ... ) |
|
1297 |
" |
|
1298 |
|item| |
|
1299 |
||
1300 |
hasConstantHeight ifTrue:[ |
|
2352 | 1301 |
constantHeight notNil ifTrue:[ ^ constantHeight ]. |
2408 | 1302 |
item := self at:1 ifAbsent:nil. |
2264 | 1303 |
|
2352 | 1304 |
item notNil ifTrue:[ |
1305 |
constantHeight := self lineHeightFor:item. |
|
1306 |
^ constantHeight |
|
1307 |
] |
|
2264 | 1308 |
] ifFalse:[ |
2408 | 1309 |
item := self at:aLineNr ifAbsent:nil. |
2264 | 1310 |
|
2352 | 1311 |
item notNil ifTrue:[ |
1312 |
^ self lineHeightFor:item |
|
1313 |
] |
|
2261 | 1314 |
]. |
2264 | 1315 |
^ 4 |
2261 | 1316 |
! |
1317 |
||
1390 | 1318 |
innerHeight |
1319 |
"returns the inner height of the contents shown |
|
1320 |
" |
|
1321 |
^ height - margin - margin |
|
1322 |
||
1323 |
! |
|
1324 |
||
1325 |
innerWidth |
|
1326 |
"returns the inner width of the contents shown |
|
1327 |
" |
|
1328 |
^ width - margin - margin |
|
1329 |
||
1330 |
! |
|
1331 |
||
1332 |
maxViewOriginY |
|
1333 |
"returns the maximum possible y of the view origin |
|
1334 |
" |
|
1335 |
^ (self heightOfContents - self innerHeight) max:0 |
|
1336 |
||
1337 |
||
1338 |
! |
|
1339 |
||
1340 |
verticalScrollStep |
|
1341 |
"return the amount to scroll when stepping up/down. |
|
1342 |
" |
|
1343 |
^ 10 |
|
1344 |
||
1345 |
! |
|
1346 |
||
1347 |
viewOrigin |
|
1348 |
"return the viewOrigin; thats the coordinate of the contents |
|
1349 |
which is shown topLeft in the view. |
|
1350 |
" |
|
1351 |
^ viewOrigin |
|
1352 |
||
1353 |
! |
|
1354 |
||
1355 |
widthOfContents |
|
1356 |
"return the width of the contents in pixels |
|
1357 |
" |
|
1358 |
|range |
|
1359 |
size "{ Class:SmallInteger }" |
|
1360 |
start "{ Class:SmallInteger }" |
|
1361 |
stop "{ Class:SmallInteger }" |
|
1362 |
| |
|
1363 |
(widthOfContents notNil and:[computeWidthInRange isNil]) ifTrue:[ |
|
2384 | 1364 |
^ widthOfContents + textStartLeft |
1390 | 1365 |
]. |
1366 |
range := computeWidthInRange. |
|
1367 |
computeWidthInRange := nil. |
|
1368 |
preferredExtent := nil. |
|
2384 | 1369 |
|
1370 |
shown ifFalse:[ ^ 60 ]. |
|
1371 |
||
2408 | 1372 |
size := self size. |
1390 | 1373 |
|
1374 |
size == 0 ifTrue:[ |
|
2384 | 1375 |
widthOfContents := 20. |
1390 | 1376 |
] ifFalse:[ |
2384 | 1377 |
widthOfContents isNil ifTrue:[ |
1378 |
widthOfContents := self widthOfWidestLineBetween:1 and:size |
|
1379 |
] ifFalse:[ |
|
1380 |
start := range x. |
|
1381 |
stop := range y min:size. |
|
1390 | 1382 |
|
2384 | 1383 |
start > stop ifFalse:[ |
1384 |
size := self widthOfWidestLineBetween:start and:stop. |
|
1390 | 1385 |
|
2384 | 1386 |
widthOfContents < size ifTrue:[ |
1387 |
widthOfContents := size |
|
1388 |
] |
|
1389 |
] |
|
1390 |
] |
|
1390 | 1391 |
]. |
1392 |
^ widthOfContents + textStartLeft |
|
1393 |
! |
|
1394 |
||
1395 |
xOriginOfContents |
|
1396 |
"return the horizontal origin of the contents in pixels |
|
1397 |
" |
|
1398 |
^ viewOrigin x |
|
1399 |
||
1400 |
! |
|
1401 |
||
1402 |
yOriginOfContents |
|
1403 |
"return the vertical origin of the contents in pixels |
|
1404 |
" |
|
1405 |
^ viewOrigin y |
|
1406 |
||
1407 |
! ! |
|
1408 |
||
1409 |
!ListModelView methodsFor:'scrolling'! |
|
1410 |
||
1411 |
halfPageDown |
|
1412 |
"scroll down half a page |
|
1413 |
" |
|
1827 | 1414 |
self scrollDown:(height // 2). |
1390 | 1415 |
|
1416 |
! |
|
1417 |
||
1418 |
halfPageUp |
|
1419 |
"scroll up half a page |
|
1420 |
" |
|
1827 | 1421 |
self scrollUp:(height // 2). |
1390 | 1422 |
|
1423 |
! |
|
1424 |
||
2367 | 1425 |
makeLineVisible:aLnNr |
1426 |
"make the line visible |
|
1427 |
" |
|
1428 |
aLnNr notNil ifTrue:[ |
|
1429 |
self scrollToLine:aLnNr |
|
1430 |
]. |
|
1431 |
! |
|
1432 |
||
1390 | 1433 |
scrollTo:anOrigin redraw:doRedraw |
1434 |
"change origin to have newOrigin be visible at the top-left. |
|
1435 |
" |
|
1538 | 1436 |
|newOrg dltOrg winGrp |
1390 | 1437 |
innerWT "{ Class:SmallInteger }" |
1438 |
innerHG "{ Class:SmallInteger }" |
|
1439 |
h "{ Class:SmallInteger }" |
|
1440 |
x "{ Class:SmallInteger }" |
|
1441 |
x0 "{ Class:SmallInteger }" |
|
1442 |
x1 "{ Class:SmallInteger }" |
|
1443 |
y "{ Class:SmallInteger }" |
|
1444 |
w "{ Class:SmallInteger }" |
|
1445 |
y0 "{ Class:SmallInteger }" |
|
1446 |
y1 "{ Class:SmallInteger }" |
|
1447 |
dX "{ Class:SmallInteger }" |
|
1448 |
dY "{ Class:SmallInteger }" |
|
1449 |
| |
|
1531 | 1450 |
|
1580 | 1451 |
realized ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1452 |
^ self |
1390 | 1453 |
]. |
1580 | 1454 |
|
1390 | 1455 |
innerWT := self innerWidth. |
1456 |
innerHG := self innerHeight. |
|
1457 |
||
1458 |
h := viewOrigin y. |
|
1459 |
||
1460 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1461 |
y > (dY := self maxViewOriginY) ifTrue:[ |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1462 |
y := dY max:h |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1463 |
] |
1390 | 1464 |
] ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1465 |
y := y max:0. |
1390 | 1466 |
]. |
1467 |
||
1468 |
(x := anOrigin x) > 0 ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1469 |
x := x min:(self widthOfContents - innerWT). |
1390 | 1470 |
]. |
1471 |
x := x max:0. |
|
1472 |
newOrg := (x @ y). |
|
1473 |
dltOrg := newOrg - viewOrigin. |
|
1474 |
dX := dltOrg x. |
|
1475 |
dY := dltOrg y. |
|
1476 |
||
1477 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1478 |
^ self |
1390 | 1479 |
]. |
1534 | 1480 |
dY := dY abs. |
1481 |
dX := dX abs. |
|
1390 | 1482 |
|
1534 | 1483 |
( (dX ~~ 0 and:[dY ~~ 0]) "/ scroll vertical & horizontal |
1484 |
or:[(innerHG - dY < 20 or:[innerWT - dX < 20])] "/ faster to invalidate screen |
|
1485 |
) ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1486 |
viewOrigin := newOrg. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1487 |
self originChanged:dltOrg. |
1534 | 1488 |
^ self invalidate |
1489 |
]. |
|
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1490 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1491 |
(winGrp := self windowGroup) notNil ifTrue:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1492 |
winGrp processRealExposeEventsFor:self. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1493 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1494 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1495 |
self originWillChange. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1496 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1497 |
doRedraw ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1498 |
viewOrigin := newOrg. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1499 |
^ self originChanged:dltOrg |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1500 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1501 |
|
1531 | 1502 |
self catchExpose. |
1503 |
viewOrigin := newOrg. |
|
1504 |
||
1390 | 1505 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1506 |
y0 := y1 := margin + dY. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1507 |
h := innerHG - dY. |
1390 | 1508 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1509 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1510 |
ifFalse:[y1 := margin. y := y1 + h]. |
1390 | 1511 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1512 |
self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1513 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h). |
1390 | 1514 |
|
1515 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1516 |
x0 := x1 := dX + margin. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1517 |
w := innerWT - dX. |
1390 | 1518 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1519 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1520 |
ifFalse:[x1 := margin. x := w]. |
1390 | 1521 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1522 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1523 |
self invalidateX:x y:margin width:(width - w) height:innerHG. |
1390 | 1524 |
]. |
1525 |
self originChanged:dltOrg. |
|
1531 | 1526 |
self waitForExpose. |
1527 |
||
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1528 |
winGrp notNil ifTrue:[ |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1529 |
winGrp processRealExposeEventsFor:self. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1530 |
]. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1531 |
|
1390 | 1532 |
! |
1533 |
||
1534 |
scrollToLine:aLineNumber |
|
1535 |
"make line visible |
|
1536 |
" |
|
1744 | 1537 |
|inHg "{ Class:SmallInteger }" |
1538 |
yTop "{ Class:SmallInteger }" |
|
1539 |
orgY "{ Class:SmallInteger }" |
|
1540 |
yBot "{ Class:SmallInteger }" |
|
1390 | 1541 |
| |
2408 | 1542 |
(shown and:[aLineNumber notNil and:[aLineNumber between:1 and:(self size)]]) ifFalse:[ |
1543 |
^ self |
|
1390 | 1544 |
]. |
1545 |
||
1744 | 1546 |
yTop := self yAbsoluteOfLine:aLineNumber. |
1547 |
inHg := self innerHeight. |
|
1548 |
orgY := viewOrigin y. |
|
1549 |
||
1550 |
yTop > orgY ifTrue:[ |
|
2408 | 1551 |
yBot := self yAbsoluteOfLine:(aLineNumber + 1). |
1390 | 1552 |
|
2408 | 1553 |
yBot <= (orgY + inHg) ifTrue:[ |
1554 |
^ self |
|
1555 |
]. |
|
1390 | 1556 |
]. |
1744 | 1557 |
yTop := (yTop - (inHg // 2)) max:0. |
1558 |
self scrollTo:(viewOrigin x @ yTop). |
|
1390 | 1559 |
! ! |
1560 |
||
1748 | 1561 |
!ListModelView methodsFor:'scrolling auto'! |
1562 |
||
1563 |
startAutoScroll:aBlock distance:aDistance |
|
1564 |
"setup for auto-scroll (when button-press-moving below view); |
|
1565 |
- timeDelta for scroll is computed from distance |
|
1566 |
" |
|
1567 |
|timeDelta| |
|
1568 |
||
1569 |
(autoScroll and:[aBlock notNil]) ifFalse:[ |
|
2265 | 1570 |
^ self stopAutoScroll |
1748 | 1571 |
]. |
1572 |
autoScrollBlock notNil ifTrue:[ |
|
2265 | 1573 |
Processor removeTimedBlock:autoScrollBlock. |
1748 | 1574 |
] ifFalse:[ |
2265 | 1575 |
self compressMotionEvents:false. |
1748 | 1576 |
]. |
1577 |
||
1578 |
timeDelta := 0.5 / (aDistance abs). |
|
1579 |
||
1580 |
autoScrollBlock := [ |
|
2265 | 1581 |
aBlock value. |
1582 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
1748 | 1583 |
]. |
1584 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
1585 |
||
1586 |
! |
|
1587 |
||
1588 |
stopAutoScroll |
|
1589 |
"stop any autoScroll |
|
1590 |
" |
|
1591 |
autoScrollBlock notNil ifTrue:[ |
|
2265 | 1592 |
Processor removeTimedBlock:autoScrollBlock. |
1593 |
autoScrollBlock := nil. |
|
1594 |
self compressMotionEvents:true. |
|
1748 | 1595 |
]. |
1596 |
! ! |
|
1597 |
||
2352 | 1598 |
!ListModelView::Renderer class methodsFor:'documentation'! |
1599 |
||
1600 |
documentation |
|
1601 |
" |
|
1602 |
prepared for ListItemRenderer |
|
1603 |
.... SelectionItemRenderer ... |
|
1604 |
||
1605 |
goal: |
|
1606 |
allow the user to redefine the display operation and the dimesion queries |
|
1607 |
" |
|
1608 |
! ! |
|
1609 |
||
1610 |
!ListModelView::Renderer class methodsFor:'instance creation'! |
|
1611 |
||
1612 |
forView:aView |
|
1613 |
|renderer| |
|
1614 |
||
1615 |
renderer := self basicNew initialize. |
|
1616 |
renderer forView:aView. |
|
1617 |
^ renderer |
|
1618 |
! ! |
|
1619 |
||
1620 |
!ListModelView::Renderer methodsFor:'displaying'! |
|
1621 |
||
1622 |
display:anItem atX:xLeft y:yTop lineHeight:h |
|
1623 |
"display the item on the view |
|
1624 |
" |
|
1625 |
|x0 y0 label| |
|
1626 |
||
1627 |
x0 := xLeft. |
|
1628 |
y0 := yTop. |
|
1629 |
||
1630 |
anItem isHierarchicalItem ifTrue:[ |
|
1631 |
anItem displayOn:view x:x0 y:y0 h:h |
|
1632 |
] ifFalse:[ |
|
1633 |
anItem isNil ifTrue:[^ self]. |
|
1634 |
||
1635 |
y0 := y0 - ((self heightFor:anItem) + 1 - h // 2). |
|
1636 |
label := anItem. |
|
1637 |
||
1638 |
label isImageOrForm ifFalse:[ |
|
1639 |
label isNumber ifTrue:[ |
|
1640 |
label := label printString |
|
1641 |
]. |
|
1642 |
y0 := y0 + view font ascent |
|
1643 |
]. |
|
1644 |
label displayOn:view x:x0 y:y0 |
|
1645 |
]. |
|
1646 |
! ! |
|
1647 |
||
1648 |
!ListModelView::Renderer methodsFor:'instance creation'! |
|
1649 |
||
1650 |
forView:aView |
|
1651 |
view := aView. |
|
1652 |
! ! |
|
1653 |
||
1654 |
!ListModelView::Renderer methodsFor:'queries-dimensions'! |
|
1655 |
||
1656 |
heightFor:anItem |
|
1657 |
"returns the height of an item on the view |
|
1658 |
" |
|
1659 |
^ anItem heightOn:view |
|
1660 |
! |
|
1661 |
||
1662 |
widthFor:anItem |
|
1663 |
"returns the width of an item on the view |
|
1664 |
" |
|
1665 |
^ anItem widthOn:view |
|
1666 |
! ! |
|
1667 |
||
1390 | 1668 |
!ListModelView class methodsFor:'documentation'! |
1669 |
||
1670 |
version |
|
2598
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
1671 |
^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.85 2004-01-07 08:18:38 ca Exp $' |
1390 | 1672 |
! ! |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
1673 |
|
1390 | 1674 |
ListModelView initialize! |