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