author | Stefan Vogel <sv@exept.de> |
Mon, 20 Sep 2004 12:33:52 +0200 | |
changeset 2745 | 5986c83276b1 |
parent 2708 | f3efc17bcbce |
child 2852 | c5651fcf9770 |
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 |
|
2640 | 193 |
renderer listWillChange. |
194 |
||
1452 | 195 |
list ~~ aList ifTrue:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
196 |
list removeDependent:self. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
197 |
list := aList. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
198 |
list isNil ifTrue:[list := self newDefaultList ]. |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
199 |
list addDependent:self |
1452 | 200 |
]. |
2264 | 201 |
preferredExtent := nil. |
202 |
widthOfContents := nil. |
|
203 |
||
204 |
self realized ifFalse:[^ self]. |
|
205 |
||
1390 | 206 |
self recomputeHeightOfContents. |
207 |
||
208 |
||
1827 | 209 |
scrollWhenUpdating == #beginOfText ifTrue:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
210 |
viewOrigin = (0@0) ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
211 |
self originWillChange. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
212 |
negatedOrg := viewOrigin negated. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
213 |
viewOrigin := (0@0). |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
214 |
self originChanged:negatedOrg. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
215 |
]. |
1827 | 216 |
] ifFalse:[ |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
217 |
scrollWhenUpdating == #endOfText ifTrue:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
218 |
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
|
219 |
] |
1422 | 220 |
]. |
1827 | 221 |
|
1422 | 222 |
self invalidate. |
1457 | 223 |
self contentsChanged |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
224 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
225 |
|
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
226 |
renderer |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
227 |
"returns the used renderer |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
228 |
" |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
229 |
^ renderer |
2644 | 230 |
! |
231 |
||
232 |
renderer:aRenderer |
|
233 |
"change the used renderer |
|
234 |
" |
|
235 |
aRenderer isNil ifTrue:[^ self]. |
|
236 |
||
237 |
renderer == aRenderer ifTrue:[^ self]. |
|
238 |
renderer notNil ifTrue:[renderer release]. |
|
239 |
||
240 |
renderer := aRenderer. |
|
241 |
renderer isBehavior ifTrue:[ |
|
242 |
renderer := renderer basicNew initialize. |
|
243 |
]. |
|
244 |
renderer forView:self. |
|
1390 | 245 |
! ! |
246 |
||
1818 | 247 |
!ListModelView methodsFor:'accessing-behavior'! |
1390 | 248 |
|
1748 | 249 |
autoScroll |
250 |
"returns true if auto scrolling is enabled |
|
251 |
" |
|
252 |
^ autoScroll |
|
253 |
! |
|
254 |
||
255 |
autoScroll:aBool |
|
256 |
"returns true if auto scrolling is enabled |
|
257 |
" |
|
258 |
autoScroll := aBool ? true. |
|
259 |
! |
|
260 |
||
1390 | 261 |
enabled |
262 |
"returns the enabled state |
|
263 |
" |
|
264 |
^ enabled |
|
265 |
||
266 |
||
267 |
! |
|
268 |
||
269 |
enabled:aBoolean |
|
270 |
"set the enabled state |
|
271 |
" |
|
272 |
enabled := aBoolean |
|
273 |
||
274 |
||
1742 | 275 |
! |
276 |
||
2261 | 277 |
hasConstantHeight |
278 |
"user configured; true if each line has the same lineHeight |
|
279 |
optimize for scroller update |
|
280 |
" |
|
281 |
^ hasConstantHeight |
|
282 |
! |
|
283 |
||
284 |
hasConstantHeight:aBool |
|
285 |
"user configured; true if each line has the same lineHeight |
|
286 |
optimize for scroller update |
|
287 |
" |
|
288 |
aBool == hasConstantHeight ifTrue:[ |
|
2265 | 289 |
^ self |
2261 | 290 |
]. |
2264 | 291 |
constantHeight := nil. |
2261 | 292 |
hasConstantHeight := aBool. |
293 |
||
294 |
self lostSynchronisation. |
|
295 |
! |
|
296 |
||
1742 | 297 |
scrollWhenUpdating:aSymbolOrNil |
298 |
"define how to scroll, when I get a new text |
|
299 |
(via the model or the #contents/#list) |
|
300 |
Allowed arguments are: |
|
2265 | 301 |
#keep / nil -> no change |
302 |
#endOfText -> scroll to the end |
|
303 |
#beginOfText -> scroll to the top |
|
1742 | 304 |
The default is #beginOfText. |
305 |
This may be useful for fields which get new values assigned from |
|
306 |
the program (i.e. not from the user) |
|
307 |
" |
|
308 |
||
1827 | 309 |
scrollWhenUpdating := aSymbolOrNil |
1742 | 310 |
|
311 |
||
1390 | 312 |
! ! |
313 |
||
1818 | 314 |
!ListModelView methodsFor:'accessing-items'! |
1390 | 315 |
|
316 |
at:anIndex |
|
317 |
"return the list element at an index |
|
318 |
" |
|
319 |
^ list at:anIndex |
|
320 |
! |
|
321 |
||
322 |
at:anIndex ifAbsent:exceptionBlock |
|
323 |
"return the list element at an index if valid. |
|
324 |
If the index is invalid, return the result of evaluating |
|
325 |
the exceptionblock. |
|
326 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
327 |
^ list at:anIndex ifAbsent:exceptionBlock |
2408 | 328 |
! |
329 |
||
330 |
findLast:aOneArgBlock |
|
331 |
"find the last list entry, for which evaluation of the argument, aOneArgBlock |
|
332 |
returns true; return its index or 0 if none detected. |
|
333 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
334 |
^ list findLast:aOneArgBlock |
1390 | 335 |
! |
336 |
||
337 |
identityIndexOf:anElement |
|
338 |
"returns the index of an element or nil |
|
339 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
340 |
^ list identityIndexOf:anElement |
2408 | 341 |
! |
1390 | 342 |
|
2408 | 343 |
last |
344 |
"returns the last list entry |
|
345 |
" |
|
346 |
^ list last |
|
1390 | 347 |
! ! |
348 |
||
1818 | 349 |
!ListModelView methodsFor:'accessing-look'! |
1390 | 350 |
|
351 |
backgroundColor |
|
352 |
"get the background color |
|
353 |
" |
|
354 |
^ bgColor |
|
355 |
||
356 |
||
357 |
! |
|
358 |
||
359 |
font:aFont |
|
360 |
"set a new font |
|
361 |
" |
|
362 |
|oldWidth oldHeight| |
|
363 |
||
364 |
(aFont isNil or:[aFont = font]) ifFalse:[ |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
365 |
oldWidth := font width. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
366 |
oldHeight := font height. |
1390 | 367 |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
368 |
super font:aFont. |
1390 | 369 |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
370 |
(font widthOn:device) ~~ oldWidth ifTrue:[ "/ force a recomputation |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
371 |
preferredExtent := nil. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
372 |
widthOfContents := nil. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
373 |
]. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
374 |
oldHeight ~~ (font heightOn:device) ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
375 |
self recomputeHeightOfContents. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
376 |
]. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
377 |
self invalidate |
1390 | 378 |
]. |
379 |
! |
|
380 |
||
381 |
foregroundColor |
|
382 |
"get the foreground color |
|
383 |
" |
|
384 |
^ fgColor |
|
385 |
||
386 |
! |
|
387 |
||
388 |
foregroundColor:aColor |
|
389 |
"set the foreground color |
|
390 |
" |
|
391 |
(aColor notNil and:[fgColor ~~ aColor]) ifTrue:[ |
|
2265 | 392 |
self realized ifTrue:[ |
393 |
fgColor := aColor onDevice:device. |
|
394 |
self invalidate |
|
395 |
] ifFalse:[ |
|
396 |
fgColor := aColor |
|
397 |
] |
|
1390 | 398 |
] |
1945 | 399 |
! |
400 |
||
401 |
lineSpacing |
|
402 |
"get the lineSpacing - thats an additional number of pixels, |
|
403 |
by which lines are vertically separated. |
|
404 |
" |
|
405 |
^ lineSpacing |
|
406 |
! |
|
407 |
||
408 |
lineSpacing:aNumber |
|
409 |
"set the lineSpacing - thats an additional number of pixels, |
|
410 |
by which lines are vertically separated. |
|
411 |
" |
|
412 |
lineSpacing ~= aNumber ifTrue:[ |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
413 |
lineSpacing := aNumber. |
1945 | 414 |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
415 |
self recomputeHeightOfContents. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
416 |
self invalidate |
1945 | 417 |
] |
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
418 |
! |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
419 |
|
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
420 |
viewBackground:aColor |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
421 |
"set the background color |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
422 |
" |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
423 |
(aColor notNil and:[bgColor ~~ aColor]) ifTrue:[ |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
424 |
bgColor := aColor. |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
425 |
super viewBackground:bgColor. |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
426 |
|
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
427 |
self realized ifTrue:[ |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
428 |
bgColor := bgColor onDevice:device. |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
429 |
self invalidate |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
430 |
]. |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
431 |
]. |
1390 | 432 |
! ! |
433 |
||
1818 | 434 |
!ListModelView methodsFor:'accessing-mvc'! |
1390 | 435 |
|
436 |
listHolder |
|
437 |
"returns the listHolder or nil |
|
438 |
" |
|
439 |
^ listHolder |
|
440 |
! |
|
441 |
||
442 |
listHolder:aListHolder |
|
443 |
"set a new listHolder |
|
444 |
" |
|
445 |
listHolder removeDependent:self. |
|
446 |
||
447 |
(listHolder := aListHolder) notNil ifTrue:[ |
|
2265 | 448 |
listHolder addDependent:self. |
1390 | 449 |
]. |
450 |
self list:(listHolder value). |
|
451 |
! ! |
|
452 |
||
453 |
!ListModelView methodsFor:'change & update'! |
|
454 |
||
455 |
lineChangedAt:aLnNr with:arg |
|
2548 | 456 |
"line changed at position; check whether line height changed" |
457 |
||
458 |
|cache |
|
1390 | 459 |
oldHeight "{ Class:SmallInteger }" |
2548 | 460 |
dltHeight "{ Class:SmallInteger }" | |
461 |
||
462 |
(arg == #icon or:[arg == #hierarchy]) ifTrue:[ |
|
2385 | 463 |
^ self |
1390 | 464 |
]. |
2264 | 465 |
hasConstantHeight ifTrue:[ |
2385 | 466 |
self invalidateLineAt:aLnNr. |
467 |
^ self |
|
2264 | 468 |
]. |
469 |
||
1390 | 470 |
oldHeight := (self yVisibleOfLine:(aLnNr + 1)) - (self yVisibleOfLine:aLnNr). |
471 |
dltHeight := (self heightOfLineAt:aLnNr) - oldHeight. |
|
472 |
||
473 |
dltHeight == 0 ifTrue:[ |
|
2385 | 474 |
self invalidateLineAt:aLnNr. |
475 |
^ self |
|
1390 | 476 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
477 |
cache := self startOfLinesY. |
1390 | 478 |
|
2548 | 479 |
aLnNr + 1 to:cache size do:[:i| |
480 |
cache at:i put:((cache at:i) + dltHeight) |
|
1390 | 481 |
]. |
482 |
self invalidate. |
|
483 |
! |
|
484 |
||
485 |
listChangedInsert:start nItems:nLines |
|
486 |
"list changed; items are added |
|
487 |
" |
|
2385 | 488 |
|newLines |
1390 | 489 |
run "{ Class: SmallInteger }" |
1457 | 490 |
newSz "{ Class: SmallInteger }" |
1390 | 491 |
cpyHg "{ Class: SmallInteger }" |
492 |
absY0 "{ Class: SmallInteger }" |
|
493 |
absY1 "{ Class: SmallInteger }" |
|
494 |
visY0 "{ Class: SmallInteger }" |
|
495 |
visY1 "{ Class: SmallInteger }" |
|
496 |
orgY "{ Class: SmallInteger }" |
|
497 |
dltY "{ Class: SmallInteger }" |
|
498 |
maxHg "{ Class: SmallInteger }" |
|
499 |
| |
|
500 |
||
501 |
nLines == 0 ifTrue:[^ self ]. |
|
502 |
self listSizeChanged:start nLines:nLines. |
|
2569 | 503 |
shown ifFalse:[^ self]. |
1390 | 504 |
|
1457 | 505 |
newSz := startOfLinesY size + nLines. |
506 |
||
2408 | 507 |
(newSz - 1) ~~ self size ifTrue:[ |
2385 | 508 |
"/ |
509 |
"/ no longer synchrounous |
|
510 |
"/ |
|
511 |
^ self lostSynchronisation |
|
1451 | 512 |
]. |
2385 | 513 |
newLines := startOfLinesY copy. |
514 |
newLines addAll:(Array new:nLines) beforeIndex:start + 1. |
|
515 |
absY0 := newLines at:start. |
|
1390 | 516 |
absY1 := absY0. |
517 |
run := start. |
|
518 |
||
519 |
nLines timesRepeat:[ |
|
2385 | 520 |
absY1 := absY1 + (self heightOfLineAt:run). |
521 |
run := run + 1. |
|
522 |
newLines at:run put:absY1. |
|
1390 | 523 |
]. |
524 |
dltY := absY1 - absY0. |
|
1457 | 525 |
|
526 |
run + 1 to:newSz do:[:i||v| |
|
2385 | 527 |
newLines at:i put:((newLines at:i) + dltY) |
1390 | 528 |
]. |
2385 | 529 |
startOfLinesY := newLines. |
1390 | 530 |
|
531 |
orgY := viewOrigin y. |
|
532 |
absY1 := absY0 + dltY. |
|
533 |
visY0 := absY0 - orgY. |
|
534 |
visY1 := absY1 - orgY. |
|
535 |
maxHg := height - margin. |
|
536 |
||
537 |
absY0 < orgY ifTrue:[ |
|
2385 | 538 |
self originWillChange. |
539 |
viewOrigin y:(dltY + orgY). |
|
540 |
self originChanged:(0 @ dltY). |
|
1390 | 541 |
]. |
1457 | 542 |
|
1390 | 543 |
(visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[ |
2385 | 544 |
^ self contentsChanged |
1390 | 545 |
]. |
546 |
visY0 := visY0 max:margin. |
|
547 |
visY1 := visY1 min:maxHg. |
|
548 |
||
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
549 |
self hasDamage ifTrue:[ |
2385 | 550 |
self invalidate:(Rectangle left:0 |
551 |
top:visY0 |
|
552 |
width:width |
|
553 |
height:height - visY0). |
|
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
554 |
|
2385 | 555 |
^ self contentsChanged. |
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
556 |
]. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
557 |
|
2408 | 558 |
(start == self size or:[(cpyHg := maxHg - visY1) < 20]) ifTrue:[ |
2385 | 559 |
visY1 := maxHg |
1390 | 560 |
] ifFalse:[ |
2385 | 561 |
self catchExpose. |
1390 | 562 |
|
2385 | 563 |
self copyFrom:self x:0 y:visY0 |
564 |
toX:0 y:visY1 |
|
565 |
width:width height:cpyHg async:true. |
|
1390 | 566 |
|
2385 | 567 |
self waitForExpose |
1390 | 568 |
]. |
569 |
||
1457 | 570 |
self invalidateX:margin |
2385 | 571 |
y:visY0 |
572 |
width:width - margin - margin |
|
573 |
height:(visY1 - visY0). |
|
1457 | 574 |
|
1390 | 575 |
self contentsChanged. |
576 |
! |
|
577 |
||
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
578 |
listChangedRemove:aStart toIndex:aStop |
1390 | 579 |
"list changed; items are removed |
580 |
" |
|
2385 | 581 |
|noRedraw newLines |
1390 | 582 |
size "{ Class: SmallInteger }" |
583 |
absY0 "{ Class: SmallInteger }" |
|
584 |
absY1 "{ Class: SmallInteger }" |
|
585 |
visY0 "{ Class: SmallInteger }" |
|
586 |
visY1 "{ Class: SmallInteger }" |
|
587 |
orgY "{ Class: SmallInteger }" |
|
588 |
orgX "{ Class: SmallInteger }" |
|
589 |
dltY "{ Class: SmallInteger }" |
|
590 |
cpyHg "{ Class: SmallInteger }" |
|
591 |
maxHg "{ Class: SmallInteger }" |
|
1444
0b7cd00e2537
check range before delete lines
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
592 |
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
|
593 |
start "{ Class: SmallInteger }" |
1457 | 594 |
newSz "{ Class: SmallInteger }" |
1390 | 595 |
| |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
596 |
stop := aStop. |
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
597 |
start := aStart. |
1390 | 598 |
|
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
599 |
(size := stop - start + 1) == 0 ifTrue:[ |
2385 | 600 |
^ self |
1390 | 601 |
]. |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
602 |
|
1390 | 603 |
self listSizeChanged:start nLines:(size negated). |
2569 | 604 |
shown ifFalse:[^ self]. |
1451 | 605 |
|
1457 | 606 |
newSz := startOfLinesY size - size. |
607 |
||
2408 | 608 |
(newSz - 1) ~~ self size ifTrue:[ |
2385 | 609 |
"/ |
610 |
"/ no longer synchrounous |
|
611 |
"/ |
|
612 |
^ self lostSynchronisation |
|
1451 | 613 |
]. |
614 |
||
1390 | 615 |
absY0 := self yAbsoluteOfLine:start. |
1457 | 616 |
absY1 := self yAbsoluteOfLine:stop + 1. |
1390 | 617 |
dltY := absY1 - absY0. |
618 |
||
2385 | 619 |
newLines := startOfLinesY copy. |
620 |
newLines removeFromIndex:(start + 1) toIndex:(stop + 1). |
|
1390 | 621 |
|
1457 | 622 |
(start + 1) to:newSz do:[:i| |
2385 | 623 |
absY0 := newLines at:i. |
624 |
newLines at:i put:(absY0 - dltY). |
|
1390 | 625 |
]. |
2385 | 626 |
startOfLinesY := newLines. |
1390 | 627 |
|
628 |
orgY := viewOrigin y. |
|
629 |
orgX := viewOrigin x. |
|
630 |
||
631 |
absY0 := self yAbsoluteOfLine:start. |
|
632 |
absY1 := absY0 + dltY. |
|
633 |
visY0 := absY0 - orgY. |
|
634 |
visY1 := absY1 - orgY. |
|
635 |
maxHg := height - margin. |
|
636 |
||
2408 | 637 |
(self size == 0 or:[(orgY ~~ 0 and:[self maxViewOriginY == 0])]) ifTrue:[ |
2385 | 638 |
(orgX ~~ 0 or:[orgY ~~ 0]) ifTrue:[ |
639 |
self originWillChange. |
|
640 |
viewOrigin := 0@0. |
|
641 |
self originChanged:((orgX @ orgY) negated). |
|
642 |
]. |
|
643 |
self invalidate. |
|
644 |
^ self contentsChanged |
|
1390 | 645 |
]. |
646 |
||
647 |
visY0 < margin ifTrue:[ |
|
2385 | 648 |
noRedraw := visY1 <= margin. |
649 |
noRedraw ifTrue:[dltY := dltY negated] ifFalse:[dltY := visY0]. |
|
1390 | 650 |
|
2385 | 651 |
self originWillChange. |
652 |
viewOrigin y:(dltY + orgY). |
|
653 |
self originChanged:(0 @ dltY). |
|
1390 | 654 |
] ifFalse:[ |
2385 | 655 |
noRedraw := visY0 >= maxHg |
1390 | 656 |
]. |
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
657 |
visY0 := visY0 max:margin. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
658 |
|
1457 | 659 |
self hasDamage ifTrue:[ |
2385 | 660 |
self invalidate:(Rectangle left:0 |
661 |
top:visY0 |
|
662 |
width:width |
|
663 |
height:height - visY0). |
|
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
664 |
|
2385 | 665 |
noRedraw := true |
1457 | 666 |
]. |
1390 | 667 |
|
1457 | 668 |
noRedraw ifFalse:[ |
2385 | 669 |
cpyHg := maxHg - visY1. |
1390 | 670 |
|
2385 | 671 |
cpyHg > 20 ifTrue:[ |
672 |
self catchExpose. |
|
673 |
self copyFrom:self x:0 y:visY1 toX:0 y:visY0 |
|
674 |
width:width height:cpyHg async:true. |
|
675 |
self waitForExpose. |
|
676 |
visY0 := visY0 + cpyHg. |
|
677 |
]. |
|
1390 | 678 |
|
2385 | 679 |
self invalidateX:margin |
680 |
y:visY0 |
|
681 |
width:width - margin - margin |
|
682 |
height:(maxHg - visY0). |
|
1390 | 683 |
]. |
684 |
self contentsChanged. |
|
685 |
! |
|
686 |
||
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
687 |
update:what with:aPara from:chgObj |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
688 |
"catch and handle any notification raised from the list model |
2745 | 689 |
or list holder" |
690 |
||
691 |
chgObj == self listHolder ifTrue:[ |
|
692 |
self list:chgObj value. |
|
693 |
^ self. |
|
694 |
]. |
|
695 |
||
696 |
chgObj == self list ifTrue:[ |
|
697 |
renderer withinUpdateFromListDo:[ |
|
698 |
self updateFromList:what with:aPara. |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
699 |
]. |
2644 | 700 |
^ self. |
701 |
]. |
|
702 |
||
2745 | 703 |
super update:what with:aPara from:chgObj |
2644 | 704 |
! |
705 |
||
706 |
updateFromList:what with:aPara |
|
707 |
"called if the list changed |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
708 |
" |
2644 | 709 |
|arg1 arg2| |
710 |
||
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
711 |
aPara isCollection ifFalse:[ |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
712 |
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
|
713 |
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
|
714 |
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
|
715 |
^ self. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
716 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
717 |
|
2644 | 718 |
arg1 := aPara at:1. |
719 |
arg2 := aPara at:2. |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
720 |
|
2644 | 721 |
(arg1 == 1 and:[arg2 == self size]) ifTrue:[ |
722 |
self list:(self list). "/ reload list |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
723 |
^ self |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
724 |
]. |
1390 | 725 |
|
2644 | 726 |
what == #at: ifTrue:[self lineChangedAt:arg1 with:arg2. ^ self]. |
727 |
what == #insertCollection: ifTrue:[self listChangedInsert:arg1 nItems:arg2. ^ self]. |
|
728 |
what == #removeFrom: ifTrue:[self listChangedRemove:arg1 toIndex:arg2. ^ self]. |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
729 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
730 |
what == #replace: ifTrue:[ |
2644 | 731 |
arg1 to:arg2 do:[:i|self lineChangedAt:i with:nil]. |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
732 |
^ self |
1995 | 733 |
]. |
1390 | 734 |
! ! |
735 |
||
736 |
!ListModelView methodsFor:'drawing'! |
|
737 |
||
2643 | 738 |
drawElementsFrom:start to:stop x:x y:y w:w |
2304 | 739 |
"draw lines from start to stop. |
740 |
clipping and clearing the background is already done |
|
1399 | 741 |
" |
2304 | 742 |
|item |
743 |
y0 "{ Class:SmallInteger }" |
|
744 |
y1 "{ Class:SmallInteger }" |
|
745 |
x0 "{ Class:SmallInteger }" |
|
746 |
| |
|
747 |
self paint:fgColor on:bgColor. |
|
748 |
||
749 |
x0 := textStartLeft - viewOrigin x. |
|
750 |
y1 := y. |
|
751 |
||
752 |
start to:stop do:[:i| |
|
2408 | 753 |
item := self at:i ifAbsent:self. "/ list changed during draw |
2304 | 754 |
item == self ifTrue:[^ self]. |
755 |
||
756 |
y0 := y1. |
|
757 |
y1 := self yVisibleOfLine:(i + 1). |
|
758 |
||
759 |
item notNil ifTrue:[ |
|
2352 | 760 |
renderer display:item atX:x0 y:y0 lineHeight:(y1 - y0). |
2304 | 761 |
] |
762 |
] |
|
1390 | 763 |
! |
764 |
||
2643 | 765 |
drawFrom:start to:stop x:xLft y:yTop w:aWidth |
766 |
"draw lines from start to stop. Test whether a new clip |
|
767 |
must be setup. |
|
768 |
" |
|
769 |
|maxX w| |
|
770 |
||
771 |
maxX := renderer maxItemWidthOrNil. |
|
2644 | 772 |
w := aWidth. |
2643 | 773 |
|
2644 | 774 |
maxX notNil ifTrue:[ |clip| |
2643 | 775 |
maxX := maxX - viewOrigin x. |
2644 | 776 |
maxX > xLft ifFalse:[^ self.]. |
2643 | 777 |
|
2644 | 778 |
w := maxX - xLft min:aWidth. |
2643 | 779 |
|
780 |
(clip := self clipRect copy) notNil ifTrue:[ |
|
781 |
clip width:w |
|
782 |
] ifFalse:[ |
|
783 |
clip := Rectangle left:xLft top:yTop width:w height:(height - yTop - margin). |
|
784 |
]. |
|
785 |
self clippingRectangle:clip. |
|
786 |
]. |
|
787 |
self drawElementsFrom:start to:stop x:xLft y:yTop w:w. |
|
788 |
! |
|
789 |
||
2304 | 790 |
invalidateLineAt:aLineNr |
791 |
"add a damage to redraw a line specified by its line number to the |
|
792 |
input event queue. |
|
1390 | 793 |
" |
2322 | 794 |
^ self invalidateLineAt:aLineNr fromX:0. |
795 |
! |
|
796 |
||
797 |
invalidateLineAt:aLineNr fromX:x |
|
798 |
"add a damage to redraw a line specified by its line number to the |
|
799 |
input event queue. |
|
800 |
" |
|
1390 | 801 |
|y0 "{ Class:SmallInteger }" |
802 |
y1 "{ Class:SmallInteger }" |
|
803 |
yB "{ Class:SmallInteger }" |
|
2322 | 804 |
x0 "{ Class:SmallInteger }" |
805 |
xR "{ Class:SmallInteger }" |
|
1390 | 806 |
| |
807 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
808 |
(shown and:[aLineNr notNil and:[aLineNr > 0]]) ifFalse:[ |
2304 | 809 |
^ self |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
810 |
]. |
1390 | 811 |
|
2322 | 812 |
xR := width - margin. |
813 |
x0 := x max:margin. |
|
814 |
x0 < xR ifFalse:[ ^ self]. |
|
815 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
816 |
yB := height - margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
817 |
y0 := (self yVisibleOfLine:aLineNr) max:margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
818 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
819 |
y0 < yB ifTrue:[ |
2304 | 820 |
y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB. |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
821 |
|
2304 | 822 |
y1 > y0 ifTrue:[ |
2322 | 823 |
self invalidateX:x0 y:y0 width:(xR - x0) height:(y1 - y0) repairNow:false. |
2304 | 824 |
] |
825 |
]. |
|
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
826 |
! |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
827 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
828 |
redraw |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
829 |
"redraw complete view |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
830 |
" |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
831 |
self redrawX:0 y:0 width:width height:height. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
832 |
|
1390 | 833 |
|
834 |
! |
|
835 |
||
836 |
redrawX:x y:y width:w height:h |
|
837 |
"redraw part of myself immediately, given logical coordinates |
|
838 |
" |
|
2644 | 839 |
|start stop yAbs yStart| |
1390 | 840 |
|
841 |
shown ifFalse:[^ self]. |
|
842 |
||
2599 | 843 |
(self startOfLinesY size == 1 and:[self size > 1]) ifTrue:[ |
2598
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
844 |
"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
|
845 |
" |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
846 |
self recomputeHeightOfContents. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
847 |
|
2599 | 848 |
self startOfLinesY size > 1 ifTrue:[ |
2598
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
849 |
"oops, the contents height changed |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
850 |
" |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
851 |
self invalidate. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
852 |
self contentsChanged. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
853 |
^ self |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
854 |
]. |
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
855 |
]. |
2304 | 856 |
widthOfContents isNil ifTrue:[ |
857 |
self preferredExtent |
|
2188 | 858 |
]. |
2644 | 859 |
yStart := y. |
860 |
start := self yVisibleToLineNr:y. |
|
1390 | 861 |
|
2644 | 862 |
start notNil ifTrue:[ |
863 |
yAbs := y + h. |
|
864 |
stop := self yVisibleToLineNr:yAbs. |
|
2304 | 865 |
|
2644 | 866 |
stop isNil ifTrue:[ |
867 |
stop := self size. |
|
868 |
] ifFalse:[ |y0| |
|
869 |
y0 := self startOfLinesY at:stop ifAbsent:nil. |
|
870 |
y0 isNil ifTrue:[^ self]. "/ oops, lines differ (will be changed) |
|
2304 | 871 |
|
2644 | 872 |
yAbs == y0 ifTrue:[ |
873 |
stop := (stop - 1) max:start |
|
874 |
]. |
|
875 |
]. |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
876 |
|
2644 | 877 |
start > stop ifTrue:[ |
878 |
start := stop := nil. |
|
879 |
] ifFalse:[ |
|
880 |
(renderer validateDrawableItemsFrom:start to:stop) ifFalse:[ |
|
881 |
self invalidate. |
|
882 |
^ self. |
|
883 |
]. |
|
884 |
yStart := self yVisibleOfLine:start. |
|
2304 | 885 |
]. |
886 |
]. |
|
2644 | 887 |
self paint:bgColor. |
888 |
self fillRectangleX:x y:y width:w height:h. |
|
1390 | 889 |
|
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
890 |
StopRedrawSignal handle:[:ex| |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
891 |
"/ an item changed its dimension during drawing, draw is aborted |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
892 |
self invalidate |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
893 |
] do:[ |
2644 | 894 |
|
895 |
||
896 |
start notNil ifTrue:[ |
|
897 |
self drawFrom:start to:stop x:x y:yStart w:w. |
|
898 |
]. |
|
899 |
renderer postRedrawX:x y:yStart w:w from:start to:stop. |
|
2304 | 900 |
]. |
1390 | 901 |
! ! |
902 |
||
903 |
!ListModelView methodsFor:'event handling'! |
|
904 |
||
905 |
keyPress:aKey x:x y:y |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
906 |
"a key was pressed - handle page-keys here" |
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
907 |
|
1390 | 908 |
<resource: #keyboard( #PreviousPage #NextPage #HalfPageUp #HalfPageDown |
2408 | 909 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
910 |
)> |
|
1390 | 911 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
912 |
|n| |
1390 | 913 |
|
2408 | 914 |
self size ~~ 0 ifTrue:[ |
915 |
(aKey == #PreviousPage) ifTrue:[^ self pageUp]. |
|
916 |
(aKey == #NextPage) ifTrue:[^ self pageDown]. |
|
917 |
(aKey == #HalfPageUp) ifTrue:[^ self halfPageUp]. |
|
918 |
(aKey == #HalfPageDown) ifTrue:[^ self halfPageDown]. |
|
919 |
(aKey == #BeginOfText) ifTrue:[^ self scrollToTop]. |
|
920 |
(aKey == #EndOfText) ifTrue:[^ self scrollToBottom]. |
|
1390 | 921 |
|
2408 | 922 |
(aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[ |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
923 |
n := 1 + (self sensor compressKeyPressEventsWithKey:aKey). |
2408 | 924 |
n := n * self verticalScrollStep. |
1390 | 925 |
|
2408 | 926 |
aKey == #ScrollUp ifTrue:[self scrollUp:n] |
927 |
ifFalse:[self scrollDown:n]. |
|
928 |
^ self |
|
929 |
]. |
|
1390 | 930 |
]. |
931 |
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
|
932 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
933 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
934 |
sizeChanged:how |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
935 |
previousExtent := self extent. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
936 |
super sizeChanged:how. |
1390 | 937 |
! ! |
938 |
||
1554 | 939 |
!ListModelView methodsFor:'event simulation'! |
940 |
||
941 |
syncronizeEvents |
|
2708 | 942 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
943 |
self obsoleteMethodWarning:'no longer supported'. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
944 |
^ false |
1554 | 945 |
! |
946 |
||
947 |
syncronizeEvents:aBoolean |
|
2708 | 948 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
949 |
self obsoleteMethodWarning:'no longer supported'. |
1554 | 950 |
! ! |
951 |
||
1390 | 952 |
!ListModelView methodsFor:'fetch resources'! |
953 |
||
954 |
colorOnDevice:aColor |
|
955 |
"fetch a device colors |
|
956 |
" |
|
2097 | 957 |
^ aColor notNil ifTrue:[aColor onDevice:device] ifFalse:[nil] |
1390 | 958 |
! |
959 |
||
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
960 |
imageOnMyDevice:anImage |
1390 | 961 |
"associate image to device and clear pixel mask |
962 |
returns the new image. |
|
963 |
" |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
964 |
|deviceImage| |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
965 |
|
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
966 |
anImage isNil ifTrue:[^ anImage]. |
1390 | 967 |
|
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
968 |
deviceImage := anImage onDevice:device. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
969 |
deviceImage isImage ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
970 |
deviceImage clearMaskedPixels. |
1390 | 971 |
]. |
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
972 |
^ deviceImage |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
973 |
"/ |image| |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
974 |
"/ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
975 |
"/ (image := anImage) notNil ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
976 |
"/ image device ~~ device ifTrue:[ |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
977 |
"/ image := image copy. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
978 |
"/ ]. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
979 |
"/ image := image onDevice:device. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
980 |
"/ image := image clearMaskedPixels. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
981 |
"/ ]. |
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
982 |
"/ ^ image |
1390 | 983 |
! ! |
984 |
||
1417 | 985 |
!ListModelView methodsFor:'focus handling'! |
986 |
||
987 |
wantsFocusWithButtonPress |
|
988 |
"catch the keyboard focus on button click |
|
989 |
" |
|
990 |
^ true |
|
991 |
||
992 |
||
993 |
! |
|
994 |
||
995 |
wantsFocusWithPointerEnter |
|
996 |
"views which like to take the keyboard focus |
|
997 |
when the pointer enters can do so by redefining this |
|
998 |
to return true" |
|
999 |
||
1000 |
^ true |
|
1001 |
||
1002 |
! ! |
|
1003 |
||
2501 | 1004 |
!ListModelView methodsFor:'initialization & release'! |
1390 | 1005 |
|
1006 |
create |
|
1007 |
"fetch device dependent resources |
|
1008 |
" |
|
1009 |
super create. |
|
1010 |
self fetchResources. |
|
1011 |
! |
|
1012 |
||
1013 |
initStyle |
|
1014 |
"setup viewStyle specifics |
|
1015 |
" |
|
1016 |
super initStyle. |
|
1017 |
||
1018 |
DefaultBackgroundColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1019 |
viewBackground := DefaultBackgroundColor |
1390 | 1020 |
]. |
1021 |
lineSpacing := 0. |
|
1022 |
textStartLeft := 2. |
|
1023 |
fgColor := DefaultForegroundColor. |
|
1024 |
bgColor := viewBackground. |
|
1025 |
startOfLinesY := OrderedCollection new. |
|
1026 |
||
1027 |
startOfLinesY add:(2 + margin). "/ top inset of first line |
|
1028 |
||
1029 |
DefaultShadowColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1030 |
shadowColor := DefaultShadowColor |
1390 | 1031 |
]. |
1032 |
||
1033 |
DefaultLightColor notNil ifTrue:[ |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1034 |
lightColor := DefaultLightColor |
1390 | 1035 |
]. |
1036 |
! |
|
1037 |
||
1038 |
initialize |
|
1039 |
"setup default attributes |
|
1040 |
" |
|
1041 |
super initialize. |
|
1042 |
||
2261 | 1043 |
viewOrigin := 0@0. |
1044 |
bitGravity := #NorthWest. |
|
1045 |
enabled := true. |
|
1046 |
autoScroll := true. |
|
1827 | 1047 |
scrollWhenUpdating := #beginOfText. |
2261 | 1048 |
hasConstantHeight := false. |
2352 | 1049 |
|
1050 |
renderer isNil ifTrue:[ |
|
1051 |
renderer := self class defaultRenderer forView:self. |
|
1052 |
]. |
|
2600 | 1053 |
self list:(self newDefaultList). |
1390 | 1054 |
! |
1055 |
||
1562 | 1056 |
mapped |
1057 |
"recompute list |
|
1058 |
" |
|
1059 |
shown ifFalse:[ |
|
2643 | 1060 |
self recomputeHeightOfContents. |
1061 |
self contentsChanged. |
|
1062 |
]. |
|
1063 |
renderer mapped. |
|
1562 | 1064 |
super mapped |
1065 |
! |
|
1066 |
||
1390 | 1067 |
recreate |
1832 | 1068 |
"sent after a snapin or a migration, reinit for new device" |
1828 | 1069 |
|
1390 | 1070 |
super recreate. |
1071 |
self fetchResources. |
|
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1072 |
! |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1073 |
|
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1074 |
reinitialize |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1075 |
"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
|
1076 |
" |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1077 |
super reinitialize. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1078 |
self recomputeHeightOfContents. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1079 |
self contentsChanged. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1080 |
|
2156 | 1081 |
! |
1082 |
||
1083 |
release |
|
1084 |
"remove dependencies |
|
1085 |
" |
|
2643 | 1086 |
renderer release. |
1087 |
||
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1088 |
self listHolder removeDependent:self. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1089 |
self list removeDependent:self. |
2156 | 1090 |
|
1091 |
super release |
|
1390 | 1092 |
! ! |
1093 |
||
1094 |
!ListModelView methodsFor:'private'! |
|
1095 |
||
1457 | 1096 |
hasDamage |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1097 |
"return true, if any damage events (i.e. expose or resize) are pending" |
1457 | 1098 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1099 |
^ self sensor hasDamageFor:self |
1457 | 1100 |
! |
1101 |
||
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1102 |
startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1103 |
"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
|
1104 |
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
|
1105 |
" |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1106 |
^ startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1107 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1108 |
|
2640 | 1109 |
xAbsoluteOfItem:anItem |
1110 |
"returns the absolute x of the labeled text |
|
1111 |
" |
|
1112 |
^ (self xVisibleOfItem:anItem) + viewOrigin x. |
|
1113 |
! |
|
1114 |
||
1115 |
xVisibleOfItem:anItem |
|
1116 |
"returns the visible x of the labeled text |
|
1117 |
" |
|
1118 |
^ textStartLeft - viewOrigin x |
|
1119 |
! |
|
1120 |
||
1390 | 1121 |
yAbsoluteOfLine:aLineNr |
1122 |
"given a lineNr, return y-coordinate absolute |
|
1123 |
" |
|
1744 | 1124 |
|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
|
1125 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1126 |
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
|
1127 |
|
1744 | 1128 |
(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
|
1129 |
^ y |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1130 |
]. |
1744 | 1131 |
|
1132 |
"/ recompute a y position |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1133 |
y1 := cash at:1 ifAbsent:2. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1134 |
y2 := cash at:2 ifAbsent:10. |
1744 | 1135 |
^ aLineNr * (y2 - y1) + y1 |
1390 | 1136 |
! |
1137 |
||
1138 |
yVisibleOfLine:aLineNr |
|
1139 |
"given a lineNr, return y-coordinate in view |
|
1140 |
" |
|
1744 | 1141 |
^ (self yAbsoluteOfLine:aLineNr) - viewOrigin y |
1390 | 1142 |
|
1143 |
||
1144 |
! |
|
1145 |
||
1146 |
yVisibleToLineNr:yVisible |
|
2301 | 1147 |
"returns the line number assigned to a physical y or nil if out of list |
1390 | 1148 |
" |
2301 | 1149 |
|cash |
1150 |
yAbs "{ Class: SmallInteger}" |
|
1151 |
size "{ Class: SmallInteger}" |
|
1152 |
ictr "{ Class: SmallInteger}" |
|
1153 |
yRun "{ Class: SmallInteger}" |
|
1390 | 1154 |
| |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1155 |
cash := self startOfLinesY. |
1390 | 1156 |
|
2301 | 1157 |
(size := cash size) < 2 ifTrue:[^ nil]. "/ empty list |
1390 | 1158 |
|
2301 | 1159 |
yAbs := yVisible + viewOrigin y. |
1160 |
yRun := cash at:size. |
|
1390 | 1161 |
|
2301 | 1162 |
yAbs >= yRun ifTrue:[ |
1163 |
yAbs == yRun ifTrue:[ ^ size - 1]. |
|
1164 |
^ nil "/ out of list |
|
1165 |
]. |
|
1390 | 1166 |
|
2301 | 1167 |
constantHeight notNil ifTrue:[ |
1168 |
yAbs := yAbs - (cash at:1). |
|
1169 |
yAbs < constantHeight ifTrue:[ ^ 1 ]. |
|
1170 |
^ yAbs // constantHeight + 1 |
|
1390 | 1171 |
]. |
1172 |
||
2301 | 1173 |
ictr := yAbs // (cash at:2). |
1174 |
ictr < 1 ifTrue:[ ictr := 1 ] |
|
1175 |
ifFalse:[ ictr := ictr min:size ]. |
|
1176 |
||
1177 |
yRun := cash at:ictr. |
|
1178 |
||
1179 |
yRun > yAbs ifTrue:[ |
|
1180 |
[(ictr := ictr - 1) > 0 ] whileTrue:[ |
|
1181 |
yRun := cash at:ictr. |
|
1182 |
yRun <= yAbs ifTrue:[ ^ ictr ]. |
|
1183 |
]. |
|
1184 |
^ 1 |
|
1390 | 1185 |
]. |
2301 | 1186 |
|
1187 |
[ yRun ~~ yAbs ] whileTrue:[ |
|
1188 |
ictr := ictr + 1. |
|
1189 |
yRun := cash at:ictr. |
|
1190 |
yRun > yAbs ifTrue:[ ^ ictr - 1 ]. |
|
1390 | 1191 |
]. |
2301 | 1192 |
^ ictr |
2464
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1193 |
! |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1194 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1195 |
yVisibleToRowNr:yVisible |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1196 |
"for protocol compatibility with DSVColumnView" |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1197 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1198 |
^ self yVisibleToLineNr:yVisible |
1390 | 1199 |
! ! |
1200 |
||
1201 |
!ListModelView methodsFor:'protocol'! |
|
1202 |
||
1203 |
fetchResources |
|
1204 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1205 |
*** called after a create or snapin to fetch all device resources |
|
1206 |
" |
|
1207 |
fgColor := self colorOnDevice:fgColor. |
|
1208 |
bgColor := self colorOnDevice:bgColor. |
|
2097 | 1209 |
font := font onDevice:device. |
1390 | 1210 |
! |
1211 |
||
2352 | 1212 |
lineHeightFor:anItem |
1213 |
"returns the computed line height for an item |
|
1390 | 1214 |
" |
2352 | 1215 |
^ lineSpacing + (renderer heightFor:anItem) |
1390 | 1216 |
! |
1217 |
||
1218 |
listSizeChanged:anIndex nLines:noLines |
|
1219 |
"list size changed; information is stored to recompute the |
|
1220 |
width if required( preferredExtent, horizontal scroller ... ). |
|
1221 |
see: widthOfContents |
|
1222 |
*** if nLines is negative, lines are removed otherwise added. |
|
1223 |
" |
|
1224 |
|start "{ Class:SmallInteger }" |
|
1225 |
stop "{ Class:SmallInteger }" |
|
1226 |
size "{ Class:SmallInteger }" |
|
1227 |
| |
|
1228 |
preferredExtent := nil. |
|
1229 |
||
1230 |
widthOfContents isNil ifTrue:[ "/ recompute whole list |
|
2408 | 1231 |
^ self |
1390 | 1232 |
]. |
1233 |
||
2408 | 1234 |
(noLines < 0 or:[(size := self size) <= noLines]) ifTrue:[ |
1235 |
widthOfContents := nil. "/ force recompute whole list |
|
1236 |
^ self |
|
1390 | 1237 |
]. |
1238 |
||
1239 |
stop := anIndex + noLines - 1. "/ recompute a range |
|
1240 |
start := anIndex. |
|
1241 |
||
1242 |
computeWidthInRange notNil ifTrue:[ |
|
2408 | 1243 |
start := computeWidthInRange y. |
1244 |
stop < start ifTrue:[stop := start min:size]. |
|
1245 |
start := (computeWidthInRange x) min:anIndex. |
|
1390 | 1246 |
]. |
1247 |
computeWidthInRange := start@stop |
|
1248 |
! |
|
1249 |
||
1457 | 1250 |
lostSynchronisation |
1251 |
"called when the changes derived from the model are faster than the handling |
|
1252 |
" |
|
1253 |
shown ifTrue:[ |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1254 |
self recomputeHeightOfContents. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1255 |
self invalidate. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1256 |
self contentsChanged |
1457 | 1257 |
]. |
1258 |
! |
|
1259 |
||
2644 | 1260 |
newDefaultList |
1261 |
"creates and returns a new default list class, on default a List |
|
1262 |
" |
|
1263 |
^ List new |
|
1264 |
! |
|
1265 |
||
1390 | 1266 |
widthOfWidestLineBetween:firstLine and:lastLine |
1267 |
"return the width in pixels of the widest line in a range |
|
1268 |
" |
|
2645 | 1269 |
|item width| |
1270 |
||
2644 | 1271 |
width := renderer widthOfWidestLineBetween:firstLine and:lastLine. |
1272 |
width notNil ifTrue:[^ width]. |
|
1273 |
||
1390 | 1274 |
width := textStartLeft. |
1275 |
||
1276 |
firstLine to:lastLine do:[:anIndex| |
|
2408 | 1277 |
item := self at:anIndex ifAbsent:nil. |
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
1278 |
|
2352 | 1279 |
item isNil ifTrue:[^ width + textStartLeft]. |
1508
9c54f2e53da1
check whether #at:ifAbsent returns nil.
Claus Gittinger <cg@exept.de>
parents:
1457
diff
changeset
|
1280 |
|
2352 | 1281 |
width := (renderer widthFor:item) max:width |
1390 | 1282 |
]. |
1283 |
^ width + textStartLeft |
|
1284 |
! ! |
|
1285 |
||
1820 | 1286 |
!ListModelView methodsFor:'queries'! |
1287 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1288 |
isLineVisible:aLineNr |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1289 |
"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
|
1290 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1291 |
^ self isLineVisible:aLineNr in:self extent |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1292 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1293 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1294 |
isLineVisible:aLineNr in:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1295 |
"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
|
1296 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1297 |
|y| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1298 |
y := self yVisibleOfLine:aLineNr. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1299 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1300 |
^ (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
|
1301 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1302 |
|
1820 | 1303 |
size |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1304 |
"returns the number of list entries |
1820 | 1305 |
" |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1306 |
^ self list size |
1820 | 1307 |
! ! |
1308 |
||
1390 | 1309 |
!ListModelView methodsFor:'recomputation'! |
1310 |
||
1311 |
preferredExtent |
|
1312 |
"returns the preferred extent |
|
1313 |
" |
|
1314 |
|x y| |
|
1315 |
||
1316 |
preferredExtent isNil ifTrue:[ |
|
2265 | 1317 |
y := self heightOfContents. |
1318 |
x := self widthOfContents. |
|
1319 |
preferredExtent := x@y |
|
1390 | 1320 |
]. |
1321 |
^ preferredExtent |
|
1322 |
||
1323 |
||
1324 |
! |
|
1325 |
||
1326 |
recomputeHeightOfContents |
|
1327 |
"recompute all the y positions |
|
1328 |
" |
|
1643 | 1329 |
|newList |
1330 |
yAbs "{ Class: SmallInteger }" |
|
1390 | 1331 |
lnHg "{ Class: SmallInteger }" |
1643 | 1332 |
size "{ Class: SmallInteger }" |
1390 | 1333 |
| |
1334 |
||
1643 | 1335 |
yAbs := startOfLinesY at:1. "/ top inset of first line |
2408 | 1336 |
size := self size. |
1643 | 1337 |
newList := OrderedCollection new:(size + 1). |
1338 |
||
1339 |
newList add:yAbs. |
|
1390 | 1340 |
|
2264 | 1341 |
size == 0 ifTrue:[ |
2408 | 1342 |
startOfLinesY := newList. |
1343 |
^ self |
|
2264 | 1344 |
]. |
1345 |
||
1346 |
hasConstantHeight ifTrue:[ |
|
2408 | 1347 |
constantHeight notNil ifTrue:[ lnHg := constantHeight ] |
1348 |
ifFalse:[ lnHg := self heightOfLineAt:1 ]. |
|
2265 | 1349 |
|
2408 | 1350 |
1 to:size do:[:anIndex| |
1351 |
newList add:(yAbs := yAbs + lnHg) |
|
1352 |
]. |
|
1353 |
startOfLinesY := newList. |
|
1354 |
^ self |
|
2264 | 1355 |
]. |
1356 |
||
1643 | 1357 |
1 to:size do:[:anIndex| |
2408 | 1358 |
lnHg := self heightOfLineAt:anIndex. |
1359 |
newList add:(yAbs := yAbs + lnHg) |
|
1390 | 1360 |
]. |
1643 | 1361 |
startOfLinesY := newList. |
1390 | 1362 |
! ! |
1363 |
||
1364 |
!ListModelView methodsFor:'scroller interface'! |
|
1365 |
||
2644 | 1366 |
getWidthOfContents |
1367 |
^ widthOfContents |
|
1368 |
! |
|
1369 |
||
1390 | 1370 |
heightOfContents |
1371 |
"return the height of the contents in pixels |
|
1372 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1373 |
^ self startOfLinesY last ? 0 |
1390 | 1374 |
! |
1375 |
||
2261 | 1376 |
heightOfLineAt:aLineNr |
1377 |
"returns the total height for a line at an index( including lineSpacing ... ) |
|
1378 |
" |
|
1379 |
|item| |
|
1380 |
||
1381 |
hasConstantHeight ifTrue:[ |
|
2352 | 1382 |
constantHeight notNil ifTrue:[ ^ constantHeight ]. |
2408 | 1383 |
item := self at:1 ifAbsent:nil. |
2264 | 1384 |
|
2352 | 1385 |
item notNil ifTrue:[ |
1386 |
constantHeight := self lineHeightFor:item. |
|
1387 |
^ constantHeight |
|
1388 |
] |
|
2264 | 1389 |
] ifFalse:[ |
2408 | 1390 |
item := self at:aLineNr ifAbsent:nil. |
2264 | 1391 |
|
2352 | 1392 |
item notNil ifTrue:[ |
1393 |
^ self lineHeightFor:item |
|
1394 |
] |
|
2261 | 1395 |
]. |
2264 | 1396 |
^ 4 |
2261 | 1397 |
! |
1398 |
||
1390 | 1399 |
innerHeight |
1400 |
"returns the inner height of the contents shown |
|
1401 |
" |
|
1402 |
^ height - margin - margin |
|
1403 |
||
1404 |
! |
|
1405 |
||
1406 |
innerWidth |
|
1407 |
"returns the inner width of the contents shown |
|
1408 |
" |
|
1409 |
^ width - margin - margin |
|
1410 |
||
1411 |
! |
|
1412 |
||
1413 |
maxViewOriginY |
|
1414 |
"returns the maximum possible y of the view origin |
|
1415 |
" |
|
1416 |
^ (self heightOfContents - self innerHeight) max:0 |
|
1417 |
||
1418 |
||
1419 |
! |
|
1420 |
||
2644 | 1421 |
setWidthOfContents: aWidth |
1422 |
widthOfContents := aWidth. |
|
1423 |
! |
|
1424 |
||
1390 | 1425 |
verticalScrollStep |
1426 |
"return the amount to scroll when stepping up/down. |
|
1427 |
" |
|
1428 |
^ 10 |
|
1429 |
||
1430 |
! |
|
1431 |
||
1432 |
viewOrigin |
|
1433 |
"return the viewOrigin; thats the coordinate of the contents |
|
1434 |
which is shown topLeft in the view. |
|
1435 |
" |
|
1436 |
^ viewOrigin |
|
1437 |
||
1438 |
! |
|
1439 |
||
1440 |
widthOfContents |
|
1441 |
"return the width of the contents in pixels |
|
1442 |
" |
|
1443 |
|range |
|
1444 |
size "{ Class:SmallInteger }" |
|
1445 |
start "{ Class:SmallInteger }" |
|
1446 |
stop "{ Class:SmallInteger }" |
|
1447 |
| |
|
1448 |
(widthOfContents notNil and:[computeWidthInRange isNil]) ifTrue:[ |
|
2384 | 1449 |
^ widthOfContents + textStartLeft |
1390 | 1450 |
]. |
1451 |
range := computeWidthInRange. |
|
1452 |
computeWidthInRange := nil. |
|
1453 |
preferredExtent := nil. |
|
2384 | 1454 |
|
1455 |
shown ifFalse:[ ^ 60 ]. |
|
1456 |
||
2408 | 1457 |
size := self size. |
1390 | 1458 |
|
1459 |
size == 0 ifTrue:[ |
|
2384 | 1460 |
widthOfContents := 20. |
1390 | 1461 |
] ifFalse:[ |
2384 | 1462 |
widthOfContents isNil ifTrue:[ |
1463 |
widthOfContents := self widthOfWidestLineBetween:1 and:size |
|
1464 |
] ifFalse:[ |
|
1465 |
start := range x. |
|
1466 |
stop := range y min:size. |
|
1390 | 1467 |
|
2384 | 1468 |
start > stop ifFalse:[ |
1469 |
size := self widthOfWidestLineBetween:start and:stop. |
|
1390 | 1470 |
|
2384 | 1471 |
widthOfContents < size ifTrue:[ |
1472 |
widthOfContents := size |
|
1473 |
] |
|
1474 |
] |
|
1475 |
] |
|
1390 | 1476 |
]. |
1477 |
^ widthOfContents + textStartLeft |
|
1478 |
! |
|
1479 |
||
1480 |
xOriginOfContents |
|
1481 |
"return the horizontal origin of the contents in pixels |
|
1482 |
" |
|
1483 |
^ viewOrigin x |
|
1484 |
||
1485 |
! |
|
1486 |
||
1487 |
yOriginOfContents |
|
1488 |
"return the vertical origin of the contents in pixels |
|
1489 |
" |
|
1490 |
^ viewOrigin y |
|
1491 |
||
1492 |
! ! |
|
1493 |
||
1494 |
!ListModelView methodsFor:'scrolling'! |
|
1495 |
||
1496 |
halfPageDown |
|
1497 |
"scroll down half a page |
|
1498 |
" |
|
1827 | 1499 |
self scrollDown:(height // 2). |
1390 | 1500 |
|
1501 |
! |
|
1502 |
||
1503 |
halfPageUp |
|
1504 |
"scroll up half a page |
|
1505 |
" |
|
1827 | 1506 |
self scrollUp:(height // 2). |
1390 | 1507 |
|
1508 |
! |
|
1509 |
||
2367 | 1510 |
makeLineVisible:aLnNr |
1511 |
"make the line visible |
|
1512 |
" |
|
1513 |
aLnNr notNil ifTrue:[ |
|
1514 |
self scrollToLine:aLnNr |
|
1515 |
]. |
|
1516 |
! |
|
1517 |
||
1390 | 1518 |
scrollTo:anOrigin redraw:doRedraw |
1519 |
"change origin to have newOrigin be visible at the top-left. |
|
1520 |
" |
|
1538 | 1521 |
|newOrg dltOrg winGrp |
1390 | 1522 |
innerWT "{ Class:SmallInteger }" |
1523 |
innerHG "{ Class:SmallInteger }" |
|
1524 |
h "{ Class:SmallInteger }" |
|
1525 |
x "{ Class:SmallInteger }" |
|
1526 |
x0 "{ Class:SmallInteger }" |
|
1527 |
x1 "{ Class:SmallInteger }" |
|
1528 |
y "{ Class:SmallInteger }" |
|
1529 |
w "{ Class:SmallInteger }" |
|
1530 |
y0 "{ Class:SmallInteger }" |
|
1531 |
y1 "{ Class:SmallInteger }" |
|
1532 |
dX "{ Class:SmallInteger }" |
|
1533 |
dY "{ Class:SmallInteger }" |
|
1534 |
| |
|
1531 | 1535 |
|
1580 | 1536 |
realized ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1537 |
^ self |
1390 | 1538 |
]. |
1580 | 1539 |
|
1390 | 1540 |
innerWT := self innerWidth. |
1541 |
innerHG := self innerHeight. |
|
1542 |
||
1543 |
h := viewOrigin y. |
|
1544 |
||
1545 |
(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
|
1546 |
y > (dY := self maxViewOriginY) ifTrue:[ |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1547 |
y := dY max:h |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1548 |
] |
1390 | 1549 |
] ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1550 |
y := y max:0. |
1390 | 1551 |
]. |
1552 |
||
1553 |
(x := anOrigin x) > 0 ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1554 |
x := x min:(self widthOfContents - innerWT). |
1390 | 1555 |
]. |
1556 |
x := x max:0. |
|
1557 |
newOrg := (x @ y). |
|
1558 |
dltOrg := newOrg - viewOrigin. |
|
1559 |
dX := dltOrg x. |
|
1560 |
dY := dltOrg y. |
|
1561 |
||
1562 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1563 |
^ self |
1390 | 1564 |
]. |
1534 | 1565 |
dY := dY abs. |
1566 |
dX := dX abs. |
|
1390 | 1567 |
|
1534 | 1568 |
( (dX ~~ 0 and:[dY ~~ 0]) "/ scroll vertical & horizontal |
1569 |
or:[(innerHG - dY < 20 or:[innerWT - dX < 20])] "/ faster to invalidate screen |
|
1570 |
) ifTrue:[ |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1571 |
viewOrigin := newOrg. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1572 |
self originChanged:dltOrg. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
1573 |
self invalidate. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
1574 |
^ self |
1534 | 1575 |
]. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1576 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1577 |
(winGrp := self windowGroup) notNil ifTrue:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1578 |
winGrp processRealExposeEventsFor:self. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1579 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1580 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1581 |
self originWillChange. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1582 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1583 |
doRedraw ifFalse:[ |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1584 |
viewOrigin := newOrg. |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
1585 |
self originChanged:dltOrg. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2645
diff
changeset
|
1586 |
^ self |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1587 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1588 |
|
1531 | 1589 |
self catchExpose. |
1590 |
viewOrigin := newOrg. |
|
1591 |
||
1390 | 1592 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1593 |
y0 := y1 := margin + dY. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1594 |
h := innerHG - dY. |
1390 | 1595 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1596 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1597 |
ifFalse:[y1 := margin. y := y1 + h]. |
1390 | 1598 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1599 |
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
|
1600 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h). |
1390 | 1601 |
|
1602 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1603 |
x0 := x1 := dX + margin. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1604 |
w := innerWT - dX. |
1390 | 1605 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1606 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1607 |
ifFalse:[x1 := margin. x := w]. |
1390 | 1608 |
|
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1609 |
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
|
1610 |
self invalidateX:x y:margin width:(width - w) height:innerHG. |
1390 | 1611 |
]. |
1612 |
self originChanged:dltOrg. |
|
1531 | 1613 |
self waitForExpose. |
1614 |
||
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1615 |
winGrp notNil ifTrue:[ |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1616 |
winGrp processRealExposeEventsFor:self. |
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1617 |
]. |
1390 | 1618 |
! |
1619 |
||
1620 |
scrollToLine:aLineNumber |
|
1621 |
"make line visible |
|
1622 |
" |
|
1744 | 1623 |
|inHg "{ Class:SmallInteger }" |
1624 |
yTop "{ Class:SmallInteger }" |
|
1625 |
orgY "{ Class:SmallInteger }" |
|
1626 |
yBot "{ Class:SmallInteger }" |
|
1390 | 1627 |
| |
2408 | 1628 |
(shown and:[aLineNumber notNil and:[aLineNumber between:1 and:(self size)]]) ifFalse:[ |
1629 |
^ self |
|
1390 | 1630 |
]. |
1631 |
||
1744 | 1632 |
yTop := self yAbsoluteOfLine:aLineNumber. |
1633 |
inHg := self innerHeight. |
|
1634 |
orgY := viewOrigin y. |
|
1635 |
||
1636 |
yTop > orgY ifTrue:[ |
|
2408 | 1637 |
yBot := self yAbsoluteOfLine:(aLineNumber + 1). |
1390 | 1638 |
|
2408 | 1639 |
yBot <= (orgY + inHg) ifTrue:[ |
1640 |
^ self |
|
1641 |
]. |
|
1390 | 1642 |
]. |
1744 | 1643 |
yTop := (yTop - (inHg // 2)) max:0. |
1644 |
self scrollTo:(viewOrigin x @ yTop). |
|
1390 | 1645 |
! ! |
1646 |
||
1748 | 1647 |
!ListModelView methodsFor:'scrolling auto'! |
1648 |
||
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1649 |
startAutoScroll:aSelectorOrBlock distance:aDistance |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1650 |
"setup for auto-scroll (when button-press-moving below/above view); |
1748 | 1651 |
- timeDelta for scroll is computed from distance |
1652 |
" |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1653 |
|timeDelta scrollBlock| |
1748 | 1654 |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1655 |
autoScroll ifFalse:[ |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1656 |
self stopAutoScroll. |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1657 |
^ self |
1748 | 1658 |
]. |
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1659 |
|
1748 | 1660 |
autoScrollBlock notNil ifTrue:[ |
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1661 |
Processor removeTimedBlock:autoScrollBlock. |
1748 | 1662 |
] ifFalse:[ |
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1663 |
self compressMotionEvents:false. |
1748 | 1664 |
]. |
1665 |
||
1666 |
timeDelta := 0.5 / (aDistance abs). |
|
1667 |
||
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1668 |
scrollBlock := |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1669 |
[ |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1670 |
aSelectorOrBlock isSymbol ifTrue:[ |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1671 |
self perform:aSelectorOrBlock. |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1672 |
] ifFalse:[ |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1673 |
aSelectorOrBlock value |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1674 |
]. |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1675 |
autoScrollBlock notNil ifTrue:[ |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1676 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1677 |
] |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1678 |
]. |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1679 |
|
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1680 |
autoScrollBlock := [self sensor pushUserEvent:#value for:scrollBlock]. |
1748 | 1681 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
1682 |
! |
|
1683 |
||
1684 |
stopAutoScroll |
|
1685 |
"stop any autoScroll |
|
1686 |
" |
|
1687 |
autoScrollBlock notNil ifTrue:[ |
|
2265 | 1688 |
Processor removeTimedBlock:autoScrollBlock. |
1689 |
autoScrollBlock := nil. |
|
1690 |
self compressMotionEvents:true. |
|
1748 | 1691 |
]. |
1692 |
! ! |
|
1693 |
||
2644 | 1694 |
!ListModelView methodsFor:'selection'! |
1695 |
||
1696 |
hasSelection |
|
1697 |
"on default false is returned |
|
1698 |
" |
|
1699 |
^ false |
|
1700 |
! ! |
|
1701 |
||
2352 | 1702 |
!ListModelView::Renderer class methodsFor:'documentation'! |
1703 |
||
1704 |
documentation |
|
1705 |
" |
|
1706 |
prepared for ListItemRenderer |
|
1707 |
.... SelectionItemRenderer ... |
|
1708 |
||
1709 |
goal: |
|
1710 |
allow the user to redefine the display operation and the dimesion queries |
|
1711 |
" |
|
1712 |
! ! |
|
1713 |
||
1714 |
!ListModelView::Renderer class methodsFor:'instance creation'! |
|
1715 |
||
1716 |
forView:aView |
|
1717 |
|renderer| |
|
1718 |
||
1719 |
renderer := self basicNew initialize. |
|
1720 |
renderer forView:aView. |
|
1721 |
^ renderer |
|
1722 |
! ! |
|
1723 |
||
2640 | 1724 |
!ListModelView::Renderer methodsFor:'change & update'! |
1725 |
||
1726 |
listWillChange |
|
1727 |
"called before the list changed, clear cashes ect. |
|
1728 |
here nothing is done |
|
1729 |
" |
|
2644 | 1730 |
! |
1731 |
||
1732 |
withinUpdateFromListDo:aBlock |
|
1733 |
"handle an update from the list |
|
1734 |
" |
|
1735 |
aBlock value |
|
2640 | 1736 |
! ! |
1737 |
||
2352 | 1738 |
!ListModelView::Renderer methodsFor:'displaying'! |
1739 |
||
1740 |
display:anItem atX:xLeft y:yTop lineHeight:h |
|
1741 |
"display the item on the view |
|
1742 |
" |
|
1743 |
|x0 y0 label| |
|
1744 |
||
1745 |
x0 := xLeft. |
|
1746 |
y0 := yTop. |
|
1747 |
||
1748 |
anItem isHierarchicalItem ifTrue:[ |
|
1749 |
anItem displayOn:view x:x0 y:y0 h:h |
|
1750 |
] ifFalse:[ |
|
1751 |
anItem isNil ifTrue:[^ self]. |
|
1752 |
||
1753 |
y0 := y0 - ((self heightFor:anItem) + 1 - h // 2). |
|
1754 |
label := anItem. |
|
1755 |
||
1756 |
label isImageOrForm ifFalse:[ |
|
1757 |
label isNumber ifTrue:[ |
|
1758 |
label := label printString |
|
1759 |
]. |
|
1760 |
y0 := y0 + view font ascent |
|
1761 |
]. |
|
1762 |
label displayOn:view x:x0 y:y0 |
|
1763 |
]. |
|
2644 | 1764 |
! |
1765 |
||
1766 |
postRedrawX:damageX y:yStartOrYDamage w:damageWidth from:startOrNil to:stopOrNil |
|
1767 |
"called after redraw of the items in range from start to stop is done; |
|
1768 |
if no items are damaged, start and stop is set to nil. |
|
1769 |
" |
|
1770 |
! |
|
1771 |
||
1772 |
validateDrawableItemsFrom:start to:stop |
|
1773 |
"called before drawing items from start to stop; if the method returns false |
|
1774 |
nothing will be drawn and a invalidate is pushed on the event queue. |
|
1775 |
On default true is returned. |
|
1776 |
" |
|
1777 |
^ true |
|
2352 | 1778 |
! ! |
1779 |
||
1780 |
!ListModelView::Renderer methodsFor:'instance creation'! |
|
1781 |
||
1782 |
forView:aView |
|
1783 |
view := aView. |
|
2644 | 1784 |
view shown ifTrue:[ self mapped ]. |
2643 | 1785 |
! |
1786 |
||
1787 |
mapped |
|
1788 |
"called if the view is mapped; can be redefined by subclass |
|
1789 |
" |
|
1790 |
! |
|
1791 |
||
1792 |
release |
|
1793 |
"called if the view is gone; can be redefined by subclass |
|
1794 |
" |
|
2352 | 1795 |
! ! |
1796 |
||
2644 | 1797 |
!ListModelView::Renderer methodsFor:'queries-behavior'! |
1798 |
||
1799 |
autoScrollHorizontal |
|
1800 |
"returns true if automatic scrolling horizontal |
|
1801 |
is allowed (the default is true). |
|
1802 |
" |
|
1803 |
^ true |
|
1804 |
! ! |
|
1805 |
||
2352 | 1806 |
!ListModelView::Renderer methodsFor:'queries-dimensions'! |
1807 |
||
1808 |
heightFor:anItem |
|
1809 |
"returns the height of an item on the view |
|
1810 |
" |
|
1811 |
^ anItem heightOn:view |
|
1812 |
! |
|
1813 |
||
2643 | 1814 |
maxItemWidthOrNil |
1815 |
"returns the maximum item width for drawing or nil |
|
1816 |
if unspecified (the default); used for cliping |
|
1817 |
" |
|
1818 |
^ nil |
|
1819 |
! |
|
1820 |
||
2352 | 1821 |
widthFor:anItem |
1822 |
"returns the width of an item on the view |
|
1823 |
" |
|
1824 |
^ anItem widthOn:view |
|
2644 | 1825 |
! |
1826 |
||
1827 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
1828 |
"returns the width of the longest line in pixels in a range; if the rendere |
|
1829 |
cannot compute the width, nil is returned (the default). |
|
1830 |
" |
|
1831 |
^ nil |
|
2352 | 1832 |
! ! |
1833 |
||
1390 | 1834 |
!ListModelView class methodsFor:'documentation'! |
1835 |
||
1836 |
version |
|
2745 | 1837 |
^ '$Header: /cvs/stx/stx/libwidg2/ListModelView.st,v 1.96 2004-09-20 10:33:52 stefan Exp $' |
1390 | 1838 |
! ! |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
1839 |
|
1390 | 1840 |
ListModelView initialize! |